add SplitButtonItem
This commit is contained in:
1 parent
a54fc69869
commit
1b49c516c3
8 files changed
+141
-36
No files matched your search
@@ -1,18 +0,0 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using HandyControl.Data.Enum;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class SplitButton : ButtonBase
|
||||
{
|
||||
public static readonly DependencyProperty HitModeProperty = DependencyProperty.Register(
|
||||
"HitMode", typeof(MouseHitMode), typeof(SplitButton), new PropertyMetadata(default(MouseHitMode)));
|
||||
|
||||
public MouseHitMode HitMode
|
||||
{
|
||||
get => (MouseHitMode) GetValue(HitModeProperty);
|
||||
set => SetValue(HitModeProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Data.Enum;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class SplitButton : ItemsControl
|
||||
{
|
||||
public static readonly DependencyProperty HitModeProperty = DependencyProperty.Register(
|
||||
"HitMode", typeof(MouseHitMode), typeof(SplitButton), new PropertyMetadata(default(MouseHitMode)));
|
||||
|
||||
public MouseHitMode HitMode
|
||||
{
|
||||
get => (MouseHitMode) GetValue(HitModeProperty);
|
||||
set => SetValue(HitModeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(
|
||||
"Content", typeof(object), typeof(SplitButton), new PropertyMetadata(default(object)));
|
||||
|
||||
public object Content
|
||||
{
|
||||
get => GetValue(ContentProperty);
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContentTemplateProperty = DependencyProperty.Register(
|
||||
"ContentTemplate", typeof(DataTemplate), typeof(SplitButton), new PropertyMetadata(default(DataTemplate)));
|
||||
|
||||
public DataTemplate ContentTemplate
|
||||
{
|
||||
get => (DataTemplate) GetValue(ContentTemplateProperty);
|
||||
set => SetValue(ContentTemplateProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MaxDropDownHeightProperty = DependencyProperty.Register(
|
||||
"MaxDropDownHeight", typeof(double), typeof(SplitButton), new PropertyMetadata(SystemParameters.PrimaryScreenHeight / 3.0));
|
||||
|
||||
public double MaxDropDownHeight
|
||||
{
|
||||
get => (double) GetValue(MaxDropDownHeightProperty);
|
||||
set => SetValue(MaxDropDownHeightProperty, value);
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item) => item is SplitButtonItem;
|
||||
|
||||
protected override DependencyObject GetContainerForItemOverride() => new SplitButtonItem();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class SplitButtonItem : MenuItem
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -132,11 +132,8 @@ namespace HandyControl.Controls
|
||||
set => SetValue(IsReadOnlyProperty, value);
|
||||
}
|
||||
|
||||
private void RateItemValueChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Value =
|
||||
(from RateItem item in Items where item.IsSelected select item.IsHalf ? 0.5 : 1).Sum();
|
||||
}
|
||||
private void RateItemValueChanged(object sender, RoutedEventArgs e) =>
|
||||
Value = (from RateItem item in Items where item.IsSelected select item.IsHalf ? 0.5 : 1).Sum();
|
||||
|
||||
private void RateItemSelectedChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -163,15 +160,9 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item)
|
||||
{
|
||||
return item is RateItem;
|
||||
}
|
||||
protected override bool IsItemItsOwnContainerOverride(object item) => item is RateItem;
|
||||
|
||||
protected override DependencyObject GetContainerForItemOverride()
|
||||
{
|
||||
return new RateItem();
|
||||
}
|
||||
protected override DependencyObject GetContainerForItemOverride() => new RateItem();
|
||||
|
||||
private void OnApplyTemplateInternal()
|
||||
{
|
||||
@@ -242,9 +233,6 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Value = DefaultValue;
|
||||
}
|
||||
public void Reset() => Value = DefaultValue;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\RectangleAttach.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Attach\TextBlockAttach.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Block\FloatingBlock.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Button\SplitButton.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Button\SplitButton\SplitButton.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Button\SplitButton\SplitButtonItem.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Growl\GrowlWindow.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Image\ImageBlock.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Magnifier.cs" />
|
||||
@@ -40,8 +41,10 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\CloseWindowCommand.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\OpenLinkCommand.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\BorderCircularClipConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\CornerRadiusSplitConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Number2PercentageConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\RectangleCircularConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\ThicknessSplitConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\FrameworkElementExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" />
|
||||
@@ -860,4 +863,10 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="$(MSBuildThisFileDirectory)Controls\Growl\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="E:\Work\GitHub\HandyControl\src\Shared\HandyControl_Shared\Themes\Styles\Base\SplitButtonBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -20,5 +20,7 @@
|
||||
<converter:Object2VisibilityConverter x:Key="Object2VisibilityConverter"/>
|
||||
<converter:Number2PercentageConverter x:Key="Number2PercentageConverter"/>
|
||||
<converter:RectangleCircularConverter x:Key="RectangleCircularConverter"/>
|
||||
<converter:ThicknessSplitConverter x:Key="ThicknessSplitConverter"/>
|
||||
<converter:CornerRadiusSplitConverter x:Key="CornerRadiusSplitConverter"/>
|
||||
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class CornerRadiusSplitConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is CornerRadius cornerRadius)
|
||||
{
|
||||
if (parameter is string str)
|
||||
{
|
||||
var arr = str.Split(',');
|
||||
if (arr.Length != 4) return cornerRadius;
|
||||
|
||||
return new CornerRadius(arr[0].Equals("1") ? cornerRadius.TopLeft : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.TopRight : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.BottomRight : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.BottomLeft : 0);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class ThicknessSplitConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Thickness cornerRadius)
|
||||
{
|
||||
if (parameter is string str)
|
||||
{
|
||||
var arr = str.Split(',');
|
||||
if (arr.Length != 4) return cornerRadius;
|
||||
|
||||
return new CornerRadius(arr[0].Equals("1") ? cornerRadius.Left : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.Top : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.Right : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.Bottom : 0);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user