mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-30 02:48:03 +08:00
added two editors
This commit is contained in:
parent
198ef78872
commit
f4b1796f98
@ -55,6 +55,7 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window">
|
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window">
|
||||||
|
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||||
<Setter Property="BorderThickness" Value="1"/>
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace HandyControlDemo.Data
|
namespace HandyControlDemo.Data
|
||||||
{
|
{
|
||||||
public class PropertyGridDemoModel
|
public class PropertyGridDemoModel
|
||||||
{
|
{
|
||||||
[Category("Info")]
|
[Category("Category1")]
|
||||||
public string Name { get; set; }
|
public string String { get; set; }
|
||||||
|
|
||||||
[Category("Achievement")]
|
[Category("Category2")]
|
||||||
public int Score { get; set; }
|
public int Integer { get; set; }
|
||||||
|
|
||||||
[Category("Achievement")]
|
[Category("Category2")]
|
||||||
public bool IsPassed { get; set; }
|
public bool Boolean { get; set; }
|
||||||
|
|
||||||
[Category("Info")]
|
[Category("Category1")]
|
||||||
public Gender Gender { get; set; }
|
public Gender Enum { get; set; }
|
||||||
|
|
||||||
|
public HorizontalAlignment HorizontalAlignment { get; set; }
|
||||||
|
|
||||||
|
public VerticalAlignment VerticalAlignment { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Gender
|
public enum Gender
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<hc:Window x:Class="HandyControlDemo.MainWindow"
|
<hc:GlowWindow x:Class="HandyControlDemo.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
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:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
@ -7,11 +7,13 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="HandyControlDemo"
|
Title="HandyControlDemo"
|
||||||
ShowTitle="False"
|
ShowTitle="False"
|
||||||
|
Style="{StaticResource WindowGlow}"
|
||||||
Background="{DynamicResource SecondaryRegionBrush}"
|
Background="{DynamicResource SecondaryRegionBrush}"
|
||||||
|
ActiveGlowColor="#f06632"
|
||||||
ResizeMode="CanResizeWithGrip"
|
ResizeMode="CanResizeWithGrip"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
d:DesignHeight="800"
|
d:DesignHeight="800"
|
||||||
d:DesignWidth="1400"
|
d:DesignWidth="1400"
|
||||||
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
|
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
|
||||||
<ContentControl Name="ControlMain"/>
|
<ContentControl Name="ControlMain"/>
|
||||||
</hc:Window>
|
</hc:GlowWindow>
|
||||||
|
@ -11,11 +11,13 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<hc:PropertyGrid Width="500" SelectedObject="{Binding DemoModel}"/>
|
<hc:PropertyGrid Width="500" SelectedObject="{Binding DemoModel}"/>
|
||||||
<StackPanel Grid.Row="1" Margin="10,16,10,10">
|
<StackPanel hc:TitleElement.TitleWidth="168" Grid.Row="1" Margin="20,16,17,10">
|
||||||
<TextBox hc:TitleElement.Title="Name" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Name,Mode=OneWay}" IsReadOnly="True"/>
|
<TextBox hc:TitleElement.Title="String" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.String,Mode=OneWay}" IsReadOnly="True"/>
|
||||||
<TextBox hc:TitleElement.Title="Gender" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Gender,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
<TextBox hc:TitleElement.Title="Enum" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Enum,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||||
<TextBox hc:TitleElement.Title="Score" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Score,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
<TextBox hc:TitleElement.Title="Integer" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Integer,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||||
<TextBox hc:TitleElement.Title="IsPassed" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.IsPassed,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
<TextBox hc:TitleElement.Title="Boolean" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.Boolean,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||||
|
<TextBox hc:TitleElement.Title="HorizontalAlignment" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.HorizontalAlignment,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||||
|
<TextBox hc:TitleElement.Title="VerticalAlignment" hc:TitleElement.TitlePlacement="Left" Style="{StaticResource TextBoxExtend}" Text="{Binding DemoModel.VerticalAlignment,Mode=OneWay}" IsReadOnly="True" Margin="0,6,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</hc:TransitioningContentControl>
|
</hc:TransitioningContentControl>
|
||||||
|
@ -11,10 +11,11 @@ namespace HandyControlDemo.UserControl
|
|||||||
|
|
||||||
DemoModel = new PropertyGridDemoModel
|
DemoModel = new PropertyGridDemoModel
|
||||||
{
|
{
|
||||||
Name = "TestName",
|
String = "TestString",
|
||||||
Gender = Gender.Female,
|
Enum = Gender.Female,
|
||||||
IsPassed = true,
|
Boolean = true,
|
||||||
Score = 98
|
Integer = 98,
|
||||||
|
VerticalAlignment = VerticalAlignment.Stretch
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@
|
|||||||
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/fr.png"/>
|
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/fr.png"/>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Button.Click="ButtonLangs_OnClick" Margin="10,0">
|
<StackPanel Button.Click="ButtonLangs_OnClick" Margin="10,0,0,0">
|
||||||
<Button Tag="ko-KR" Style="{StaticResource ButtonCustom}">
|
<Button Tag="ko-KR" Style="{StaticResource ButtonCustom}">
|
||||||
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/ko-KR.png"/>
|
<Image Width="32" Source="/HandyControlDemo;component/Resources/Img/Flag/ko-KR.png"/>
|
||||||
</Button>
|
</Button>
|
||||||
@ -142,6 +142,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<hc:Divider LineStrokeDashArray="2,2" Orientation="Vertical" Margin="0,20" LineStrokeThickness="2"/>
|
||||||
<StackPanel Button.Click="ButtonSkins_OnClick" Margin="10,10,10,10">
|
<StackPanel Button.Click="ButtonSkins_OnClick" Margin="10,10,10,10">
|
||||||
<Button Tag="{x:Static hc:SkinType.Default}" Style="{StaticResource ButtonCustom}">
|
<Button Tag="{x:Static hc:SkinType.Default}" Style="{StaticResource ButtonCustom}">
|
||||||
<Border Background="White" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
|
<Border Background="White" Width="32" Height="21" CornerRadius="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}"/>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||||
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
|
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
Style="{StaticResource WindowBlur}"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Title="{ex:Lang Key={x:Static langs:LangKeys.Title}}"
|
Title="{ex:Lang Key={x:Static langs:LangKeys.Title}}"
|
||||||
Height="450"
|
Height="450"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||||
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
|
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
Style="{StaticResource WindowGlow}"
|
||||||
Background="{DynamicResource MainContentBackgroundBrush}"
|
Background="{DynamicResource MainContentBackgroundBrush}"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Title="{ex:Lang Key={x:Static langs:LangKeys.Title}}"
|
Title="{ex:Lang Key={x:Static langs:LangKeys.Title}}"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using HandyControl.Tools;
|
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
{
|
{
|
||||||
@ -18,15 +17,6 @@ namespace HandyControl.Controls
|
|||||||
set => SetValue(OrientationProperty, value);
|
set => SetValue(OrientationProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty ItemStyleSelectorProperty = DependencyProperty.Register(
|
|
||||||
"ItemStyleSelector", typeof(StyleSelector), typeof(ButtonGroup), new PropertyMetadata(new ButtonGroupItemStyleSelector()));
|
|
||||||
|
|
||||||
public StyleSelector ItemStyleSelector
|
|
||||||
{
|
|
||||||
get => (StyleSelector)GetValue(ItemStyleSelectorProperty);
|
|
||||||
set => SetValue(ItemStyleSelectorProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
|
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
|
||||||
{
|
{
|
||||||
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
|
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
|
||||||
@ -35,7 +25,7 @@ namespace HandyControl.Controls
|
|||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var item = (ButtonBase)Items[i];
|
var item = (ButtonBase)Items[i];
|
||||||
item.Style = ItemStyleSelector?.SelectStyle(item, this);
|
item.Style = ItemContainerStyleSelector?.SelectStyle(item, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using HandyControl.Tools;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls
|
||||||
|
{
|
||||||
|
public class HorizontalAlignmentPropertyEditor : PropertyEditorBase
|
||||||
|
{
|
||||||
|
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new System.Windows.Controls.ComboBox
|
||||||
|
{
|
||||||
|
Style = ResourceHelper.GetResource<Style>("ComboBoxCapsule"),
|
||||||
|
ItemsSource = Enum.GetValues(propertyItem.PropertyType),
|
||||||
|
ItemTemplateSelector = ResourceHelper.GetResource<DataTemplateSelector>("HorizontalAlignmentPathTemplateSelector"),
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left
|
||||||
|
};
|
||||||
|
|
||||||
|
public override DependencyProperty GetDependencyProperty() => Selector.SelectedValueProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HorizontalAlignmentPathTemplateSelector : DataTemplateSelector
|
||||||
|
{
|
||||||
|
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||||
|
{
|
||||||
|
if (item is HorizontalAlignment horizontalAlignment)
|
||||||
|
{
|
||||||
|
var dataTemplate = new DataTemplate
|
||||||
|
{
|
||||||
|
DataType = typeof(System.Windows.Controls.ComboBox)
|
||||||
|
};
|
||||||
|
|
||||||
|
var factory = new FrameworkElementFactory(typeof(Path));
|
||||||
|
factory.SetValue(FrameworkElement.WidthProperty, 12.0);
|
||||||
|
factory.SetValue(FrameworkElement.HeightProperty, 10.0);
|
||||||
|
factory.SetBinding(Shape.FillProperty, new Binding(Control.ForegroundProperty.Name)
|
||||||
|
{
|
||||||
|
RelativeSource = new RelativeSource
|
||||||
|
{
|
||||||
|
AncestorType = typeof(ComboBoxItem)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (horizontalAlignment)
|
||||||
|
{
|
||||||
|
case HorizontalAlignment.Left:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignLeftGeometry"));
|
||||||
|
break;
|
||||||
|
case HorizontalAlignment.Center:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignHCenterGeometry"));
|
||||||
|
break;
|
||||||
|
case HorizontalAlignment.Right:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignRightGeometry"));
|
||||||
|
break;
|
||||||
|
case HorizontalAlignment.Stretch:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignHStretchGeometry"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTemplate.VisualTree = factory;
|
||||||
|
return dataTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,11 @@ using System.Windows.Data;
|
|||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
{
|
{
|
||||||
public abstract class PropertyEditorBase : FrameworkElement
|
public abstract class PropertyEditorBase : DependencyObject
|
||||||
{
|
{
|
||||||
public abstract FrameworkElement CreateElement(PropertyItem propertyItem);
|
public abstract FrameworkElement CreateElement(PropertyItem propertyItem);
|
||||||
|
|
||||||
public virtual void CreateBinding(PropertyItem propertyItem, FrameworkElement element) =>
|
public virtual void CreateBinding(PropertyItem propertyItem, DependencyObject element) =>
|
||||||
BindingOperations.SetBinding(element, GetDependencyProperty(),
|
BindingOperations.SetBinding(element, GetDependencyProperty(),
|
||||||
new Binding($"({propertyItem.PropertyName})")
|
new Binding($"({propertyItem.PropertyName})")
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using HandyControl.Tools;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls
|
||||||
|
{
|
||||||
|
public class VerticalAlignmentPropertyEditor : PropertyEditorBase
|
||||||
|
{
|
||||||
|
public override FrameworkElement CreateElement(PropertyItem propertyItem) => new System.Windows.Controls.ComboBox
|
||||||
|
{
|
||||||
|
Style = ResourceHelper.GetResource<Style>("ComboBoxCapsule"),
|
||||||
|
ItemsSource = Enum.GetValues(propertyItem.PropertyType),
|
||||||
|
ItemTemplateSelector = ResourceHelper.GetResource<DataTemplateSelector>("VerticalAlignmentPathTemplateSelector"),
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Left
|
||||||
|
};
|
||||||
|
|
||||||
|
public override DependencyProperty GetDependencyProperty() => Selector.SelectedValueProperty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class VerticalAlignmentPathTemplateSelector : DataTemplateSelector
|
||||||
|
{
|
||||||
|
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||||
|
{
|
||||||
|
if (item is VerticalAlignment verticalAlignment)
|
||||||
|
{
|
||||||
|
var dataTemplate = new DataTemplate
|
||||||
|
{
|
||||||
|
DataType = typeof(System.Windows.Controls.ComboBox)
|
||||||
|
};
|
||||||
|
|
||||||
|
var factory = new FrameworkElementFactory(typeof(Path));
|
||||||
|
factory.SetValue(FrameworkElement.WidthProperty, 10.0);
|
||||||
|
factory.SetValue(FrameworkElement.HeightProperty, 12.0);
|
||||||
|
factory.SetBinding(Shape.FillProperty, new Binding(Control.ForegroundProperty.Name)
|
||||||
|
{
|
||||||
|
RelativeSource = new RelativeSource
|
||||||
|
{
|
||||||
|
AncestorType = typeof(ComboBoxItem)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (verticalAlignment)
|
||||||
|
{
|
||||||
|
case VerticalAlignment.Top:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignTopGeometry"));
|
||||||
|
break;
|
||||||
|
case VerticalAlignment.Center:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignVCenterGeometry"));
|
||||||
|
break;
|
||||||
|
case VerticalAlignment.Bottom:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignBottomGeometry"));
|
||||||
|
break;
|
||||||
|
case VerticalAlignment.Stretch:
|
||||||
|
factory.SetValue(Path.DataProperty, ResourceHelper.GetResource<Geometry>("AlignVStretchGeometry"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTemplate.VisualTree = factory;
|
||||||
|
return dataTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using HandyControl.Properties.Langs;
|
using HandyControl.Properties.Langs;
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
@ -22,18 +23,20 @@ namespace HandyControl.Controls
|
|||||||
[typeof(float)] = EditorTypeCode.SingleNumber,
|
[typeof(float)] = EditorTypeCode.SingleNumber,
|
||||||
[typeof(double)] = EditorTypeCode.DoubleNumber,
|
[typeof(double)] = EditorTypeCode.DoubleNumber,
|
||||||
[typeof(bool)] = EditorTypeCode.Switch,
|
[typeof(bool)] = EditorTypeCode.Switch,
|
||||||
[typeof(DateTime)] = EditorTypeCode.DateTime
|
[typeof(DateTime)] = EditorTypeCode.DateTime,
|
||||||
|
[typeof(HorizontalAlignment)] = EditorTypeCode.HorizontalAlignment,
|
||||||
|
[typeof(VerticalAlignment)] = EditorTypeCode.VerticalAlignment
|
||||||
};
|
};
|
||||||
|
|
||||||
public string ResolveCategory(PropertyDescriptor propertyDescriptor)
|
public string ResolveCategory(PropertyDescriptor propertyDescriptor)
|
||||||
{
|
{
|
||||||
var category = propertyDescriptor.Category;
|
var categoryAttribute = propertyDescriptor.Attributes.OfType<CategoryAttribute>().FirstOrDefault();
|
||||||
if (string.IsNullOrEmpty(category))
|
|
||||||
{
|
|
||||||
category = Lang.Miscellaneous;
|
|
||||||
}
|
|
||||||
|
|
||||||
return category;
|
return categoryAttribute == null ?
|
||||||
|
Lang.Miscellaneous :
|
||||||
|
string.IsNullOrEmpty(categoryAttribute.Category) ?
|
||||||
|
Lang.Miscellaneous :
|
||||||
|
categoryAttribute.Category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ResolveDisplayName(PropertyDescriptor propertyDescriptor)
|
public string ResolveDisplayName(PropertyDescriptor propertyDescriptor)
|
||||||
@ -88,6 +91,8 @@ namespace HandyControl.Controls
|
|||||||
EditorTypeCode.DoubleNumber => new NumberPropertyEditor(double.MinValue, double.MaxValue),
|
EditorTypeCode.DoubleNumber => new NumberPropertyEditor(double.MinValue, double.MaxValue),
|
||||||
EditorTypeCode.Switch => new SwitchPropertyEditor(),
|
EditorTypeCode.Switch => new SwitchPropertyEditor(),
|
||||||
EditorTypeCode.DateTime => new DateTimePropertyEditor(),
|
EditorTypeCode.DateTime => new DateTimePropertyEditor(),
|
||||||
|
EditorTypeCode.HorizontalAlignment => new HorizontalAlignmentPropertyEditor(),
|
||||||
|
EditorTypeCode.VerticalAlignment => new VerticalAlignmentPropertyEditor(),
|
||||||
_ => new ReadOnlyTextPropertyEditor()
|
_ => new ReadOnlyTextPropertyEditor()
|
||||||
}
|
}
|
||||||
: type.IsSubclassOf(typeof(Enum))
|
: type.IsSubclassOf(typeof(Enum))
|
||||||
@ -110,7 +115,9 @@ namespace HandyControl.Controls
|
|||||||
SingleNumber,
|
SingleNumber,
|
||||||
DoubleNumber,
|
DoubleNumber,
|
||||||
Switch,
|
Switch,
|
||||||
DateTime
|
DateTime,
|
||||||
|
HorizontalAlignment,
|
||||||
|
VerticalAlignment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
@ -9,11 +8,6 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
public class BlurWindow : Window
|
public class BlurWindow : Window
|
||||||
{
|
{
|
||||||
static BlurWindow()
|
|
||||||
{
|
|
||||||
StyleProperty.OverrideMetadata(typeof(BlurWindow), new FrameworkPropertyMetadata(ResourceHelper.GetResource<Style>(ResourceToken.WindowBlur)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnApplyTemplate()
|
public override void OnApplyTemplate()
|
||||||
{
|
{
|
||||||
base.OnApplyTemplate();
|
base.OnApplyTemplate();
|
||||||
|
@ -48,12 +48,6 @@ namespace HandyControl.Controls
|
|||||||
set => SetValue(InactiveGlowColorProperty, value);
|
set => SetValue(InactiveGlowColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GlowWindow()
|
|
||||||
{
|
|
||||||
StyleProperty.OverrideMetadata(typeof(GlowWindow), new FrameworkPropertyMetadata(ResourceHelper.GetResource<Style>(ResourceToken.WindowGlow)));
|
|
||||||
ResizeModeProperty.OverrideMetadata(typeof(GlowWindow), new FrameworkPropertyMetadata(OnResizeModeChanged));
|
|
||||||
}
|
|
||||||
|
|
||||||
#region internal
|
#region internal
|
||||||
|
|
||||||
internal void EndDeferGlowChanges()
|
internal void EndDeferGlowChanges()
|
||||||
|
@ -358,6 +358,18 @@
|
|||||||
|
|
||||||
internal const string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast);
|
internal const string TabItemCapsuleVerticalLast = nameof(TabItemCapsuleVerticalLast);
|
||||||
|
|
||||||
|
internal const string ComboBoxItemCapsuleDefault = nameof(ComboBoxItemCapsuleDefault);
|
||||||
|
|
||||||
|
internal const string ComboBoxItemCapsuleSingle = nameof(ComboBoxItemCapsuleSingle);
|
||||||
|
|
||||||
|
internal const string ComboBoxItemCapsuleHorizontalFirst = nameof(ComboBoxItemCapsuleHorizontalFirst);
|
||||||
|
|
||||||
|
internal const string ComboBoxItemCapsuleHorizontalLast = nameof(ComboBoxItemCapsuleHorizontalLast);
|
||||||
|
|
||||||
|
internal const string ComboBoxItemCapsuleVerticalFirst = nameof(ComboBoxItemCapsuleVerticalFirst);
|
||||||
|
|
||||||
|
internal const string ComboBoxItemCapsuleVerticalLast = nameof(ComboBoxItemCapsuleVerticalLast);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,11 +35,13 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Divider.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Divider.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Drawer.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Drawer.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Magnifier.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Magnifier.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\ButtonGroup.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Button\ButtonGroup.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Card.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Notification.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Notification.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Poptip.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Poptip.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Watermark.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Watermark.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\VerticalAlignmentPropertyEditor.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\HorizontalAlignmentPropertyEditor.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\EnumPropertyEditor.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\EnumPropertyEditor.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\ReadOnlyTextPropertyEditor.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\ReadOnlyTextPropertyEditor.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\TimePropertyEditor.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Controls\PropertyGrid\Editors\TimePropertyEditor.cs" />
|
||||||
@ -370,6 +372,7 @@
|
|||||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\RegularJudgment.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Tools\RegularJudgment.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\RegularPatterns.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Tools\RegularPatterns.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\StyleSelector\ButtonGroupItemStyleSelector.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Tools\StyleSelector\ButtonGroupItemStyleSelector.cs" />
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)Tools\StyleSelector\ComboBoxItemCapsuleStyleSelector.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\StyleSelector\TabItemCapsuleStyleSelector.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)Tools\StyleSelector\TabItemCapsuleStyleSelector.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -26,6 +26,14 @@
|
|||||||
<Geometry o:Freeze="True" x:Key="WindowRestoreGeometry">M1,3 L1,9 L7,9 L7,3 z M3,1 L3,2 L8,2 L8,7 L9,7 L9,1 z M2,0 L10,0 L10,8 L8,8 L8,10 L0,10 L0,2 L2,2 z</Geometry>
|
<Geometry o:Freeze="True" x:Key="WindowRestoreGeometry">M1,3 L1,9 L7,9 L7,3 z M3,1 L3,2 L8,2 L8,7 L9,7 L9,1 z M2,0 L10,0 L10,8 L8,8 L8,10 L0,10 L0,2 L2,2 z</Geometry>
|
||||||
<Geometry o:Freeze="True" x:Key="WindowMaxGeometry">M1,1 L1,9 L9,9 L9,1 z M0,0 L10,0 L10,10 L0,10 z</Geometry>
|
<Geometry o:Freeze="True" x:Key="WindowMaxGeometry">M1,1 L1,9 L9,9 L9,1 z M0,0 L10,0 L10,10 L0,10 z</Geometry>
|
||||||
<Geometry o:Freeze="True" x:Key="CheckedGeometry">M 0,2 3,5 8,0</Geometry>
|
<Geometry o:Freeze="True" x:Key="CheckedGeometry">M 0,2 3,5 8,0</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignLeftGeometry">M0,8 L4,8 4,10 0,10 z M0,4 L8,4 8,6 0,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignRightGeometry">M8,8 L12,8 12,10 8,10 z M4,4 L12,4 12,6 4,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignHCenterGeometry">M4,8 L8,8 8,10 4,10 z M2,4 L10,4 10,6 2,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignHStretchGeometry">M0,8 L12,8 12,10 0,10 z M0,4 L12,4 12,6 0,6 z M0,0 L12,0 12,2 0,2 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignTopGeometry">M8,0 L10,0 10,4 8,4 z M4,0 L6,0 6,8 4,8 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignBottomGeometry">M8,8 L10,8 10,12 8,12 z M4,4 L6,4 6,12 4,12 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignVCenterGeometry">M8,4 L10,4 10,8 8,8 z M4,2 L6,2 6,10 4,10 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
||||||
|
<Geometry o:Freeze="True" x:Key="AlignVStretchGeometry">M8,0 L10,0 10,12 8,12 z M4,0 L6,0 6,12 4,12 z M0,0 L2,0 2,12 0,12 z</Geometry>
|
||||||
<Geometry o:Freeze="True" x:Key="PageModeGeometry">M1.0000002,12 L1.0000002,13 11,13 11,12 z M1.0000002,10 L1.0000002,11 11,11 11,10 z M1.0000002,8 L1.0000002,9 11,9 11,8 z M1.0000002,6 L1.0000002,7 11,7 11,6 z M1.0000002,4 L1.0000002,5 11,5 11,4 z M1.0000002,2 L1.0000002,3 11,3 11,2 z M0,0 L12,0 12,14 0,14 z</Geometry>
|
<Geometry o:Freeze="True" x:Key="PageModeGeometry">M1.0000002,12 L1.0000002,13 11,13 11,12 z M1.0000002,10 L1.0000002,11 11,11 11,10 z M1.0000002,8 L1.0000002,9 11,9 11,8 z M1.0000002,6 L1.0000002,7 11,7 11,6 z M1.0000002,4 L1.0000002,5 11,5 11,4 z M1.0000002,2 L1.0000002,3 11,3 11,2 z M0,0 L12,0 12,14 0,14 z</Geometry>
|
||||||
<Geometry o:Freeze="True" x:Key="TwoPageModeGeometry">M8.99999988079071,12L8.99999988079071,13 13,13 13,12z M1,12L1,13 5,13 5,12z M9.00000011920929,10L9.00000011920929,11 13,11 13,10z M1,10L1,11 5,11 5,10z M9.00000011920929,8L9.00000011920929,9 13,9 13,8z M1,8L1,9 5,9 5,8z M9.00000011920929,6L9.00000011920929,7 13,7 13,6z M1,6L1,7 5,7 5,6z M9.00000011920929,4L9.00000011920929,5 13,5 13,4z M1,4L1,5 5,5 5,4z M8.99999988079071,2L8.99999988079071,3 13,3 13,2z M1,2L1,3 5,3 5,2z M7.99999994039536,0L14,0 14,14 7.99999994039536,14z M0,0L6,0 6,14 0,14z</Geometry>
|
<Geometry o:Freeze="True" x:Key="TwoPageModeGeometry">M8.99999988079071,12L8.99999988079071,13 13,13 13,12z M1,12L1,13 5,13 5,12z M9.00000011920929,10L9.00000011920929,11 13,11 13,10z M1,10L1,11 5,11 5,10z M9.00000011920929,8L9.00000011920929,9 13,9 13,8z M1,8L1,9 5,9 5,8z M9.00000011920929,6L9.00000011920929,7 13,7 13,6z M1,6L1,7 5,7 5,6z M9.00000011920929,4L9.00000011920929,5 13,5 13,4z M1,4L1,5 5,5 5,4z M8.99999988079071,2L8.99999988079071,3 13,3 13,2z M1,2L1,3 5,3 5,2z M7.99999994039536,0L14,0 14,14 7.99999994039536,14z M0,0L6,0 6,14 0,14z</Geometry>
|
||||||
<Geometry o:Freeze="True" x:Key="ScrollModeGeometry">M1,12L1,13 8,13 8,12z M1,10L1,11 8,11 8,10z M1,8L1,9 8,9 8,8z M1,6L1,7 8,7 8,6z M11.0000002384186,5L11.0000002384186,9 13,9 13,5z M1,4L1,5 8,5 8,4z M1,2L1,3 8,3 8,2z M10.0000000298023,0L14,0 14,14 10.0000000298023,14z M0,0L9.00000011920929,0 9.00000011920929,14 0,14z</Geometry>
|
<Geometry o:Freeze="True" x:Key="ScrollModeGeometry">M1,12L1,13 8,13 8,12z M1,10L1,11 8,11 8,10z M1,8L1,9 8,9 8,8z M1,6L1,7 8,7 8,6z M11.0000002384186,5L11.0000002384186,9 13,9 13,5z M1,4L1,5 8,5 8,4z M1,2L1,3 8,3 8,2z M10.0000000298023,0L14,0 14,14 10.0000000298023,14z M0,0L9.00000011920929,0 9.00000011920929,14 0,14z</Geometry>
|
||||||
|
@ -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:controls="clr-namespace:HandyControl.Controls">
|
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||||
|
xmlns:tools="clr-namespace:HandyControl.Tools">
|
||||||
|
|
||||||
<ItemsPanelTemplate x:Key="ButtonGroupHorizontalItemsPanelTemplate">
|
<ItemsPanelTemplate x:Key="ButtonGroupHorizontalItemsPanelTemplate">
|
||||||
<UniformGrid FocusVisualStyle="{x:Null}" Rows="1"/>
|
<UniformGrid FocusVisualStyle="{x:Null}" Rows="1"/>
|
||||||
@ -10,7 +11,10 @@
|
|||||||
<UniformGrid FocusVisualStyle="{x:Null}" Columns="1"/>
|
<UniformGrid FocusVisualStyle="{x:Null}" Columns="1"/>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
|
|
||||||
|
<tools:ButtonGroupItemStyleSelector x:Key="ButtonGroupItemStyleSelector"/>
|
||||||
|
|
||||||
<Style x:Key="ButtonGroupBaseStyle" TargetType="controls:ButtonGroup">
|
<Style x:Key="ButtonGroupBaseStyle" TargetType="controls:ButtonGroup">
|
||||||
|
<Setter Property="ItemContainerStyleSelector" Value="{StaticResource ButtonGroupItemStyleSelector}"/>
|
||||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||||
<Setter Property="Focusable" Value="False"/>
|
<Setter Property="Focusable" Value="False"/>
|
||||||
|
@ -115,7 +115,7 @@
|
|||||||
<Setter Property="Focusable" Value="False"/>
|
<Setter Property="Focusable" Value="False"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="hc:PropertyGrid">
|
<Style x:Key="PropertyGridBaseStyle" TargetType="hc:PropertyGrid">
|
||||||
<Setter Property="MaxTitleWidth" Value="200"/>
|
<Setter Property="MaxTitleWidth" Value="200"/>
|
||||||
<Setter Property="MinTitleWidth" Value="120"/>
|
<Setter Property="MinTitleWidth" Value="120"/>
|
||||||
<Setter Property="Focusable" Value="False"/>
|
<Setter Property="Focusable" Value="False"/>
|
||||||
|
@ -1,11 +1,100 @@
|
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:controls="clr-namespace:HandyControl.Controls"
|
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||||
xmlns:themes="clr-namespace:HandyControl.Themes">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:themes="clr-namespace:HandyControl.Themes"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||||
|
xmlns:tools="clr-namespace:HandyControl.Tools">
|
||||||
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Base/PropertyGridBaseStyle.xaml"/>
|
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Base/PropertyGridBaseStyle.xaml"/>
|
||||||
|
<themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/ComboBox.xaml"/>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
<Style BasedOn="{StaticResource PropertyGridBaseStyle}" TargetType="controls:Badge"/>
|
<Style BasedOn="{StaticResource PropertyGridBaseStyle}" TargetType="controls:PropertyGrid"/>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleBaseStyle" BasedOn="{x:Null}" TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="MinWidth" Value="40"/>
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||||
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Setter Property="BorderThickness" Value="1"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
|
<Setter Property="controls:BorderElement.CornerRadius" Value="0"/>
|
||||||
|
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}"/>
|
||||||
|
<Setter Property="Padding" Value="10,0"/>
|
||||||
|
<Setter Property="Margin" Value="-1,0,0,0"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ComboBoxItem">
|
||||||
|
<Border x:Name="BorderRoot" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||||
|
<ContentPresenter x:Name="contentPresenter" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" TextElement.Foreground="{TemplateBinding Foreground}" Focusable="False" HorizontalAlignment="Center" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Panel.ZIndex" Value="{x:Static system:Int32.MaxValue}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||||
|
<Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsSelected" Value="true">
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
|
||||||
|
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||||
|
<Setter Property="TextElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleDefault" BasedOn="{StaticResource ComboBoxItemCapsuleBaseStyle}" TargetType="ComboBoxItem"/>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleHorizontalFirst" BasedOn="{StaticResource ComboBoxItemCapsuleBaseStyle}" TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="controls:BorderElement.CornerRadius" Value="4,0,0,4"/>
|
||||||
|
<Setter Property="Margin" Value="0"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleHorizontalLast" BasedOn="{StaticResource ComboBoxItemCapsuleBaseStyle}" TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="controls:BorderElement.CornerRadius" Value="0,4,4,0"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleSingle" BasedOn="{StaticResource ComboBoxItemCapsuleBaseStyle}" TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="controls:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleVerticalFirst" BasedOn="{StaticResource ComboBoxItemCapsuleBaseStyle}" TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="controls:BorderElement.CornerRadius" Value="4,4,0,0"/>
|
||||||
|
<Setter Property="Margin" Value="0"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxItemCapsuleVerticalLast" BasedOn="{StaticResource ComboBoxItemCapsuleBaseStyle}" TargetType="ComboBoxItem">
|
||||||
|
<Setter Property="controls:BorderElement.CornerRadius" Value="0,0,4,4"/>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<ItemsPanelTemplate x:Key="ComboBoxCapsuleItemsPanelTemplate">
|
||||||
|
<UniformGrid FocusVisualStyle="{x:Null}" Rows="1"/>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
|
||||||
|
<tools:ComboBoxItemCapsuleStyleSelector x:Key="ComboBoxItemCapsuleStyleSelector"/>
|
||||||
|
|
||||||
|
<Style x:Key="ComboBoxCapsule" BasedOn="{x:Null}" TargetType="ComboBox">
|
||||||
|
<Setter Property="ItemContainerStyleSelector" Value="{StaticResource ComboBoxItemCapsuleStyleSelector}"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||||
|
<Setter Property="Focusable" Value="False"/>
|
||||||
|
<Setter Property="ItemsPanel" Value="{StaticResource ComboBoxCapsuleItemsPanelTemplate}"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ComboBox">
|
||||||
|
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<controls:HorizontalAlignmentPathTemplateSelector x:Key="HorizontalAlignmentPathTemplateSelector"/>
|
||||||
|
<controls:VerticalAlignmentPathTemplateSelector x:Key="VerticalAlignmentPathTemplateSelector"/>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
@ -0,0 +1,30 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using HandyControl.Data;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools
|
||||||
|
{
|
||||||
|
public class ComboBoxItemCapsuleStyleSelector : StyleSelector
|
||||||
|
{
|
||||||
|
public override Style SelectStyle(object item, DependencyObject container)
|
||||||
|
{
|
||||||
|
if (container is ComboBoxItem comboBoxItem && VisualHelper.GetParent<ComboBox>(comboBoxItem) is { } comboBox)
|
||||||
|
{
|
||||||
|
var count = comboBox.Items.Count;
|
||||||
|
if (count == 1)
|
||||||
|
{
|
||||||
|
return ResourceHelper.GetResource<Style>(ResourceToken.ComboBoxItemCapsuleSingle);
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = comboBox.ItemContainerGenerator.IndexFromContainer(comboBoxItem);
|
||||||
|
return index == 0
|
||||||
|
? ResourceHelper.GetResource<Style>(ResourceToken.ComboBoxItemCapsuleHorizontalFirst)
|
||||||
|
: ResourceHelper.GetResource<Style>(index == count - 1
|
||||||
|
? ResourceToken.ComboBoxItemCapsuleHorizontalLast
|
||||||
|
: ResourceToken.ComboBoxItemCapsuleDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ namespace HandyControl.Tools
|
|||||||
{
|
{
|
||||||
public override Style SelectStyle(object item, DependencyObject container)
|
public override Style SelectStyle(object item, DependencyObject container)
|
||||||
{
|
{
|
||||||
if (item is TabItem tabItem && tabItem.Parent is TabControl tabControl)
|
if (container is TabItem tabItem && VisualHelper.GetParent<TabControl>(tabItem) is { } tabControl)
|
||||||
{
|
{
|
||||||
var count = tabControl.Items.Count;
|
var count = tabControl.Items.Count;
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
@ -16,7 +16,7 @@ namespace HandyControl.Tools
|
|||||||
return ResourceHelper.GetResource<Style>(ResourceToken.TabItemCapsuleSingle);
|
return ResourceHelper.GetResource<Style>(ResourceToken.TabItemCapsuleSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = tabControl.Items.IndexOf(tabItem);
|
var index = tabControl.ItemContainerGenerator.IndexFromContainer(tabItem);
|
||||||
return index == 0
|
return index == 0
|
||||||
? ResourceHelper.GetResource<Style>(
|
? ResourceHelper.GetResource<Style>(
|
||||||
tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
||||||
|
Loading…
Reference in New Issue
Block a user