Skip to content

Commit

Permalink
TEMP HACK: Remove dependency on ImageMoniker class
Browse files Browse the repository at this point in the history
  • Loading branch information
debonte committed Apr 6, 2021
1 parent cb495aa commit 9310fa2
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/NuGet.Clients/NuGet.Console/PowerConsoleToolWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public PowerConsoleToolWindow()
: base(null)
{
Caption = Resources.ToolWindowTitle;
BitmapImageMoniker = KnownMonikers.Console;
//BitmapImageMoniker = KnownMonikers.Console;
ToolBar = new CommandID(GuidList.guidNuGetCmdSet, PkgCmdIDList.idToolbar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ namespace NuGet.PackageManagement.UI
{
public static class PackageIconMonikers
{
private static readonly Guid ManifestGuid = new Guid("8F5EAE8F-9892-4CE2-826C-764BEDE6D2EC");
private const int _prefixReservedIndicator = 1;
private const int _updateAvailableIndicator = 2;
private const int _uninstallIndicator = 3;
private const int _downloadIndicator = 4;
// ERIKD TODO REENABLE private static readonly Guid ManifestGuid = new Guid("8F5EAE8F-9892-4CE2-826C-764BEDE6D2EC");
// private const int _prefixReservedIndicator = 1;
// private const int _updateAvailableIndicator = 2;
// private const int _uninstallIndicator = 3;
// private const int _downloadIndicator = 4;

public static ImageMoniker PrefixReservedIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _prefixReservedIndicator };
public static ImageMoniker UpdateAvailableIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _updateAvailableIndicator };
public static ImageMoniker UninstallIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _uninstallIndicator };
public static ImageMoniker DownloadIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _downloadIndicator };
// public static ImageMoniker PrefixReservedIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _prefixReservedIndicator };
// public static ImageMoniker UpdateAvailableIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _updateAvailableIndicator };
// public static ImageMoniker UninstallIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _uninstallIndicator };
// public static ImageMoniker DownloadIndicator => new ImageMoniker { Guid = ManifestGuid, Id = _downloadIndicator };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
VerticalAlignment="Top"
AutomationProperties.Name="{x:Static nuget:Resources.Accessibility_PrefixReserved}"
Visibility="{Binding Path=PrefixReserved, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
ToolTip="{x:Static nuget:Resources.Tooltip_PrefixReserved}"
Moniker="{x:Static nuget:PackageIconMonikers.PrefixReservedIndicator}" />
ToolTip="{x:Static nuget:Resources.Tooltip_PrefixReserved}" />
<!-- ERIKD TODO REENABLE Moniker="{x:Static nuget:PackageIconMonikers.PrefixReservedIndicator}" / -->
</Grid>
<Grid
Grid.Column="2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
VerticalAlignment="Top"
Visibility="{Binding IsUpdateAvailable, Converter={StaticResource BooleanToVisibilityConverter}}"
ToolTip="{x:Static nuget:Resources.ToolTip_UpdateAvailable}"
AutomationProperties.Name="{x:Static nuget:Resources.ToolTip_UpdateAvailable}"
Moniker="{x:Static nuget:PackageIconMonikers.UpdateAvailableIndicator}"/>
AutomationProperties.Name="{x:Static nuget:Resources.ToolTip_UpdateAvailable}" />
<!-- ERIKD TODO REENABLE Moniker="{x:Static nuget:PackageIconMonikers.UpdateAvailableIndicator}" / -->

<TextBlock
Grid.Row="1"
Expand Down Expand Up @@ -177,8 +177,8 @@
VerticalAlignment="Top"
Visibility="{Binding PrefixReserved, Converter={StaticResource BooleanToVisibilityConverter}}"
ToolTip="{x:Static nuget:Resources.Tooltip_PrefixReserved}"
AutomationProperties.Name="{x:Static nuget:Resources.Tooltip_PrefixReserved}"
Moniker="{x:Static nuget:PackageIconMonikers.PrefixReservedIndicator}" />
AutomationProperties.Name="{x:Static nuget:Resources.Tooltip_PrefixReserved}" />
<!-- ERIKD TODO REENABLE Moniker="{x:Static nuget:PackageIconMonikers.PrefixReservedIndicator}" / -->
<!-- author and download count -->
<nuget:AuthorAndDownloadCount
Margin="5,4,0,0"
Expand Down Expand Up @@ -328,8 +328,8 @@
<imaging:CrispImage
Width="16"
Height="16"
Cursor="Hand"
Moniker="{x:Static nuget:PackageIconMonikers.UninstallIndicator}"/>
Cursor="Hand" />
<!-- ERIKD TODO REENABLE Moniker="{x:Static nuget:PackageIconMonikers.UninstallIndicator}"/ -->
</Button>

<!-- install button. It occupies the same position of the install button -->
Expand Down Expand Up @@ -368,7 +368,7 @@
</Style.Triggers>
</Style>
</Button.Style>
<imaging:CrispImage Cursor="Hand" Moniker="{x:Static nuget:PackageIconMonikers.DownloadIndicator}" />
<imaging:CrispImage Cursor="Hand" /> <!-- ERIKD TODO REENABLE Moniker="{x:Static nuget:PackageIconMonikers.DownloadIndicator}" / -->
</Button>

<!-- row 1: latest version and the update button-->
Expand Down Expand Up @@ -434,7 +434,7 @@
<Binding Path="LatestVersion" Converter="{StaticResource VersionToStringConverter}" />
</MultiBinding>
</AutomationProperties.Name>
<imaging:CrispImage Cursor="Hand" Moniker="{x:Static nuget:PackageIconMonikers.UpdateAvailableIndicator}" />
<imaging:CrispImage Cursor="Hand" /> <!-- ERIKD TODO REENABLE Moniker="{x:Static nuget:PackageIconMonikers.UpdateAvailableIndicator}" / -->
</Button>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,62 @@
#nullable enable

using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Internal.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.ProjectSystem;
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
using LogLevel = NuGet.Common.LogLevel;

namespace NuGet.VisualStudio.SolutionExplorer
{
internal abstract class ReplacementBaseClass : IRelatableItem//, ITreeDisplayItem, ITreeDisplayItemWithImages, IPrioritizedComparable, IComparable, IInteractionPatternProvider, IBrowsablePattern, IContextMenuPattern, INotifyPropertyChanged
{
public ReplacementBaseClass(string foo)
{ }

public string Text { get; set; } = "Default";

public abstract object Identity { get; }

public abstract int Priority { get; }

public AggregateContainsRelationCollection? ContainsCollection { get; }

public AggregateContainedByRelationCollection? ContainedByCollection { get; set; }

protected virtual IContextMenuController? ContextMenuController => null;

public virtual object? GetBrowseObject() { return null; }

public bool TryGetOrCreateContainsCollection(IRelationProvider relationProvider, [NotNullWhen(returnValue: true)] out AggregateContainsRelationCollection? relationCollection)
{
relationCollection = null;
return false;
}

protected virtual bool TryGetProjectNode(IProjectTree targetRootNode, IRelatableItem item, [NotNullWhen(returnValue: true)] out IProjectTree? projectTree)
{
projectTree = null;
return false;
}

bool IRelatableItem.TryGetProjectNode(IProjectTree targetRootNode, IRelatableItem item, [NotNullWhen(returnValue: true)] out IProjectTree? projectTree)
{
throw new NotImplementedException();
}
}


/// <summary>
/// Backing object for diagnostic message items within a package within the dependencies tree.
/// </summary>
internal sealed class DiagnosticItem : RelatableItemBase
internal sealed class DiagnosticItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; private set; }
public AssetsFileTargetLibrary Library { get; private set; }
Expand All @@ -34,12 +77,13 @@ public DiagnosticItem(AssetsFileTarget target, AssetsFileTargetLibrary library,

public override int Priority => AttachedItemPriority.Diagnostic;

public override ImageMoniker IconMoniker => Log.Level switch
{
LogLevel.Error => KnownMonikers.StatusError,
LogLevel.Warning => KnownMonikers.StatusWarning,
_ => KnownMonikers.StatusInformation
};
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => Log.Level switch
//{
// LogLevel.Error => KnownMonikers.StatusError,
// LogLevel.Warning => KnownMonikers.StatusWarning,
// _ => KnownMonikers.StatusInformation
//};

public bool TryUpdateState(AssetsFileTarget target, AssetsFileTargetLibrary library, in AssetsFileLogMessage log)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;

namespace NuGet.VisualStudio.SolutionExplorer
{
Expand All @@ -19,7 +20,7 @@ namespace NuGet.VisualStudio.SolutionExplorer
/// <remarks>
/// Items within this group have type <see cref="PackageAssemblyItem"/>.
/// </remarks>
internal sealed class PackageAssemblyGroupItem : RelatableItemBase
internal sealed class PackageAssemblyGroupItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; }
public AssetsFileTargetLibrary Library { get; }
Expand Down Expand Up @@ -52,7 +53,8 @@ private static string GetGroupLabel(PackageAssemblyGroupType groupType)
_ => throw new InvalidEnumArgumentException(nameof(GroupType), (int)GroupType, typeof(PackageAssemblyGroupType))
};

public override ImageMoniker IconMoniker => KnownMonikers.ReferenceGroup;
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => KnownMonikers.ReferenceGroup;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;

namespace NuGet.VisualStudio.SolutionExplorer
{
Expand All @@ -19,7 +20,7 @@ namespace NuGet.VisualStudio.SolutionExplorer
/// <remarks>
/// Items of this type are grouped within <see cref="PackageAssemblyGroupItem"/>.
/// </remarks>
internal sealed class PackageAssemblyItem : RelatableItemBase
internal sealed class PackageAssemblyItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; }
public AssetsFileTargetLibrary Library { get; }
Expand All @@ -40,7 +41,8 @@ public PackageAssemblyItem(AssetsFileTarget target, AssetsFileTargetLibrary libr
// All siblings are assemblies, so no prioritization needed (sort alphabetically)
public override int Priority => 0;

public override ImageMoniker IconMoniker => KnownMonikers.Reference;
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => KnownMonikers.Reference;

protected override IContextMenuController? ContextMenuController => MenuController.TransitiveAssembly;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;

namespace NuGet.VisualStudio.SolutionExplorer
{
Expand All @@ -17,7 +18,7 @@ namespace NuGet.VisualStudio.SolutionExplorer
/// <remarks>
/// Items within this group have type <see cref="PackageContentFileItem"/>.
/// </remarks>
internal sealed class PackageContentFileGroupItem : RelatableItemBase
internal sealed class PackageContentFileGroupItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; }
public AssetsFileTargetLibrary Library { get; }
Expand All @@ -33,8 +34,10 @@ public PackageContentFileGroupItem(AssetsFileTarget target, AssetsFileTargetLibr

public override int Priority => AttachedItemPriority.ContentFilesGroup;

public override ImageMoniker IconMoniker => KnownMonikers.PackageFolderClosed;
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => KnownMonikers.PackageFolderClosed;

public override ImageMoniker ExpandedIconMoniker => KnownMonikers.PackageFolderOpened;
// ERIKD TODO REENABLE
// public override ImageMoniker ExpandedIconMoniker => KnownMonikers.PackageFolderOpened;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;

namespace NuGet.VisualStudio.SolutionExplorer
{
Expand All @@ -18,7 +19,7 @@ namespace NuGet.VisualStudio.SolutionExplorer
/// <remarks>
/// Items of this type are grouped within <see cref="PackageContentFileGroupItem"/>.
/// </remarks>
internal sealed class PackageContentFileItem : RelatableItemBase
internal sealed class PackageContentFileItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; }
public AssetsFileTargetLibrary Library { get; }
Expand Down Expand Up @@ -47,7 +48,8 @@ private static string GetProcessedContentFilePath(string rawPath)
// All siblings are content files, so no prioritization needed (sort alphabetically)
public override int Priority => 0;

public override ImageMoniker IconMoniker => _fileIconProvider.GetFileExtensionImageMoniker(Text);
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => _fileIconProvider.GetFileExtensionImageMoniker(Text);

public override object? GetBrowseObject() => new BrowseObject(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;

namespace NuGet.VisualStudio.SolutionExplorer
{
/// <summary>
/// Backing object for transitive package reference nodes in the dependencies tree.
/// </summary>
internal sealed class PackageReferenceItem : RelatableItemBase
internal sealed class PackageReferenceItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; private set; }
public AssetsFileTargetLibrary Library { get; private set; }
Expand Down Expand Up @@ -49,7 +50,8 @@ internal bool TryUpdateState(AssetsFileTarget target, AssetsFileTargetLibrary li

public override int Priority => AttachedItemPriority.Package;

public override ImageMoniker IconMoniker => KnownMonikers.NuGetNoColor;
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => KnownMonikers.NuGetNoColor;

protected override IContextMenuController? ContextMenuController => MenuController.TransitivePackage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
using Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.AttachedCollections;
using NuGet.VisualStudio.Implementation.Resources;
using NuGet.VisualStudio.SolutionExplorer.Models;
using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;
// ERIKD TODO REENABLE
// using ImageMoniker = Microsoft.VisualStudio.Imaging.Interop.ImageMoniker;

namespace NuGet.VisualStudio.SolutionExplorer
{
/// <summary>
/// Backing object for transitive project reference nodes in the dependencies tree.
/// </summary>
internal sealed class ProjectReferenceItem : RelatableItemBase
internal sealed class ProjectReferenceItem : ReplacementBaseClass
{
public AssetsFileTarget Target { get; private set; }
public AssetsFileTargetLibrary Library { get; private set; }
Expand Down Expand Up @@ -45,7 +46,8 @@ internal bool TryUpdateState(AssetsFileTarget target, AssetsFileTargetLibrary li

public override int Priority => AttachedItemPriority.Project;

public override ImageMoniker IconMoniker => KnownMonikers.Application;
// ERIKD TODO REENABLE
// public override ImageMoniker IconMoniker => KnownMonikers.Application;

protected override IContextMenuController? ContextMenuController => MenuController.TransitiveProject;

Expand Down

0 comments on commit 9310fa2

Please sign in to comment.