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 5ce52f21..c17c05bc 100644 --- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj +++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj @@ -412,9 +412,6 @@ Resources\Img\LeftMainContent\MainMenuControl_16x.png - - Resources\Img\LeftMainContent\Geometry_16x.png - Resources\fabric-icons.ttf 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 b3896d28..0a009190 100644 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj +++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj @@ -411,9 +411,6 @@ Resources\Img\LeftMainContent\MainMenuControl_16x.png - - - Resources\Img\LeftMainContent\Geometry_16x.png Resources\fabric-icons.ttf diff --git a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj index dbbb46a4..6181daab 100644 --- a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj +++ b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj @@ -273,6 +273,9 @@ UserControl\Styles\FrameDemoCtl.xaml + + UserControl\Styles\GeometryDemoCtl.xaml + UserControl\Styles\GroupBoxDemoCtl.xaml @@ -706,6 +709,10 @@ UserControl\Styles\FrameDemoCtl.xaml.cs FrameDemoCtl.xaml + + UserControl\Styles\GeometryDemoCtl.xaml.cs + GeometryDemoCtl.xaml + UserControl\Styles\GroupBoxDemoCtl.xaml.cs GroupBoxDemoCtl.xaml diff --git a/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json b/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json index 613c2d5a..c1e8e21e 100644 --- a/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json +++ b/src/Shared/HandyControlDemo_Shared/Data/DemoInfo.json @@ -33,7 +33,7 @@ [ "Label", "LabelDemoCtl", "Label_16x", "" ], [ "Frame", "FrameDemoCtl", "frame_16xLG", "1" ], [ "Window", "NativeWindowDemoCtl", "WindowsForm_16x", "1" ], - [ "Geometry", "GeometryDemoCtl", "Geometry_16x", "1" ] + [ "Geometry", "GeometryDemoCtl", "Path_16x", "1" ] ] }, { diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs new file mode 100644 index 00000000..dca49b44 --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs @@ -0,0 +1,13 @@ +using System.Windows.Media; + +namespace HandyControlDemo.Data +{ + public class GeometryItemModel + { + public Geometry Data { get; set; } + + public string Key { get; set; } + + public bool Line { get; set; } + } +} \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems index f32f6c4b..1ae0db8c 100644 --- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems +++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems @@ -19,6 +19,7 @@ + @@ -45,6 +46,9 @@ ChatBox.xaml + + GeometryItem.xaml + InteractiveDialog.xaml @@ -316,7 +320,7 @@ FrameDemoCtl.xaml - + GeometryDemoCtl.xaml @@ -506,6 +510,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -866,7 +874,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx index fc08c26a..34a270a9 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx @@ -757,6 +757,6 @@ 图片选择器 - Geometry + 几何形状 \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs index 41dba43c..93ca4c9c 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs +++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs @@ -593,7 +593,11 @@ namespace HandyControlDemo.Properties.Langs /// public string Frame => Lang.Frame; + /// + /// 查找类似 几何形状 的本地化字符串。 + /// public string Geometry => Lang.Geometry; + /// /// 查找类似 Gif图片 的本地化字符串。 /// @@ -1668,6 +1672,9 @@ namespace HandyControlDemo.Properties.Langs /// public static string Frame = nameof(Frame); + /// + /// 查找类似 几何形状 的本地化字符串。 + /// public static string Geometry = nameof(Geometry); /// diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/Geometry_16x.png b/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/Geometry_16x.png deleted file mode 100644 index 4075b3dc..00000000 Binary files a/src/Shared/HandyControlDemo_Shared/Resources/Img/LeftMainContent/Geometry_16x.png and /dev/null differ diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml index d17b720f..c526ea38 100644 --- a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml +++ b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml @@ -187,4 +187,20 @@ + + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml new file mode 100644 index 00000000..0e7eb744 --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs new file mode 100644 index 00000000..63eb3343 --- /dev/null +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs @@ -0,0 +1,19 @@ +using System.Windows; +using HandyControlDemo.Data; + +namespace HandyControlDemo.UserControl +{ + public partial class GeometryItem + { + public GeometryItem() => InitializeComponent(); + + public static readonly DependencyProperty InfoProperty = DependencyProperty.Register( + "Info", typeof(GeometryItemModel), typeof(GeometryItem), new PropertyMetadata(default(GeometryItemModel))); + + public GeometryItemModel Info + { + get => (GeometryItemModel) GetValue(InfoProperty); + set => SetValue(InfoProperty, value); + } + } +} \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml index 88cf8319..28168ea8 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml @@ -2,10 +2,27 @@ 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" - xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs" - xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension" + xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" + DataContext="{Binding RelativeSource={RelativeSource Self}}" Background="{DynamicResource RegionBrush}"> - + + + + + + + + + + + + + + + + + + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml.cs index d2af7c22..a5db3370 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml.cs +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Styles/GeometryDemoCtl.xaml.cs @@ -1,15 +1,24 @@ - -using HandyControl.Data; -using System; -using System.Windows; -using System.Windows.Controls; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; using System.Windows.Media; -using System.Windows.Shapes; +using HandyControl.Themes; +using HandyControl.Tools; +using HandyControlDemo.Data; namespace HandyControlDemo.UserControl { public partial class GeometryDemoCtl { + private readonly HashSet _lineSet = new HashSet + { + "CheckedGeometry" + }; + + public ObservableCollection GeometryItems { get; set; } = + new ObservableCollection(); + public GeometryDemoCtl() { InitializeComponent(); @@ -18,16 +27,19 @@ namespace HandyControlDemo.UserControl public void GenerateGeometries() { - ResourceDictionary dictionary = new ResourceDictionary(); - dictionary.Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Basic/Geometries.xaml", UriKind.Absolute); - foreach (var item in dictionary.Keys) + var uri = new Uri("pack://application:,,,/HandyControl;component/Themes/Basic/Geometries.xaml", UriKind.Absolute); + var dic = SharedResourceDictionary.SharedDictionaries[uri]; + var keys = dic.Keys.OfType().OrderBy(item => item); + + foreach (var key in keys) { - StackPanel stack = new StackPanel { Margin = new Thickness(10) }; - TextBlock text = new TextBlock { Text = item.ToString(), HorizontalAlignment = HorizontalAlignment.Stretch }; - Path path = new Path { Width = 26, Height = 26, Data = TryFindResource(item.ToString()) as Geometry, Fill = TryFindResource(ResourceToken.PrimaryTextBrush) as Brush }; - stack.Children.Add(path); - stack.Children.Add(text); - panel.Children.Add(stack); + var data = ResourceHelper.GetResource(key); + GeometryItems.Add(new GeometryItemModel + { + Key = key, + Data = data, + Line = _lineSet.Contains(key) + }); } } }