Browse Source

Add the VS Light+ theme from VS Code

pull/2906/head
Lucas Trzesniewski 2 years ago
parent
commit
f5e2caa20f
  1. 15
      ILSpy/Themes/SyntaxColor.cs
  2. 13
      ILSpy/Themes/ThemeManager.cs
  3. 87
      ILSpy/Themes/VSLightTheme.xaml

15
ILSpy/Themes/SyntaxColor.cs

@ -16,16 +16,9 @@ public class SyntaxColor @@ -16,16 +16,9 @@ public class SyntaxColor
public void ApplyTo(HighlightingColor color)
{
if (Foreground is { } foreground)
color.Foreground = new SimpleHighlightingBrush(foreground);
if (Background is { } background)
color.Background = new SimpleHighlightingBrush(background);
if (FontWeight is { } fontWeight)
color.FontWeight = fontWeight;
if (FontStyle is { } fontStyle)
color.FontStyle = fontStyle;
color.Foreground = Foreground is { } foreground ? new SimpleHighlightingBrush(foreground) : null;
color.Background = Background is { } background ? new SimpleHighlightingBrush(background) : null;
color.FontWeight = FontWeight ?? FontWeights.Normal;
color.FontStyle = FontStyle ?? FontStyles.Normal;
}
}

13
ILSpy/Themes/ThemeManager.cs

@ -42,10 +42,15 @@ namespace ICSharpCode.ILSpy.Themes @@ -42,10 +42,15 @@ namespace ICSharpCode.ILSpy.Themes
}
public string DefaultTheme => "Light";
public static IReadOnlyCollection<string> AllThemes => new[] { "Light", "Dark" };
public string Theme {
get => _theme ?? DefaultTheme;
public static IReadOnlyCollection<string> AllThemes => new[] {
"Dark",
"Light",
"VS Light"
};
public string? Theme {
get => _theme;
set {
_theme = value;
UpdateTheme();
@ -84,7 +89,7 @@ namespace ICSharpCode.ILSpy.Themes @@ -84,7 +89,7 @@ namespace ICSharpCode.ILSpy.Themes
private void UpdateTheme()
{
_themeDictionaryContainer.MergedDictionaries.Clear();
_themeDictionaryContainer.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"themes/{Theme}Theme.xaml", UriKind.Relative) });
_themeDictionaryContainer.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"themes/{(_theme ?? DefaultTheme).Replace(" ", "")}Theme.xaml", UriKind.Relative) });
_syntaxColors.Clear();
ProcessDictionary(_themeDictionaryContainer);

87
ILSpy/Themes/VSLightTheme.xaml

@ -0,0 +1,87 @@ @@ -0,0 +1,87 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="LightTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
<!--
Colors taken from the VS Code Light+ theme
https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/light_vs.json
https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/light_plus.json
-->
<SolidColorBrush x:Key="{x:Static themes:ResourceKeys.TextBackgroundColor}" Color="White" />
<SolidColorBrush x:Key="{x:Static themes:ResourceKeys.TextForegroundColor}" Color="Black" />
<!-- ILAsm -->
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Comment" Foreground="#008000" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.String" Foreground="#a31515" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Instructions" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Keywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Directives" Foreground="#795E26" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Security" Foreground="#0000ff" />
<!-- Asm -->
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Comment" Foreground="#008000" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.NumberLiteral" Foreground="#098658" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.String" Foreground="#a31515" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Instructions" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Math Instructions" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Extended Instructions" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Registers" Foreground="#795E26" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Directives" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Directive Operands" Foreground="#795E26" />
<!-- CSharp -->
<themes:SyntaxColor x:Key="SyntaxColor.C#.Comment" Foreground="#008000" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.String" Foreground="#a31515" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.StringInterpolation" Foreground="#d16969" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Char" Foreground="#a31515" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Preprocessor" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Punctuation" Foreground="Black" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ValueTypeKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ReferenceTypeKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.NumberLiteral" Foreground="#098658" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ThisOrBaseReference" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.NullOrValueKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Keywords" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.GotoKeywords" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.QueryKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ExceptionKeywords" Foreground="#AF00DB" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.CheckedKeyword" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.UnsafeKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.OperatorKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ParameterModifiers" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Modifiers" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Visibility" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.NamespaceKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.GetSetAddRemove" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.TrueFalse" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.TypeKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.AttributeKeywords" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ReferenceTypes" Foreground="#267f99" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.InterfaceTypes" Foreground="#267f99" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.TypeParameters" Foreground="#267f99" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.DelegateTypes" Foreground="#267f99" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ValueTypes" Foreground="#267f99" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.EnumTypes" Foreground="#267f99" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.MethodCall" Foreground="#795E26" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.FieldAccess" Foreground="#001080" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.InactiveCode" Foreground="#767676" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.SemanticError" Foreground="#cd3131" />
<!-- XML -->
<themes:SyntaxColor x:Key="SyntaxColor.XML.Comment" Foreground="#008000" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.CData" Foreground="#800000" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.DocType" Foreground="#800000" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.XmlDeclaration" Foreground="#800000" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.XmlTag" Foreground="#800000" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.AttributeName" Foreground="#e50000" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.AttributeValue" Foreground="#0000ff" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.Entity" Foreground="#098658" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.BrokenEntity" Foreground="#cd3131" />
</ResourceDictionary>
Loading…
Cancel
Save