add HatchBrushGenerator
This commit is contained in:
1 parent
3d5e5a4306
commit
994c9e642f
25 files changed
+382
-42
No files matched your search
@@ -420,6 +420,9 @@
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\SplitButton_16x.png">
|
||||
<Link>Resources\Img\SplitButton_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DataGenerator_16x.png">
|
||||
<Link>Resources\Img\DataGenerator_16x.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
|
||||
|
||||
@@ -429,6 +429,9 @@
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\DataGenerator_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\DataGenerator_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\SplitButton_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\SplitButton_16x.png</Link>
|
||||
</Resource>
|
||||
|
||||
@@ -492,6 +492,9 @@
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\DataGenerator_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\DataGenerator_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\SplitButton_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\SplitButton_16x.png</Link>
|
||||
</Resource>
|
||||
|
||||
@@ -42,6 +42,11 @@
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
<ObjectDataProvider x:Key="HatchStyles" MethodName="GetValues" ObjectType="sys:Enum">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type Type="hc:HatchStyle"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
</ResourceDictionary>
|
||||
|
||||
</Application.Resources>
|
||||
|
||||
@@ -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")
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -94,6 +94,10 @@ var styleList = new List<string>
|
||||
"ToolBarDemoCtl",
|
||||
"LabelDemoCtl"
|
||||
};
|
||||
var toolList = new List<string>
|
||||
{
|
||||
"HatchBrushGeneratorDemoCtl"
|
||||
};
|
||||
var windowList = new List<string>
|
||||
{
|
||||
"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#>);
|
||||
|
||||
<#}#>
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Service\Data\DataService.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\HatchBrushConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\String2BrushConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\StringRepeatConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\AssemblyHelper.cs" />
|
||||
@@ -327,6 +328,9 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Styles\TreeViewDemoCtl.xaml.cs">
|
||||
<DependentUpon>TreeViewDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Tools\HatchBrushGeneratorDemoCtl.xaml.cs">
|
||||
<DependentUpon>HatchBrushGeneratorDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Basic\ChatBoxViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Basic\InteractiveDialogViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||
@@ -817,6 +821,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)UserControl\Tools\HatchBrushGeneratorDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)Window\AboutWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -690,6 +690,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 阴影画笔生成器 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string HatchBrushGenerator {
|
||||
get {
|
||||
return ResourceManager.GetString("HatchBrushGenerator", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 蜂窝布局 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -1617,6 +1626,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 工具 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Tools {
|
||||
get {
|
||||
return ResourceManager.GetString("Tools", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 穿梭框 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -666,4 +666,10 @@
|
||||
<data name="SplitButton" xml:space="preserve">
|
||||
<value>SplitButton</value>
|
||||
</data>
|
||||
<data name="Tools" xml:space="preserve">
|
||||
<value>Tools</value>
|
||||
</data>
|
||||
<data name="HatchBrushGenerator" xml:space="preserve">
|
||||
<value>HatchBrushGenerator</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -666,4 +666,10 @@
|
||||
<data name="SplitButton" xml:space="preserve">
|
||||
<value>SplitButton</value>
|
||||
</data>
|
||||
<data name="Tools" xml:space="preserve">
|
||||
<value>Tools</value>
|
||||
</data>
|
||||
<data name="HatchBrushGenerator" xml:space="preserve">
|
||||
<value>HatchBrushGenerator</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -666,4 +666,10 @@
|
||||
<data name="SplitButton" xml:space="preserve">
|
||||
<value>SplitButton</value>
|
||||
</data>
|
||||
<data name="Tools" xml:space="preserve">
|
||||
<value>Tools</value>
|
||||
</data>
|
||||
<data name="HatchBrushGenerator" xml:space="preserve">
|
||||
<value>HatchBrushGenerator</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -666,4 +666,10 @@
|
||||
<data name="SplitButton" xml:space="preserve">
|
||||
<value>分割按钮</value>
|
||||
</data>
|
||||
<data name="Tools" xml:space="preserve">
|
||||
<value>工具</value>
|
||||
</data>
|
||||
<data name="HatchBrushGenerator" xml:space="preserve">
|
||||
<value>阴影画笔生成器</value>
|
||||
</data>
|
||||
</root>
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 252 B |
@@ -4,5 +4,6 @@
|
||||
|
||||
<converter:StringRepeatConverter x:Key="StringRepeatConverter"/>
|
||||
<converter:String2BrushConverter x:Key="String2BrushConverter"/>
|
||||
<converter:HatchBrushConverter x:Key="HatchBrushConverter"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -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<Color>("DarkPrimaryColor"), ResourceHelper.GetResource<Color>("BackgroundColor"));
|
||||
}
|
||||
return Brushes.Transparent;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterKey}" Margin="4" Tag="{Binding ElementName=ListBoxStyle, Mode=OneWay}"/>
|
||||
<ToggleButton Name="ButtonStyleAscending" Click="ButtonStyleAscending_OnClick" Grid.Row="0" Grid.Column="1" Margin="0,0,4,0" Style="{StaticResource ToggleButtonCustom}">
|
||||
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterKey}" Margin="4" Tag="{Binding ElementName=ListBoxStyle}"/>
|
||||
<ToggleButton Tag="{Binding ElementName=ListBoxStyle}" Name="ButtonStyleAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Margin="0,0,4,0" Style="{StaticResource ToggleButtonCustom}">
|
||||
<Border CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource RegionBrush}" Height="30" Width="30" >
|
||||
<Image Stretch="None" Source="/HandyControlDemo;component/Resources/Img/LeftMainContent/SortAscending_grey_16x.png"/>
|
||||
</Border>
|
||||
@@ -185,8 +185,8 @@
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterKey}" Margin="4" Tag="{Binding ElementName=ListBoxControl, Mode=OneWay}"/>
|
||||
<ToggleButton Name="ButtonControlAscending" Click="ButtonControlAscending_OnClick" Grid.Row="0" Grid.Column="1" Margin="0,0,4,0" Style="{StaticResource ToggleButtonCustom}">
|
||||
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterKey}" Margin="4" Tag="{Binding ElementName=ListBoxControl}"/>
|
||||
<ToggleButton Tag="{Binding ElementName=ListBoxControl}" Name="ButtonControlAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Margin="0,0,4,0" Style="{StaticResource ToggleButtonCustom}">
|
||||
<Border CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource RegionBrush}" Height="30" Width="30" >
|
||||
<Image Stretch="None" Source="/HandyControlDemo;component/Resources/Img/LeftMainContent/SortAscending_grey_16x.png"/>
|
||||
</Border>
|
||||
@@ -478,6 +478,34 @@
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Background="Transparent" Header="{x:Static langs:Lang.Tools}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{x:Static langs:Lang.PlsEnterKey}" Margin="4" Tag="{Binding ElementName=ListBoxStyle}"/>
|
||||
<ToggleButton Tag="{Binding ElementName=ListBoxTool}" Name="ButtonToolAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Margin="0,0,4,0" Style="{StaticResource ToggleButtonCustom}">
|
||||
<Border CornerRadius="4" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource RegionBrush}" Height="30" Width="30" >
|
||||
<Image Stretch="None" Source="/HandyControlDemo;component/Resources/Img/LeftMainContent/SortAscending_grey_16x.png"/>
|
||||
</Border>
|
||||
<hc:StatusSwitchElement.CheckedElement>
|
||||
<Border CornerRadius="4" Height="30" Width="30" BorderThickness="1" BorderBrush="{DynamicResource PrimaryBrush}"/>
|
||||
</hc:StatusSwitchElement.CheckedElement>
|
||||
</ToggleButton>
|
||||
<ListBox Name="ListBoxTool" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.HatchBrushGeneratorDemoCtl}" Content="{x:Static langs:Lang.HatchBrushGenerator}">
|
||||
<hc:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/DataGenerator_16x.png"/>
|
||||
</hc:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
@@ -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<ListBox>(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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.HatchBrushGeneratorDemoCtl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<hc:TransitioningContentControl>
|
||||
<Border Style="{StaticResource BorderRegion}" Margin="32" Background="{Binding SelectedValue,ElementName=ComboBoxDemo,Converter={StaticResource HatchBrushConverter}}">
|
||||
<ComboBox SelectedIndex="0" VerticalAlignment="Center" Name="ComboBoxDemo" Width="180" ItemsSource="{Binding Source={StaticResource HatchStyles}}"/>
|
||||
</Border>
|
||||
</hc:TransitioningContentControl>
|
||||
</UserControl>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class HatchBrushGeneratorDemoCtl
|
||||
{
|
||||
public HatchBrushGeneratorDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeThumb.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\TwoWayRangeBase.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Block\RunningBlock.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\HatchStyle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\MouseHitMode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ShowAnimation.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\NotifyIconInfoType.cs" />
|
||||
@@ -264,7 +265,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\GeometryExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\UIElementExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\GifImageAnimator.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\GithubGravatarGenerator.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Generator\GithubGravatarGenerator.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Generator\HatchBrushGenerator.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\AnimationHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ArithmeticHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ColorHelper.cs" />
|
||||
@@ -864,6 +866,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="$(MSBuildThisFileDirectory)Controls\Growl\" />
|
||||
<Folder Include="$(MSBuildThisFileDirectory)Tools\Generator\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="E:\Work\GitHub\HandyControl\src\Shared\HandyControl_Shared\Themes\Styles\Base\SplitButtonBaseStyle.xaml">
|
||||
|
||||
File renamed without changes.
@@ -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];
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace HandyControl.Tools
|
||||
: null;
|
||||
}
|
||||
|
||||
internal static T GetChild<T>(DependencyObject d) where T : DependencyObject
|
||||
public static T GetChild<T>(DependencyObject d) where T : DependencyObject
|
||||
{
|
||||
if (d is T t)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user