diff --git a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
index a86f2c96..afaf4354 100644
--- a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
+++ b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
@@ -420,6 +420,9 @@
Resources\Img\SplitButton_16x.png
+
+ Resources\Img\DataGenerator_16x.png
+
diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
index 3c9f4539..272f80dc 100644
--- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
+++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj
@@ -429,6 +429,9 @@
TextTemplatingFileGenerator
MessageToken.cs
+
+ Resources\Img\LeftMainContent\DataGenerator_16x.png
+
Resources\Img\LeftMainContent\SplitButton_16x.png
diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
index dfa44c93..be876603 100644
--- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
+++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
@@ -492,6 +492,9 @@
TextTemplatingFileGenerator
MessageToken.cs
+
+ Resources\Img\LeftMainContent\DataGenerator_16x.png
+
Resources\Img\LeftMainContent\SplitButton_16x.png
diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml b/src/Shared/HandyControlDemo_Shared/App.xaml
index a9f0c1ee..4a95a856 100644
--- a/src/Shared/HandyControlDemo_Shared/App.xaml
+++ b/src/Shared/HandyControlDemo_Shared/App.xaml
@@ -42,6 +42,11 @@
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
index 8aa3870f..1392706a 100644
--- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
@@ -53,16 +53,6 @@ namespace HandyControlDemo
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
});
Current.MainWindow?.OnApplyTemplate();
-
- Resources.MergedDictionaries.Clear();
- Resources.MergedDictionaries.Add(new ResourceDictionary
- {
- Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin.ToString()}.xaml")
- });
- Resources.MergedDictionaries.Add(new ResourceDictionary
- {
- Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
- });
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
index 5df6ed53..ecf3653f 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
@@ -2,6 +2,8 @@
{
public class MessageToken
{
+ /*-------------------- Controls --------------------*/
+
public static readonly string GrowlDemoCtl = nameof(GrowlDemoCtl);
public static readonly string LoadingDemoCtl = nameof(LoadingDemoCtl);
@@ -118,7 +120,13 @@
public static readonly string SplitButtonDemoCtl = nameof(SplitButtonDemoCtl);
- public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
+ /*-------------------- Tools --------------------*/
+
+ public static readonly string HatchBrushGeneratorDemoCtl = nameof(HatchBrushGeneratorDemoCtl);
+
+ /*-------------------- Styles --------------------*/
+
+ public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
@@ -174,11 +182,15 @@
public static readonly string LabelDemoCtl = nameof(LabelDemoCtl);
- public static readonly string CommonWindow = nameof(CommonWindow);
+ /*-------------------- Windows --------------------*/
+
+ public static readonly string CommonWindow = nameof(CommonWindow);
public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow);
- public static readonly string LoadShowContent = nameof(LoadShowContent);
+ /*-------------------- Messages --------------------*/
+
+ public static readonly string LoadShowContent = nameof(LoadShowContent);
public static readonly string FullSwitch = nameof(FullSwitch);
diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
index 8b0426b2..53ce827c 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
+++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
@@ -94,6 +94,10 @@ var styleList = new List
"ToolBarDemoCtl",
"LabelDemoCtl"
};
+var toolList = new List
+{
+ "HatchBrushGeneratorDemoCtl"
+};
var windowList = new List
{
"CommonWindow",
@@ -120,19 +124,33 @@ namespace HandyControlDemo.Data
{
public class MessageToken
{
+ /*-------------------- Controls --------------------*/
+
<#foreach(var item in controlList){#>
public static readonly string <#=item#> = nameof(<#=item#>);
<#}#>
-<#foreach(var item in styleList){#>
+ /*-------------------- Tools --------------------*/
+
+ <#foreach(var item in toolList){#>
public static readonly string <#=item#> = nameof(<#=item#>);
<#}#>
-<#foreach(var item in windowList){#>
+ /*-------------------- Styles --------------------*/
+
+ <#foreach(var item in styleList){#>
public static readonly string <#=item#> = nameof(<#=item#>);
<#}#>
-<#foreach(var item in messageList){#>
+ /*-------------------- Windows --------------------*/
+
+ <#foreach(var item in windowList){#>
+ public static readonly string <#=item#> = nameof(<#=item#>);
+
+ <#}#>
+ /*-------------------- Messages --------------------*/
+
+ <#foreach(var item in messageList){#>
public static readonly string <#=item#> = nameof(<#=item#>);
<#}#>
diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
index 38e214fb..b52b7007 100644
--- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
+++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
@@ -27,6 +27,7 @@
MainWindow.xaml
+
@@ -327,6 +328,9 @@
TreeViewDemoCtl.xaml
+
+ HatchBrushGeneratorDemoCtl.xaml
+
@@ -817,6 +821,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
index a5c6c81e..b06c9166 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
@@ -690,6 +690,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 阴影画笔生成器 的本地化字符串。
+ ///
+ public static string HatchBrushGenerator {
+ get {
+ return ResourceManager.GetString("HatchBrushGenerator", resourceCulture);
+ }
+ }
+
///
/// 查找类似 蜂窝布局 的本地化字符串。
///
@@ -1617,6 +1626,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 工具 的本地化字符串。
+ ///
+ public static string Tools {
+ get {
+ return ResourceManager.GetString("Tools", resourceCulture);
+ }
+ }
+
///
/// 查找类似 穿梭框 的本地化字符串。
///
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
index 3159b7da..29bce738 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
@@ -666,4 +666,10 @@
SplitButton
+
+ Tools
+
+
+ HatchBrushGenerator
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
index 5c85daba..611a9438 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
@@ -666,4 +666,10 @@
SplitButton
+
+ Tools
+
+
+ HatchBrushGenerator
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
index 6963d7af..b0d16fb4 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
@@ -666,4 +666,10 @@
SplitButton
+
+ Tools
+
+
+ HatchBrushGenerator
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
index 4da16852..3131e9b0 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
@@ -666,4 +666,10 @@
分割按钮
+
+ 工具
+
+
+ 阴影画笔生成器
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/DataGenerator_16x.png b/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/DataGenerator_16x.png
new file mode 100644
index 00000000..efadacf8
Binary files /dev/null and b/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/DataGenerator_16x.png differ
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Converters.xaml b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Converters.xaml
index 82870e28..00802683 100644
--- a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Converters.xaml
+++ b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Converters.xaml
@@ -4,5 +4,6 @@
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs b/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs
new file mode 100644
index 00000000..878605f7
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using System.Windows.Media;
+using HandyControl.Data;
+using HandyControl.Tools;
+
+namespace HandyControlDemo.Tools.Converter
+{
+ public class HatchBrushConverter : IValueConverter
+ {
+ private readonly HatchBrushGenerator _brushGenerator;
+
+ public HatchBrushConverter()
+ {
+ _brushGenerator = new HatchBrushGenerator();
+ }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is HatchStyle style)
+ {
+ return _brushGenerator.GetHatchBrush(style, ResourceHelper.GetResource("DarkPrimaryColor"), ResourceHelper.GetResource("BackgroundColor"));
+ }
+ return Brushes.Transparent;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
index 4f903dd1..adf8987d 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
@@ -26,8 +26,8 @@
-
-
+
+
@@ -185,8 +185,8 @@
-
-
+
+
@@ -478,6 +478,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs
index b401825d..b99fe9c9 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs
@@ -2,7 +2,9 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
using HandyControl.Data;
+using HandyControl.Tools;
using HandyControl.Tools.Extension;
@@ -28,7 +30,8 @@ namespace HandyControlDemo.UserControl
private void TabControl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count == 0) return;
- if (e.AddedItems[0] is TabItem tabItem && tabItem.Content is ListBox listBox)
+ if (e.AddedItems[0] is TabItem tabItem &&
+ VisualHelper.GetChild(tabItem.Content as DependencyObject) is ListBox listBox)
{
if (listBox.SelectedItem != null)
{
@@ -39,27 +42,18 @@ namespace HandyControlDemo.UserControl
}
}
- private void ButtonStyleAscending_OnClick(object sender, RoutedEventArgs e)
+ private void ButtonAscending_OnClick(object sender, RoutedEventArgs e)
{
- if (ButtonStyleAscending.IsChecked == true)
+ if (sender is ToggleButton button && button.Tag is ItemsControl itemsControl)
{
- ListBoxStyle.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
- }
- else
- {
- ListBoxStyle.Items.SortDescriptions.Clear();
- }
- }
-
- private void ButtonControlAscending_OnClick(object sender, RoutedEventArgs e)
- {
- if (ButtonControlAscending.IsChecked == true)
- {
- ListBoxControl.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
- }
- else
- {
- ListBoxControl.Items.SortDescriptions.Clear();
+ if (button.IsChecked == true)
+ {
+ itemsControl.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
+ }
+ else
+ {
+ itemsControl.Items.SortDescriptions.Clear();
+ }
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Tools/HatchBrushGeneratorDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/HatchBrushGeneratorDemoCtl.xaml
new file mode 100644
index 00000000..f13d884c
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/HatchBrushGeneratorDemoCtl.xaml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Tools/HatchBrushGeneratorDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/HatchBrushGeneratorDemoCtl.xaml.cs
new file mode 100644
index 00000000..c0b53b05
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Tools/HatchBrushGeneratorDemoCtl.xaml.cs
@@ -0,0 +1,10 @@
+namespace HandyControlDemo.UserControl
+{
+ public partial class HatchBrushGeneratorDemoCtl
+ {
+ public HatchBrushGeneratorDemoCtl()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/Data/Enum/HatchStyle.cs b/src/Shared/HandyControl_Shared/Data/Enum/HatchStyle.cs
new file mode 100644
index 00000000..6f7f12e4
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Data/Enum/HatchStyle.cs
@@ -0,0 +1,59 @@
+namespace HandyControl.Data
+{
+ public enum HatchStyle
+ {
+ Horizontal,
+ Vertical,
+ ForwardDiagonal,
+ BackwardDiagonal,
+ Cross,
+ DiagonalCross,
+ Percent05,
+ Percent10,
+ Percent20,
+ Percent25,
+ Percent30,
+ Percent40,
+ Percent50,
+ Percent60,
+ Percent70,
+ Percent75,
+ Percent80,
+ Percent90,
+ LightDownwardDiagonal,
+ LightUpwardDiagonal,
+ DarkDownwardDiagonal,
+ DarkUpwardDiagonal,
+ WideDownwardDiagonal,
+ WideUpwardDiagonal,
+ LightVertical,
+ LightHorizontal,
+ NarrowVertical,
+ NarrowHorizontal,
+ DarkVertical,
+ DarkHorizontal,
+ DashedDownwardDiagonal,
+ DashedUpwardDiagonal,
+ DashedHorizontal,
+ DashedVertical,
+ SmallConfetti,
+ LargeConfetti,
+ ZigZag,
+ Wave,
+ DiagonalBrick,
+ HorizontalBrick,
+ Weave,
+ Plaid,
+ Divot,
+ DottedGrid,
+ DottedDiamond,
+ Shingle,
+ Trellis,
+ Sphere,
+ SmallGrid,
+ SmallCheckerBoard,
+ LargeCheckerBoard,
+ OutlinedDiamond,
+ SolidDiamond
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
index 5ef63b50..ae517b09 100644
--- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
+++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
@@ -35,6 +35,7 @@
+
@@ -264,7 +265,8 @@
-
+
+
@@ -864,6 +866,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Tools/GithubGravatarGenerator.cs b/src/Shared/HandyControl_Shared/Tools/Generator/GithubGravatarGenerator.cs
similarity index 100%
rename from src/Shared/HandyControl_Shared/Tools/GithubGravatarGenerator.cs
rename to src/Shared/HandyControl_Shared/Tools/Generator/GithubGravatarGenerator.cs
diff --git a/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs b/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs
new file mode 100644
index 00000000..d57d11ac
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs
@@ -0,0 +1,117 @@
+using System;
+using System.Windows;
+using System.Windows.Media;
+using HandyControl.Data;
+
+namespace HandyControl.Tools
+{
+ public class HatchBrushGenerator
+ {
+ private static readonly byte[][] HatchBrushes =
+ {
+ new byte[] {0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00}, // Horizontal
+ new byte[] {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, // Vertical
+ new byte[] {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, // ForwardDiagonal
+ new byte[] {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, // BackwardDiagonal
+ new byte[] {0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08}, // Cross
+ new byte[] {0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81}, // DiagonalCross
+ new byte[] {0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80}, // Percent05
+ new byte[] {0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88}, // Percent10
+ new byte[] {0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc}, // Percent20
+ new byte[] {0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc}, // Percent25
+ new byte[] {0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc}, // Percent30
+ new byte[] {0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc}, // Percent40
+ new byte[] {0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc}, // Percent50
+ new byte[] {0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee}, // Percent60
+ new byte[] {0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff}, // Percent70
+ new byte[] {0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff}, // Percent75
+ new byte[] {0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff}, // Percent80
+ new byte[] {0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff}, // Percent90
+ new byte[] {0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88}, // LightDownwardDiagonal
+ new byte[] {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11}, // LightUpwardDiagonal
+ new byte[] {0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc}, // DarkDownwardDiagonal
+ new byte[] {0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99}, // DarkUpwardDiagonal
+ new byte[] {0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0}, // WideDownwardDiagonal
+ new byte[] {0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1}, // WideUpwardDiagonal
+ new byte[] {0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88}, // LightVertical
+ new byte[] {0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff}, // LightHorizontal
+ new byte[] {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, // NarrowVertical
+ new byte[] {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff}, // NarrowHorizontal
+ new byte[] {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc}, // DarkVertical
+ new byte[] {0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff}, // DarkHorizontal
+ new byte[] {0x11, 0x22, 0x44, 0x88, 0x00, 0x00, 0x00, 0x00}, // DashedDownwardDiagonal
+ new byte[] {0x88, 0x44, 0x22, 0x11, 0x00, 0x00, 0x00, 0x00}, // DashedUpwardDiagonal
+ new byte[] {0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00}, // DashedHorizontal
+ new byte[] {0x01, 0x01, 0x01, 0x01, 0x10, 0x10, 0x10, 0x10}, // DashedVertical
+ new byte[] {0x01, 0x08, 0x80, 0x10, 0x02, 0x40, 0x04, 0x20}, // SmallConfetti
+ new byte[] {0x03, 0x63, 0x6c, 0x0c, 0xc0, 0xc6, 0x36, 0x30}, // LargeConfetti
+ new byte[] {0x03, 0x84, 0x48, 0x30, 0x03, 0x84, 0x48, 0x30}, // ZigZag
+ new byte[] {0x30, 0x49, 0x06, 0x00, 0x30, 0x49, 0x06, 0x00}, // Wave
+ new byte[] {0x81, 0x42, 0x24, 0x18, 0x08, 0x04, 0x02, 0x01}, // DiagonalBrick
+ new byte[] {0xff, 0x01, 0x01, 0x01, 0xff, 0x10, 0x10, 0x10}, // HorizontalBrick
+ new byte[] {0x11, 0x82, 0x44, 0xa8, 0x11, 0xa2, 0x44, 0x2a}, // Weave
+ new byte[] {0x55, 0xaa, 0x55, 0xaa, 0x0f, 0x0f, 0x0f, 0x0f}, // Plaid
+ new byte[] {0x02, 0x01, 0x02, 0x00, 0x10, 0x20, 0x10, 0x00}, // Divot
+ new byte[] {0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00}, // DottedGrid
+ new byte[] {0x11, 0x00, 0x04, 0x00, 0x11, 0x00, 0x40, 0x00}, // DottedDiamond
+ new byte[] {0x03, 0x0c, 0x10, 0x20, 0x20, 0x30, 0x48, 0x84}, // Shingle
+ new byte[] {0xff, 0x33, 0xff, 0xcc, 0xff, 0x33, 0xff, 0xcc}, // Trellis
+ new byte[] {0xee, 0x19, 0x1f, 0x1f, 0xee, 0x91, 0xf1, 0xf1}, // Sphere
+ new byte[] {0xff, 0x11, 0x11, 0x11, 0xff, 0x11, 0x11, 0x11}, // SmallGrid
+ new byte[] {0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc}, // SmallCheckerBoard
+ new byte[] {0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0}, // LargeCheckerBoard
+ new byte[] {0x01, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82}, // OutlinedDiamond
+ new byte[] {0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00} // SolidDiamond
+ };
+
+ public Brush GetHatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
+ {
+ var hatchData = GetHatchData(hatchStyle);
+
+ var foreGeometryGroup = new GeometryGroup();
+
+ for (var y = 0; y < 8; y++)
+ {
+ for (var x = 0; x < 8; x++)
+ {
+ if ((hatchData[y] & (0x80 >> x)) > 0)
+ {
+ foreGeometryGroup.Children.Add(new RectangleGeometry(new Rect(x, y, 1, 1)));
+ }
+ }
+ }
+
+ var drawingBrush = new DrawingBrush
+ {
+ Viewport = new Rect(0, 0, 8, 8),
+ ViewportUnits = BrushMappingMode.Absolute,
+ Stretch = Stretch.None,
+ TileMode = TileMode.Tile,
+ Drawing = new DrawingGroup
+ {
+ Children =
+ {
+ new GeometryDrawing
+ {
+ Brush = new SolidColorBrush(backColor),
+ Geometry = new RectangleGeometry(new Rect(0, 0, 8, 8))
+ },
+ new GeometryDrawing
+ {
+ Brush = new SolidColorBrush(foreColor),
+ Geometry = foreGeometryGroup
+ }
+ }
+ }
+ };
+ RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);
+
+ return drawingBrush;
+ }
+
+ private byte[] GetHatchData(HatchStyle hatchStyle) =>
+ hatchStyle < HatchStyle.Horizontal || hatchStyle > HatchStyle.SolidDiamond
+ ? throw new ArgumentOutOfRangeException(nameof(hatchStyle))
+ : HatchBrushes[(int)hatchStyle];
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
index 7afa19a2..489a0d49 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
@@ -29,7 +29,7 @@ namespace HandyControl.Tools
: null;
}
- internal static T GetChild(DependencyObject d) where T : DependencyObject
+ public static T GetChild(DependencyObject d) where T : DependencyObject
{
if (d is T t)
{