Browse Source

Add theme menu item

pull/2931/head
Lucas Trzesniewski 2 years ago
parent
commit
ef9aa46cec
  1. 2
      ILSpy/Commands/ILSpyCommands.cs
  2. 11
      ILSpy/Commands/SetThemeCommand.cs
  3. 18
      ILSpy/MainWindow.xaml

2
ILSpy/Commands/ILSpyCommands.cs

@ -24,6 +24,7 @@ using System.Threading.Tasks; @@ -24,6 +24,7 @@ using System.Threading.Tasks;
using System.Windows.Input;
using ICSharpCode.ILSpy.Analyzers;
using ICSharpCode.ILSpy.Commands;
namespace ICSharpCode.ILSpy
{
@ -31,5 +32,6 @@ namespace ICSharpCode.ILSpy @@ -31,5 +32,6 @@ namespace ICSharpCode.ILSpy
{
public static readonly AnalyzeCommand Analyze = new AnalyzeCommand();
public static readonly ManageAssemblyListsCommand ManageAssemblyListsCommand = new ManageAssemblyListsCommand();
public static readonly SetThemeCommand SetTheme = new SetThemeCommand();
}
}

11
ILSpy/Commands/SetThemeCommand.cs

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
namespace ICSharpCode.ILSpy.Commands
{
public class SetThemeCommand : SimpleCommand
{
public override void Execute(object parameter)
{
if (parameter is string theme)
MainWindow.Instance.SessionSettings.Theme = theme;
}
}
}

18
ILSpy/MainWindow.xaml

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
xmlns:styles="urn:TomsToolbox.Wpf.Styles"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes"
xmlns:toms="urn:TomsToolbox"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
>
<Window.Resources>
@ -138,6 +139,23 @@ @@ -138,6 +139,23 @@
<MenuItem Header="{x:Static properties:Resources.Show_internalTypesMembers}" IsCheckable="True" IsChecked="{Binding Workspace.ActiveTabPage.FilterSettings.ApiVisPublicAndInternal}" />
<MenuItem Header="{x:Static properties:Resources.Show_allTypesAndMembers}" IsCheckable="True" IsChecked="{Binding Workspace.ActiveTabPage.FilterSettings.ApiVisAll}" />
<Separator/>
<MenuItem Header="{x:Static properties:Resources.Theme}" ItemsSource="{x:Static themes:ThemeManager.AllThemes}">
<MenuItem.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Command" Value="{x:Static local:ILSpyCommands.SetTheme}" />
<Setter Property="CommandParameter" Value="{Binding}" />
<Setter Property="IsCheckable" Value="True" /> <!-- Required by AvalonDock's MenuItem style to show the checkmark -->
<Setter Property="IsChecked">
<Setter.Value>
<MultiBinding Converter="{x:Static toms:BinaryOperationConverter.Equality}" Mode="OneWay">
<Binding />
<Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}" Path="SessionSettings.Theme" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<MenuItem Header="{x:Static properties:Resources.UILanguage}">
<MenuItem Header="{x:Static properties:Resources.UILanguage_System}" IsCheckable="True" IsChecked="{Binding SessionSettings.CurrentCulture, Converter={StaticResource cultureSelectionConverter}, ConverterParameter={x:Null}}" />
<MenuItem Header="English" IsCheckable="True" IsChecked="{Binding SessionSettings.CurrentCulture, Converter={StaticResource cultureSelectionConverter}, ConverterParameter=en-US}" />

Loading…
Cancel
Save