diff --git a/ILSpy/Analyzers/AnalyzeCommand.cs b/ILSpy/Analyzers/AnalyzeCommand.cs index 72117338b..7d73e9039 100644 --- a/ILSpy/Analyzers/AnalyzeCommand.cs +++ b/ILSpy/Analyzers/AnalyzeCommand.cs @@ -25,7 +25,7 @@ using ICSharpCode.ILSpy.TreeNodes; namespace ICSharpCode.ILSpy.Analyzers { - [ExportContextMenuEntry(Header = nameof(Resources.Analyze), Icon = "images/Search.png", Category = nameof(Resources.Analyze), InputGestureText = "Ctrl+R", Order = 100)] + [ExportContextMenuEntry(Header = nameof(Resources.Analyze), Icon = "images/Search", Category = nameof(Resources.Analyze), InputGestureText = "Ctrl+R", Order = 100)] internal sealed class AnalyzeCommand : SimpleCommand, IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/Commands/BrowseBackCommand.cs b/ILSpy/Commands/BrowseBackCommand.cs index a79f11855..e3fe411b5 100644 --- a/ILSpy/Commands/BrowseBackCommand.cs +++ b/ILSpy/Commands/BrowseBackCommand.cs @@ -21,7 +21,7 @@ using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { - [ExportToolbarCommand(ToolTip = nameof(Resources.Back), ToolbarIcon = "Images/Back.png", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 0)] + [ExportToolbarCommand(ToolTip = nameof(Resources.Back), ToolbarIcon = "Images/Back", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 0)] sealed class BrowseBackCommand : CommandWrapper { public BrowseBackCommand() diff --git a/ILSpy/Commands/BrowseForwardCommand.cs b/ILSpy/Commands/BrowseForwardCommand.cs index 583ddede1..e16b871fc 100644 --- a/ILSpy/Commands/BrowseForwardCommand.cs +++ b/ILSpy/Commands/BrowseForwardCommand.cs @@ -21,7 +21,7 @@ using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { - [ExportToolbarCommand(ToolTip = nameof(Resources.Forward), ToolbarIcon = "Images/Forward.png", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 1)] + [ExportToolbarCommand(ToolTip = nameof(Resources.Forward), ToolbarIcon = "Images/Forward", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 1)] sealed class BrowseForwardCommand : CommandWrapper { public BrowseForwardCommand() diff --git a/ILSpy/Commands/OpenCommand.cs b/ILSpy/Commands/OpenCommand.cs index 0f5e86ca9..88a632610 100644 --- a/ILSpy/Commands/OpenCommand.cs +++ b/ILSpy/Commands/OpenCommand.cs @@ -21,8 +21,8 @@ using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { - [ExportToolbarCommand(ToolTip = nameof(Resources.Open), ToolbarIcon = "Images/Open.png", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 0)] - [ExportMainMenuCommand(Menu = nameof(Resources._File), Header = nameof(Resources._Open), MenuIcon = "Images/Open.png", MenuCategory = nameof(Resources.Open), MenuOrder = 0)] + [ExportToolbarCommand(ToolTip = nameof(Resources.Open), ToolbarIcon = "Images/Open", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 0)] + [ExportMainMenuCommand(Menu = nameof(Resources._File), Header = nameof(Resources._Open), MenuIcon = "Images/Open", MenuCategory = nameof(Resources.Open), MenuOrder = 0)] sealed class OpenCommand : CommandWrapper { public OpenCommand() diff --git a/ILSpy/Commands/RefreshCommand.cs b/ILSpy/Commands/RefreshCommand.cs index 96e421882..bf92dc491 100644 --- a/ILSpy/Commands/RefreshCommand.cs +++ b/ILSpy/Commands/RefreshCommand.cs @@ -21,8 +21,8 @@ using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { - [ExportToolbarCommand(ToolTip = nameof(Resources.RefreshCommand_ReloadAssemblies), ToolbarIcon = "Images/Refresh.png", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 2)] - [ExportMainMenuCommand(Menu = nameof(Resources._File), Header = nameof(Resources._Reload), MenuIcon = "Images/Refresh.png", MenuCategory = nameof(Resources.Open), MenuOrder = 2)] + [ExportToolbarCommand(ToolTip = nameof(Resources.RefreshCommand_ReloadAssemblies), ToolbarIcon = "Images/Refresh", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 2)] + [ExportMainMenuCommand(Menu = nameof(Resources._File), Header = nameof(Resources._Reload), MenuIcon = "Images/Refresh", MenuCategory = nameof(Resources.Open), MenuOrder = 2)] sealed class RefreshCommand : CommandWrapper { public RefreshCommand() diff --git a/ILSpy/Commands/SortAssemblyListCommand.cs b/ILSpy/Commands/SortAssemblyListCommand.cs index b205cc03a..5347f61cc 100644 --- a/ILSpy/Commands/SortAssemblyListCommand.cs +++ b/ILSpy/Commands/SortAssemblyListCommand.cs @@ -23,8 +23,8 @@ using ICSharpCode.TreeView; namespace ICSharpCode.ILSpy { - [ExportMainMenuCommand(Menu = nameof(Resources._View), Header = nameof(Resources.SortAssembly_listName), MenuIcon = "Images/Sort.png", MenuCategory = nameof(Resources.View))] - [ExportToolbarCommand(ToolTip = nameof(Resources.SortAssemblyListName), ToolbarIcon = "Images/Sort.png", ToolbarCategory = nameof(Resources.View))] + [ExportMainMenuCommand(Menu = nameof(Resources._View), Header = nameof(Resources.SortAssembly_listName), MenuIcon = "Images/Sort", MenuCategory = nameof(Resources.View))] + [ExportToolbarCommand(ToolTip = nameof(Resources.SortAssemblyListName), ToolbarIcon = "Images/Sort", ToolbarCategory = nameof(Resources.View))] sealed class SortAssemblyListCommand : SimpleCommand, IComparer { public override void Execute(object parameter) @@ -39,8 +39,8 @@ namespace ICSharpCode.ILSpy } } - [ExportMainMenuCommand(Menu = nameof(Resources._View), Header = nameof(Resources._CollapseTreeNodes), MenuIcon = "Images/CollapseAll.png", MenuCategory = nameof(Resources.View))] - [ExportToolbarCommand(ToolTip = nameof(Resources.CollapseTreeNodes), ToolbarIcon = "Images/CollapseAll.png", ToolbarCategory = nameof(Resources.View))] + [ExportMainMenuCommand(Menu = nameof(Resources._View), Header = nameof(Resources._CollapseTreeNodes), MenuIcon = "Images/CollapseAll", MenuCategory = nameof(Resources.View))] + [ExportToolbarCommand(ToolTip = nameof(Resources.CollapseTreeNodes), ToolbarIcon = "Images/CollapseAll", ToolbarCategory = nameof(Resources.View))] sealed class CollapseAllCommand : SimpleCommand { public override void Execute(object parameter) diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 85086edcd..dc5fc15fb 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -312,6 +312,13 @@ + + + + + + + @@ -345,7 +352,6 @@ - @@ -389,6 +395,34 @@ + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile diff --git a/ILSpy/Images/Back.png b/ILSpy/Images/Back.png index e3f39762c..9f597cd91 100644 Binary files a/ILSpy/Images/Back.png and b/ILSpy/Images/Back.png differ diff --git a/ILSpy/Images/Back.xaml b/ILSpy/Images/Back.xaml new file mode 100644 index 000000000..ac68f11e4 --- /dev/null +++ b/ILSpy/Images/Back.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/CollapseAll.png b/ILSpy/Images/CollapseAll.png index 5e23dbc81..d5b3ed03b 100644 Binary files a/ILSpy/Images/CollapseAll.png and b/ILSpy/Images/CollapseAll.png differ diff --git a/ILSpy/Images/CollapseAll.xaml b/ILSpy/Images/CollapseAll.xaml new file mode 100644 index 000000000..8fefbcf4f --- /dev/null +++ b/ILSpy/Images/CollapseAll.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/Find.png b/ILSpy/Images/Find.png deleted file mode 100644 index 7a5ae62e3..000000000 Binary files a/ILSpy/Images/Find.png and /dev/null differ diff --git a/ILSpy/Images/Forward.png b/ILSpy/Images/Forward.png index d6c52613d..89ec5fb44 100644 Binary files a/ILSpy/Images/Forward.png and b/ILSpy/Images/Forward.png differ diff --git a/ILSpy/Images/Forward.xaml b/ILSpy/Images/Forward.xaml new file mode 100644 index 000000000..77f14b469 --- /dev/null +++ b/ILSpy/Images/Forward.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/Images.cs b/ILSpy/Images/Images.cs index 61ed764d8..2433c7d30 100644 --- a/ILSpy/Images/Images.cs +++ b/ILSpy/Images/Images.cs @@ -21,6 +21,9 @@ using System.Windows.Media.Imaging; using System.Windows.Media; using System.Windows; using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows.Markup; +using System.IO; namespace ICSharpCode.ILSpy { @@ -100,21 +103,62 @@ namespace ICSharpCode.ILSpy private static readonly BitmapImage OverlayStatic = LoadBitmap("OverlayStatic"); + public static object Load(object part, string icon) + { + if (icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) + return LoadImage(part, icon); + Uri uri = GetUri(part, icon + ".xaml"); + if (ResourceExists(uri)) { + return LoadVector(part, icon); + } + return LoadImage(part, icon + ".png"); + } + public static BitmapImage LoadImage(object part, string icon) + { + Uri uri = GetUri(part, icon); + BitmapImage image = new BitmapImage(uri); + image.Freeze(); + return image; + } + + public static Viewbox LoadVector(object part, string icon) + { + return (Viewbox)Application.LoadComponent(GetUri(part, icon + ".xaml", absolute: false)); + } + + private static Uri GetUri(object part, string icon, bool absolute = true) { Uri uri; var assembly = part.GetType().Assembly; + string prefix; + UriKind kind; + if (absolute) { + prefix = "pack://application:,,,/"; + kind = UriKind.Absolute; + } else { + prefix = "/"; + kind = UriKind.Relative; + } if (assembly == typeof(Images).Assembly) { - uri = new Uri("pack://application:,,,/" + icon); + uri = new Uri(prefix + icon, kind); } else { var name = assembly.GetName(); - uri = new Uri("pack://application:,,,/" + name.Name + ";v" + name.Version + ";component/" + icon); + uri = new Uri(prefix + name.Name + ";v" + name.Version + ";component/" + icon, kind); } - BitmapImage image = new BitmapImage(uri); - image.Freeze(); - return image; + + return uri; } + private static bool ResourceExists(Uri uri) + { + try { + Application.GetResourceStream(uri); + return true; + } catch (IOException) { + return false; + } + } private static readonly TypeIconCache typeIconCache = new TypeIconCache(); private static readonly MemberIconCache memberIconCache = new MemberIconCache(); diff --git a/ILSpy/Images/Open.png b/ILSpy/Images/Open.png index 02ea25394..77f4645fc 100644 Binary files a/ILSpy/Images/Open.png and b/ILSpy/Images/Open.png differ diff --git a/ILSpy/Images/Open.xaml b/ILSpy/Images/Open.xaml new file mode 100644 index 000000000..624c8619f --- /dev/null +++ b/ILSpy/Images/Open.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/Refresh.png b/ILSpy/Images/Refresh.png index 6d68b75b8..23ffe551e 100644 Binary files a/ILSpy/Images/Refresh.png and b/ILSpy/Images/Refresh.png differ diff --git a/ILSpy/Images/Refresh.xaml b/ILSpy/Images/Refresh.xaml new file mode 100644 index 000000000..99eeaa8c5 --- /dev/null +++ b/ILSpy/Images/Refresh.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/Search.png b/ILSpy/Images/Search.png index 7a5ae62e3..06da21465 100644 Binary files a/ILSpy/Images/Search.png and b/ILSpy/Images/Search.png differ diff --git a/ILSpy/Images/Search.xaml b/ILSpy/Images/Search.xaml new file mode 100644 index 000000000..b86ad5db5 --- /dev/null +++ b/ILSpy/Images/Search.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/Sort.png b/ILSpy/Images/Sort.png index b508e9a49..7c6ea30e5 100644 Binary files a/ILSpy/Images/Sort.png and b/ILSpy/Images/Sort.png differ diff --git a/ILSpy/Images/Sort.xaml b/ILSpy/Images/Sort.xaml new file mode 100644 index 000000000..440c50a3d --- /dev/null +++ b/ILSpy/Images/Sort.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index 5732b5673..d65111a11 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -139,15 +139,19 @@ namespace ICSharpCode.ILSpy Button MakeToolbarItem(Lazy command) { + object image = Images.Load(command.Value, command.Metadata.ToolbarIcon); + if (!(image is Viewbox)) { + image = new Image { + Width = 16, + Height = 16, + Source = (ImageSource)image + }; + } return new Button { Command = CommandWrapper.Unwrap(command.Value), - ToolTip =Properties.Resources.ResourceManager.GetString( command.Metadata.ToolTip), + ToolTip = Properties.Resources.ResourceManager.GetString(command.Metadata.ToolTip), Tag = command.Metadata.Tag, - Content = new Image { - Width = 16, - Height = 16, - Source = Images.LoadImage(command.Value, command.Metadata.ToolbarIcon) - } + Content = image }; } #endregion @@ -173,11 +177,15 @@ namespace ICSharpCode.ILSpy if (!string.IsNullOrEmpty(GetResourceString(entry.Metadata.Header))) menuItem.Header = GetResourceString(entry.Metadata.Header); if (!string.IsNullOrEmpty(entry.Metadata.MenuIcon)) { - menuItem.Icon = new Image { - Width = 16, - Height = 16, - Source = Images.LoadImage(entry.Value, entry.Metadata.MenuIcon) - }; + object image = Images.Load(entry.Value, entry.Metadata.MenuIcon); + if (!(image is Viewbox)) { + image = new Image { + Width = 16, + Height = 16, + Source = (ImageSource)image + }; + } + menuItem.Icon = image; } menuItem.IsEnabled = entry.Metadata.IsEnabled; diff --git a/ILSpy/Search/SearchPane.cs b/ILSpy/Search/SearchPane.cs index 501c2aade..5bb2b7c70 100644 --- a/ILSpy/Search/SearchPane.cs +++ b/ILSpy/Search/SearchPane.cs @@ -398,8 +398,8 @@ namespace ICSharpCode.ILSpy } } - [ExportMainMenuCommand(Menu = nameof(Properties.Resources._View), Header =nameof(Properties.Resources.Search), MenuIcon = "Images/Find.png", MenuCategory = nameof(Properties.Resources.View), MenuOrder = 100)] - [ExportToolbarCommand(ToolTip = nameof(Properties.Resources.SearchCtrlShiftFOrCtrlE), ToolbarIcon = "Images/Find.png", ToolbarCategory = nameof(Properties.Resources.View), ToolbarOrder = 100)] + [ExportMainMenuCommand(Menu = nameof(Properties.Resources._View), Header =nameof(Properties.Resources.Search), MenuIcon = "Images/Search", MenuCategory = nameof(Properties.Resources.View), MenuOrder = 100)] + [ExportToolbarCommand(ToolTip = nameof(Properties.Resources.SearchCtrlShiftFOrCtrlE), ToolbarIcon = "Images/Search", ToolbarCategory = nameof(Properties.Resources.View), ToolbarOrder = 100)] sealed class ShowSearchCommand : CommandWrapper { public ShowSearchCommand()