fixed a bug of demo
This commit is contained in:
1 parent
8c7f34ad4a
commit
add2fd8237
6 files changed
+106
-6
No files matched your search
@@ -141,4 +141,18 @@
|
|||||||
<SolidColorBrush o:Freeze="True" x:Key="MainContentForegroundBrush" Color="{DynamicResource MainContentForegroundColor}"/>
|
<SolidColorBrush o:Freeze="True" x:Key="MainContentForegroundBrush" Color="{DynamicResource MainContentForegroundColor}"/>
|
||||||
<SolidColorBrush o:Freeze="True" x:Key="MainContentBackgroundBrush" Color="{DynamicResource MainContentBackgroundColor}"/>
|
<SolidColorBrush o:Freeze="True" x:Key="MainContentBackgroundBrush" Color="{DynamicResource MainContentBackgroundColor}"/>
|
||||||
|
|
||||||
|
<!--region AvalonEdit-->
|
||||||
|
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="ControlAccentBrushKey" Color="{DynamicResource ControlAccentColorKey}"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorBackground" Color="{DynamicResource EditorBackgroundColor}"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorForeground" Color="{DynamicResource EditorForegroundColor}"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorLineNumbersForeground" Color="{DynamicResource EditorLineNumbersForegroundColor}"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorSelectionBrush" Color="{DynamicResource ControlAccentColorKey}" Opacity="0.75"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorSelectionBorder" Color="{DynamicResource ControlAccentColorKey}" Opacity="0.75"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorNonPrintableCharacterBrush" Color="{DynamicResource EditorNonPrintableCharacterColor}"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorLinkTextForegroundBrush" Color="{DynamicResource EditorLinkTextForegroundColor}"/>
|
||||||
|
<SolidColorBrush o:Freeze="True" x:Key="EditorLinkTextBackgroundBrush" Color="{DynamicResource EditorLinkTextBackgroundColor}"/>
|
||||||
|
|
||||||
|
<!--endregion-->
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -5,4 +5,16 @@
|
|||||||
<Color x:Key="MainContentForegroundColor">#FFF0F0F0</Color>
|
<Color x:Key="MainContentForegroundColor">#FFF0F0F0</Color>
|
||||||
<Color x:Key="MainContentBackgroundColor">#FFF5F5F5</Color>
|
<Color x:Key="MainContentBackgroundColor">#FFF5F5F5</Color>
|
||||||
|
|
||||||
|
<!--region AvalonEdit-->
|
||||||
|
|
||||||
|
<Color x:Key="ControlAccentColorKey">#1ba1e2</Color>
|
||||||
|
<Color x:Key="EditorBackgroundColor">White</Color>
|
||||||
|
<Color x:Key="EditorForegroundColor">Black</Color>
|
||||||
|
<Color x:Key="EditorLineNumbersForegroundColor">Black</Color>
|
||||||
|
<Color x:Key="EditorNonPrintableCharacterColor">#3F8080FF</Color>
|
||||||
|
<Color x:Key="EditorLinkTextForegroundColor">#FF4040FF</Color>
|
||||||
|
<Color x:Key="EditorLinkTextBackgroundColor">#00000000</Color>
|
||||||
|
|
||||||
|
<!--endregion-->
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -5,4 +5,16 @@
|
|||||||
<Color x:Key="MainContentForegroundColor">#FF1A1A1A</Color>
|
<Color x:Key="MainContentForegroundColor">#FF1A1A1A</Color>
|
||||||
<Color x:Key="MainContentBackgroundColor">#FF1C1C1C</Color>
|
<Color x:Key="MainContentBackgroundColor">#FF1C1C1C</Color>
|
||||||
|
|
||||||
|
<!--region AvalonEdit-->
|
||||||
|
|
||||||
|
<Color x:Key="ControlAccentColorKey">#1ba1e2</Color>
|
||||||
|
<Color x:Key="EditorBackgroundColor">#FF181818</Color>
|
||||||
|
<Color x:Key="EditorForegroundColor">#FFFFFFFF</Color>
|
||||||
|
<Color x:Key="EditorLineNumbersForegroundColor">#ff929292</Color>
|
||||||
|
<Color x:Key="EditorNonPrintableCharacterColor">#2FFFFFFF</Color>
|
||||||
|
<Color x:Key="EditorLinkTextForegroundColor">#FFAAAAFF</Color>
|
||||||
|
<Color x:Key="EditorLinkTextBackgroundColor">#18FFFFFF</Color>
|
||||||
|
|
||||||
|
<!--endregion-->
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit">
|
||||||
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
|
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
|
||||||
@@ -127,4 +128,62 @@
|
|||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
</Storyboard>
|
</Storyboard>
|
||||||
|
|
||||||
|
<Style x:Key="TextEditorCustom" TargetType="avalonedit:TextEditor">
|
||||||
|
<Setter Property="IsReadOnly" Value="True"/>
|
||||||
|
<Setter Property="FontFamily" Value="Consolas"/>
|
||||||
|
<Setter Property="Margin" Value="4"/>
|
||||||
|
<Setter Property="ShowLineNumbers" Value="True"/>
|
||||||
|
<Setter Property="LineNumbersForeground" Value="{DynamicResource EditorLineNumbersForeground}"/>
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource EditorForeground}"/>
|
||||||
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="avalonedit:TextEditor">
|
||||||
|
<ControlTemplate.Resources>
|
||||||
|
<Style TargetType="avalonedit:TextView">
|
||||||
|
<Setter Property="NonPrintableCharacterBrush" Value="{DynamicResource EditorNonPrintableCharacterBrush}" />
|
||||||
|
<Setter Property="LinkTextForegroundBrush" Value="{DynamicResource EditorLinkTextForegroundBrush}" />
|
||||||
|
<Setter Property="LinkTextBackgroundBrush" Value="{DynamicResource EditorLinkTextBackgroundBrush}" />
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="avalonedit:TextArea">
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||||
|
<Setter Property="SelectionBrush" Value="{DynamicResource EditorSelectionBrush}" />
|
||||||
|
<Setter Property="SelectionBorder">
|
||||||
|
<Setter.Value>
|
||||||
|
<Pen Brush="{DynamicResource EditorSelectionBorder}" Thickness="1" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Setter Property="SelectionCornerRadius" Value="0" />
|
||||||
|
<Setter Property="SelectionForeground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="avalonedit:TextArea">
|
||||||
|
<DockPanel Focusable="False">
|
||||||
|
<ItemsControl DockPanel.Dock="Left" Focusable="False" ItemsSource="{Binding LeftMargins,RelativeSource={RelativeSource TemplatedParent}}">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
</ItemsControl>
|
||||||
|
<ContentPresenter Panel.ZIndex="-1" Content="{Binding TextView,RelativeSource={RelativeSource TemplatedParent}}" Focusable="False" />
|
||||||
|
</DockPanel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ControlTemplate.Resources>
|
||||||
|
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
|
||||||
|
<ScrollViewer Name="PART_ScrollViewer" Padding="{TemplateBinding Padding}" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" CanContentScroll="True" Content="{Binding TextArea,RelativeSource={RelativeSource TemplatedParent}}" Focusable="False" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" />
|
||||||
|
</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>
|
</ResourceDictionary>
|
||||||
@@ -17,13 +17,13 @@
|
|||||||
<Border Style="{StaticResource BorderClip}" Margin="32,32,0,32" CornerRadius="10,0,0,10" Background="{DynamicResource RegionBrush}" Width="800">
|
<Border Style="{StaticResource BorderClip}" Margin="32,32,0,32" CornerRadius="10,0,0,10" Background="{DynamicResource RegionBrush}" Width="800">
|
||||||
<TabControl Grid.Row="1" Style="{StaticResource TabControlInLine}">
|
<TabControl Grid.Row="1" Style="{StaticResource TabControlInLine}">
|
||||||
<TabItem Header="XAML">
|
<TabItem Header="XAML">
|
||||||
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="XML" Name="EditorXaml" Margin="4" ShowLineNumbers="True"/>
|
<avalonedit:TextEditor Style="{StaticResource TextEditorCustom}" SyntaxHighlighting="XML" Name="EditorXaml"/>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="C#">
|
<TabItem Header="C#">
|
||||||
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="C#" Name="EditorCs" Margin="4" ShowLineNumbers="True"/>
|
<avalonedit:TextEditor Style="{StaticResource TextEditorCustom}" SyntaxHighlighting="C#" Name="EditorCs"/>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="VM">
|
<TabItem Header="VM">
|
||||||
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="C#" Name="EditorVm" Margin="4" ShowLineNumbers="True"/>
|
<avalonedit:TextEditor Style="{StaticResource TextEditorCustom}" SyntaxHighlighting="C#" Name="EditorVm"/>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
</Border>
|
</Border>
|
||||||
|
|||||||
@@ -56,10 +56,13 @@ namespace HandyControlDemo.UserControl
|
|||||||
|
|
||||||
if (ViewModelLocator.Instance.Main.SubContent is FrameworkElement demoCtl)
|
if (ViewModelLocator.Instance.Main.SubContent is FrameworkElement demoCtl)
|
||||||
{
|
{
|
||||||
var xamlPath = $"UserControl/{typeKey}/{demoCtl.GetType().Name}.xaml";
|
var demoCtlTypeName = demoCtl.GetType().Name;
|
||||||
|
var xamlPath = $"UserControl/{typeKey}/{demoCtlTypeName}.xaml";
|
||||||
var dc = demoCtl.DataContext;
|
var dc = demoCtl.DataContext;
|
||||||
var dcTypeName = dc.GetType().Name;
|
var dcTypeName = dc.GetType().Name;
|
||||||
var vmPath = $"ViewModel/{dcTypeName}";
|
var vmPath = !Equals(dcTypeName, demoCtlTypeName)
|
||||||
|
? $"ViewModel/{dcTypeName}"
|
||||||
|
: xamlPath;
|
||||||
|
|
||||||
EditorXaml.Text = DemoHelper.GetCode(xamlPath);
|
EditorXaml.Text = DemoHelper.GetCode(xamlPath);
|
||||||
EditorCs.Text = DemoHelper.GetCode($"{xamlPath}.cs");
|
EditorCs.Text = DemoHelper.GetCode($"{xamlPath}.cs");
|
||||||
|
|||||||
Reference in new issue
Block a user