This commit is contained in:
NaBian committed 2020-06-30 00:09:24 +08:00
1 parent 2d9b6bb8ad
commit 148530b91d
14 files changed
+132 -28

No files matched your search

@@ -0,0 +1,11 @@
<Border x:Class="HandyControlDemo.UserControl.GeometryItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Margin="16"
Cursor="Hand"
mc:Ignorable="d"
Style="{StaticResource BorderCircular}" Background="{DynamicResource RegionBrush}" ToolTip="{Binding Info.Key,RelativeSource={RelativeSource Self}}">
<Path Style="{StaticResource Path4GeometryItem}"/>
</Border>
@@ -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);
}
}
}
@@ -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}">
<hc:TransitioningContentControl>
<WrapPanel Name="panel"/>
<ListBox Effect="{StaticResource EffectShadow2}" Margin="32" BorderThickness="0" Style="{StaticResource ListBoxCustom}" Background="Transparent" ItemsSource="{Binding GeometryItems}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<hc:HoneycombPanel>
<hc:HoneycombPanel.RenderTransform>
<TransformGroup>
<TranslateTransform X="-32"/>
</TransformGroup>
</hc:HoneycombPanel.RenderTransform>
</hc:HoneycombPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<userControl:GeometryItem Info="{Binding}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</hc:TransitioningContentControl>
</UserControl>
@@ -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<string> _lineSet = new HashSet<string>
{
"CheckedGeometry"
};
public ObservableCollection<GeometryItemModel> GeometryItems { get; set; } =
new ObservableCollection<GeometryItemModel>();
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<string>().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<Geometry>(key);
GeometryItems.Add(new GeometryItemModel
{
Key = key,
Data = data,
Line = _lineSet.Contains(key)
});
}
}
}