mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
update ui
This commit is contained in:
parent
88be992176
commit
978e03d940
@ -11,6 +11,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ui:ThemesDictionary Theme="Dark" />
|
||||
<ui:ControlsDictionary />
|
||||
<ResourceDictionary x:Name="CustomTheme" Source="UI/Style/Dark.xaml" /> <!-- NOTE: WpfUiWindow::ApplyTheme relies on this order. If you plan to change the order, please update the index in the function. -->
|
||||
<ResourceDictionary x:Name="Default" Source="UI/Style/Default.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
<Resource Include="Resources\MessageBox\Information.png" />
|
||||
<Resource Include="Resources\MessageBox\Question.png" />
|
||||
<Resource Include="Resources\MessageBox\Warning.png" />
|
||||
<EmbeddedResource Include="UI\Style\Editor-Theme-Dark.xshd" />
|
||||
<EmbeddedResource Include="UI\Style\Editor-Theme-Light.xshd" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -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);
|
||||
|
@ -39,6 +39,7 @@
|
||||
Grid.Row="1"
|
||||
Margin="10,10,10,0"
|
||||
ShowLineNumbers="True"
|
||||
Style="{StaticResource NewTextEditor}"
|
||||
SyntaxHighlighting="XML"
|
||||
TextChanged="OnCodeChanged" />
|
||||
|
||||
|
@ -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)
|
||||
|
5
Bloxstrap/UI/Style/Dark.xaml
Normal file
5
Bloxstrap/UI/Style/Dark.xaml
Normal file
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<SolidColorBrush x:Key="NewTextEditorBackground" Color="#2D2D2D" />
|
||||
<SolidColorBrush x:Key="NewTextEditorForeground" Color="White" />
|
||||
<SolidColorBrush x:Key="NewTextEditorLink" Color="#3A9CEA" />
|
||||
</ResourceDictionary>
|
@ -1,6 +1,7 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
|
||||
|
||||
<!-- Taken from DefaultUiCardExpanderStyle -->
|
||||
@ -151,4 +152,38 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Taken from https://github.com/icsharpcode/AvalonEdit/blob/30cad99ce905412ed5f5e847e3c00e72e69aee77/ICSharpCode.AvalonEdit/TextEditor.xaml -->
|
||||
<Style x:Key="NewTextEditor" TargetType="{x:Type avalonedit:TextEditor}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource NewTextEditorForeground}" />
|
||||
<Setter Property="Background" Value="{DynamicResource NewTextEditorBackground}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type avalonedit:TextEditor}">
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4">
|
||||
<ScrollViewer
|
||||
Name="PART_ScrollViewer"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
HorizontalContentAlignment="Left"
|
||||
VerticalContentAlignment="Top"
|
||||
CanContentScroll="True"
|
||||
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TextArea}"
|
||||
Focusable="False"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="WordWrap" Value="True">
|
||||
<Setter TargetName="PART_ScrollViewer" Property="HorizontalScrollBarVisibility" Value="Disabled" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
63
Bloxstrap/UI/Style/Editor-Theme-Dark.xshd
Normal file
63
Bloxstrap/UI/Style/Editor-Theme-Dark.xshd
Normal file
@ -0,0 +1,63 @@
|
||||
<SyntaxDefinition name="XML" extensions=".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.booproj;.build;.xfrm;.targets;.xaml;.xpt;.xft;.map;.wsdl;.disco;.ps1xml;.nuspec" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color foreground="#529955" name="Comment" exampleText="<!-- comment -->" />
|
||||
<Color foreground="White" name="CData" exampleText="<![CDATA[data]]>" />
|
||||
<Color foreground="White" name="DocType" exampleText="<!DOCTYPE rootElement>" />
|
||||
<Color foreground="White" name="XmlDeclaration" exampleText='<?xml version="1.0"?>' />
|
||||
<Color foreground="#569CD6" name="XmlTag" exampleText='<tag attribute="value" />' />
|
||||
<Color foreground="#9CDCFE" name="AttributeName" exampleText='<tag attribute="value" />' />
|
||||
<Color foreground="#CE9178" name="AttributeValue" exampleText='<tag attribute="value" />' />
|
||||
<Color foreground="White" name="Entity" exampleText="index.aspx?a=1&amp;b=2" />
|
||||
<Color foreground="White" name="BrokenEntity" exampleText="index.aspx?a=1&b=2" />
|
||||
|
||||
<RuleSet>
|
||||
<Span color="Comment" multiline="true">
|
||||
<Begin><!--</Begin>
|
||||
<End>--></End>
|
||||
</Span>
|
||||
<Span color="CData" multiline="true">
|
||||
<Begin><!\[CDATA\[</Begin>
|
||||
<End>]]></End>
|
||||
</Span>
|
||||
<Span color="DocType" multiline="true">
|
||||
<Begin><!DOCTYPE</Begin>
|
||||
<End>></End>
|
||||
</Span>
|
||||
<Span color="XmlDeclaration" multiline="true">
|
||||
<Begin><\?</Begin>
|
||||
<End>\?></End>
|
||||
</Span>
|
||||
<Span color="XmlTag" multiline="true">
|
||||
<Begin><</Begin>
|
||||
<End>></End>
|
||||
<RuleSet>
|
||||
<!-- Treat the position before '<' as end, as that's not a valid character
|
||||
in attribute names and indicates the user forgot a closing quote. -->
|
||||
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
|
||||
<Begin>"</Begin>
|
||||
<End>"|(?=<)</End>
|
||||
</Span>
|
||||
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
|
||||
<Begin>'</Begin>
|
||||
<End>'|(?=<)</End>
|
||||
</Span>
|
||||
<Rule color="AttributeName">[\d\w_\-\.]+(?=(\s*=))</Rule>
|
||||
<Rule color="AttributeValue">=</Rule>
|
||||
</RuleSet>
|
||||
</Span>
|
||||
<Import ruleSet="EntitySet"/>
|
||||
</RuleSet>
|
||||
|
||||
<RuleSet name="EntitySet">
|
||||
<Rule color="Entity">
|
||||
&
|
||||
[\w\d\#]+
|
||||
;
|
||||
</Rule>
|
||||
|
||||
<Rule color="BrokenEntity">
|
||||
&
|
||||
[\w\d\#]*
|
||||
#missing ;
|
||||
</Rule>
|
||||
</RuleSet>
|
||||
</SyntaxDefinition>
|
63
Bloxstrap/UI/Style/Editor-Theme-Light.xshd
Normal file
63
Bloxstrap/UI/Style/Editor-Theme-Light.xshd
Normal file
@ -0,0 +1,63 @@
|
||||
<SyntaxDefinition name="XML" extensions=".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.booproj;.build;.xfrm;.targets;.xaml;.xpt;.xft;.map;.wsdl;.disco;.ps1xml;.nuspec" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color foreground="Green" name="Comment" exampleText="<!-- comment -->" />
|
||||
<Color foreground="Blue" name="CData" exampleText="<![CDATA[data]]>" />
|
||||
<Color foreground="Blue" name="DocType" exampleText="<!DOCTYPE rootElement>" />
|
||||
<Color foreground="Blue" name="XmlDeclaration" exampleText='<?xml version="1.0"?>' />
|
||||
<Color foreground="DarkMagenta" name="XmlTag" exampleText='<tag attribute="value" />' />
|
||||
<Color foreground="Red" name="AttributeName" exampleText='<tag attribute="value" />' />
|
||||
<Color foreground="Blue" name="AttributeValue" exampleText='<tag attribute="value" />' />
|
||||
<Color foreground="Teal" name="Entity" exampleText="index.aspx?a=1&amp;b=2" />
|
||||
<Color foreground="Olive" name="BrokenEntity" exampleText="index.aspx?a=1&b=2" />
|
||||
|
||||
<RuleSet>
|
||||
<Span color="Comment" multiline="true">
|
||||
<Begin><!--</Begin>
|
||||
<End>--></End>
|
||||
</Span>
|
||||
<Span color="CData" multiline="true">
|
||||
<Begin><!\[CDATA\[</Begin>
|
||||
<End>]]></End>
|
||||
</Span>
|
||||
<Span color="DocType" multiline="true">
|
||||
<Begin><!DOCTYPE</Begin>
|
||||
<End>></End>
|
||||
</Span>
|
||||
<Span color="XmlDeclaration" multiline="true">
|
||||
<Begin><\?</Begin>
|
||||
<End>\?></End>
|
||||
</Span>
|
||||
<Span color="XmlTag" multiline="true">
|
||||
<Begin><</Begin>
|
||||
<End>></End>
|
||||
<RuleSet>
|
||||
<!-- Treat the position before '<' as end, as that's not a valid character
|
||||
in attribute names and indicates the user forgot a closing quote. -->
|
||||
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
|
||||
<Begin>"</Begin>
|
||||
<End>"|(?=<)</End>
|
||||
</Span>
|
||||
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
|
||||
<Begin>'</Begin>
|
||||
<End>'|(?=<)</End>
|
||||
</Span>
|
||||
<Rule color="AttributeName">[\d\w_\-\.]+(?=(\s*=))</Rule>
|
||||
<Rule color="AttributeValue">=</Rule>
|
||||
</RuleSet>
|
||||
</Span>
|
||||
<Import ruleSet="EntitySet"/>
|
||||
</RuleSet>
|
||||
|
||||
<RuleSet name="EntitySet">
|
||||
<Rule color="Entity">
|
||||
&
|
||||
[\w\d\#]+
|
||||
;
|
||||
</Rule>
|
||||
|
||||
<Rule color="BrokenEntity">
|
||||
&
|
||||
[\w\d\#]*
|
||||
#missing ;
|
||||
</Rule>
|
||||
</RuleSet>
|
||||
</SyntaxDefinition>
|
5
Bloxstrap/UI/Style/Light.xaml
Normal file
5
Bloxstrap/UI/Style/Light.xaml
Normal file
@ -0,0 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<SolidColorBrush x:Key="NewTextEditorBackground" Color="White" />
|
||||
<SolidColorBrush x:Key="NewTextEditorForeground" Color="Black" />
|
||||
<SolidColorBrush x:Key="NewTextEditorLink" Color="Blue" />
|
||||
</ResourceDictionary>
|
Loading…
Reference in New Issue
Block a user