diff --git a/Bloxstrap/App.xaml b/Bloxstrap/App.xaml index 685eaad..2029b34 100644 --- a/Bloxstrap/App.xaml +++ b/Bloxstrap/App.xaml @@ -11,6 +11,7 @@ + diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 361ca8f..8598d98 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -25,6 +25,8 @@ + + diff --git a/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs b/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs index db06e7f..9802ab1 100644 --- a/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs +++ b/Bloxstrap/UI/Elements/Base/WpfUiWindow.cs @@ -18,9 +18,15 @@ namespace Bloxstrap.UI.Elements.Base public void ApplyTheme() { + const int customThemeIndex = 2; // index for CustomTheme merged dictionary + _themeService.SetTheme(App.Settings.Prop.Theme.GetFinal() == Enums.Theme.Dark ? ThemeType.Dark : ThemeType.Light); _themeService.SetSystemAccent(); + // there doesn't seem to be a way to query the name for merged dictionaries + var dict = new ResourceDictionary { Source = new Uri($"pack://application:,,,/UI/Style/{Enum.GetName(App.Settings.Prop.Theme.GetFinal())}.xaml") }; + Application.Current.Resources.MergedDictionaries[customThemeIndex] = dict; + #if QA_BUILD this.BorderBrush = System.Windows.Media.Brushes.Red; this.BorderThickness = new Thickness(4); diff --git a/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml b/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml index 4c4cdf4..f27f802 100644 --- a/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml +++ b/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml @@ -39,6 +39,7 @@ Grid.Row="1" Margin="10,10,10,0" ShowLineNumbers="True" + Style="{StaticResource NewTextEditor}" SyntaxHighlighting="XML" TextChanged="OnCodeChanged" /> diff --git a/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs b/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs index 63acc34..5888c63 100644 --- a/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs +++ b/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs @@ -1,8 +1,11 @@ using System.Windows.Input; +using System.Xml; using ICSharpCode.AvalonEdit.CodeCompletion; using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; +using ICSharpCode.AvalonEdit.Highlighting.Xshd; +using ICSharpCode.AvalonEdit.Highlighting; using Bloxstrap.UI.Elements.Base; using Bloxstrap.UI.ViewModels.Editor; @@ -146,6 +149,18 @@ namespace Bloxstrap.UI.Elements.Editor UIXML.Text = viewModel.Code; UIXML.TextArea.TextEntered += OnTextAreaTextEntered; + + LoadHighlightingTheme(); + } + + private void LoadHighlightingTheme() + { + string name = $"Editor-Theme-{App.Settings.Prop.Theme.GetFinal()}.xshd"; + using Stream xmlStream = Resource.GetStream(name); + using XmlReader reader = XmlReader.Create(xmlStream); + UIXML.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); + + UIXML.TextArea.TextView.SetResourceReference(ICSharpCode.AvalonEdit.Rendering.TextView.LinkTextForegroundBrushProperty, "NewTextEditorLink"); } private static string ToCRLF(string text) diff --git a/Bloxstrap/UI/Style/Dark.xaml b/Bloxstrap/UI/Style/Dark.xaml new file mode 100644 index 0000000..2c7b0cb --- /dev/null +++ b/Bloxstrap/UI/Style/Dark.xaml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Bloxstrap/UI/Style/Default.xaml b/Bloxstrap/UI/Style/Default.xaml index b2a646a..9083a8b 100644 --- a/Bloxstrap/UI/Style/Default.xaml +++ b/Bloxstrap/UI/Style/Default.xaml @@ -1,6 +1,7 @@  @@ -151,4 +152,38 @@ + + + + \ No newline at end of file diff --git a/Bloxstrap/UI/Style/Editor-Theme-Dark.xshd b/Bloxstrap/UI/Style/Editor-Theme-Dark.xshd new file mode 100644 index 0000000..5f5da3e --- /dev/null +++ b/Bloxstrap/UI/Style/Editor-Theme-Dark.xshd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + <!-- + --> + + + <!\[CDATA\[ + ]]> + + + <!DOCTYPE + > + + + <\? + \?> + + + < + > + + + + " + "|(?=<) + + + ' + '|(?=<) + + [\d\w_\-\.]+(?=(\s*=)) + = + + + + + + + + & + [\w\d\#]+ + ; + + + + & + [\w\d\#]* + #missing ; + + + \ No newline at end of file diff --git a/Bloxstrap/UI/Style/Editor-Theme-Light.xshd b/Bloxstrap/UI/Style/Editor-Theme-Light.xshd new file mode 100644 index 0000000..8f0bdef --- /dev/null +++ b/Bloxstrap/UI/Style/Editor-Theme-Light.xshd @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + <!-- + --> + + + <!\[CDATA\[ + ]]> + + + <!DOCTYPE + > + + + <\? + \?> + + + < + > + + + + " + "|(?=<) + + + ' + '|(?=<) + + [\d\w_\-\.]+(?=(\s*=)) + = + + + + + + + + & + [\w\d\#]+ + ; + + + + & + [\w\d\#]* + #missing ; + + + \ No newline at end of file diff --git a/Bloxstrap/UI/Style/Light.xaml b/Bloxstrap/UI/Style/Light.xaml new file mode 100644 index 0000000..fcc308d --- /dev/null +++ b/Bloxstrap/UI/Style/Light.xaml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file