mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-29 18:38:30 +08:00
Add ColorPicker
This commit is contained in:
parent
09766e18eb
commit
a0b6fc87f9
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
/HandyControl/obj/Debug
|
||||
/HandyControlDemo/bin/Debug
|
||||
/HandyControlDemo/obj/Debug
|
||||
/HandyControl.sln.DotSettings.user
|
||||
|
128
HandyControl/Controls/ColorPicker.xaml
Normal file
128
HandyControl/Controls/ColorPicker.xaml
Normal file
@ -0,0 +1,128 @@
|
||||
<UserControl x:Class="HandyControl.Controls.ColorPicker"
|
||||
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"
|
||||
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||
mc:Ignorable="d"
|
||||
Name="UserControlMain"
|
||||
Width="230"
|
||||
UseLayoutRounding="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="122"/>
|
||||
<RowDefinition Height="110"/>
|
||||
<RowDefinition Height="62"/>
|
||||
<RowDefinition Height="62"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Border BorderThickness="1" BorderBrush="{StaticResource BorderBrush}" Grid.RowSpan="4" Background="White" CornerRadius="{Binding CornerRadius,ElementName=UserControlMain}"></Border>
|
||||
<Grid Margin="1" Grid.Row="0" Name="GridColor">
|
||||
<Border Background="{Binding BackColor,ElementName=UserControlMain}" CornerRadius="2,2,0,0"></Border>
|
||||
<Border CornerRadius="2,2,0,0">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="/HandyControl;component/Resources/colorPickerBack.png"/>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<!--<Border CornerRadius="2,2,0,0">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
|
||||
<GradientStop Color="#00FFFFFF" Offset="1"/>
|
||||
<GradientStop Color="#FFFFFFFF" Offset="0"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Border CornerRadius="2,2,0,0">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="#00FFFFFF" Offset="0"/>
|
||||
<GradientStop Color="#FF000000" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>-->
|
||||
</Grid>
|
||||
<Border Name="BorderColor" Grid.Row="0" CornerRadius="2,2,0,0" ClipToBounds="True">
|
||||
<Canvas Margin="-6">
|
||||
<Border Name="BorderPicker" Background="Transparent" Height="12" CornerRadius="6" Width="12" BorderThickness="1" BorderBrush="White">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect ShadowDepth="0" Opacity=".4"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Canvas>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Background="Transparent" Name="BorderDrag">
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactivity:MouseDragElementBehavior DragFinished="MouseDragElementBehavior_OnDragFinished" DragBegun="MouseDragElementBehavior_OnDragging" Dragging="MouseDragElementBehavior_OnDragging"/>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</Border>
|
||||
<Grid Margin="16,16,10,0" Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="28"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Width="60" Height="32" CornerRadius="2" Background="{StaticResource ColorPickerOpacityBrush}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1"></Border>
|
||||
<Border Grid.Row="0" Grid.Column="0" Width="60" Height="32" CornerRadius="2" Background="{Binding SelectedBrush,ElementName=UserControlMain}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1"></Border>
|
||||
<Slider Name="SliderColor" LargeChange="0.01" SmallChange="0.01" Grid.ColumnSpan="2" ValueChanged="SliderColor_OnValueChanged" Value="1" Maximum="1" Background="{StaticResource ColorPickerRainbowBrush}" Margin="10,1,0,0" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" Style="{StaticResource ColorPickerSlider}" IsMoveToPointEnabled="True"></Slider>
|
||||
<Slider Grid.ColumnSpan="2" IsSnapToTickEnabled="True" Name="SliderOpacity" ValueChanged="SliderOpacity_OnValueChanged" Value="255" Maximum="255" SmallChange="1" Foreground="{Binding SelectedBrushWithoutOpacity,ElementName=UserControlMain}" Background="{StaticResource ColorPickerOpacityBrush}" Margin="10,0,0,0" Grid.Row="0" Grid.Column="1" VerticalAlignment="Bottom" Style="{StaticResource ColorPickerSlider}" IsMoveToPointEnabled="True"></Slider>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,14,0,0" VerticalAlignment="Top" Visibility="{Binding ShowList[0],ElementName=UserControlMain,Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||
<controls:InfoTextBox Text="{Binding SelectedBrush,ElementName=UserControlMain,Mode=TwoWay,Converter={StaticResource Color2HexStrConverter},UpdateSourceTrigger=LostFocus}" FontSize="10" ShowSmallCornerRadius="True" MaxLength="10" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoTextBox>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="HEX" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<UniformGrid controls:InfoNumericUpDown.ValueChanged="InfoNumericUpDownRgb_OnValueChanged" Visibility="{Binding ShowList[1],ElementName=UserControlMain,Converter={StaticResource Boolean2VisibilityConverter}}" Rows="1" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="-2,14,-2,0" VerticalAlignment="Top">
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoNumericUpDown Tag="R" x:Name="ChannelR" Value="255" ShowUpDownButton="False" Maximum="255" Minimum="0" TextPadding="0" FontSize="10" ShowSmallCornerRadius="True" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoNumericUpDown>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="R" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoNumericUpDown Tag="G" x:Name="ChannelG" Value="255" ShowUpDownButton="False" Maximum="255" Minimum="0" TextPadding="0" FontSize="10" ShowSmallCornerRadius="True" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoNumericUpDown>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="G" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoNumericUpDown Tag="B" x:Name="ChannelB" Value="255" ShowUpDownButton="False" Maximum="255" Minimum="0" TextPadding="0" FontSize="10" ShowSmallCornerRadius="True" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoNumericUpDown>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="B" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoNumericUpDown Value="{Binding Value,ElementName=SliderOpacity,Mode=TwoWay}" ShowUpDownButton="False" Maximum="255" Minimum="0" TextPadding="0" FontSize="10" ShowSmallCornerRadius="True" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoNumericUpDown>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="A" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
</UniformGrid>
|
||||
<!--<UniformGrid Visibility="{Binding ShowList[2],ElementName=UserControlMain,Converter={StaticResource Boolean2VisibilityConverter}}" Rows="1" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="-2,14,-2,0" VerticalAlignment="Top">
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoTextBox TextPadding="0" Text="{Binding ColorInfoList[5],ElementName=UserControlMain}" FontSize="10" ShowSmallCornerRadius="True" MaxLength="3" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoTextBox>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="H" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoTextBox TextPadding="0" Text="{Binding ColorInfoList[6],ElementName=UserControlMain}" FontSize="10" ShowSmallCornerRadius="True" MaxLength="3" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoTextBox>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="S" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoTextBox TextPadding="0" Text="{Binding ColorInfoList[7],ElementName=UserControlMain}" FontSize="10" ShowSmallCornerRadius="True" MaxLength="3" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoTextBox>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="L" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="2,0">
|
||||
<controls:InfoTextBox TextPadding="0" Text="{Binding ColorInfoList[8],ElementName=UserControlMain}" FontSize="10" ShowSmallCornerRadius="True" MaxLength="3" ShowClearButton="False" HorizontalTextAlignment="Center" IsNeedly="False" Height="24" ></controls:InfoTextBox>
|
||||
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="A" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
</UniformGrid>-->
|
||||
<Button Click="ButtonSwitch_OnClick" Padding="6" FontSize="8" BorderThickness="0" Foreground="#323534" HorizontalAlignment="Right" Height="24" Width="20" Grid.Column="2" Grid.Row="1">
|
||||
<Button.Content>
|
||||
<Path Fill="#323534" Style="{StaticResource UpDownPathStyle}"></Path>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</Grid>
|
||||
<Border Grid.Row="2" BorderThickness="0,1,0,0" BorderBrush="{StaticResource BorderBrush}">
|
||||
<WrapPanel Name="PanelColor" Margin="12,12,0,12" HorizontalAlignment="Center"></WrapPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="{StaticResource BorderBrush}">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button Click="ButtonCancel_OnClick" Content="取消" Width="60" Margin="0,0,16,0"></Button>
|
||||
<Button Click="ButtonSure_OnClick" Content="确定" Width="60" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
558
HandyControl/Controls/ColorPicker.xaml.cs
Normal file
558
HandyControl/Controls/ColorPicker.xaml.cs
Normal file
@ -0,0 +1,558 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色拾取器
|
||||
/// </summary>
|
||||
public partial class ColorPicker
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前显示的颜色类型
|
||||
/// </summary>
|
||||
private int _colorType;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经加载控件
|
||||
/// </summary>
|
||||
private bool _isLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要更新小球位置
|
||||
/// </summary>
|
||||
private bool _isNeedUpdatePicker = true;
|
||||
|
||||
/// <summary>
|
||||
/// 是否在拖动小球
|
||||
/// </summary>
|
||||
private bool _isOnDragging;
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要更新信息
|
||||
/// </summary>
|
||||
private bool IsNeedUpdateInfo { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色分值
|
||||
/// </summary>
|
||||
private const double ColorInterval = 1 / 6.0;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色选取面板宽度
|
||||
/// </summary>
|
||||
private const double ColorPanelWidth = 230;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色选取面板高度
|
||||
/// </summary>
|
||||
private const double ColorPanelHeight = 122;
|
||||
|
||||
/// <summary>
|
||||
/// 预设的颜色(一共18个,两行)
|
||||
/// </summary>
|
||||
private readonly List<string> _colorPresetList = new List<string>
|
||||
{
|
||||
"#f44336",
|
||||
"#e91e63",
|
||||
"#9c27b0",
|
||||
"#673ab7",
|
||||
"#3f51b5",
|
||||
"#2196f3",
|
||||
"#03a9f4",
|
||||
"#00bcd4",
|
||||
"#009688",
|
||||
|
||||
"#4caf50",
|
||||
"#8bc34a",
|
||||
"#cddc39",
|
||||
"#ffeb3b",
|
||||
"#ffc107",
|
||||
"#ff9800",
|
||||
"#ff5722",
|
||||
"#795548",
|
||||
"#9e9e9e"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 颜色范围集合
|
||||
/// </summary>
|
||||
private readonly List<ColorRange> _colorRangeList = new List<ColorRange>
|
||||
{
|
||||
new ColorRange
|
||||
{
|
||||
Color1 = Color.FromRgb(255, 0, 0),
|
||||
Color2 = Color.FromRgb(255, 0, 255)
|
||||
},
|
||||
new ColorRange
|
||||
{
|
||||
Color1 = Color.FromRgb(255, 0, 255),
|
||||
Color2 = Color.FromRgb(0, 0, 255)
|
||||
},
|
||||
new ColorRange
|
||||
{
|
||||
Color1 = Color.FromRgb(0, 0, 255),
|
||||
Color2 = Color.FromRgb(0, 255, 255)
|
||||
},
|
||||
new ColorRange
|
||||
{
|
||||
Color1 = Color.FromRgb(0, 255, 255),
|
||||
Color2 = Color.FromRgb(0, 255, 0)
|
||||
},
|
||||
new ColorRange
|
||||
{
|
||||
Color1 = Color.FromRgb(0, 255, 0),
|
||||
Color2 = Color.FromRgb(255, 255, 0)
|
||||
},
|
||||
new ColorRange
|
||||
{
|
||||
Color1 = Color.FromRgb(255, 255, 0),
|
||||
Color2 = Color.FromRgb(255, 0, 0)
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 颜色分隔集合
|
||||
/// </summary>
|
||||
private readonly List<Color> _colorSeparateList = new List<Color>
|
||||
{
|
||||
Color.FromRgb(255, 0, 0),
|
||||
Color.FromRgb(255, 0, 255),
|
||||
Color.FromRgb(0, 0, 255),
|
||||
Color.FromRgb(0, 255, 255),
|
||||
Color.FromRgb(0, 255, 0),
|
||||
Color.FromRgb(255, 255, 0)
|
||||
};
|
||||
|
||||
internal static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
|
||||
"CornerRadius", typeof(CornerRadius), typeof(ColorPicker), new PropertyMetadata(new CornerRadius(2)));
|
||||
|
||||
internal CornerRadius CornerRadius
|
||||
{
|
||||
get => (CornerRadius)GetValue(CornerRadiusProperty);
|
||||
set => SetValue(CornerRadiusProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 颜色改变事件
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent ColorSelectedEvent =
|
||||
EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
|
||||
typeof(EventHandler<FunctionEventArgs<Color>>), typeof(ColorPicker));
|
||||
|
||||
/// <summary>
|
||||
/// 颜色改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<FunctionEventArgs<Color>> ColorSelected
|
||||
{
|
||||
add => AddHandler(ColorSelectedEvent, value);
|
||||
remove => RemoveHandler(ColorSelectedEvent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消事件
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent CanceledEvent =
|
||||
EventManager.RegisterRoutedEvent("Canceled", RoutingStrategy.Bubble,
|
||||
typeof(EventHandler), typeof(ColorPicker));
|
||||
|
||||
/// <summary>
|
||||
/// 取消事件
|
||||
/// </summary>
|
||||
public event EventHandler Canceled
|
||||
{
|
||||
add => AddHandler(CanceledEvent, value);
|
||||
remove => RemoveHandler(CanceledEvent, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedBrushProperty = DependencyProperty.Register(
|
||||
"SelectedBrush", typeof(SolidColorBrush), typeof(ColorPicker), new PropertyMetadata(Brushes.White,
|
||||
(o, args) =>
|
||||
{
|
||||
var ctl = (ColorPicker)o;
|
||||
var v = (SolidColorBrush)args.NewValue;
|
||||
|
||||
if (ctl.ChannelR == null) return;
|
||||
|
||||
if (ctl.IsNeedUpdateInfo)
|
||||
{
|
||||
ctl.IsNeedUpdateInfo = false;
|
||||
ctl.ChannelR.Value = v.Color.R;
|
||||
ctl.ChannelG.Value = v.Color.G;
|
||||
ctl.ChannelB.Value = v.Color.B;
|
||||
ctl.SliderOpacity.Value = v.Color.A;
|
||||
ctl.IsNeedUpdateInfo = true;
|
||||
}
|
||||
ctl.UpdateStatus(v.Color);
|
||||
ctl.SelectedBrushWithoutOpacity = new SolidColorBrush(Color.FromRgb(v.Color.R, v.Color.G, v.Color.B));
|
||||
}));
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的颜色
|
||||
/// </summary>
|
||||
public SolidColorBrush SelectedBrush
|
||||
{
|
||||
get => (SolidColorBrush)GetValue(SelectedBrushProperty);
|
||||
set => SetValue(SelectedBrushProperty, value);
|
||||
}
|
||||
|
||||
private static readonly DependencyProperty SelectedBrushWithoutOpacityProperty = DependencyProperty.Register(
|
||||
"SelectedBrushWithoutOpacity", typeof(SolidColorBrush), typeof(ColorPicker), new PropertyMetadata(Brushes.White));
|
||||
|
||||
private SolidColorBrush SelectedBrushWithoutOpacity
|
||||
{
|
||||
get => (SolidColorBrush)GetValue(SelectedBrushWithoutOpacityProperty);
|
||||
set => SetValue(SelectedBrushWithoutOpacityProperty, value);
|
||||
}
|
||||
|
||||
private static readonly DependencyProperty BackColorProperty = DependencyProperty.Register(
|
||||
"BackColor", typeof(SolidColorBrush), typeof(ColorPicker), new PropertyMetadata(Brushes.Red));
|
||||
|
||||
private SolidColorBrush BackColor
|
||||
{
|
||||
get => (SolidColorBrush)GetValue(BackColorProperty);
|
||||
set => SetValue(BackColorProperty, value);
|
||||
}
|
||||
|
||||
private static readonly DependencyProperty ShowListProperty = DependencyProperty.Register(
|
||||
"ShowList", typeof(List<bool>), typeof(ColorPicker), new PropertyMetadata(new List<bool>
|
||||
{
|
||||
true, false, false
|
||||
}));
|
||||
|
||||
private List<bool> ShowList
|
||||
{
|
||||
get => (List<bool>)GetValue(ShowListProperty);
|
||||
set => SetValue(ShowListProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前显示的颜色类型
|
||||
/// </summary>
|
||||
private int ColorType
|
||||
{
|
||||
get => _colorType;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
_colorType = 1;
|
||||
}
|
||||
else if (value > 1)
|
||||
{
|
||||
_colorType = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_colorType = value;
|
||||
}
|
||||
|
||||
var list = new List<bool>();
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
list.Add(false);
|
||||
}
|
||||
list[_colorType] = true;
|
||||
ShowList = list;
|
||||
}
|
||||
}
|
||||
|
||||
public ColorPicker()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
UpdateStatus(SelectedBrush.Color);
|
||||
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
if (!_isLoaded)
|
||||
{
|
||||
Init();
|
||||
_isLoaded = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
private void Init()
|
||||
{
|
||||
foreach (var item in _colorPresetList)
|
||||
{
|
||||
PanelColor.Children.Add(CreateColorButton(item));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建颜色按钮
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Button CreateColorButton(string colorStr)
|
||||
{
|
||||
var colorObj = ColorConverter.ConvertFromString(colorStr);
|
||||
var color = default(Color);
|
||||
if (colorObj != null)
|
||||
{
|
||||
color = (Color)colorObj;
|
||||
}
|
||||
var brush = new SolidColorBrush(color);
|
||||
|
||||
var button = new Button
|
||||
{
|
||||
Margin = new Thickness(0, 0, 12, 12),
|
||||
Style = FindResource("ButtonOpacityStyle") as Style,
|
||||
Content = new Border
|
||||
{
|
||||
Background = brush,
|
||||
Width = 12,
|
||||
Height = 12,
|
||||
CornerRadius = new CornerRadius(2)
|
||||
}
|
||||
};
|
||||
|
||||
button.Click += (s, e) =>
|
||||
{
|
||||
SelectedBrush = brush;
|
||||
SliderOpacity.Value = SliderOpacity.Maximum;
|
||||
};
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内部更新
|
||||
/// </summary>
|
||||
private void UpdateStatus(Color color)
|
||||
{
|
||||
if (_isOnDragging) return;
|
||||
|
||||
var r = color.R;
|
||||
var g = color.G;
|
||||
var b = color.B;
|
||||
var list = new List<byte>
|
||||
{
|
||||
r,
|
||||
g,
|
||||
b
|
||||
};
|
||||
|
||||
var max = list.Max();
|
||||
var min = list.Min();
|
||||
|
||||
if (min == max)
|
||||
{
|
||||
if (!(r == g && b == g))
|
||||
{
|
||||
BackColor = Brushes.Red;
|
||||
IsNeedUpdateInfo = false;
|
||||
if (!SliderColor.IsMouseOver && !SliderOpacity.IsMouseOver)
|
||||
{
|
||||
SliderColor.Value = 0;
|
||||
}
|
||||
IsNeedUpdateInfo = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var maxIndex = list.IndexOf(max);
|
||||
var minIndex = list.IndexOf(min);
|
||||
var commonIndex = 3 - maxIndex - minIndex;
|
||||
if (commonIndex == 3)
|
||||
{
|
||||
BackColor = Brushes.Red;
|
||||
IsNeedUpdateInfo = false;
|
||||
if (!SliderColor.IsMouseOver && !SliderOpacity.IsMouseOver)
|
||||
{
|
||||
SliderColor.Value = 0;
|
||||
}
|
||||
IsNeedUpdateInfo = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var common = list[commonIndex];
|
||||
list[maxIndex] = 255;
|
||||
list[minIndex] = 0;
|
||||
list[commonIndex] = (byte)(255 * max * (min - common) / (double)(max * (min - max)));
|
||||
BackColor = new SolidColorBrush(Color.FromRgb(list[0], list[1], list[2]));
|
||||
|
||||
list[commonIndex] = 0;
|
||||
var cIndex = _colorSeparateList.IndexOf(Color.FromRgb(list[0], list[1], list[2]));
|
||||
int sub;
|
||||
var direc = 0;
|
||||
if (cIndex < 5 && cIndex > 0)
|
||||
{
|
||||
var nextColorList = _colorSeparateList[cIndex + 1].ToList();
|
||||
var prevColorList = _colorSeparateList[cIndex - 1].ToList();
|
||||
if (nextColorList[minIndex] > 0)
|
||||
{
|
||||
var target = prevColorList[commonIndex];
|
||||
direc = 1;
|
||||
sub = target - common;
|
||||
}
|
||||
else
|
||||
{
|
||||
sub = common;
|
||||
}
|
||||
}
|
||||
else if (cIndex == 0)
|
||||
{
|
||||
sub = common;
|
||||
if (minIndex == 2)
|
||||
{
|
||||
sub = 255 - common;
|
||||
direc = -5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sub = 255 - common;
|
||||
}
|
||||
var scale = sub / 255.0;
|
||||
var scaleTotal = ColorInterval * (cIndex - direc) + scale * ColorInterval;
|
||||
IsNeedUpdateInfo = false;
|
||||
if (!SliderColor.IsMouseOver && !SliderOpacity.IsMouseOver)
|
||||
{
|
||||
SliderColor.Value = SliderColor.Maximum * scaleTotal;
|
||||
}
|
||||
IsNeedUpdateInfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
var matrix = BorderPicker.RenderTransform.Value;
|
||||
var x = max == 0 ? 0 : (1 - min / (double)max) * ColorPanelWidth;
|
||||
var y = (1 - max / 255.0) * ColorPanelHeight;
|
||||
if (_isNeedUpdatePicker)
|
||||
{
|
||||
BorderPicker.RenderTransform = new MatrixTransform(matrix.M11, matrix.M12, matrix.M21, matrix.M22, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private void SliderColor_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (!_isLoaded || !IsNeedUpdateInfo) return;
|
||||
var newValue = e.NewValue;
|
||||
var div = newValue / ColorInterval;
|
||||
var index = Math.Min(5, (int)Math.Floor(newValue / ColorInterval));
|
||||
var sub = div - index;
|
||||
var range = _colorRangeList[index];
|
||||
|
||||
var color = range.GetColor(sub);
|
||||
BackColor = new SolidColorBrush(color);
|
||||
var matrix = BorderPicker.RenderTransform.Value;
|
||||
_isNeedUpdatePicker = false;
|
||||
UpdateColorWhenDrag(new Point(matrix.OffsetX, matrix.OffsetY));
|
||||
_isNeedUpdatePicker = true;
|
||||
}
|
||||
|
||||
private void SliderOpacity_OnValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (!_isLoaded || !IsNeedUpdateInfo) return;
|
||||
var color = SelectedBrush.Color;
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb((byte)SliderOpacity.Value, color.R, color.G, color.B));
|
||||
}
|
||||
|
||||
private void MouseDragElementBehavior_OnDragging(object sender, MouseEventArgs e)
|
||||
{
|
||||
var p = e.GetPosition(BorderColor);
|
||||
_isOnDragging = true;
|
||||
UpdateColorWhenDrag(p);
|
||||
_isOnDragging = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拖动时更新颜色
|
||||
/// </summary>
|
||||
private void UpdateColorWhenDrag(Point p)
|
||||
{
|
||||
var matrix = BorderPicker.RenderTransform.Value;
|
||||
|
||||
if (p.X < 0)
|
||||
{
|
||||
p.X = 0;
|
||||
}
|
||||
else if (p.X > ColorPanelWidth)
|
||||
{
|
||||
p.X = ColorPanelWidth;
|
||||
}
|
||||
|
||||
if (p.Y < 0)
|
||||
{
|
||||
p.Y = 0;
|
||||
}
|
||||
else if (p.Y > ColorPanelHeight)
|
||||
{
|
||||
p.Y = ColorPanelHeight;
|
||||
}
|
||||
|
||||
if (_isNeedUpdatePicker)
|
||||
{
|
||||
BorderPicker.RenderTransform = new MatrixTransform(matrix.M11, matrix.M12, matrix.M21, matrix.M22, p.X, p.Y);
|
||||
}
|
||||
|
||||
var scaleX = p.X / ColorPanelWidth;
|
||||
var scaleY = 1 - p.Y / ColorPanelHeight;
|
||||
|
||||
var colorYLeft = Color.FromRgb((byte)(255 * scaleY), (byte)(255 * scaleY), (byte)(255 * scaleY));
|
||||
var colorYRight = Color.FromRgb((byte)(BackColor.Color.R * scaleY), (byte)(BackColor.Color.G * scaleY), (byte)(BackColor.Color.B * scaleY));
|
||||
|
||||
var subR = colorYLeft.R - colorYRight.R;
|
||||
var subG = colorYLeft.G - colorYRight.G;
|
||||
var subB = colorYLeft.B - colorYRight.B;
|
||||
|
||||
var color = Color.FromArgb((byte)SliderOpacity.Value, (byte)(colorYLeft.R - subR * scaleX),
|
||||
(byte)(colorYLeft.G - subG * scaleX), (byte)(colorYLeft.B - subB * scaleX));
|
||||
SelectedBrush = new SolidColorBrush(color);
|
||||
}
|
||||
|
||||
private void MouseDragElementBehavior_OnDragFinished(object sender, MouseEventArgs e) => BorderDrag.RenderTransform = new MatrixTransform();
|
||||
|
||||
private void ButtonSwitch_OnClick(object sender, RoutedEventArgs e) => ColorType++;
|
||||
|
||||
private void InfoNumericUpDownRgb_OnValueChanged(object sender, FunctionEventArgs<double> e)
|
||||
{
|
||||
if (!_isLoaded || !IsNeedUpdateInfo) return;
|
||||
if (e.OriginalSource is InfoNumericUpDown ctl && ctl.Tag is string tag)
|
||||
{
|
||||
var color = SelectedBrush.Color;
|
||||
IsNeedUpdateInfo = false;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case "R":
|
||||
{
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb(color.A, (byte)e.Info, color.G, color.B));
|
||||
break;
|
||||
}
|
||||
case "G":
|
||||
{
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, (byte)e.Info, color.B));
|
||||
break;
|
||||
}
|
||||
case "B":
|
||||
{
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, (byte)e.Info));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IsNeedUpdateInfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSure_OnClick(object sender, RoutedEventArgs e)
|
||||
=> RaiseEvent(new FunctionEventArgs<Color>(ColorSelectedEvent, this)
|
||||
{
|
||||
Info = SelectedBrush.Color
|
||||
});
|
||||
|
||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
||||
}
|
||||
}
|
35
HandyControl/Controls/IconElement.cs
Normal file
35
HandyControl/Controls/IconElement.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class IconElement : DependencyObject
|
||||
{
|
||||
public static readonly DependencyProperty GeometryProperty = DependencyProperty.RegisterAttached(
|
||||
"Geometry", typeof(Geometry), typeof(IconElement), new PropertyMetadata(default(Geometry)));
|
||||
|
||||
public static void SetGeometry(DependencyObject element, Geometry value)
|
||||
{
|
||||
element.SetValue(GeometryProperty, value);
|
||||
}
|
||||
|
||||
public static Geometry GetGeometry(DependencyObject element)
|
||||
{
|
||||
return (Geometry)element.GetValue(GeometryProperty);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AngleProperty = DependencyProperty.RegisterAttached(
|
||||
"Angle", typeof(double), typeof(IconElement), new PropertyMetadata(default(double)));
|
||||
|
||||
public static void SetAngle(DependencyObject element, double value)
|
||||
{
|
||||
element.SetValue(AngleProperty, value);
|
||||
}
|
||||
|
||||
public static double GetAngle(DependencyObject element)
|
||||
{
|
||||
return (double)element.GetValue(AngleProperty);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
374
HandyControl/Controls/Info/InfoControl.cs
Normal file
374
HandyControl/Controls/Info/InfoControl.cs
Normal file
@ -0,0 +1,374 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using HandyControl.Data.Enum;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Converter;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public abstract class InfoControl : UserControl
|
||||
{
|
||||
private bool _isFocused;
|
||||
|
||||
protected TextBlock ErrorTextBlock;
|
||||
|
||||
protected TextBox ContentTextBox;
|
||||
|
||||
protected StackPanel TitleStackPanel;
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
||||
"Title", typeof(string), typeof(InfoControl), new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get => (string)GetValue(TitleProperty);
|
||||
set => SetValue(TitleProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||
"Text", typeof(string), typeof(InfoControl), new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
||||
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
public string Text
|
||||
{
|
||||
get => (string)GetValue(TextProperty);
|
||||
set => SetValue(TextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为必填项
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsNeedlyProperty = DependencyProperty.Register(
|
||||
"IsNeedly", typeof(bool), typeof(InfoControl), new PropertyMetadata(true));
|
||||
|
||||
/// <summary>
|
||||
/// 是否为必填项
|
||||
/// </summary>
|
||||
public bool IsNeedly
|
||||
{
|
||||
get => (bool)GetValue(IsNeedlyProperty);
|
||||
set => SetValue(IsNeedlyProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 占位符
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty PlaceHolderProperty = DependencyProperty.Register(
|
||||
"PlaceHolder", typeof(string), typeof(InfoControl), new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// 占位符
|
||||
/// </summary>
|
||||
public string PlaceHolder
|
||||
{
|
||||
get => (string)GetValue(PlaceHolderProperty);
|
||||
set => SetValue(PlaceHolderProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ErrorStrProperty = DependencyProperty.Register(
|
||||
"ErrorStr", typeof(string), typeof(InfoControl), new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorStr
|
||||
{
|
||||
get => (string)GetValue(ErrorStrProperty);
|
||||
set => SetValue(ErrorStrProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控件是否包含错误
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register(
|
||||
"IsError", typeof(bool), typeof(InfoControl), new PropertyMetadata(default(bool)));
|
||||
|
||||
/// <summary>
|
||||
/// 控件是否包含错误
|
||||
/// </summary>
|
||||
public bool IsError
|
||||
{
|
||||
get => (bool)GetValue(IsErrorProperty);
|
||||
set => SetValue(IsErrorProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题宽度
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.RegisterAttached(
|
||||
"TitleWidth", typeof(GridLength), typeof(InfoControl),
|
||||
new FrameworkPropertyMetadata(GridLength.Auto, FrameworkPropertyMetadataOptions.Inherits));
|
||||
|
||||
/// <summary>
|
||||
/// 设置标题宽度
|
||||
/// </summary>
|
||||
public static void SetTitleWidth(DependencyObject element, GridLength value)
|
||||
{
|
||||
element.SetValue(TitleWidthProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题宽度
|
||||
/// </summary>
|
||||
public static GridLength GetTitleWidth(DependencyObject element)
|
||||
{
|
||||
return (GridLength)element.GetValue(TitleWidthProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题宽度
|
||||
/// </summary>
|
||||
public GridLength TitleWidth
|
||||
{
|
||||
get => (GridLength)GetValue(TitleWidthProperty);
|
||||
set => SetValue(TitleWidthProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题对齐方式
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TitleAlignmentProperty = DependencyProperty.Register(
|
||||
"TitleAlignment", typeof(TitleAlignment), typeof(InfoControl), new PropertyMetadata(TitleAlignment.Left,
|
||||
(o, args) =>
|
||||
{
|
||||
var ctl = (InfoControl)o;
|
||||
var v = (TitleAlignment)args.NewValue;
|
||||
if (v == TitleAlignment.Left)
|
||||
{
|
||||
Grid.SetColumn(ctl.TitleStackPanel, 0);
|
||||
Grid.SetRow(ctl.TitleStackPanel, 1);
|
||||
ctl.HorizontalAlignment = HorizontalAlignment.Right;
|
||||
ctl.Height = ctl.MaxHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
Grid.SetColumn(ctl.TitleStackPanel, 1);
|
||||
Grid.SetRow(ctl.TitleStackPanel, 0);
|
||||
ctl.TitleStackPanel.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
ctl.TitleStackPanel.Margin = new Thickness(4, 0, 0, 4);
|
||||
ctl.Height += 18;
|
||||
}
|
||||
}));
|
||||
|
||||
/// <summary>
|
||||
/// 标题对齐方式
|
||||
/// </summary>
|
||||
public TitleAlignment TitleAlignment
|
||||
{
|
||||
get => (TitleAlignment)GetValue(TitleAlignmentProperty);
|
||||
set => SetValue(TitleAlignmentProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本的水平对齐方式
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HorizontalTextAlignmentProperty = DependencyProperty.Register(
|
||||
"HorizontalTextAlignment", typeof(HorizontalAlignment), typeof(InfoControl), new PropertyMetadata(HorizontalAlignment.Left));
|
||||
|
||||
/// <summary>
|
||||
/// 文本的水平对齐方式
|
||||
/// </summary>
|
||||
public HorizontalAlignment HorizontalTextAlignment
|
||||
{
|
||||
get => (HorizontalAlignment)GetValue(HorizontalTextAlignmentProperty);
|
||||
set => SetValue(HorizontalTextAlignmentProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示清除按钮
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowClearButtonProperty = DependencyProperty.Register(
|
||||
"ShowClearButton", typeof(bool), typeof(InfoControl), new PropertyMetadata(true, (o, args) =>
|
||||
{
|
||||
var ctl = (InfoControl)o;
|
||||
var v = (bool)args.NewValue;
|
||||
if (!(ctl.FindName("ButtonClear") is Button button)) return;
|
||||
BindingOperations.ClearBinding(button, VisibilityProperty);
|
||||
button.IsEnabled = v;
|
||||
if (v)
|
||||
{
|
||||
button.SetBinding(VisibilityProperty, new Binding("Text")
|
||||
{
|
||||
Source = ctl,
|
||||
Converter = new String2VisibilityConverter()
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
button.Collapse();
|
||||
}
|
||||
}));
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示清除按钮
|
||||
/// </summary>
|
||||
public bool ShowClearButton
|
||||
{
|
||||
get => (bool)GetValue(ShowClearButtonProperty);
|
||||
set => SetValue(ShowClearButtonProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示小圆角
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowSmallCornerRadiusProperty = DependencyProperty.Register(
|
||||
"ShowSmallCornerRadius", typeof(bool), typeof(InfoControl), new PropertyMetadata(default(bool), (o, args) =>
|
||||
{
|
||||
var ctl = (InfoControl)o;
|
||||
var v = (bool)args.NewValue;
|
||||
ctl.CornerRadius = v ? new CornerRadius(2, 2, 2, 2) : new CornerRadius(4, 4, 4, 4);
|
||||
}));
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示小圆角
|
||||
/// </summary>
|
||||
public bool ShowSmallCornerRadius
|
||||
{
|
||||
get => (bool)GetValue(ShowSmallCornerRadiusProperty);
|
||||
set => SetValue(ShowSmallCornerRadiusProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 圆角
|
||||
/// </summary>
|
||||
protected static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
|
||||
"CornerRadius", typeof(CornerRadius), typeof(InfoControl), new PropertyMetadata(new CornerRadius(4, 4, 4, 4)));
|
||||
|
||||
/// <summary>
|
||||
/// 圆角
|
||||
/// </summary>
|
||||
protected CornerRadius CornerRadius
|
||||
{
|
||||
get => (CornerRadius)GetValue(CornerRadiusProperty);
|
||||
set => SetValue(CornerRadiusProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本内边距
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty TextPaddingProperty = DependencyProperty.Register(
|
||||
"TextPadding", typeof(Thickness), typeof(InfoControl), new PropertyMetadata(new Thickness(6, 0, 0, 0)));
|
||||
|
||||
/// <summary>
|
||||
/// 文本内边距
|
||||
/// </summary>
|
||||
public Thickness TextPadding
|
||||
{
|
||||
get => (Thickness)GetValue(TextPaddingProperty);
|
||||
set => SetValue(TextPaddingProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
public virtual void Update()
|
||||
{
|
||||
if (!IsError)
|
||||
{
|
||||
if (!_isFocused)
|
||||
{
|
||||
(TryFindResource("Storyboard2") as Storyboard)?.Begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
(TryFindResource("Storyboard3") as Storyboard)?.Begin();
|
||||
}
|
||||
ErrorTextBlock.BeginAnimation(MarginProperty, AnimationHelper.CreateAnimation(new Thickness(4, 0, 0, 1)));
|
||||
return;
|
||||
}
|
||||
(TryFindResource("Storyboard4") as Storyboard)?.Begin();
|
||||
ErrorTextBlock.BeginAnimation(MarginProperty, AnimationHelper.CreateAnimation(new Thickness(4, 0, 0, -ErrorTextBlock.ActualHeight - 2)));
|
||||
}
|
||||
|
||||
protected virtual void InputBox_OnLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isFocused = false;
|
||||
CheckInfo();
|
||||
}
|
||||
|
||||
protected virtual void InputBox_OnGotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isFocused = true;
|
||||
if (!IsError)
|
||||
{
|
||||
(TryFindResource("Storyboard3") as Storyboard)?.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InputBox_OnMouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!IsError && !ContentTextBox.IsFocused)
|
||||
{
|
||||
(TryFindResource("Storyboard1") as Storyboard)?.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InputBox_OnMouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!IsError && !ContentTextBox.IsFocused)
|
||||
{
|
||||
(TryFindResource("Storyboard2") as Storyboard)?.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InputBox_OnTextChanged(object sender, TextChangedEventArgs e) => CheckInfo();
|
||||
|
||||
protected virtual void ButtonClear_OnClick(object sender, RoutedEventArgs e) => Text = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 文本类型
|
||||
/// </summary>
|
||||
public TextType TextType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 正则字符串(当文本类型为Common时,此属性才生效)
|
||||
/// </summary>
|
||||
public string RegularStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用于监测数据的正确性
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool CheckInfo()
|
||||
{
|
||||
bool result;
|
||||
if (TextType == TextType.Common)
|
||||
{
|
||||
if (string.IsNullOrEmpty(RegularStr))
|
||||
{
|
||||
result = !IsNeedly || !string.IsNullOrEmpty(Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Text.IsKindOf(RegularStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Text.IsKindOf(TextType);
|
||||
}
|
||||
IsError = !result;
|
||||
Update();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
65
HandyControl/Controls/Info/InfoNumericUpDown.xaml
Normal file
65
HandyControl/Controls/Info/InfoNumericUpDown.xaml
Normal file
@ -0,0 +1,65 @@
|
||||
<controls:InfoControl x:Class="HandyControl.Controls.InfoNumericUpDown"
|
||||
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"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||
mc:Ignorable="d"
|
||||
Validation.ErrorTemplate="{x:Null}"
|
||||
FontSize="14"
|
||||
MinHeight="24"
|
||||
Height="36"
|
||||
MaxHeight="54"
|
||||
d:DesignWidth="300">
|
||||
<controls:InfoControl.Resources>
|
||||
<Storyboard x:Key="Storyboard1">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource PrimaryTextColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Storyboard2">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource BorderColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Storyboard3">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource PrimaryColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Storyboard4">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource DangerColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</controls:InfoControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding TitleWidth,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Name="StackPanelTitle" Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<TextBlock Visibility="{Binding IsNeedly,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource Boolean2VisibilityConverter}}" VerticalAlignment="Center" Margin="0,0,6,0" Text="*" Foreground="{DynamicResource DangerBrush}"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource String2VisibilityFeConverter}}" Margin="0,0,10,0" Text="{Binding Title,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"></TextBlock>
|
||||
</StackPanel>
|
||||
<TextBlock Margin="4,0,0,1" Grid.Row="1" Name="TextBlockError" Grid.Column="1" VerticalAlignment="Bottom" FontSize="12" Foreground="{DynamicResource DangerBrush}" Text="{Binding ErrorStr,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"></TextBlock>
|
||||
<Border Grid.Row="1" Name="Border" Background="White" Grid.Column="1" CornerRadius="{Binding CornerRadius,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" BorderThickness="1" BorderBrush="Transparent">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding PlaceHolder,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" HorizontalAlignment="Left" Padding="10,0" FontSize="14" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityConverter}}" VerticalAlignment="Center" Foreground="{DynamicResource ThirdlyTextBrush}"/>
|
||||
<TextBox Grid.Column="0" MouseWheel="MyTextBox_OnMouseWheel" HorizontalContentAlignment="{Binding HorizontalTextAlignment,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" TextChanged="InputBox_OnTextChanged" MouseLeave="InputBox_OnMouseLeave" MouseEnter="InputBox_OnMouseEnter" GotFocus="InputBox_OnGotFocus" LostFocus="InputBox_OnLostFocus" Name="MyTextBox" Margin="4,0" BorderThickness="0" VerticalContentAlignment="Center" Padding="{Binding TextPadding,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" Text="{Binding Value,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},UpdateSourceTrigger=PropertyChanged}" Background="{x:Null}"></TextBox>
|
||||
<Button Padding="7" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityFeConverter}}" Focusable="True" Grid.Column="1" Name="ButtonClear" Click="ButtonClear_OnClick" Foreground="{DynamicResource ThirdlyTextBrush}" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Style="{StaticResource ButtonIconTransparent}" Width="36" HorizontalAlignment="Right"></Button>
|
||||
<Button Visibility="{Binding ShowUpDownButton,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource Boolean2VisibilityConverter}}" Padding="7,7,7,3" Focusable="True" Grid.Column="2" Click="ButtonUp_OnClick" Foreground="{DynamicResource ThirdlyTextBrush}" controls:IconElement.Geometry="{StaticResource UpGeometry}" Style="{StaticResource ButtonIconTransparent}" Width="36" HorizontalAlignment="Right" VerticalAlignment="Top" Height="17"></Button>
|
||||
<Button Visibility="{Binding ShowUpDownButton,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource Boolean2VisibilityConverter}}" Padding="7,3,7,7" Focusable="True" Grid.Column="2" Click="ButtonDown_OnClick" Foreground="{DynamicResource ThirdlyTextBrush}" controls:IconElement.Geometry="{StaticResource DownGeometry}" Style="{StaticResource ButtonIconTransparent}" Width="36" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="17"></Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</controls:InfoControl>
|
191
HandyControl/Controls/Info/InfoNumericUpDown.xaml.cs
Normal file
191
HandyControl/Controls/Info/InfoNumericUpDown.xaml.cs
Normal file
@ -0,0 +1,191 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using HandyControl.Data;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// InfoNumericUpDown.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class InfoNumericUpDown
|
||||
{
|
||||
public InfoNumericUpDown()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ErrorTextBlock = TextBlockError;
|
||||
ContentTextBox = MyTextBox;
|
||||
TitleStackPanel = StackPanelTitle;
|
||||
|
||||
(TryFindResource("Storyboard2") as Storyboard)?.Begin();
|
||||
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
StackPanelTitle.Focusable = true;
|
||||
StackPanelTitle.Focus();
|
||||
StackPanelTitle.Focusable = false;
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
|
||||
"Maximum", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(100.0, (o, args) =>
|
||||
{
|
||||
o.CoerceValue(MinimumProperty);
|
||||
o.CoerceValue(ValueProperty);
|
||||
}, (o, value) =>
|
||||
{
|
||||
var info = (InfoNumericUpDown)o;
|
||||
var max = (double)value;
|
||||
if (max < info.Minimum) max = info.Minimum;
|
||||
return max;
|
||||
}), ValidateValueCallback);
|
||||
|
||||
/// <summary>
|
||||
/// 最大值
|
||||
/// </summary>
|
||||
public double Maximum
|
||||
{
|
||||
get => (double)GetValue(MaximumProperty);
|
||||
set => SetValue(MaximumProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(
|
||||
"Minimum", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(0.0, (o, args) =>
|
||||
{
|
||||
o.CoerceValue(MaximumProperty);
|
||||
o.CoerceValue(ValueProperty);
|
||||
}, (o, value) =>
|
||||
{
|
||||
var info = (InfoNumericUpDown)o;
|
||||
var min = (double)value;
|
||||
if (min > info.Maximum) min = info.Maximum;
|
||||
return min;
|
||||
}), ValidateValueCallback);
|
||||
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public double Minimum
|
||||
{
|
||||
get => (double)GetValue(MinimumProperty);
|
||||
set => SetValue(MinimumProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前值
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
|
||||
"Value", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(1.0, (o, args) =>
|
||||
{
|
||||
o.CoerceValue(MinimumProperty);
|
||||
o.CoerceValue(MaximumProperty);
|
||||
var ctl = (InfoNumericUpDown)o;
|
||||
ctl.RaiseEvent(new FunctionEventArgs<double>(ValueChangedEvent, ctl)
|
||||
{
|
||||
Info = (double)args.NewValue
|
||||
});
|
||||
}, (o, value) =>
|
||||
{
|
||||
var info = (InfoNumericUpDown)o;
|
||||
var current = (double)value;
|
||||
|
||||
if (current < info.Minimum) current = info.Minimum;
|
||||
if (current > info.Maximum) current = info.Maximum;
|
||||
|
||||
return current;
|
||||
}), ValidateValueCallback);
|
||||
|
||||
/// <summary>
|
||||
/// 值验证回调
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private static bool ValidateValueCallback(object value)
|
||||
{
|
||||
var v = (double)value;
|
||||
return !(double.IsNaN(v) || double.IsInfinity(v));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前值
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get => (double)GetValue(ValueProperty);
|
||||
set => SetValue(ValueProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最小改变值
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty SmallChangeProperty = DependencyProperty.Register(
|
||||
"SmallChange", typeof(double), typeof(InfoNumericUpDown), new PropertyMetadata(1.0), ValidateValueCallback);
|
||||
|
||||
/// <summary>
|
||||
/// 最小改变值
|
||||
/// </summary>
|
||||
public double SmallChange
|
||||
{
|
||||
get => (double)GetValue(SmallChangeProperty);
|
||||
set => SetValue(SmallChangeProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示上下调整按钮
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowUpDownButtonProperty = DependencyProperty.Register(
|
||||
"ShowUpDownButton", typeof(bool), typeof(InfoNumericUpDown), new PropertyMetadata(true));
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示上下调整按钮
|
||||
/// </summary>
|
||||
public bool ShowUpDownButton
|
||||
{
|
||||
get => (bool)GetValue(ShowUpDownButtonProperty);
|
||||
set => SetValue(ShowUpDownButtonProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 值改变事件
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent ValueChangedEvent =
|
||||
EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
|
||||
typeof(EventHandler<FunctionEventArgs<double>>), typeof(InfoNumericUpDown));
|
||||
|
||||
/// <summary>
|
||||
/// 值改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<FunctionEventArgs<double>> ValueChanged
|
||||
{
|
||||
add => AddHandler(ValueChangedEvent, value);
|
||||
remove => RemoveHandler(ValueChangedEvent, value);
|
||||
}
|
||||
|
||||
private void ButtonUp_OnClick(object sender, RoutedEventArgs e) => Value += SmallChange;
|
||||
|
||||
private void ButtonDown_OnClick(object sender, RoutedEventArgs e) => Value -= SmallChange;
|
||||
|
||||
private void MyTextBox_OnMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
if (e.Delta > 0)
|
||||
{
|
||||
Value += SmallChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
Value -= SmallChange;
|
||||
}
|
||||
MyTextBox.Select(MyTextBox.Text.Length, 0);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
61
HandyControl/Controls/Info/InfoTextBox.xaml
Normal file
61
HandyControl/Controls/Info/InfoTextBox.xaml
Normal file
@ -0,0 +1,61 @@
|
||||
<controls:InfoControl x:Class="HandyControl.Controls.InfoTextBox"
|
||||
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"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls"
|
||||
mc:Ignorable="d"
|
||||
FontSize="14"
|
||||
MinHeight="24"
|
||||
Height="36"
|
||||
MaxHeight="54"
|
||||
d:DesignWidth="300">
|
||||
<controls:InfoControl.Resources>
|
||||
<Storyboard x:Key="Storyboard1">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource PrimaryTextColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Storyboard2">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource BorderColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Storyboard3">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource PrimaryColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="Storyboard4">
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
|
||||
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource DangerColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</controls:InfoControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding TitleWidth,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Name="StackPanelTitle" Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<TextBlock Visibility="{Binding IsNeedly,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource Boolean2VisibilityConverter}}" VerticalAlignment="Center" Margin="0,0,6,0" Text="*" Foreground="{DynamicResource DangerBrush}"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource String2VisibilityFeConverter}}" Margin="0,0,10,0" Text="{Binding Title,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"></TextBlock>
|
||||
</StackPanel>
|
||||
<TextBlock Margin="4,0,0,1" Grid.Row="1" Name="TextBlockError" Grid.Column="1" VerticalAlignment="Bottom" FontSize="12" Foreground="{DynamicResource DangerBrush}" Text="{Binding ErrorStr,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"></TextBlock>
|
||||
<Border Grid.Row="1" Name="Border" Background="White" Grid.Column="1" CornerRadius="{Binding CornerRadius,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" BorderThickness="1" BorderBrush="Transparent">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding PlaceHolder,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" HorizontalAlignment="Left" Padding="10,0" FontSize="14" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityConverter}}" VerticalAlignment="Center" Foreground="{DynamicResource ThirdlyTextBrush}"/>
|
||||
<TextBox MaxLines="1" MaxLength="{Binding MaxLength,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" HorizontalContentAlignment="{Binding HorizontalTextAlignment,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" Grid.Column="0" TextChanged="InputBox_OnTextChanged" MouseLeave="InputBox_OnMouseLeave" MouseEnter="InputBox_OnMouseEnter" GotFocus="InputBox_OnGotFocus" LostFocus="InputBox_OnLostFocus" Name="MyTextBox" Margin="4,0" BorderThickness="0" VerticalContentAlignment="Center" Padding="{Binding TextPadding,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" Text="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},UpdateSourceTrigger=PropertyChanged}" Background="{x:Null}"></TextBox>
|
||||
<Button Padding="7" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityFeConverter}}" Focusable="True" Grid.Column="1" Name="ButtonClear" Click="ButtonClear_OnClick" Foreground="{DynamicResource ThirdlyTextBrush}" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Style="{StaticResource ButtonIconTransparent}" Width="36" HorizontalAlignment="Right"></Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</controls:InfoControl>
|
45
HandyControl/Controls/Info/InfoTextBox.xaml.cs
Normal file
45
HandyControl/Controls/Info/InfoTextBox.xaml.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// InfoTextBox.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class InfoTextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// 可输入的最大字符数
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty MaxLengthProperty = DependencyProperty.Register(
|
||||
"MaxLength", typeof(int), typeof(InfoTextBox), new PropertyMetadata(default(int)));
|
||||
|
||||
/// <summary>
|
||||
/// 可输入的最大字符数
|
||||
/// </summary>
|
||||
public int MaxLength
|
||||
{
|
||||
get => (int)GetValue(MaxLengthProperty);
|
||||
set => SetValue(MaxLengthProperty, value);
|
||||
}
|
||||
|
||||
public InfoTextBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ErrorTextBlock = TextBlockError;
|
||||
ContentTextBox = MyTextBox;
|
||||
TitleStackPanel = StackPanelTitle;
|
||||
|
||||
(TryFindResource("Storyboard2") as Storyboard)?.Begin();
|
||||
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
StackPanelTitle.Focusable = true;
|
||||
StackPanelTitle.Focus();
|
||||
StackPanelTitle.Focusable = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
75
HandyControl/Data/ColorRange.cs
Normal file
75
HandyControl/Data/ColorRange.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System.Windows.Media;
|
||||
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色范围
|
||||
/// </summary>
|
||||
public class ColorRange
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色1
|
||||
/// </summary>
|
||||
private Color _color1;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色1
|
||||
/// </summary>
|
||||
public Color Color1
|
||||
{
|
||||
get => _color1;
|
||||
set
|
||||
{
|
||||
_color1 = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 颜色2
|
||||
/// </summary>
|
||||
private Color _color2;
|
||||
|
||||
/// <summary>
|
||||
/// 颜色2
|
||||
/// </summary>
|
||||
public Color Color2
|
||||
{
|
||||
get => _color2;
|
||||
set
|
||||
{
|
||||
_color2 = value;
|
||||
Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 颜色差值
|
||||
/// </summary>
|
||||
private readonly int[] _subColorArr = new int[4];
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
_subColorArr[0] = Color1.A - Color2.A;
|
||||
_subColorArr[1] = Color1.R - Color2.R;
|
||||
_subColorArr[2] = Color1.G - Color2.G;
|
||||
_subColorArr[3] = Color1.B - Color2.B;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定比例处的颜色
|
||||
/// </summary>
|
||||
/// <param name="range">范围(0-1)</param>
|
||||
/// <returns></returns>
|
||||
public Color GetColor(double range)
|
||||
{
|
||||
if (range < 0 || range > 1) return default(Color);
|
||||
return Color.FromArgb((byte)(_color1.A - _subColorArr[0] * range), (byte)(_color1.R - _subColorArr[1] * range),
|
||||
(byte)(_color1.G - _subColorArr[2] * range), (byte)(_color1.B - _subColorArr[3] * range));
|
||||
}
|
||||
}
|
||||
}
|
29
HandyControl/Data/Enum/IpType.cs
Normal file
29
HandyControl/Data/Enum/IpType.cs
Normal file
@ -0,0 +1,29 @@
|
||||
namespace HandyControl.Data.Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// IP类型枚举
|
||||
/// </summary>
|
||||
public enum IpType
|
||||
{
|
||||
/// <summary>
|
||||
/// A类IP地址
|
||||
/// </summary>
|
||||
A = 0,
|
||||
/// <summary>
|
||||
/// B类IP地址
|
||||
/// </summary>
|
||||
B,
|
||||
/// <summary>
|
||||
/// C类IP地址
|
||||
/// </summary>
|
||||
C,
|
||||
/// <summary>
|
||||
/// D类IP地址
|
||||
/// </summary>
|
||||
D,
|
||||
/// <summary>
|
||||
/// E类IP地址
|
||||
/// </summary>
|
||||
E
|
||||
}
|
||||
}
|
26
HandyControl/Data/Enum/TextType.cs
Normal file
26
HandyControl/Data/Enum/TextType.cs
Normal file
@ -0,0 +1,26 @@
|
||||
namespace HandyControl.Data.Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// 文本类型枚举
|
||||
/// </summary>
|
||||
public enum TextType
|
||||
{
|
||||
Common = 0,
|
||||
Phone,
|
||||
Mail,
|
||||
Url,
|
||||
Chinese,
|
||||
Number,
|
||||
Digits,
|
||||
PInt,
|
||||
NInt,
|
||||
Int,
|
||||
NnInt,
|
||||
NpInt,
|
||||
PDouble,
|
||||
NDouble,
|
||||
Double,
|
||||
NnDouble,
|
||||
NpDouble,
|
||||
}
|
||||
}
|
11
HandyControl/Data/Enum/TitleAlignment.cs
Normal file
11
HandyControl/Data/Enum/TitleAlignment.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace HandyControl.Data.Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题对齐方式
|
||||
/// </summary>
|
||||
public enum TitleAlignment
|
||||
{
|
||||
Left,
|
||||
Top
|
||||
}
|
||||
}
|
14
HandyControl/Data/FunctionEventArgs!1.cs
Normal file
14
HandyControl/Data/FunctionEventArgs!1.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Windows;
|
||||
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class FunctionEventArgs<T> : RoutedEventArgs
|
||||
{
|
||||
public FunctionEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source)
|
||||
{
|
||||
}
|
||||
|
||||
public T Info { get; set; }
|
||||
}
|
||||
}
|
@ -31,9 +31,174 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ColorPicker.xaml.cs">
|
||||
<DependentUpon>ColorPicker.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\IconElement.cs" />
|
||||
<Compile Include="Controls\Info\InfoControl.cs" />
|
||||
<Compile Include="Controls\Info\InfoNumericUpDown.xaml.cs">
|
||||
<DependentUpon>InfoNumericUpDown.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\Info\InfoTextBox.xaml.cs">
|
||||
<DependentUpon>InfoTextBox.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Data\ColorRange.cs" />
|
||||
<Compile Include="Data\Enum\IpType.cs" />
|
||||
<Compile Include="Data\Enum\TextType.cs" />
|
||||
<Compile Include="Data\Enum\TitleAlignment.cs" />
|
||||
<Compile Include="Data\FunctionEventArgs!1.cs" />
|
||||
<Compile Include="Interactivity\AdornerContainer.cs" />
|
||||
<Compile Include="Interactivity\AttachableCollection!1.cs" />
|
||||
<Compile Include="Interactivity\Behavior!1.cs" />
|
||||
<Compile Include="Interactivity\Behavior.cs" />
|
||||
<Compile Include="Interactivity\BehaviorCollection.cs" />
|
||||
<Compile Include="Interactivity\DefaultTriggerAttribute.cs" />
|
||||
<Compile Include="Interactivity\EventTrigger.cs" />
|
||||
<Compile Include="Interactivity\EventTriggerBase!1.cs" />
|
||||
<Compile Include="Interactivity\EventTriggerBase.cs" />
|
||||
<Compile Include="Interactivity\ExceptionStringTable.cs" />
|
||||
<Compile Include="Interactivity\ExtendedVisualStateManager.cs" />
|
||||
<Compile Include="Interactivity\FluidMoveBehavior.cs" />
|
||||
<Compile Include="Interactivity\FluidMoveBehaviorBase.cs" />
|
||||
<Compile Include="Interactivity\FluidMoveScope.cs" />
|
||||
<Compile Include="Interactivity\IAttachedObject.cs" />
|
||||
<Compile Include="Interactivity\Interaction.cs" />
|
||||
<Compile Include="Interactivity\MouseDragElementBehavior.cs" />
|
||||
<Compile Include="Interactivity\NameResolvedEventArgs.cs" />
|
||||
<Compile Include="Interactivity\NameResolver.cs" />
|
||||
<Compile Include="Interactivity\PreviewInvokeEventArgs.cs" />
|
||||
<Compile Include="Interactivity\TagType.cs" />
|
||||
<Compile Include="Interactivity\TransitionEffect.cs" />
|
||||
<Compile Include="Interactivity\TriggerAction.cs" />
|
||||
<Compile Include="Interactivity\TriggerActionCollection.cs" />
|
||||
<Compile Include="Interactivity\TriggerBase.cs" />
|
||||
<Compile Include="Interactivity\TriggerCollection.cs" />
|
||||
<Compile Include="Interactivity\TypeConstraintAttribute.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Tools\AnimationHelper.cs" />
|
||||
<Compile Include="Tools\Converter\Boolean2BooleanFeConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Boolean2VisibilityFeConverter.cs" />
|
||||
<Compile Include="Tools\Converter\BooleanArr2VisibilityConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Color2ChannelAConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Color2HexStrConverter.cs" />
|
||||
<Compile Include="Tools\Converter\IsNullConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Long2FileSizeConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Object2BooleanConverter.cs" />
|
||||
<Compile Include="Tools\Converter\Source2ImageConverter.cs" />
|
||||
<Compile Include="Tools\Converter\String2VisibilityConverter.cs" />
|
||||
<Compile Include="Tools\Converter\String2VisibilityFeConverter.cs" />
|
||||
<Compile Include="Tools\Converter\TreeViewItemMarginConverter.cs" />
|
||||
<Compile Include="Tools\Extension\ColorExtension.cs" />
|
||||
<Compile Include="Tools\Extension\UIElementExtension.cs" />
|
||||
<Compile Include="Tools\RegularJudgment.cs" />
|
||||
<Compile Include="Tools\RegularPatterns.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\colorPickerBack.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Controls\ColorPicker.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\Info\InfoNumericUpDown.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Controls\Info\InfoTextBox.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Basic.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Brushes.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Colors.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Converters.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Effects.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Fonts.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Geometries.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Paths.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Basic\Sizes.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\BaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\ButtonBaseBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\ButtonBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\TextBlockBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Border.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Button.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Slider.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Style.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\TextBlock.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Window.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\ThemesDefault.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
40
HandyControl/Interactivity/AdornerContainer.cs
Normal file
40
HandyControl/Interactivity/AdornerContainer.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public class AdornerContainer : Adorner
|
||||
{
|
||||
private UIElement _child;
|
||||
|
||||
public AdornerContainer(UIElement adornedElement) : base(adornedElement)
|
||||
{
|
||||
}
|
||||
|
||||
public UIElement Child
|
||||
{
|
||||
get =>
|
||||
_child;
|
||||
set
|
||||
{
|
||||
AddVisualChild(value);
|
||||
_child = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override int VisualChildrenCount => _child != null ? 1 : 0;
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
_child?.Arrange(new Rect(finalSize));
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
if (index == 0 && _child != null) return _child;
|
||||
return base.GetVisualChild(index);
|
||||
}
|
||||
}
|
||||
}
|
168
HandyControl/Interactivity/AttachableCollection!1.cs
Normal file
168
HandyControl/Interactivity/AttachableCollection!1.cs
Normal file
@ -0,0 +1,168 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class AttachableCollection<T> : FreezableCollection<T>, IAttachedObject
|
||||
where T : DependencyObject, IAttachedObject
|
||||
{
|
||||
private DependencyObject _associatedObject;
|
||||
private Collection<T> _snapshot;
|
||||
|
||||
internal AttachableCollection()
|
||||
{
|
||||
INotifyCollectionChanged changed = this;
|
||||
changed.CollectionChanged += OnCollectionChanged;
|
||||
_snapshot = new Collection<T>();
|
||||
}
|
||||
|
||||
public DependencyObject AssociatedObject
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedObject;
|
||||
}
|
||||
}
|
||||
|
||||
DependencyObject IAttachedObject.AssociatedObject => AssociatedObject;
|
||||
|
||||
public void Attach(DependencyObject dependencyObject)
|
||||
{
|
||||
if (Equals(dependencyObject, AssociatedObject))
|
||||
return;
|
||||
if (AssociatedObject != null)
|
||||
throw new InvalidOperationException();
|
||||
if (Interaction.ShouldRunInDesignMode || !(bool) GetValue(DesignerProperties.IsInDesignModeProperty))
|
||||
{
|
||||
WritePreamble();
|
||||
_associatedObject = dependencyObject;
|
||||
WritePostscript();
|
||||
}
|
||||
OnAttached();
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
OnDetaching();
|
||||
WritePreamble();
|
||||
_associatedObject = null;
|
||||
WritePostscript();
|
||||
}
|
||||
|
||||
protected abstract void OnAttached();
|
||||
|
||||
protected abstract void OnDetaching();
|
||||
|
||||
internal abstract void ItemAdded(T item);
|
||||
|
||||
internal abstract void ItemRemoved(T item);
|
||||
|
||||
private void VerifyAdd(T item)
|
||||
{
|
||||
if (item == null) throw new ArgumentNullException(nameof(item));
|
||||
if (_snapshot.Contains(item))
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.DuplicateItemInCollectionExceptionMessage, new object[]
|
||||
{
|
||||
typeof(T).Name,
|
||||
GetType().Name
|
||||
}));
|
||||
}
|
||||
|
||||
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
var enumerator1 = e.NewItems.GetEnumerator();
|
||||
try
|
||||
{
|
||||
while (enumerator1.MoveNext())
|
||||
{
|
||||
var current = (T) enumerator1.Current;
|
||||
try
|
||||
{
|
||||
VerifyAdd(current);
|
||||
ItemAdded(current);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_snapshot.Insert(IndexOf(current), current);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (enumerator1 is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
}
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
var enumerator2 = e.OldItems.GetEnumerator();
|
||||
try
|
||||
{
|
||||
while (enumerator2.MoveNext())
|
||||
{
|
||||
var current = (T) enumerator2.Current;
|
||||
ItemRemoved(current);
|
||||
_snapshot.Remove(current);
|
||||
}
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (enumerator2 is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
}
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
foreach (T oldItem in e.OldItems)
|
||||
{
|
||||
ItemRemoved(oldItem);
|
||||
_snapshot.Remove(oldItem);
|
||||
}
|
||||
var enumerator3 = e.NewItems.GetEnumerator();
|
||||
try
|
||||
{
|
||||
while (enumerator3.MoveNext())
|
||||
{
|
||||
var current = (T) enumerator3.Current;
|
||||
try
|
||||
{
|
||||
VerifyAdd(current);
|
||||
ItemAdded(current);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_snapshot.Insert(IndexOf(current), current);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (enumerator3 is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
}
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
foreach (var obj in _snapshot)
|
||||
ItemRemoved(obj);
|
||||
_snapshot = new Collection<T>();
|
||||
using (var enumerator4 = GetEnumerator())
|
||||
{
|
||||
while (enumerator4.MoveNext())
|
||||
{
|
||||
var current = enumerator4.Current;
|
||||
VerifyAdd(current);
|
||||
ItemAdded(current);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
HandyControl/Interactivity/Behavior!1.cs
Normal file
13
HandyControl/Interactivity/Behavior!1.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class Behavior<T> : Behavior where T : DependencyObject
|
||||
{
|
||||
protected Behavior() : base(typeof(T))
|
||||
{
|
||||
}
|
||||
|
||||
protected new T AssociatedObject => (T)base.AssociatedObject;
|
||||
}
|
||||
}
|
87
HandyControl/Interactivity/Behavior.cs
Normal file
87
HandyControl/Interactivity/Behavior.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class Behavior : Animatable, IAttachedObject
|
||||
{
|
||||
private DependencyObject _associatedObject;
|
||||
private readonly Type _associatedType;
|
||||
|
||||
internal Behavior(Type associatedType)
|
||||
{
|
||||
_associatedType = associatedType;
|
||||
}
|
||||
|
||||
protected DependencyObject AssociatedObject
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedObject;
|
||||
}
|
||||
}
|
||||
|
||||
protected Type AssociatedType
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedType;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach(DependencyObject dependencyObject)
|
||||
{
|
||||
if (!Equals(dependencyObject, AssociatedObject))
|
||||
{
|
||||
if (AssociatedObject != null)
|
||||
throw new InvalidOperationException(ExceptionStringTable
|
||||
.CannotHostBehaviorMultipleTimesExceptionMessage);
|
||||
if (dependencyObject != null && !AssociatedType.IsInstanceOfType(dependencyObject))
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.TypeConstraintViolatedExceptionMessage,
|
||||
new object[] {GetType().Name, dependencyObject.GetType().Name, AssociatedType.Name}));
|
||||
WritePreamble();
|
||||
_associatedObject = dependencyObject;
|
||||
WritePostscript();
|
||||
OnAssociatedObjectChanged();
|
||||
OnAttached();
|
||||
}
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
OnDetaching();
|
||||
WritePreamble();
|
||||
_associatedObject = null;
|
||||
WritePostscript();
|
||||
OnAssociatedObjectChanged();
|
||||
}
|
||||
|
||||
DependencyObject IAttachedObject.AssociatedObject =>
|
||||
AssociatedObject;
|
||||
|
||||
internal event EventHandler AssociatedObjectChanged;
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return (Freezable) Activator.CreateInstance(GetType());
|
||||
}
|
||||
|
||||
private void OnAssociatedObjectChanged()
|
||||
{
|
||||
AssociatedObjectChanged?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
protected virtual void OnAttached()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDetaching()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
42
HandyControl/Interactivity/BehaviorCollection.cs
Normal file
42
HandyControl/Interactivity/BehaviorCollection.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public sealed class BehaviorCollection : AttachableCollection<Behavior>
|
||||
{
|
||||
internal BehaviorCollection()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
foreach (var behavior in this)
|
||||
behavior.Attach(AssociatedObject);
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
foreach (var behavior in this)
|
||||
behavior.Detach();
|
||||
}
|
||||
|
||||
internal override void ItemAdded(Behavior item)
|
||||
{
|
||||
if (AssociatedObject == null)
|
||||
return;
|
||||
item.Attach(AssociatedObject);
|
||||
}
|
||||
|
||||
internal override void ItemRemoved(Behavior item)
|
||||
{
|
||||
if (((IAttachedObject) item).AssociatedObject == null)
|
||||
return;
|
||||
item.Detach();
|
||||
}
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new BehaviorCollection();
|
||||
}
|
||||
}
|
||||
}
|
49
HandyControl/Interactivity/DefaultTriggerAttribute.cs
Normal file
49
HandyControl/Interactivity/DefaultTriggerAttribute.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class DefaultTriggerAttribute : Attribute
|
||||
{
|
||||
private readonly object[] _parameters;
|
||||
|
||||
public DefaultTriggerAttribute(Type targetType, Type triggerType, object parameter) : this(targetType,
|
||||
triggerType, new[] {parameter})
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultTriggerAttribute(Type targetType, Type triggerType, params object[] parameters)
|
||||
{
|
||||
if (!typeof(TriggerBase).IsAssignableFrom(triggerType))
|
||||
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.DefaultTriggerAttributeInvalidTriggerTypeSpecifiedExceptionMessage,
|
||||
new object[] {triggerType.Name}));
|
||||
TargetType = targetType;
|
||||
TriggerType = triggerType;
|
||||
_parameters = parameters;
|
||||
}
|
||||
|
||||
public IEnumerable Parameters =>
|
||||
_parameters;
|
||||
|
||||
public Type TargetType { get; }
|
||||
|
||||
public Type TriggerType { get; }
|
||||
|
||||
public TriggerBase Instantiate()
|
||||
{
|
||||
object obj2 = null;
|
||||
try
|
||||
{
|
||||
obj2 = Activator.CreateInstance(TriggerType, _parameters);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
return (TriggerBase) obj2;
|
||||
}
|
||||
}
|
||||
}
|
29
HandyControl/Interactivity/EventTrigger.cs
Normal file
29
HandyControl/Interactivity/EventTrigger.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public class EventTrigger : EventTriggerBase<object>
|
||||
{
|
||||
public static readonly DependencyProperty EventNameProperty = DependencyProperty.Register("EventName", typeof(string), typeof(EventTrigger), new FrameworkPropertyMetadata("Loaded", OnEventNameChanged));
|
||||
|
||||
public EventTrigger()
|
||||
{
|
||||
}
|
||||
|
||||
public EventTrigger(string eventName) => EventName = eventName;
|
||||
|
||||
protected override string GetEventName() => EventName;
|
||||
|
||||
private static void OnEventNameChanged(object sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
((EventTrigger)sender).OnEventNameChanged((string)args.OldValue, (string)args.NewValue);
|
||||
}
|
||||
|
||||
public string EventName
|
||||
{
|
||||
get => (string)GetValue(EventNameProperty);
|
||||
|
||||
set => SetValue(EventNameProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
21
HandyControl/Interactivity/EventTriggerBase!1.cs
Normal file
21
HandyControl/Interactivity/EventTriggerBase!1.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class EventTriggerBase<T> : EventTriggerBase where T : class
|
||||
{
|
||||
protected EventTriggerBase() : base(typeof(T))
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnSourceChanged(T oldSource, T newSource)
|
||||
{
|
||||
}
|
||||
|
||||
internal sealed override void OnSourceChangedImpl(object oldSource, object newSource)
|
||||
{
|
||||
base.OnSourceChangedImpl(oldSource, newSource);
|
||||
OnSourceChanged(oldSource as T, newSource as T);
|
||||
}
|
||||
|
||||
public new T Source => (T)base.Source;
|
||||
}
|
||||
}
|
313
HandyControl/Interactivity/EventTriggerBase.cs
Normal file
313
HandyControl/Interactivity/EventTriggerBase.cs
Normal file
@ -0,0 +1,313 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class EventTriggerBase : TriggerBase
|
||||
{
|
||||
public static readonly DependencyProperty SourceNameProperty = DependencyProperty.Register("SourceName",
|
||||
typeof(string), typeof(EventTriggerBase), new PropertyMetadata(OnSourceNameChanged));
|
||||
|
||||
public static readonly DependencyProperty SourceObjectProperty = DependencyProperty.Register("SourceObject",
|
||||
typeof(object), typeof(EventTriggerBase), new PropertyMetadata(OnSourceObjectChanged));
|
||||
|
||||
private MethodInfo _eventHandlerMethodInfo;
|
||||
|
||||
internal EventTriggerBase(Type sourceTypeConstraint) : base(typeof(DependencyObject))
|
||||
{
|
||||
SourceTypeConstraint = sourceTypeConstraint;
|
||||
SourceNameResolver = new NameResolver();
|
||||
RegisterSourceChanged();
|
||||
}
|
||||
|
||||
protected sealed override Type AssociatedObjectTypeConstraint
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TypeDescriptor.GetAttributes(GetType())[typeof(TypeConstraintAttribute)] is TypeConstraintAttribute attribute)
|
||||
return attribute.Constraint;
|
||||
return typeof(DependencyObject);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLoadedRegistered { get; set; }
|
||||
|
||||
private bool IsSourceChangedRegistered { get; set; }
|
||||
|
||||
private bool IsSourceNameSet
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(SourceName))
|
||||
return ReadLocalValue(SourceNameProperty) != DependencyProperty.UnsetValue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public object Source
|
||||
{
|
||||
get
|
||||
{
|
||||
object associatedObject = AssociatedObject;
|
||||
if (SourceObject != null)
|
||||
return SourceObject;
|
||||
if (IsSourceNameSet)
|
||||
{
|
||||
associatedObject = SourceNameResolver.Object;
|
||||
if (associatedObject != null && !SourceTypeConstraint.IsInstanceOfType(associatedObject))
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.RetargetedTypeConstraintViolatedExceptionMessage, GetType().Name,
|
||||
associatedObject.GetType(), SourceTypeConstraint, "Source"));
|
||||
}
|
||||
return associatedObject;
|
||||
}
|
||||
}
|
||||
|
||||
public string SourceName
|
||||
{
|
||||
get =>
|
||||
(string) GetValue(SourceNameProperty);
|
||||
set => SetValue(SourceNameProperty, value);
|
||||
}
|
||||
|
||||
private NameResolver SourceNameResolver { get; }
|
||||
|
||||
public object SourceObject
|
||||
{
|
||||
get =>
|
||||
GetValue(SourceObjectProperty);
|
||||
set => SetValue(SourceObjectProperty, value);
|
||||
}
|
||||
|
||||
protected Type SourceTypeConstraint { get; }
|
||||
|
||||
protected abstract string GetEventName();
|
||||
|
||||
private static bool IsValidEvent(EventInfo eventInfo)
|
||||
{
|
||||
var eventHandlerType = eventInfo.EventHandlerType;
|
||||
if (!typeof(Delegate).IsAssignableFrom(eventInfo.EventHandlerType))
|
||||
return false;
|
||||
var parameters = eventHandlerType.GetMethod("Invoke")?.GetParameters();
|
||||
return parameters != null && parameters.Length == 2 && typeof(object).IsAssignableFrom(parameters[0].ParameterType) && typeof(EventArgs).IsAssignableFrom(parameters[1].ParameterType);
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
var associatedObject = AssociatedObject;
|
||||
var behavior = associatedObject as Behavior;
|
||||
var element = associatedObject as FrameworkElement;
|
||||
RegisterSourceChanged();
|
||||
if (behavior != null)
|
||||
{
|
||||
behavior.AssociatedObjectChanged += OnBehaviorHostChanged;
|
||||
}
|
||||
else if (SourceObject != null || element == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnSourceChanged(null, Source);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SourceNameResolver.NameScopeReferenceElement = element;
|
||||
}
|
||||
if (string.Compare(GetEventName(), "Loaded", StringComparison.Ordinal) == 0 && element != null &&
|
||||
!Interaction.IsElementLoaded(element))
|
||||
RegisterLoaded(element);
|
||||
}
|
||||
|
||||
private void OnBehaviorHostChanged(object sender, EventArgs e)
|
||||
{
|
||||
SourceNameResolver.NameScopeReferenceElement =
|
||||
((IAttachedObject) sender).AssociatedObject as FrameworkElement;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
base.OnDetaching();
|
||||
var associatedObject = AssociatedObject as Behavior;
|
||||
var associatedElement = AssociatedObject as FrameworkElement;
|
||||
try
|
||||
{
|
||||
OnSourceChanged(Source, null);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
}
|
||||
UnregisterSourceChanged();
|
||||
if (associatedObject != null)
|
||||
associatedObject.AssociatedObjectChanged -= OnBehaviorHostChanged;
|
||||
SourceNameResolver.NameScopeReferenceElement = null;
|
||||
if (string.Compare(GetEventName(), "Loaded", StringComparison.Ordinal) == 0 && associatedElement != null)
|
||||
UnregisterLoaded(associatedElement);
|
||||
}
|
||||
|
||||
protected virtual void OnEvent(EventArgs eventArgs)
|
||||
{
|
||||
InvokeActions(eventArgs);
|
||||
}
|
||||
|
||||
private void OnEventImpl(object sender, EventArgs eventArgs)
|
||||
{
|
||||
OnEvent(eventArgs);
|
||||
}
|
||||
|
||||
internal void OnEventNameChanged(string oldEventName, string newEventName)
|
||||
{
|
||||
if (AssociatedObject != null)
|
||||
{
|
||||
var source = Source as FrameworkElement;
|
||||
if (source != null && string.Compare(oldEventName, "Loaded", StringComparison.Ordinal) == 0)
|
||||
UnregisterLoaded(source);
|
||||
else if (!string.IsNullOrEmpty(oldEventName))
|
||||
UnregisterEvent(Source, oldEventName);
|
||||
if (source != null && string.Compare(newEventName, "Loaded", StringComparison.Ordinal) == 0)
|
||||
RegisterLoaded(source);
|
||||
else if (!string.IsNullOrEmpty(newEventName))
|
||||
RegisterEvent(Source, newEventName);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSourceChanged(object oldSource, object newSource)
|
||||
{
|
||||
if (AssociatedObject != null)
|
||||
OnSourceChangedImpl(oldSource, newSource);
|
||||
}
|
||||
|
||||
internal virtual void OnSourceChangedImpl(object oldSource, object newSource)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(GetEventName()) &&
|
||||
string.Compare(GetEventName(), "Loaded", StringComparison.Ordinal) != 0)
|
||||
{
|
||||
if (oldSource != null && SourceTypeConstraint.IsInstanceOfType(oldSource))
|
||||
UnregisterEvent(oldSource, GetEventName());
|
||||
if (newSource != null && SourceTypeConstraint.IsInstanceOfType(newSource))
|
||||
RegisterEvent(newSource, GetEventName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnSourceNameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var base2 = (EventTriggerBase) obj;
|
||||
base2.SourceNameResolver.Name = (string) args.NewValue;
|
||||
}
|
||||
|
||||
private void OnSourceNameResolverElementChanged(object sender, NameResolvedEventArgs e)
|
||||
{
|
||||
if (SourceObject == null)
|
||||
OnSourceChanged(e.OldObject, e.NewObject);
|
||||
}
|
||||
|
||||
private static void OnSourceObjectChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var base2 = (EventTriggerBase) obj;
|
||||
object newSource = base2.SourceNameResolver.Object;
|
||||
if (args.NewValue == null)
|
||||
{
|
||||
base2.OnSourceChanged(args.OldValue, newSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.OldValue == null && newSource != null)
|
||||
base2.UnregisterEvent(newSource, base2.GetEventName());
|
||||
base2.OnSourceChanged(args.OldValue, args.NewValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterEvent(object obj, string eventName)
|
||||
{
|
||||
var eventInfo = obj.GetType().GetEvent(eventName);
|
||||
if (eventInfo == null)
|
||||
{
|
||||
if (SourceObject != null)
|
||||
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.EventTriggerCannotFindEventNameExceptionMessage,
|
||||
new object[] {eventName, obj.GetType().Name}));
|
||||
}
|
||||
else if (!IsValidEvent(eventInfo))
|
||||
{
|
||||
if (SourceObject != null)
|
||||
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMessage,
|
||||
new object[] {eventName, obj.GetType().Name}));
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventHandlerMethodInfo =
|
||||
typeof(EventTriggerBase).GetMethod("OnEventImpl", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
eventInfo.AddEventHandler(obj,
|
||||
Delegate.CreateDelegate(eventInfo.EventHandlerType, this, _eventHandlerMethodInfo ?? throw new InvalidOperationException()));
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterLoaded(FrameworkElement associatedElement)
|
||||
{
|
||||
if (!IsLoadedRegistered && associatedElement != null)
|
||||
{
|
||||
associatedElement.Loaded += OnEventImpl;
|
||||
IsLoadedRegistered = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterSourceChanged()
|
||||
{
|
||||
if (!IsSourceChangedRegistered)
|
||||
{
|
||||
SourceNameResolver.ResolvedElementChanged += OnSourceNameResolverElementChanged;
|
||||
IsSourceChangedRegistered = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnregisterEvent(object obj, string eventName)
|
||||
{
|
||||
if (string.Compare(eventName, "Loaded", StringComparison.Ordinal) == 0)
|
||||
{
|
||||
if (obj is FrameworkElement associatedElement)
|
||||
UnregisterLoaded(associatedElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
UnregisterEventImpl(obj, eventName);
|
||||
}
|
||||
}
|
||||
|
||||
private void UnregisterEventImpl(object obj, string eventName)
|
||||
{
|
||||
var type = obj.GetType();
|
||||
if (_eventHandlerMethodInfo != null)
|
||||
{
|
||||
var info = type.GetEvent(eventName);
|
||||
info.RemoveEventHandler(obj,
|
||||
Delegate.CreateDelegate(info.EventHandlerType, this, _eventHandlerMethodInfo));
|
||||
_eventHandlerMethodInfo = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnregisterLoaded(FrameworkElement associatedElement)
|
||||
{
|
||||
if (IsLoadedRegistered && associatedElement != null)
|
||||
{
|
||||
associatedElement.Loaded -= OnEventImpl;
|
||||
IsLoadedRegistered = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnregisterSourceChanged()
|
||||
{
|
||||
if (IsSourceChangedRegistered)
|
||||
{
|
||||
SourceNameResolver.ResolvedElementChanged -= OnSourceNameResolverElementChanged;
|
||||
IsSourceChangedRegistered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
HandyControl/Interactivity/ExceptionStringTable.cs
Normal file
58
HandyControl/Interactivity/ExceptionStringTable.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
internal class ExceptionStringTable
|
||||
{
|
||||
private static ResourceManager ResourceMan;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static ResourceManager ResourceManager => ResourceMan ?? (ResourceMan = new ResourceManager(nameof(ExceptionStringTable),
|
||||
typeof(ExceptionStringTable).Assembly));
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static CultureInfo Culture { get; set; }
|
||||
|
||||
internal static string CannotHostBehaviorCollectionMultipleTimesExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(CannotHostBehaviorCollectionMultipleTimesExceptionMessage), Culture);
|
||||
|
||||
internal static string CannotHostBehaviorMultipleTimesExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(CannotHostBehaviorMultipleTimesExceptionMessage), Culture);
|
||||
|
||||
internal static string CannotHostTriggerActionMultipleTimesExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(CannotHostTriggerActionMultipleTimesExceptionMessage), Culture);
|
||||
|
||||
internal static string CannotHostTriggerCollectionMultipleTimesExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(CannotHostTriggerCollectionMultipleTimesExceptionMessage), Culture);
|
||||
|
||||
internal static string CannotHostTriggerMultipleTimesExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(CannotHostTriggerMultipleTimesExceptionMessage), Culture);
|
||||
|
||||
internal static string CommandDoesNotExistOnBehaviorWarningMessage =>
|
||||
ResourceManager.GetString(nameof(CommandDoesNotExistOnBehaviorWarningMessage), Culture);
|
||||
|
||||
internal static string DefaultTriggerAttributeInvalidTriggerTypeSpecifiedExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(DefaultTriggerAttributeInvalidTriggerTypeSpecifiedExceptionMessage),
|
||||
Culture);
|
||||
|
||||
internal static string DuplicateItemInCollectionExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(DuplicateItemInCollectionExceptionMessage), Culture);
|
||||
|
||||
internal static string EventTriggerBaseInvalidEventExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(EventTriggerBaseInvalidEventExceptionMessage), Culture);
|
||||
|
||||
internal static string EventTriggerCannotFindEventNameExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(EventTriggerCannotFindEventNameExceptionMessage), Culture);
|
||||
|
||||
internal static string RetargetedTypeConstraintViolatedExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(RetargetedTypeConstraintViolatedExceptionMessage), Culture);
|
||||
|
||||
internal static string TypeConstraintViolatedExceptionMessage =>
|
||||
ResourceManager.GetString(nameof(TypeConstraintViolatedExceptionMessage), Culture);
|
||||
|
||||
internal static string UnableToResolveTargetNameWarningMessage =>
|
||||
ResourceManager.GetString(nameof(UnableToResolveTargetNameWarningMessage), Culture);
|
||||
}
|
||||
}
|
1141
HandyControl/Interactivity/ExtendedVisualStateManager.cs
Normal file
1141
HandyControl/Interactivity/ExtendedVisualStateManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
448
HandyControl/Interactivity/FluidMoveBehavior.cs
Normal file
448
HandyControl/Interactivity/FluidMoveBehavior.cs
Normal file
@ -0,0 +1,448 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public sealed class FluidMoveBehavior : FluidMoveBehaviorBase
|
||||
{
|
||||
private static readonly DependencyProperty CacheDuringOverlayProperty =
|
||||
DependencyProperty.RegisterAttached("CacheDuringOverlay", typeof(object),
|
||||
typeof(FluidMoveBehavior), new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty DurationProperty = DependencyProperty.Register("Duration",
|
||||
typeof(Duration), typeof(FluidMoveBehavior),
|
||||
new PropertyMetadata(new Duration(TimeSpan.FromSeconds(1.0))));
|
||||
|
||||
public static readonly DependencyProperty EaseXProperty = DependencyProperty.Register("EaseX",
|
||||
typeof(IEasingFunction), typeof(FluidMoveBehavior), new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty EaseYProperty = DependencyProperty.Register("EaseY",
|
||||
typeof(IEasingFunction), typeof(FluidMoveBehavior), new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty FloatAboveProperty =
|
||||
DependencyProperty.Register("FloatAbove", typeof(bool), typeof(FluidMoveBehavior),
|
||||
new PropertyMetadata(true));
|
||||
|
||||
private static readonly DependencyProperty HasTransformWrapperProperty =
|
||||
DependencyProperty.RegisterAttached("HasTransformWrapper", typeof(bool),
|
||||
typeof(FluidMoveBehavior), new PropertyMetadata(false));
|
||||
|
||||
private static readonly DependencyProperty InitialIdentityTagProperty =
|
||||
DependencyProperty.RegisterAttached("InitialIdentityTag", typeof(object),
|
||||
typeof(FluidMoveBehavior), new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty InitialTagPathProperty =
|
||||
DependencyProperty.Register("InitialTagPath", typeof(string), typeof(FluidMoveBehavior),
|
||||
new PropertyMetadata(string.Empty));
|
||||
|
||||
public static readonly DependencyProperty InitialTagProperty =
|
||||
DependencyProperty.Register("InitialTag", typeof(TagType), typeof(FluidMoveBehavior),
|
||||
new PropertyMetadata(TagType.Element));
|
||||
|
||||
private static readonly DependencyProperty OverlayProperty =
|
||||
DependencyProperty.RegisterAttached("Overlay", typeof(object), typeof(FluidMoveBehavior),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
private static readonly Dictionary<object, Storyboard> TransitionStoryboardDictionary =
|
||||
new Dictionary<object, Storyboard>();
|
||||
|
||||
public Duration Duration
|
||||
{
|
||||
get =>
|
||||
(Duration) GetValue(DurationProperty);
|
||||
set => SetValue(DurationProperty, value);
|
||||
}
|
||||
|
||||
public IEasingFunction EaseX
|
||||
{
|
||||
get =>
|
||||
(IEasingFunction) GetValue(EaseXProperty);
|
||||
set => SetValue(EaseXProperty, value);
|
||||
}
|
||||
|
||||
public IEasingFunction EaseY
|
||||
{
|
||||
get =>
|
||||
(IEasingFunction) GetValue(EaseYProperty);
|
||||
set => SetValue(EaseYProperty, value);
|
||||
}
|
||||
|
||||
public bool FloatAbove
|
||||
{
|
||||
get =>
|
||||
(bool) GetValue(FloatAboveProperty);
|
||||
set => SetValue(FloatAboveProperty, value);
|
||||
}
|
||||
|
||||
public TagType InitialTag
|
||||
{
|
||||
get =>
|
||||
(TagType) GetValue(InitialTagProperty);
|
||||
set => SetValue(InitialTagProperty, value);
|
||||
}
|
||||
|
||||
public string InitialTagPath
|
||||
{
|
||||
get =>
|
||||
(string) GetValue(InitialTagPathProperty);
|
||||
set => SetValue(InitialTagPathProperty, value);
|
||||
}
|
||||
|
||||
protected override bool ShouldSkipInitialLayout
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!base.ShouldSkipInitialLayout) return InitialTag == TagType.DataContext;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddTransform(FrameworkElement child, Transform transform)
|
||||
{
|
||||
if (!(child.RenderTransform is TransformGroup renderTransform))
|
||||
{
|
||||
renderTransform = new TransformGroup
|
||||
{
|
||||
Children = {child.RenderTransform}
|
||||
};
|
||||
child.RenderTransform = renderTransform;
|
||||
SetHasTransformWrapper(child, true);
|
||||
}
|
||||
|
||||
renderTransform.Children.Add(transform);
|
||||
}
|
||||
|
||||
private Storyboard CreateTransitionStoryboard(FrameworkElement child, bool usingBeforeLoaded,
|
||||
ref Rect layoutRect, ref Rect currentRect)
|
||||
{
|
||||
var duration = Duration;
|
||||
var storyboard = new Storyboard
|
||||
{
|
||||
Duration = duration
|
||||
};
|
||||
var num = !usingBeforeLoaded || Math.Abs(layoutRect.Width) < 0.001
|
||||
? 1.0
|
||||
: currentRect.Width / layoutRect.Width;
|
||||
var num2 = !usingBeforeLoaded || Math.Abs(layoutRect.Height) < 0.001
|
||||
? 1.0
|
||||
: currentRect.Height / layoutRect.Height;
|
||||
var num3 = currentRect.Left - layoutRect.Left;
|
||||
var num4 = currentRect.Top - layoutRect.Top;
|
||||
var group = new TransformGroup();
|
||||
var transform = new ScaleTransform
|
||||
{
|
||||
ScaleX = num,
|
||||
ScaleY = num2
|
||||
};
|
||||
group.Children.Add(transform);
|
||||
var transform2 = new TranslateTransform
|
||||
{
|
||||
X = num3,
|
||||
Y = num4
|
||||
};
|
||||
group.Children.Add(transform2);
|
||||
AddTransform(child, group);
|
||||
var str = "(FrameworkElement.RenderTransform).";
|
||||
if (child.RenderTransform is TransformGroup renderTransform && GetHasTransformWrapper(child))
|
||||
{
|
||||
object obj2 = str;
|
||||
str = string.Concat(obj2, "(TransformGroup.Children)[", renderTransform.Children.Count - 1,
|
||||
"].");
|
||||
}
|
||||
|
||||
if (usingBeforeLoaded)
|
||||
{
|
||||
if (Math.Abs(num - 1.0) > 0.001)
|
||||
{
|
||||
var element = new DoubleAnimation
|
||||
{
|
||||
Duration = duration,
|
||||
From = num,
|
||||
To = 1.0
|
||||
};
|
||||
Storyboard.SetTarget(element, child);
|
||||
Storyboard.SetTargetProperty(element,
|
||||
new PropertyPath(str + "(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
|
||||
element.EasingFunction = EaseX;
|
||||
storyboard.Children.Add(element);
|
||||
}
|
||||
|
||||
if (Math.Abs(num2 - 1.0) > 0.001)
|
||||
{
|
||||
var animation3 = new DoubleAnimation
|
||||
{
|
||||
Duration = duration,
|
||||
From = num2,
|
||||
To = 1.0
|
||||
};
|
||||
Storyboard.SetTarget(animation3, child);
|
||||
Storyboard.SetTargetProperty(animation3,
|
||||
new PropertyPath(str + "(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
|
||||
animation3.EasingFunction = EaseY;
|
||||
storyboard.Children.Add(animation3);
|
||||
}
|
||||
}
|
||||
|
||||
if (Math.Abs(num3) > 0.001)
|
||||
{
|
||||
var animation5 = new DoubleAnimation
|
||||
{
|
||||
Duration = duration,
|
||||
From = num3,
|
||||
To = 0.0
|
||||
};
|
||||
Storyboard.SetTarget(animation5, child);
|
||||
Storyboard.SetTargetProperty(animation5,
|
||||
new PropertyPath(str + "(TransformGroup.Children)[1].(TranslateTransform.X)"));
|
||||
animation5.EasingFunction = EaseX;
|
||||
storyboard.Children.Add(animation5);
|
||||
}
|
||||
|
||||
if (Math.Abs(num4) > 0.001)
|
||||
{
|
||||
var animation7 = new DoubleAnimation
|
||||
{
|
||||
Duration = duration,
|
||||
From = num4,
|
||||
To = 0.0
|
||||
};
|
||||
Storyboard.SetTarget(animation7, child);
|
||||
Storyboard.SetTargetProperty(animation7,
|
||||
new PropertyPath(str + "(TransformGroup.Children)[1].(TranslateTransform.Y)"));
|
||||
animation7.EasingFunction = EaseY;
|
||||
storyboard.Children.Add(animation7);
|
||||
}
|
||||
|
||||
return storyboard;
|
||||
}
|
||||
|
||||
protected override void EnsureTags(FrameworkElement child)
|
||||
{
|
||||
base.EnsureTags(child);
|
||||
if (InitialTag == TagType.DataContext &&
|
||||
!(child.ReadLocalValue(InitialIdentityTagProperty) is BindingExpression))
|
||||
child.SetBinding(InitialIdentityTagProperty, new Binding(InitialTagPath));
|
||||
}
|
||||
|
||||
private static bool GetHasTransformWrapper(DependencyObject obj)
|
||||
{
|
||||
return (bool) obj.GetValue(HasTransformWrapperProperty);
|
||||
}
|
||||
|
||||
private static object GetInitialIdentityTag(DependencyObject obj)
|
||||
{
|
||||
return obj.GetValue(InitialIdentityTagProperty);
|
||||
}
|
||||
|
||||
private static object GetOverlay(DependencyObject obj)
|
||||
{
|
||||
return obj.GetValue(OverlayProperty);
|
||||
}
|
||||
|
||||
private static Transform GetTransform(FrameworkElement child)
|
||||
{
|
||||
if (child.RenderTransform is TransformGroup renderTransform && renderTransform.Children.Count > 0)
|
||||
return renderTransform.Children[renderTransform.Children.Count - 1];
|
||||
return new TranslateTransform();
|
||||
}
|
||||
|
||||
private static bool IsClose(double a, double b)
|
||||
{
|
||||
return Math.Abs(a - b) < 1E-07;
|
||||
}
|
||||
|
||||
private static bool IsEmptyRect(Rect rect)
|
||||
{
|
||||
if (!rect.IsEmpty && !double.IsNaN(rect.Left)) return double.IsNaN(rect.Top);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void RemoveTransform(FrameworkElement child)
|
||||
{
|
||||
if (child.RenderTransform is TransformGroup renderTransform)
|
||||
{
|
||||
if (GetHasTransformWrapper(child))
|
||||
{
|
||||
child.RenderTransform = renderTransform.Children[0];
|
||||
SetHasTransformWrapper(child, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderTransform.Children.RemoveAt(renderTransform.Children.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetHasTransformWrapper(DependencyObject obj, bool value)
|
||||
{
|
||||
obj.SetValue(HasTransformWrapperProperty, value);
|
||||
}
|
||||
|
||||
private static void SetOverlay(DependencyObject obj, object value)
|
||||
{
|
||||
obj.SetValue(OverlayProperty, value);
|
||||
}
|
||||
|
||||
private static void TransferLocalValue(FrameworkElement element, DependencyProperty source,
|
||||
DependencyProperty dest)
|
||||
{
|
||||
var obj2 = element.ReadLocalValue(source);
|
||||
if (obj2 is BindingExpressionBase base2)
|
||||
element.SetBinding(dest, base2.ParentBindingBase);
|
||||
else if (obj2 == DependencyProperty.UnsetValue)
|
||||
element.ClearValue(dest);
|
||||
else
|
||||
element.SetValue(dest, element.GetAnimationBaseValue(source));
|
||||
element.ClearValue(source);
|
||||
}
|
||||
|
||||
internal override void UpdateLayoutTransitionCore(FrameworkElement child, FrameworkElement root,
|
||||
object tag, TagData newTagData)
|
||||
{
|
||||
Rect empty;
|
||||
var flag = false;
|
||||
var usingBeforeLoaded = false;
|
||||
var initialIdentityTag = GetInitialIdentityTag(child);
|
||||
var flag3 = TagDictionary.TryGetValue(tag, out var data);
|
||||
if (flag3 && data.InitialTag != initialIdentityTag)
|
||||
{
|
||||
flag3 = false;
|
||||
TagDictionary.Remove(tag);
|
||||
}
|
||||
|
||||
if (!flag3)
|
||||
{
|
||||
if (initialIdentityTag != null && TagDictionary.TryGetValue(initialIdentityTag, out var data2))
|
||||
{
|
||||
empty = TranslateRect(data2.AppRect, root, newTagData.Parent);
|
||||
flag = true;
|
||||
usingBeforeLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty = Rect.Empty;
|
||||
}
|
||||
|
||||
data = new TagData
|
||||
{
|
||||
ParentRect = Rect.Empty,
|
||||
AppRect = Rect.Empty,
|
||||
Parent = newTagData.Parent,
|
||||
Child = child,
|
||||
Timestamp = DateTime.Now,
|
||||
InitialTag = initialIdentityTag
|
||||
};
|
||||
TagDictionary.Add(tag, data);
|
||||
}
|
||||
else if (!Equals(data.Parent, VisualTreeHelper.GetParent(child)))
|
||||
{
|
||||
empty = TranslateRect(data.AppRect, root, newTagData.Parent);
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty = data.ParentRect;
|
||||
}
|
||||
|
||||
var originalChild = child;
|
||||
if (!IsEmptyRect(empty) && !IsEmptyRect(newTagData.ParentRect) &&
|
||||
(!IsClose(empty.Left, newTagData.ParentRect.Left) ||
|
||||
!IsClose(empty.Top, newTagData.ParentRect.Top)) || !Equals(child, data.Child) &&
|
||||
TransitionStoryboardDictionary.ContainsKey(tag))
|
||||
{
|
||||
var rect = empty;
|
||||
var flag4 = false;
|
||||
if (TransitionStoryboardDictionary.TryGetValue(tag, out var storyboard))
|
||||
{
|
||||
var obj3 = GetOverlay(data.Child);
|
||||
var adorner = (AdornerContainer) obj3;
|
||||
flag4 = obj3 != null;
|
||||
var element = data.Child;
|
||||
if (obj3 != null)
|
||||
{
|
||||
if (adorner.Child is Canvas canvas) element = canvas.Children[0] as FrameworkElement;
|
||||
}
|
||||
|
||||
if (!usingBeforeLoaded) rect = GetTransform(element).TransformBounds(rect);
|
||||
TransitionStoryboardDictionary.Remove(tag);
|
||||
storyboard.Stop();
|
||||
RemoveTransform(element);
|
||||
if (obj3 != null)
|
||||
{
|
||||
AdornerLayer.GetAdornerLayer(root).Remove(adorner);
|
||||
TransferLocalValue(data.Child, CacheDuringOverlayProperty,
|
||||
UIElement.RenderTransformProperty);
|
||||
SetOverlay(data.Child, null);
|
||||
}
|
||||
}
|
||||
|
||||
object overlay = null;
|
||||
if (flag4 || flag && FloatAbove)
|
||||
{
|
||||
var canvas2 = new Canvas
|
||||
{
|
||||
Width = newTagData.ParentRect.Width,
|
||||
Height = newTagData.ParentRect.Height,
|
||||
IsHitTestVisible = false
|
||||
};
|
||||
var rectangle = new Rectangle
|
||||
{
|
||||
Width = newTagData.ParentRect.Width,
|
||||
Height = newTagData.ParentRect.Height,
|
||||
IsHitTestVisible = false,
|
||||
Fill = new VisualBrush(child)
|
||||
};
|
||||
canvas2.Children.Add(rectangle);
|
||||
var container2 = new AdornerContainer(child)
|
||||
{
|
||||
Child = canvas2
|
||||
};
|
||||
overlay = container2;
|
||||
SetOverlay(originalChild, overlay);
|
||||
AdornerLayer.GetAdornerLayer(root).Add(container2);
|
||||
TransferLocalValue(child, UIElement.RenderTransformProperty, CacheDuringOverlayProperty);
|
||||
child.RenderTransform = new TranslateTransform(-10000.0, -10000.0);
|
||||
canvas2.RenderTransform = new TranslateTransform(10000.0, 10000.0);
|
||||
child = rectangle;
|
||||
}
|
||||
|
||||
var parentRect = newTagData.ParentRect;
|
||||
var transitionStoryboard =
|
||||
CreateTransitionStoryboard(child, usingBeforeLoaded, ref parentRect, ref rect);
|
||||
TransitionStoryboardDictionary.Add(tag, transitionStoryboard);
|
||||
transitionStoryboard.Completed += delegate
|
||||
{
|
||||
if (TransitionStoryboardDictionary.TryGetValue(tag, out var storyboard1) &&
|
||||
Equals(storyboard1, transitionStoryboard))
|
||||
{
|
||||
TransitionStoryboardDictionary.Remove(tag);
|
||||
transitionStoryboard.Stop();
|
||||
RemoveTransform(child);
|
||||
child.InvalidateMeasure();
|
||||
if (overlay != null)
|
||||
{
|
||||
AdornerLayer.GetAdornerLayer(root).Remove((AdornerContainer) overlay);
|
||||
TransferLocalValue(originalChild, CacheDuringOverlayProperty,
|
||||
UIElement.RenderTransformProperty);
|
||||
SetOverlay(originalChild, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
transitionStoryboard.Begin();
|
||||
}
|
||||
|
||||
data.ParentRect = newTagData.ParentRect;
|
||||
data.AppRect = newTagData.AppRect;
|
||||
data.Parent = newTagData.Parent;
|
||||
data.Child = newTagData.Child;
|
||||
data.Timestamp = newTagData.Timestamp;
|
||||
}
|
||||
}
|
||||
}
|
195
HandyControl/Interactivity/FluidMoveBehaviorBase.cs
Normal file
195
HandyControl/Interactivity/FluidMoveBehaviorBase.cs
Normal file
@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class FluidMoveBehaviorBase : Behavior<FrameworkElement>
|
||||
{
|
||||
public static readonly DependencyProperty AppliesToProperty = DependencyProperty.Register("AppliesTo",
|
||||
typeof(FluidMoveScope), typeof(FluidMoveBehaviorBase), new PropertyMetadata(FluidMoveScope.Self));
|
||||
|
||||
protected static readonly DependencyProperty IdentityTagProperty =
|
||||
DependencyProperty.RegisterAttached("IdentityTag", typeof(object), typeof(FluidMoveBehaviorBase),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register("IsActive",
|
||||
typeof(bool), typeof(FluidMoveBehaviorBase), new PropertyMetadata(true));
|
||||
|
||||
private static DateTime LastPurgeTick = DateTime.MinValue;
|
||||
|
||||
private static readonly TimeSpan MinTickDelta = TimeSpan.FromSeconds(0.5);
|
||||
|
||||
private static DateTime NextToLastPurgeTick = DateTime.MinValue;
|
||||
|
||||
internal static Dictionary<object, TagData> TagDictionary = new Dictionary<object, TagData>();
|
||||
|
||||
public static readonly DependencyProperty TagPathProperty = DependencyProperty.Register("TagPath",
|
||||
typeof(string), typeof(FluidMoveBehaviorBase), new PropertyMetadata(string.Empty));
|
||||
|
||||
public static readonly DependencyProperty TagProperty = DependencyProperty.Register("Tag",
|
||||
typeof(TagType), typeof(FluidMoveBehaviorBase), new PropertyMetadata(TagType.Element));
|
||||
|
||||
public FluidMoveScope AppliesTo
|
||||
{
|
||||
get =>
|
||||
(FluidMoveScope) GetValue(AppliesToProperty);
|
||||
set => SetValue(AppliesToProperty, value);
|
||||
}
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get =>
|
||||
(bool) GetValue(IsActiveProperty);
|
||||
set => SetValue(IsActiveProperty, value);
|
||||
}
|
||||
|
||||
protected virtual bool ShouldSkipInitialLayout =>
|
||||
Tag == TagType.DataContext;
|
||||
|
||||
public TagType Tag
|
||||
{
|
||||
get =>
|
||||
(TagType) GetValue(TagProperty);
|
||||
set => SetValue(TagProperty, value);
|
||||
}
|
||||
|
||||
public string TagPath
|
||||
{
|
||||
get =>
|
||||
(string) GetValue(TagPathProperty);
|
||||
set => SetValue(TagPathProperty, value);
|
||||
}
|
||||
|
||||
private void AssociatedObject_LayoutUpdated(object sender, EventArgs e)
|
||||
{
|
||||
if (IsActive)
|
||||
{
|
||||
if (DateTime.Now - LastPurgeTick >= MinTickDelta)
|
||||
{
|
||||
List<object> list = null;
|
||||
foreach (var pair in TagDictionary)
|
||||
if (pair.Value.Timestamp < NextToLastPurgeTick)
|
||||
{
|
||||
if (list == null) list = new List<object>();
|
||||
list.Add(pair.Key);
|
||||
}
|
||||
|
||||
if (list != null)
|
||||
foreach (var obj2 in list)
|
||||
TagDictionary.Remove(obj2);
|
||||
NextToLastPurgeTick = LastPurgeTick;
|
||||
LastPurgeTick = DateTime.Now;
|
||||
}
|
||||
|
||||
if (AppliesTo == FluidMoveScope.Self)
|
||||
{
|
||||
UpdateLayoutTransition(AssociatedObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AssociatedObject is Panel associatedObject)
|
||||
foreach (FrameworkElement element in associatedObject.Children)
|
||||
UpdateLayoutTransition(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void EnsureTags(FrameworkElement child)
|
||||
{
|
||||
if (Tag == TagType.DataContext &&
|
||||
!(child.ReadLocalValue(IdentityTagProperty) is BindingExpression))
|
||||
child.SetBinding(IdentityTagProperty, new Binding(TagPath));
|
||||
}
|
||||
|
||||
protected static object GetIdentityTag(DependencyObject obj)
|
||||
{
|
||||
return obj.GetValue(IdentityTagProperty);
|
||||
}
|
||||
|
||||
private static FrameworkElement GetVisualRoot(FrameworkElement child)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (!(VisualTreeHelper.GetParent(child) is FrameworkElement parent)) return child;
|
||||
if (AdornerLayer.GetAdornerLayer(parent) == null) return child;
|
||||
child = parent;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
AssociatedObject.LayoutUpdated += AssociatedObject_LayoutUpdated;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
base.OnDetaching();
|
||||
AssociatedObject.LayoutUpdated -= AssociatedObject_LayoutUpdated;
|
||||
}
|
||||
|
||||
protected static void SetIdentityTag(DependencyObject obj, object value)
|
||||
{
|
||||
obj.SetValue(IdentityTagProperty, value);
|
||||
}
|
||||
|
||||
internal static Rect TranslateRect(Rect rect, FrameworkElement from, FrameworkElement to)
|
||||
{
|
||||
if (from == null || to == null) return rect;
|
||||
var point = new Point(rect.Left, rect.Top);
|
||||
point = from.TransformToVisual(to).Transform(point);
|
||||
return new Rect(point.X, point.Y, rect.Width, rect.Height);
|
||||
}
|
||||
|
||||
private void UpdateLayoutTransition(FrameworkElement child)
|
||||
{
|
||||
if (child.Visibility != Visibility.Collapsed && child.IsLoaded || !ShouldSkipInitialLayout)
|
||||
{
|
||||
var visualRoot = GetVisualRoot(child);
|
||||
var newTagData = new TagData
|
||||
{
|
||||
Parent = VisualTreeHelper.GetParent(child) as FrameworkElement,
|
||||
ParentRect = ExtendedVisualStateManager.GetLayoutRect(child),
|
||||
Child = child,
|
||||
Timestamp = DateTime.Now
|
||||
};
|
||||
try
|
||||
{
|
||||
newTagData.AppRect = TranslateRect(newTagData.ParentRect, newTagData.Parent, visualRoot);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
if (ShouldSkipInitialLayout) return;
|
||||
}
|
||||
|
||||
EnsureTags(child);
|
||||
var identityTag = GetIdentityTag(child) ?? child;
|
||||
UpdateLayoutTransitionCore(child, visualRoot, identityTag, newTagData);
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract void UpdateLayoutTransitionCore(FrameworkElement child, FrameworkElement root,
|
||||
object tag, TagData newTagData);
|
||||
|
||||
|
||||
internal class TagData
|
||||
{
|
||||
public Rect AppRect { get; set; }
|
||||
|
||||
public FrameworkElement Child { get; set; }
|
||||
|
||||
public object InitialTag { get; set; }
|
||||
|
||||
public FrameworkElement Parent { get; set; }
|
||||
|
||||
public Rect ParentRect { get; set; }
|
||||
|
||||
public DateTime Timestamp { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
8
HandyControl/Interactivity/FluidMoveScope.cs
Normal file
8
HandyControl/Interactivity/FluidMoveScope.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public enum FluidMoveScope
|
||||
{
|
||||
Self,
|
||||
Children
|
||||
}
|
||||
}
|
12
HandyControl/Interactivity/IAttachedObject.cs
Normal file
12
HandyControl/Interactivity/IAttachedObject.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public interface IAttachedObject
|
||||
{
|
||||
void Attach(DependencyObject dependencyObject);
|
||||
void Detach();
|
||||
|
||||
DependencyObject AssociatedObject { get; }
|
||||
}
|
||||
}
|
77
HandyControl/Interactivity/Interaction.cs
Normal file
77
HandyControl/Interactivity/Interaction.cs
Normal file
@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public static class Interaction
|
||||
{
|
||||
private static readonly DependencyProperty TriggersProperty =
|
||||
DependencyProperty.RegisterAttached("ShadowTriggers", typeof(TriggerCollection), typeof(Interaction),
|
||||
new FrameworkPropertyMetadata(OnTriggersChanged));
|
||||
|
||||
private static readonly DependencyProperty BehaviorsProperty =
|
||||
DependencyProperty.RegisterAttached("ShadowBehaviors", typeof(BehaviorCollection), typeof(Interaction),
|
||||
new FrameworkPropertyMetadata(OnBehaviorsChanged));
|
||||
|
||||
internal static bool ShouldRunInDesignMode { get; set; }
|
||||
|
||||
public static TriggerCollection GetTriggers(DependencyObject obj)
|
||||
{
|
||||
var triggerCollection = (TriggerCollection) obj.GetValue(TriggersProperty);
|
||||
if (triggerCollection == null)
|
||||
{
|
||||
triggerCollection = new TriggerCollection();
|
||||
obj.SetValue(TriggersProperty, triggerCollection);
|
||||
}
|
||||
return triggerCollection;
|
||||
}
|
||||
|
||||
public static BehaviorCollection GetBehaviors(DependencyObject obj)
|
||||
{
|
||||
var behaviorCollection = (BehaviorCollection) obj.GetValue(BehaviorsProperty);
|
||||
if (behaviorCollection == null)
|
||||
{
|
||||
behaviorCollection = new BehaviorCollection();
|
||||
obj.SetValue(BehaviorsProperty, behaviorCollection);
|
||||
}
|
||||
return behaviorCollection;
|
||||
}
|
||||
|
||||
private static void OnBehaviorsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var oldValue = (BehaviorCollection) args.OldValue;
|
||||
var newValue = (BehaviorCollection) args.NewValue;
|
||||
if (Equals(oldValue, newValue))
|
||||
return;
|
||||
if (oldValue?.AssociatedObject != null)
|
||||
oldValue.Detach();
|
||||
if (newValue == null || obj == null)
|
||||
return;
|
||||
if (newValue.AssociatedObject != null)
|
||||
throw new InvalidOperationException(ExceptionStringTable
|
||||
.CannotHostBehaviorCollectionMultipleTimesExceptionMessage);
|
||||
newValue.Attach(obj);
|
||||
}
|
||||
|
||||
private static void OnTriggersChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var oldValue = args.OldValue as TriggerCollection;
|
||||
var newValue = args.NewValue as TriggerCollection;
|
||||
if (Equals(oldValue, newValue))
|
||||
return;
|
||||
if (oldValue?.AssociatedObject != null)
|
||||
oldValue.Detach();
|
||||
if (newValue == null || obj == null)
|
||||
return;
|
||||
if (newValue.AssociatedObject != null)
|
||||
throw new InvalidOperationException(ExceptionStringTable
|
||||
.CannotHostTriggerCollectionMultipleTimesExceptionMessage);
|
||||
newValue.Attach(obj);
|
||||
}
|
||||
|
||||
internal static bool IsElementLoaded(FrameworkElement element)
|
||||
{
|
||||
return element.IsLoaded;
|
||||
}
|
||||
}
|
||||
}
|
352
HandyControl/Interactivity/MouseDragElementBehavior.cs
Normal file
352
HandyControl/Interactivity/MouseDragElementBehavior.cs
Normal file
@ -0,0 +1,352 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public class MouseDragElementBehavior : Behavior<FrameworkElement>
|
||||
{
|
||||
public static readonly DependencyProperty ConstrainToParentBoundsProperty =
|
||||
DependencyProperty.Register("ConstrainToParentBounds", typeof(bool), typeof(MouseDragElementBehavior),
|
||||
new PropertyMetadata(false, OnConstrainToParentBoundsChanged));
|
||||
|
||||
public static readonly DependencyProperty XProperty = DependencyProperty.Register("X", typeof(double),
|
||||
typeof(MouseDragElementBehavior), new PropertyMetadata(1.0 / 0.0, OnXChanged));
|
||||
|
||||
public static readonly DependencyProperty YProperty = DependencyProperty.Register("Y", typeof(double),
|
||||
typeof(MouseDragElementBehavior), new PropertyMetadata(1.0 / 0.0, OnYChanged));
|
||||
|
||||
// Fields
|
||||
private Transform _cachedRenderTransform;
|
||||
|
||||
private Point _relativePosition;
|
||||
private bool _settingPosition;
|
||||
|
||||
// Properties
|
||||
|
||||
public bool ConstrainToParentBounds
|
||||
{
|
||||
get =>
|
||||
(bool) GetValue(ConstrainToParentBoundsProperty);
|
||||
set => SetValue(ConstrainToParentBoundsProperty, value);
|
||||
}
|
||||
|
||||
private Rect ElementBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
var layoutRect = ExtendedVisualStateManager.GetLayoutRect(AssociatedObject);
|
||||
return new Rect(new Point(0.0, 0.0), new Size(layoutRect.Width, layoutRect.Height));
|
||||
}
|
||||
}
|
||||
|
||||
private FrameworkElement ParentElement =>
|
||||
AssociatedObject.Parent as FrameworkElement;
|
||||
|
||||
private Transform RenderTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cachedRenderTransform == null ||
|
||||
!ReferenceEquals(_cachedRenderTransform, AssociatedObject.RenderTransform))
|
||||
{
|
||||
var transform = CloneTransform(AssociatedObject.RenderTransform);
|
||||
RenderTransform = transform;
|
||||
}
|
||||
return _cachedRenderTransform;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Equals(_cachedRenderTransform, value))
|
||||
{
|
||||
_cachedRenderTransform = value;
|
||||
AssociatedObject.RenderTransform = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UIElement RootElement
|
||||
{
|
||||
get
|
||||
{
|
||||
DependencyObject associatedObject = AssociatedObject;
|
||||
for (var obj3 = associatedObject; obj3 != null; obj3 = VisualTreeHelper.GetParent(associatedObject))
|
||||
associatedObject = obj3;
|
||||
return associatedObject as UIElement;
|
||||
}
|
||||
}
|
||||
|
||||
public double X
|
||||
{
|
||||
get =>
|
||||
(double) GetValue(XProperty);
|
||||
set => SetValue(XProperty, value);
|
||||
}
|
||||
|
||||
public double Y
|
||||
{
|
||||
get =>
|
||||
(double) GetValue(YProperty);
|
||||
set => SetValue(YProperty, value);
|
||||
}
|
||||
|
||||
// Events
|
||||
public event MouseEventHandler DragBegun;
|
||||
|
||||
public event MouseEventHandler DragFinished;
|
||||
|
||||
public event MouseEventHandler Dragging;
|
||||
|
||||
// Methods
|
||||
private void ApplyTranslation(double x, double y)
|
||||
{
|
||||
if (ParentElement != null)
|
||||
{
|
||||
var point = TransformAsVector(RootElement.TransformToVisual(ParentElement), x, y);
|
||||
x = point.X;
|
||||
y = point.Y;
|
||||
if (ConstrainToParentBounds)
|
||||
{
|
||||
var parentElement = ParentElement;
|
||||
var rect = new Rect(0.0, 0.0, parentElement.ActualWidth, parentElement.ActualHeight);
|
||||
var transform2 = AssociatedObject.TransformToVisual(parentElement);
|
||||
var elementBounds = ElementBounds;
|
||||
var rect3 = transform2.TransformBounds(elementBounds);
|
||||
rect3.X += x;
|
||||
rect3.Y += y;
|
||||
if (!RectContainsRect(rect, rect3))
|
||||
{
|
||||
if (rect3.X < rect.Left)
|
||||
{
|
||||
var num = rect3.X - rect.Left;
|
||||
x -= num;
|
||||
}
|
||||
else if (rect3.Right > rect.Right)
|
||||
{
|
||||
var num2 = rect3.Right - rect.Right;
|
||||
x -= num2;
|
||||
}
|
||||
if (rect3.Y < rect.Top)
|
||||
{
|
||||
var num3 = rect3.Y - rect.Top;
|
||||
y -= num3;
|
||||
}
|
||||
else if (rect3.Bottom > rect.Bottom)
|
||||
{
|
||||
var num4 = rect3.Bottom - rect.Bottom;
|
||||
y -= num4;
|
||||
}
|
||||
}
|
||||
}
|
||||
ApplyTranslationTransform(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ApplyTranslationTransform(double x, double y)
|
||||
{
|
||||
var renderTransform = RenderTransform;
|
||||
var transform2 = renderTransform as TranslateTransform;
|
||||
if (transform2 == null)
|
||||
{
|
||||
var group = renderTransform as TransformGroup;
|
||||
var transform3 = renderTransform as MatrixTransform;
|
||||
if (group != null)
|
||||
{
|
||||
if (group.Children.Count > 0)
|
||||
transform2 = group.Children[group.Children.Count - 1] as TranslateTransform;
|
||||
if (transform2 == null)
|
||||
{
|
||||
transform2 = new TranslateTransform();
|
||||
group.Children.Add(transform2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (transform3 != null)
|
||||
{
|
||||
var matrix = transform3.Matrix;
|
||||
matrix.OffsetX += x;
|
||||
matrix.OffsetY += y;
|
||||
var transform4 = new MatrixTransform
|
||||
{
|
||||
Matrix = matrix
|
||||
};
|
||||
RenderTransform = transform4;
|
||||
return;
|
||||
}
|
||||
var group2 = new TransformGroup();
|
||||
transform2 = new TranslateTransform();
|
||||
if (renderTransform != null)
|
||||
group2.Children.Add(renderTransform);
|
||||
group2.Children.Add(transform2);
|
||||
RenderTransform = group2;
|
||||
}
|
||||
}
|
||||
transform2.X += x;
|
||||
transform2.Y += y;
|
||||
}
|
||||
|
||||
internal static Transform CloneTransform(Transform transform)
|
||||
{
|
||||
if (transform == null)
|
||||
return null;
|
||||
if (transform is ScaleTransform transform2)
|
||||
return new ScaleTransform
|
||||
{
|
||||
CenterX = transform2.CenterX,
|
||||
CenterY = transform2.CenterY,
|
||||
ScaleX = transform2.ScaleX,
|
||||
ScaleY = transform2.ScaleY
|
||||
};
|
||||
if (transform is RotateTransform transform3)
|
||||
return new RotateTransform
|
||||
{
|
||||
Angle = transform3.Angle,
|
||||
CenterX = transform3.CenterX,
|
||||
CenterY = transform3.CenterY
|
||||
};
|
||||
if (transform is SkewTransform transform4)
|
||||
return new SkewTransform
|
||||
{
|
||||
AngleX = transform4.AngleX,
|
||||
AngleY = transform4.AngleY,
|
||||
CenterX = transform4.CenterX,
|
||||
CenterY = transform4.CenterY
|
||||
};
|
||||
if (transform is TranslateTransform transform5)
|
||||
return new TranslateTransform
|
||||
{
|
||||
X = transform5.X,
|
||||
Y = transform5.Y
|
||||
};
|
||||
if (transform is MatrixTransform transform6)
|
||||
return new MatrixTransform {Matrix = transform6.Matrix};
|
||||
if (!(transform is TransformGroup group))
|
||||
return null;
|
||||
var group2 = new TransformGroup();
|
||||
foreach (var transform12 in group.Children)
|
||||
group2.Children.Add(CloneTransform(transform12));
|
||||
return group2;
|
||||
}
|
||||
|
||||
internal void EndDrag()
|
||||
{
|
||||
AssociatedObject.MouseMove -= OnMouseMove;
|
||||
AssociatedObject.LostMouseCapture -= OnLostMouseCapture;
|
||||
AssociatedObject.RemoveHandler(UIElement.MouseLeftButtonUpEvent,
|
||||
new MouseButtonEventHandler(OnMouseLeftButtonUp));
|
||||
}
|
||||
|
||||
private static Point GetTransformOffset(GeneralTransform transform)
|
||||
{
|
||||
return transform.Transform(new Point(0.0, 0.0));
|
||||
}
|
||||
|
||||
internal void HandleDrag(Point newPositionInElementCoordinates)
|
||||
{
|
||||
var x = newPositionInElementCoordinates.X - _relativePosition.X;
|
||||
var y = newPositionInElementCoordinates.Y - _relativePosition.Y;
|
||||
var point = TransformAsVector(AssociatedObject.TransformToVisual(RootElement), x, y);
|
||||
_settingPosition = true;
|
||||
ApplyTranslation(point.X, point.Y);
|
||||
UpdatePosition();
|
||||
_settingPosition = false;
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
AssociatedObject.AddHandler(UIElement.MouseLeftButtonDownEvent,
|
||||
new MouseButtonEventHandler(OnMouseLeftButtonDown), false);
|
||||
}
|
||||
|
||||
private static void OnConstrainToParentBoundsChanged(object sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var behavior = (MouseDragElementBehavior) sender;
|
||||
behavior.UpdatePosition(new Point(behavior.X, behavior.Y));
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
AssociatedObject.RemoveHandler(UIElement.MouseLeftButtonDownEvent,
|
||||
new MouseButtonEventHandler(OnMouseLeftButtonDown));
|
||||
}
|
||||
|
||||
private void OnLostMouseCapture(object sender, MouseEventArgs e)
|
||||
{
|
||||
EndDrag();
|
||||
DragFinished?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
StartDrag(e.GetPosition(AssociatedObject));
|
||||
DragBegun?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
AssociatedObject.ReleaseMouseCapture();
|
||||
}
|
||||
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
HandleDrag(e.GetPosition(AssociatedObject));
|
||||
Dragging?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private static void OnXChanged(object sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var behavior = (MouseDragElementBehavior) sender;
|
||||
behavior.UpdatePosition(new Point((double) args.NewValue, behavior.Y));
|
||||
}
|
||||
|
||||
private static void OnYChanged(object sender, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
var behavior = (MouseDragElementBehavior) sender;
|
||||
behavior.UpdatePosition(new Point(behavior.X, (double) args.NewValue));
|
||||
}
|
||||
|
||||
private static bool RectContainsRect(Rect rect1, Rect rect2)
|
||||
{
|
||||
if (rect1.IsEmpty || rect2.IsEmpty)
|
||||
return false;
|
||||
return rect1.X <= rect2.X && rect1.Y <= rect2.Y && rect1.X + rect1.Width >= rect2.X + rect2.Width &&
|
||||
rect1.Y + rect1.Height >= rect2.Y + rect2.Height;
|
||||
}
|
||||
|
||||
internal void StartDrag(Point positionInElementCoordinates)
|
||||
{
|
||||
_relativePosition = positionInElementCoordinates;
|
||||
AssociatedObject.CaptureMouse();
|
||||
AssociatedObject.MouseMove += OnMouseMove;
|
||||
AssociatedObject.LostMouseCapture += OnLostMouseCapture;
|
||||
AssociatedObject.AddHandler(UIElement.MouseLeftButtonUpEvent,
|
||||
new MouseButtonEventHandler(OnMouseLeftButtonUp), false);
|
||||
}
|
||||
|
||||
private static Point TransformAsVector(GeneralTransform transform, double x, double y)
|
||||
{
|
||||
var point = transform.Transform(new Point(0.0, 0.0));
|
||||
var point2 = transform.Transform(new Point(x, y));
|
||||
return new Point(point2.X - point.X, point2.Y - point.Y);
|
||||
}
|
||||
|
||||
private void UpdatePosition()
|
||||
{
|
||||
var transformOffset = GetTransformOffset(AssociatedObject.TransformToVisual(RootElement));
|
||||
X = transformOffset.X;
|
||||
Y = transformOffset.Y;
|
||||
}
|
||||
|
||||
private void UpdatePosition(Point point)
|
||||
{
|
||||
if (!_settingPosition && AssociatedObject != null)
|
||||
{
|
||||
var transformOffset = GetTransformOffset(AssociatedObject.TransformToVisual(RootElement));
|
||||
var x = double.IsNaN(point.X) ? 0.0 : point.X - transformOffset.X;
|
||||
var y = double.IsNaN(point.Y) ? 0.0 : point.Y - transformOffset.Y;
|
||||
ApplyTranslation(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
17
HandyControl/Interactivity/NameResolvedEventArgs.cs
Normal file
17
HandyControl/Interactivity/NameResolvedEventArgs.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
internal sealed class NameResolvedEventArgs : EventArgs
|
||||
{
|
||||
public NameResolvedEventArgs(object oldObject, object newObject)
|
||||
{
|
||||
OldObject = oldObject;
|
||||
NewObject = newObject;
|
||||
}
|
||||
|
||||
public object NewObject { get; }
|
||||
|
||||
public object OldObject { get; }
|
||||
}
|
||||
}
|
124
HandyControl/Interactivity/NameResolver.cs
Normal file
124
HandyControl/Interactivity/NameResolver.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
internal sealed class NameResolver
|
||||
{
|
||||
private string _name;
|
||||
private FrameworkElement _nameScopeReferenceElement;
|
||||
|
||||
private FrameworkElement ActualNameScopeReferenceElement
|
||||
{
|
||||
get
|
||||
{
|
||||
if (NameScopeReferenceElement != null && Interaction.IsElementLoaded(NameScopeReferenceElement))
|
||||
return GetActualNameScopeReference(NameScopeReferenceElement);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasAttempedResolve { get; set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get =>
|
||||
_name;
|
||||
set
|
||||
{
|
||||
var oldObject = Object;
|
||||
_name = value;
|
||||
UpdateObjectFromName(oldObject);
|
||||
}
|
||||
}
|
||||
|
||||
public FrameworkElement NameScopeReferenceElement
|
||||
{
|
||||
get =>
|
||||
_nameScopeReferenceElement;
|
||||
set
|
||||
{
|
||||
var nameScopeReferenceElement = NameScopeReferenceElement;
|
||||
_nameScopeReferenceElement = value;
|
||||
OnNameScopeReferenceElementChanged(nameScopeReferenceElement);
|
||||
}
|
||||
}
|
||||
|
||||
public DependencyObject Object
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name) && HasAttempedResolve)
|
||||
return NameScopeReferenceElement;
|
||||
return ResolvedObject;
|
||||
}
|
||||
}
|
||||
|
||||
private bool PendingReferenceElementLoad { get; set; }
|
||||
|
||||
private DependencyObject ResolvedObject { get; set; }
|
||||
|
||||
public event EventHandler<NameResolvedEventArgs> ResolvedElementChanged;
|
||||
|
||||
private FrameworkElement GetActualNameScopeReference(FrameworkElement initialReferenceElement)
|
||||
{
|
||||
var element = initialReferenceElement;
|
||||
if (!IsNameScope(initialReferenceElement))
|
||||
return element;
|
||||
return initialReferenceElement.Parent as FrameworkElement ?? element;
|
||||
}
|
||||
|
||||
private bool IsNameScope(FrameworkElement frameworkElement)
|
||||
{
|
||||
return frameworkElement.Parent is FrameworkElement parent && parent.FindName(Name) != null;
|
||||
}
|
||||
|
||||
private void OnNameScopeReferenceElementChanged(FrameworkElement oldNameScopeReference)
|
||||
{
|
||||
if (PendingReferenceElementLoad)
|
||||
{
|
||||
oldNameScopeReference.Loaded -= OnNameScopeReferenceLoaded;
|
||||
PendingReferenceElementLoad = false;
|
||||
}
|
||||
HasAttempedResolve = false;
|
||||
UpdateObjectFromName(Object);
|
||||
}
|
||||
|
||||
private void OnNameScopeReferenceLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PendingReferenceElementLoad = false;
|
||||
NameScopeReferenceElement.Loaded -= OnNameScopeReferenceLoaded;
|
||||
UpdateObjectFromName(Object);
|
||||
}
|
||||
|
||||
private void OnObjectChanged(DependencyObject oldTarget, DependencyObject newTarget)
|
||||
{
|
||||
ResolvedElementChanged?.Invoke(this, new NameResolvedEventArgs(oldTarget, newTarget));
|
||||
}
|
||||
|
||||
private void UpdateObjectFromName(DependencyObject oldObject)
|
||||
{
|
||||
DependencyObject obj2 = null;
|
||||
ResolvedObject = null;
|
||||
if (NameScopeReferenceElement != null)
|
||||
{
|
||||
if (!Interaction.IsElementLoaded(NameScopeReferenceElement))
|
||||
{
|
||||
NameScopeReferenceElement.Loaded += OnNameScopeReferenceLoaded;
|
||||
PendingReferenceElementLoad = true;
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Name))
|
||||
{
|
||||
var actualNameScopeReferenceElement = ActualNameScopeReferenceElement;
|
||||
if (actualNameScopeReferenceElement != null)
|
||||
obj2 = actualNameScopeReferenceElement.FindName(Name) as DependencyObject;
|
||||
}
|
||||
}
|
||||
HasAttempedResolve = true;
|
||||
ResolvedObject = obj2;
|
||||
if (!Equals(oldObject, Object))
|
||||
OnObjectChanged(oldObject, Object);
|
||||
}
|
||||
}
|
||||
}
|
9
HandyControl/Interactivity/PreviewInvokeEventArgs.cs
Normal file
9
HandyControl/Interactivity/PreviewInvokeEventArgs.cs
Normal file
@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public class PreviewInvokeEventArgs : EventArgs
|
||||
{
|
||||
public bool Cancelling { get; set; }
|
||||
}
|
||||
}
|
8
HandyControl/Interactivity/TagType.cs
Normal file
8
HandyControl/Interactivity/TagType.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public enum TagType
|
||||
{
|
||||
Element,
|
||||
DataContext
|
||||
}
|
||||
}
|
56
HandyControl/Interactivity/TransitionEffect.cs
Normal file
56
HandyControl/Interactivity/TransitionEffect.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Effects;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public abstract class TransitionEffect : ShaderEffect
|
||||
{
|
||||
// Fields
|
||||
public static readonly DependencyProperty InputProperty =
|
||||
RegisterPixelShaderSamplerProperty("Input", typeof(TransitionEffect), 0, SamplingMode.NearestNeighbor);
|
||||
|
||||
public static readonly DependencyProperty OldImageProperty =
|
||||
RegisterPixelShaderSamplerProperty("OldImage", typeof(TransitionEffect), 1, SamplingMode.NearestNeighbor);
|
||||
|
||||
public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register("Progress",
|
||||
typeof(double), typeof(TransitionEffect), new PropertyMetadata(0.0, PixelShaderConstantCallback(0)));
|
||||
|
||||
// Methods
|
||||
protected TransitionEffect()
|
||||
{
|
||||
UpdateShaderValue(InputProperty);
|
||||
UpdateShaderValue(OldImageProperty);
|
||||
UpdateShaderValue(ProgressProperty);
|
||||
}
|
||||
|
||||
// Properties
|
||||
public Brush Input
|
||||
{
|
||||
get =>
|
||||
(Brush) GetValue(InputProperty);
|
||||
set => SetValue(InputProperty, value);
|
||||
}
|
||||
|
||||
public Brush OldImage
|
||||
{
|
||||
get =>
|
||||
(Brush) GetValue(OldImageProperty);
|
||||
set => SetValue(OldImageProperty, value);
|
||||
}
|
||||
|
||||
public double Progress
|
||||
{
|
||||
get =>
|
||||
(double) GetValue(ProgressProperty);
|
||||
set => SetValue(ProgressProperty, value);
|
||||
}
|
||||
|
||||
public new TransitionEffect CloneCurrentValue()
|
||||
{
|
||||
return (TransitionEffect) base.CloneCurrentValue();
|
||||
}
|
||||
|
||||
protected abstract TransitionEffect DeepCopy();
|
||||
}
|
||||
}
|
118
HandyControl/Interactivity/TriggerAction.cs
Normal file
118
HandyControl/Interactivity/TriggerAction.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
[DefaultTrigger(typeof(UIElement), typeof(EventTrigger), "MouseLeftButtonDown")]
|
||||
[DefaultTrigger(typeof(ButtonBase), typeof(EventTrigger), "Click")]
|
||||
public abstract class TriggerAction : Animatable, IAttachedObject
|
||||
{
|
||||
public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.Register("IsEnabled",
|
||||
typeof(bool), typeof(TriggerAction), new FrameworkPropertyMetadata(true));
|
||||
|
||||
private readonly Type _associatedObjectTypeConstraint;
|
||||
|
||||
private DependencyObject _associatedObject;
|
||||
private bool _isHosted;
|
||||
|
||||
internal TriggerAction(Type associatedObjectTypeConstraint)
|
||||
{
|
||||
_associatedObjectTypeConstraint = associatedObjectTypeConstraint;
|
||||
}
|
||||
|
||||
protected DependencyObject AssociatedObject
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedObject;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Type AssociatedObjectTypeConstraint
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedObjectTypeConstraint;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get =>
|
||||
(bool) GetValue(IsEnabledProperty);
|
||||
set => SetValue(IsEnabledProperty, value);
|
||||
}
|
||||
|
||||
internal bool IsHosted
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _isHosted;
|
||||
}
|
||||
set
|
||||
{
|
||||
WritePreamble();
|
||||
_isHosted = value;
|
||||
WritePostscript();
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach(DependencyObject dependencyObject)
|
||||
{
|
||||
if (!Equals(dependencyObject, AssociatedObject))
|
||||
{
|
||||
if (AssociatedObject != null)
|
||||
throw new InvalidOperationException(ExceptionStringTable
|
||||
.CannotHostTriggerActionMultipleTimesExceptionMessage);
|
||||
if (dependencyObject != null &&
|
||||
!AssociatedObjectTypeConstraint.IsInstanceOfType(dependencyObject))
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.TypeConstraintViolatedExceptionMessage,
|
||||
new object[]
|
||||
{GetType().Name, dependencyObject.GetType().Name, AssociatedObjectTypeConstraint.Name}));
|
||||
WritePreamble();
|
||||
_associatedObject = dependencyObject;
|
||||
WritePostscript();
|
||||
OnAttached();
|
||||
}
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
OnDetaching();
|
||||
WritePreamble();
|
||||
_associatedObject = null;
|
||||
WritePostscript();
|
||||
}
|
||||
|
||||
DependencyObject IAttachedObject.AssociatedObject =>
|
||||
AssociatedObject;
|
||||
|
||||
internal void CallInvoke(object parameter)
|
||||
{
|
||||
if (IsEnabled)
|
||||
Invoke(parameter);
|
||||
}
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return (Freezable) Activator.CreateInstance(GetType());
|
||||
}
|
||||
|
||||
protected abstract void Invoke(object parameter);
|
||||
|
||||
protected virtual void OnAttached()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDetaching()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
46
HandyControl/Interactivity/TriggerActionCollection.cs
Normal file
46
HandyControl/Interactivity/TriggerActionCollection.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public class TriggerActionCollection : AttachableCollection<TriggerAction>
|
||||
{
|
||||
internal TriggerActionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new TriggerActionCollection();
|
||||
}
|
||||
|
||||
internal override void ItemAdded(TriggerAction item)
|
||||
{
|
||||
if (item.IsHosted)
|
||||
throw new InvalidOperationException(ExceptionStringTable
|
||||
.CannotHostTriggerActionMultipleTimesExceptionMessage);
|
||||
if (AssociatedObject != null)
|
||||
item.Attach(AssociatedObject);
|
||||
item.IsHosted = true;
|
||||
}
|
||||
|
||||
internal override void ItemRemoved(TriggerAction item)
|
||||
{
|
||||
if (((IAttachedObject) item).AssociatedObject != null)
|
||||
item.Detach();
|
||||
item.IsHosted = false;
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
foreach (var action in this)
|
||||
action.Attach(AssociatedObject);
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
foreach (var action in this)
|
||||
action.Detach();
|
||||
}
|
||||
}
|
||||
}
|
110
HandyControl/Interactivity/TriggerBase.cs
Normal file
110
HandyControl/Interactivity/TriggerBase.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
[ContentProperty("Actions")]
|
||||
public abstract class TriggerBase : Animatable, IAttachedObject
|
||||
{
|
||||
public static readonly DependencyProperty ActionsProperty = ActionsPropertyKey.DependencyProperty;
|
||||
|
||||
private static readonly DependencyPropertyKey ActionsPropertyKey =
|
||||
DependencyProperty.RegisterReadOnly("Actions", typeof(TriggerActionCollection), typeof(TriggerBase),
|
||||
new FrameworkPropertyMetadata());
|
||||
|
||||
private DependencyObject _associatedObject;
|
||||
private readonly Type _associatedObjectTypeConstraint;
|
||||
|
||||
internal TriggerBase(Type associatedObjectTypeConstraint)
|
||||
{
|
||||
_associatedObjectTypeConstraint = associatedObjectTypeConstraint;
|
||||
var actions = new TriggerActionCollection();
|
||||
SetValue(ActionsPropertyKey, actions);
|
||||
}
|
||||
|
||||
public TriggerActionCollection Actions =>
|
||||
(TriggerActionCollection) GetValue(ActionsProperty);
|
||||
|
||||
protected DependencyObject AssociatedObject
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedObject;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Type AssociatedObjectTypeConstraint
|
||||
{
|
||||
get
|
||||
{
|
||||
ReadPreamble();
|
||||
return _associatedObjectTypeConstraint;
|
||||
}
|
||||
}
|
||||
|
||||
public void Attach(DependencyObject dependencyObject)
|
||||
{
|
||||
if (!Equals(dependencyObject, AssociatedObject))
|
||||
{
|
||||
if (AssociatedObject != null)
|
||||
throw new InvalidOperationException(ExceptionStringTable
|
||||
.CannotHostTriggerMultipleTimesExceptionMessage);
|
||||
if (dependencyObject != null &&
|
||||
!AssociatedObjectTypeConstraint.IsInstanceOfType(dependencyObject))
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.TypeConstraintViolatedExceptionMessage,
|
||||
new object[]
|
||||
{GetType().Name, dependencyObject.GetType().Name, AssociatedObjectTypeConstraint.Name}));
|
||||
WritePreamble();
|
||||
_associatedObject = dependencyObject;
|
||||
WritePostscript();
|
||||
Actions.Attach(dependencyObject);
|
||||
OnAttached();
|
||||
}
|
||||
}
|
||||
|
||||
public void Detach()
|
||||
{
|
||||
OnDetaching();
|
||||
WritePreamble();
|
||||
_associatedObject = null;
|
||||
WritePostscript();
|
||||
Actions.Detach();
|
||||
}
|
||||
|
||||
DependencyObject IAttachedObject.AssociatedObject =>
|
||||
AssociatedObject;
|
||||
|
||||
public event EventHandler<PreviewInvokeEventArgs> PreviewInvoke;
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return (Freezable) Activator.CreateInstance(GetType());
|
||||
}
|
||||
|
||||
protected void InvokeActions(object parameter)
|
||||
{
|
||||
if (PreviewInvoke != null)
|
||||
{
|
||||
var e = new PreviewInvokeEventArgs();
|
||||
PreviewInvoke(this, e);
|
||||
if (e.Cancelling)
|
||||
return;
|
||||
}
|
||||
foreach (var action in Actions)
|
||||
action.CallInvoke(parameter);
|
||||
}
|
||||
|
||||
protected virtual void OnAttached()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDetaching()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
42
HandyControl/Interactivity/TriggerCollection.cs
Normal file
42
HandyControl/Interactivity/TriggerCollection.cs
Normal file
@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
public sealed class TriggerCollection : AttachableCollection<TriggerBase>
|
||||
{
|
||||
internal TriggerCollection()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
foreach (var triggerBase in this)
|
||||
triggerBase.Attach(AssociatedObject);
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
foreach (var triggerBase in this)
|
||||
triggerBase.Detach();
|
||||
}
|
||||
|
||||
internal override void ItemAdded(TriggerBase item)
|
||||
{
|
||||
if (AssociatedObject == null)
|
||||
return;
|
||||
item.Attach(AssociatedObject);
|
||||
}
|
||||
|
||||
internal override void ItemRemoved(TriggerBase item)
|
||||
{
|
||||
if (((IAttachedObject) item).AssociatedObject == null)
|
||||
return;
|
||||
item.Detach();
|
||||
}
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new TriggerCollection();
|
||||
}
|
||||
}
|
||||
}
|
15
HandyControl/Interactivity/TypeConstraintAttribute.cs
Normal file
15
HandyControl/Interactivity/TypeConstraintAttribute.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public sealed class TypeConstraintAttribute : Attribute
|
||||
{
|
||||
public TypeConstraintAttribute(Type constraint)
|
||||
{
|
||||
Constraint = constraint;
|
||||
}
|
||||
|
||||
public Type Constraint { get; }
|
||||
}
|
||||
}
|
BIN
HandyControl/Resources/colorPickerBack.png
Normal file
BIN
HandyControl/Resources/colorPickerBack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
16
HandyControl/Themes/Basic/Basic.xaml
Normal file
16
HandyControl/Themes/Basic/Basic.xaml
Normal file
@ -0,0 +1,16 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<ResourceDictionary Source="../Basic/Colors.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Brushes.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Converters.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Effects.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Fonts.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Geometries.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Paths.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="../Basic/Sizes.xaml"></ResourceDictionary>
|
||||
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
35
HandyControl/Themes/Basic/Brushes.xaml
Normal file
35
HandyControl/Themes/Basic/Brushes.xaml
Normal file
@ -0,0 +1,35 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<SolidColorBrush x:Key="PrimaryBrush" Color="{DynamicResource PrimaryColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkPrimaryBrush" Color="{DynamicResource DarkPrimaryColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="LightPrimaryBrush" Color="{DynamicResource LightPrimaryColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="PrimaryTextBrush" Color="{DynamicResource PrimaryTextColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="SecondaryTextBrush" Color="{DynamicResource SecondaryTextColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="ThirdlyTextBrush" Color="{DynamicResource ThirdlyTextColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="TextIconBrush" Color="{DynamicResource TextIconColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="{DynamicResource BorderColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="BackgroundBrush" Color="{DynamicResource BackgroundColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="RegionBrush" Color="{DynamicResource RegionColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="DefaultBrush" Color="{DynamicResource DefaultColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkDefaultBrush" Color="{DynamicResource DarkDefaultColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="DangerBrush" Color="{DynamicResource DangerColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkDangerBrush" Color="{DynamicResource DarkDangerColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="WarningBrush" Color="{DynamicResource WarningColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkWarningBrush" Color="{DynamicResource DarkWarningColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="InfoBrush" Color="{DynamicResource InfoColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkInfoBrush" Color="{DynamicResource DarkInfoColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="SuccessBrush" Color="{DynamicResource SuccessColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkSuccessBrush" Color="{DynamicResource DarkSuccessColor}"></SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="AccentBrush" Color="{DynamicResource AccentColor}"></SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkAccentBrush" Color="{DynamicResource DarkAccentColor}"></SolidColorBrush>
|
||||
|
||||
</ResourceDictionary>
|
35
HandyControl/Themes/Basic/Colors.xaml
Normal file
35
HandyControl/Themes/Basic/Colors.xaml
Normal file
@ -0,0 +1,35 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Color x:Key="PrimaryColor">#2196F3</Color>
|
||||
<Color x:Key="DarkPrimaryColor">#1976D2</Color>
|
||||
<Color x:Key="LightPrimaryColor">#81d4fa</Color>
|
||||
|
||||
<Color x:Key="DangerColor">#d9534f</Color>
|
||||
<Color x:Key="DarkDangerColor">#d43f3a</Color>
|
||||
|
||||
<Color x:Key="WarningColor">#f0ad4e</Color>
|
||||
<Color x:Key="DarkWarningColor">#eea236</Color>
|
||||
|
||||
<Color x:Key="InfoColor">#5bc0de</Color>
|
||||
<Color x:Key="DarkInfoColor">#46b8da</Color>
|
||||
|
||||
<Color x:Key="SuccessColor">#5cb85c</Color>
|
||||
<Color x:Key="DarkSuccessColor">#4cae4c</Color>
|
||||
|
||||
<Color x:Key="PrimaryTextColor">#212121</Color>
|
||||
<Color x:Key="SecondaryTextColor">#757575</Color>
|
||||
<Color x:Key="ThirdlyTextColor">#bdbdbd</Color>
|
||||
<Color x:Key="TextIconColor">White</Color>
|
||||
|
||||
<Color x:Key="BorderColor">#e0e0e0</Color>
|
||||
<Color x:Key="BackgroundColor">#eeeeee</Color>
|
||||
<Color x:Key="RegionColor">White</Color>
|
||||
|
||||
<Color x:Key="DefaultColor">White</Color>
|
||||
<Color x:Key="DarkDefaultColor">#f4f4f4</Color>
|
||||
|
||||
<Color x:Key="AccentColor">#ff5722</Color>
|
||||
<Color x:Key="DarkAccentColor">#d43f3a</Color>
|
||||
|
||||
</ResourceDictionary>
|
18
HandyControl/Themes/Basic/Converters.xaml
Normal file
18
HandyControl/Themes/Basic/Converters.xaml
Normal file
@ -0,0 +1,18 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converter="clr-namespace:HandyControl.Tools.Converter">
|
||||
|
||||
<converter:Boolean2BooleanFeConverter x:Key="Boolean2BooleanFeConverter"/>
|
||||
<converter:Boolean2VisibilityFeConverter x:Key="Boolean2VisibilityFeConverter"/>
|
||||
<converter:BooleanArr2VisibilityConverter x:Key="BooleanArr2VisibilityConverter"/>
|
||||
<converter:IsNullConverter x:Key="IsNullConverter"/>
|
||||
<converter:Long2FileSizeConverter x:Key="Long2FileSizeConverter"/>
|
||||
<converter:Source2ImageConverter x:Key="Source2ImageConverter"/>
|
||||
<converter:String2VisibilityConverter x:Key="String2VisibilityConverter"/>
|
||||
<converter:String2VisibilityFeConverter x:Key="String2VisibilityFeConverter"/>
|
||||
<BooleanToVisibilityConverter x:Key="Boolean2VisibilityConverter"/>
|
||||
<converter:TreeViewItemMarginConverter x:Key="TreeViewItemMarginConverter"/>
|
||||
<converter:Color2HexStrConverter x:Key="Color2HexStrConverter"></converter:Color2HexStrConverter>
|
||||
<converter:Object2BooleanConverter x:Key="Object2BooleanConverter"></converter:Object2BooleanConverter>
|
||||
|
||||
</ResourceDictionary>
|
13
HandyControl/Themes/Basic/Effects.xaml
Normal file
13
HandyControl/Themes/Basic/Effects.xaml
Normal file
@ -0,0 +1,13 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">
|
||||
|
||||
<Color x:Key="MaterialDesignShadow">#AA000000</Color>
|
||||
|
||||
<DropShadowEffect x:Key="EffectShadow1" BlurRadius="5" ShadowDepth="1" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" RenderingBias="Performance" po:Freeze="True" />
|
||||
<DropShadowEffect x:Key="EffectShadow2" BlurRadius="8" ShadowDepth="1.5" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" RenderingBias="Performance" po:Freeze="True" />
|
||||
<DropShadowEffect x:Key="EffectShadow3" BlurRadius="14" ShadowDepth="4.5" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" RenderingBias="Performance" po:Freeze="True" />
|
||||
<DropShadowEffect x:Key="EffectShadow4" BlurRadius="25" ShadowDepth="8" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" RenderingBias="Performance" po:Freeze="True" />
|
||||
<DropShadowEffect x:Key="EffectShadow5" BlurRadius="35" ShadowDepth="13" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".42" RenderingBias="Performance" po:Freeze="True" />
|
||||
|
||||
</ResourceDictionary>
|
10
HandyControl/Themes/Basic/Fonts.xaml
Normal file
10
HandyControl/Themes/Basic/Fonts.xaml
Normal file
@ -0,0 +1,10 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="LargeFontSize">24</system:Double>
|
||||
<system:Double x:Key="HeadFontSize">20</system:Double>
|
||||
<system:Double x:Key="SubHeadFontSize">16</system:Double>
|
||||
<system:Double x:Key="TextFontSize">12</system:Double>
|
||||
|
||||
</ResourceDictionary>
|
23
HandyControl/Themes/Basic/Geometries.xaml
Normal file
23
HandyControl/Themes/Basic/Geometries.xaml
Normal file
@ -0,0 +1,23 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Geometry x:Key="CalendarGeometry">M377.897477 116.291025l265.298718 0 0 47.459125-265.298718 0 0-47.459125ZM888.317416 116.291025 748.229288 116.291025l0 47.459125 123.54866 0c18.167626 0 32.894732 14.727106 32.894732 32.894732l0 92.92987L115.42936 289.574752l0-92.92987c0-18.167626 14.727106-32.894732 32.894732-32.894732l123.54866 0 0-47.459125L131.776437 116.291025c-35.244356 0-63.814389 28.571056-63.814389 63.815412l0.004093 713.966329c0 35.243333 28.571056 63.814389 63.814389 63.814389l756.540979 0c35.244356 0 63.814389-28.571056 63.814389-63.815412l-0.004093-713.966329C952.131805 144.861058 923.560749 116.291025 888.317416 116.291025zM904.67268 337.033877l0 540.498398c0 18.167626-14.727106 32.894732-32.894732 32.894732L148.324092 910.427007c-18.167626 0-32.894732-14.727106-32.894732-32.894732L115.42936 337.033877 904.67268 337.033877zM300.659736 64.801927l47.459125 0 0 170.241292-47.459125 0 0-170.241292ZM672.97481 64.801927l47.450938 0 0 170.241292-47.450938 0 0-170.241292ZM358.384138 547.939214l0 231.021432 52.863464 0L411.247602 459.226591l-34.580198 0-2.651514 3.804835c-18.000819 25.896006-41.448959 48.758786-69.681285 67.955908l-3.886703 2.643327 0 53.742526 13.441772-8.069156C330.690097 569.215794 345.588103 558.712075 358.384138 547.939214zM618.031888 726.552576c-10.287791 6.395971-24.435678 8.069156-42.059902 4.948946-16.094309-2.842881-27.898712-18.373321-35.082666-46.159464l-2.261615-8.753781-48.312603 13.424375 1.68956 8.129534c6.270098 30.168514 18.347737 52.052967 35.884976 65.017855 17.120734 12.705979 35.542152 19.777364 54.731087 21.043255 3.358652 0.225138 6.655903 0.337707 9.897892 0.337707 14.859119 0 28.430857-2.374184 40.452211-7.072408 14.417029-5.641758 26.88866-13.338413 37.076162-22.86278 10.365566-9.723922 18.230051-22.143362 23.378552-36.920612 4.918246-14.170401 7.739636-28.296797 8.385373-42.025108 0.60685-13.658723-0.667228-26.650218-3.791531-38.619382l-0.008187-0.017397c-3.111-11.777796-8.133628-23.738773-14.946104-35.551363-7.353831-12.679372-19.028268-22.750211-34.710165-29.952586-15.037183-6.872854-30.927843-10.685876-47.24729-11.32752-11.414505-0.415482-23.487027 1.386646-36.04462 5.434017 3.813022-14.568486 7.648557-31.884681 11.465673-51.775637l113.87693 0 0-49.357449L535.645647 464.492778l-1.495122 7.028404c-24.621928 115.77116-31.589954 145.497585-33.102473 150.039235l-3.432334 10.338958 45.829943 5.391036 3.054716-4.20292c8.146931-11.214951 18.247448-18.139996 30.879746-21.164011 13.004799-3.137607 24.743707-3.180588 34.879018-0.129966 9.857981 2.95545 17.822756 8.771178 24.327202 17.758284 6.512633 9.03111 10.084143 20.392401 10.617311 33.757421 0.519864 13.849067-1.603598 26.442477-6.314102 37.440476C636.315153 711.429431 628.843637 719.871089 618.031888 726.552576z</Geometry>
|
||||
<Geometry x:Key="DeleteGeometry">M512 620.544l253.3376 253.3376a76.6976 76.6976 0 1 0 108.544-108.544L620.6464 512l253.2352-253.3376a76.6976 76.6976 0 1 0-108.544-108.544L512 403.3536 258.6624 150.1184a76.6976 76.6976 0 1 0-108.544 108.544L403.3536 512 150.1184 765.3376a76.6976 76.6976 0 1 0 108.544 108.544L512 620.6464z</Geometry>
|
||||
<Geometry x:Key="DeleteFillCircleGeometry">M7.4038057,6.4038057 C7.1478834,6.4038057 6.8919611,6.5014372 6.6966991,6.6966991 6.3061748,7.0872235 6.3061748,7.7203884 6.6966991,8.1109123 L10.585787,12 6.6966991,15.889088 C6.3061748,16.279612 6.3061748,16.912777 6.6966991,17.303301 7.0872235,17.693825 7.7203879,17.693825 8.1109123,17.303301 L12,13.414213 15.889088,17.303301 C16.279612,17.693825 16.912777,17.693825 17.303301,17.303301 17.693825,16.912777 17.693825,16.279612 17.303301,15.889088 L13.414213,12 17.303301,8.1109123 C17.693825,7.7203884 17.693825,7.0872235 17.303301,6.6966991 16.912777,6.3061748 16.279612,6.3061748 15.889088,6.6966991 L12,10.585787 8.1109123,6.6966991 C7.9156504,6.5014372 7.6597281,6.4038057 7.4038057,6.4038057 z M12,0 C18.627417,0 24,5.3725829 24,12 24,18.627417 18.627417,24 12,24 5.3725829,24 0,18.627417 0,12 0,5.3725829 5.3725829,0 12,0 z</Geometry>
|
||||
<Geometry x:Key="CloseGeometry">M0.353553533554077,0L3.71231077611446,3.35875718295574 7.07106781005859,0 7.42462134361267,0.353553295135498 7.07106781005859,0.707106828689575 4.06586414575577,3.71231056749821 7.42462134361267,7.07106781005859 7.07106781005859,7.42462134361267 6.7175145149231,7.07106781005859 3.71231067180634,4.06586402654648 0.707106828689575,7.07106781005859 0.353553533554077,7.42462110519409 0,7.07106781005859 3.35875730216503,3.71231067180634 0.353553533554077,0.707106828689575 0,0.353553533554077z</Geometry>
|
||||
<Geometry x:Key="DownGeometry">M512 801.6896L5.12 282.0096l58.1632-59.5968L512 682.3936l448.7168-460.0832 58.1632 59.5968-506.88 519.7824z</Geometry>
|
||||
<Geometry x:Key="UpGeometry">M50.000001,0 L100,51.262779 94.262627,57.141584 50.000001,11.767713 5.7373757,57.151686 0,51.27288 z</Geometry>
|
||||
<Geometry x:Key="ClockGeometry">M498.506684 256.571517 425.359734 256.571517 425.359734 622.190635 720.166063 622.190635 720.166063 549.725206 498.506684 549.725206ZM512.714268 80.162738c-245.740844 0-445.181175 197.577914-445.181175 441.024505s199.439308 441.024505 445.181175 441.024505c245.738797 0 445.178105-197.577914 445.178105-441.024505S758.453065 80.162738 512.714268 80.162738zM512.714268 874.005824c-195.880249 0-356.145349-158.768003-356.145349-352.818581s160.2651-352.821651 356.145349-352.821651c195.877179 0 356.14228 158.77005 356.14228 352.821651S708.591447 874.005824 512.714268 874.005824z</Geometry>
|
||||
<Geometry x:Key="LeftGeometry">M394.24 512L683.52 248.32c10.24-10.24 10.24-25.6 0-35.84-10.24-10.24-25.6-10.24-35.84 0l-307.2 279.04c-5.12 5.12-7.68 12.8-7.68 20.48 0 7.68 2.56 15.36 7.68 20.48l307.2 279.04c10.24 10.24 25.6 10.24 35.84 0 10.24-10.24 10.24-25.6 0-35.84L394.24 512z</Geometry>
|
||||
<Geometry x:Key="RotateLeftGeometry">M165.238899 508.178506C164.450369 456.442676 171.767779 404.485842 187.244542 353.863631 266.138632 95.812692 533.436225-51.353028 784.380224 25.368251 1035.324219 102.08953 1174.62994 373.566359 1095.735851 631.617298 1016.84176 889.66824 749.544168 1036.833959 498.600172 960.11268 424.134741 937.346313 357.837833 896.870788 303.973868 842.276436 291.310328 829.441176 291.396506 808.495802 304.166356 795.493625 316.936205 782.491452 337.554042 782.356136 350.217582 795.191397 396.640587 842.243889 453.73137 877.098901 517.975091 896.740177 734.436966 962.919213 965.320335 835.802028 1033.557737 612.607541 1101.795139 389.413057 981.467179 154.919792 765.005305 88.740755 548.543428 22.561718 317.660056 149.678904 249.422655 372.873388 235.597198 418.094418 229.294871 464.461039 230.4403 510.559881L311.240978 429.759202C323.584094 417.416085 343.892513 417.712357 356.601099 430.420946 369.309686 443.129535 369.605959 463.437952 357.262842 475.781068L230.778782 602.265128C229.273826 605.769679 227.098877 609.041396 224.251145 611.889128 211.908029 624.232245 191.59961 623.935974 178.891024 611.227385L40.825428 473.16179C28.11684 460.453206 27.820569 440.144784 40.163685 427.801668 52.506801 415.458551 72.815218 415.754827 85.523806 428.463411L165.238899 508.178506Z</Geometry>
|
||||
<Geometry x:Key="EnlargeGeometry">M750.3 198.7C598 46.4 351.1 46.4 198.7 198.7s-152.3 399.2 0 551.5C345.1 896.6 578.8 902.3 732 767.3l172.1 172.1 35.4-35.4-172.1-171.9c135-153.2 129.3-387-17.1-533.4z m39.3 403.8c-17.1 42.1-42.2 80-74.7 112.4-32.5 32.5-70.3 57.6-112.4 74.7-40.7 16.5-83.8 24.9-128 24.9s-87.2-8.4-128-24.9c-42.1-17.1-80-42.2-112.4-74.7s-57.6-70.3-74.7-112.4c-16.5-40.7-24.9-83.8-24.9-128s8.4-87.2 24.9-128c17.1-42.1 42.2-80 74.7-112.4s70.3-57.6 112.4-74.7c40.7-16.5 83.8-24.9 128-24.9s87.2 8.4 128 24.9c42.1 17.1 80 42.2 112.4 74.7 32.5 32.5 57.6 70.3 74.7 112.4 16.5 40.7 24.9 83.8 24.9 128s-8.4 87.3-24.9 128zM671 502H496v175h-50V502H271v-50h175V277h50v175h175v50z</Geometry>
|
||||
<Geometry x:Key="ReduceGeometry">M750.3 198.7C598 46.4 351.1 46.4 198.7 198.7s-152.3 399.2 0 551.5C345.1 896.6 578.8 902.3 732 767.3l172.1 172.1 35.4-35.4-172.1-171.9c135-153.2 129.3-387-17.1-533.4z m39.3 403.8c-17.1 42.1-42.2 80-74.7 112.4-32.5 32.5-70.3 57.6-112.4 74.7-40.7 16.5-83.8 24.9-128 24.9s-87.2-8.4-128-24.9c-42.1-17.1-80-42.2-112.4-74.7s-57.6-70.3-74.7-112.4c-16.5-40.7-24.9-83.8-24.9-128s8.4-87.2 24.9-128c17.1-42.1 42.2-80 74.7-112.4s70.3-57.6 112.4-74.7c40.7-16.5 83.8-24.9 128-24.9s87.2 8.4 128 24.9c42.1 17.1 80 42.2 112.4 74.7 32.5 32.5 57.6 70.3 74.7 112.4 16.5 40.7 24.9 83.8 24.9 128s-8.4 87.3-24.9 128zM671 502H271v-50h400v50z</Geometry>
|
||||
<Geometry x:Key="DownloadGeometry">M868.100096 742.600704l-0.049152 0L216.246272 742.600704l-0.049152 0c-13.98784 0-25.327616 11.33568-25.327616 25.352192 0 13.993984 11.360256 25.327616 25.327616 25.327616l0.049152 0 651.804672 0 0.049152 0c13.996032 0 25.33376-11.333632 25.33376-25.327616C893.431808 753.936384 882.096128 742.600704 868.100096 742.600704L868.100096 742.600704 868.100096 742.600704M523.15136 688.433152c4.728832 4.757504 11.237376 7.733248 18.47296 7.733248l0 0 0 0c7.231488 0 13.740032-2.951168 18.42176-7.757824l314.836992-314.83904c4.732928-4.704256 7.714816-11.214848 7.7312-18.395136 0-14.342144-11.712512-25.9584-25.972736-25.9584-7.213056-0.02048-13.694976 2.930688-18.376704 7.636992L567.578624 607.51872 567.578624 117.52448c-0.024576-0.026624-0.024576-0.026624-0.024576-0.0512 0.024576-14.344192-11.59168-25.980928-25.901056-25.980928-14.348288 0-25.960448 11.634688-25.960448 25.980928 0 0 0 0.024576 0.024576 0.0512l0 489.967616L245.055488 336.826368c-4.683776-4.704256-11.2128-7.6288-18.374656-7.60832-14.342144-0.02048-25.954304 11.614208-26.005504 25.9072 0 7.20896 2.951168 13.768704 7.684096 18.423808L523.15136 688.433152 523.15136 688.433152 523.15136 688.433152M523.15136 688.433152 523.15136 688.433152z</Geometry>
|
||||
<Geometry x:Key="SaveGeometry">M608 320C625.664 320 640 305.696 640 288L640 160C640 142.304 625.664 128 608 128 590.336 128 576 142.304 576 160L576 288C576 305.696 590.336 320 608 320L608 320ZM960 896C960 931.328 931.328 960 896 960L128 960C92.672 960 64 931.328 64 896L64 128C64 92.672 92.672 64 128 64L192 64 192 384C192 419.328 220.672 448 256 448L768 448C803.328 448 832 419.328 832 384L832 64 896 64C931.328 64 960 92.672 960 128L960 896 960 896ZM256 64 768 64 768 352C768 369.696 753.664 384 736 384L288 384C270.336 384 256 369.696 256 352L256 64 256 64ZM896 0 128 0C57.312 0 0 57.312 0 128L0 896C0 966.688 57.312 1024 128 1024L896 1024C966.688 1024 1024 966.688 1024 896L1024 128C1024 57.312 966.688 0 896 0L896 0Z</Geometry>
|
||||
<Geometry x:Key="WindowsGeometry">M426.276571 574.829714l0 372.004571-389.705143-53.686857 0-318.317714 389.705143 0zM426.276571 150.308571l0 376.539429-389.705143 0 0-322.852571zM987.428571 574.829714l0 449.170286-518.290286-71.460571 0-377.709714 518.290286 0zM987.428571 73.142857l0 453.705143-518.290286 0 0-382.317714z</Geometry>
|
||||
<Geometry x:Key="FullScreenGeometry">M942 82v320h-50V167.4l-274 274-35.4-35.4 274-274H622V82h320zM406 582.6l-274 274V622H82v320h320v-50H167.4l274-274-35.4-35.4zM132 132h302V82H82v352h50V132z m760 760H590v50h352V590h-50v302z</Geometry>
|
||||
<Geometry x:Key="FullScreenReturnGeometry">M94.186081,59.07 L100,59.07 100,100 59.07,100 59.07,94.186081 94.186081,94.186081 z M4.5814285,58.208999 L41.791,58.208999 41.791,95.418571 35.977005,95.418571 35.977005,68.139304 4.1163101,100 0,95.88369 31.860695,64.022995 4.5814285,64.022995 z M95.88369,0 L100,4.1163101 68.139304,35.977005 95.418571,35.977005 95.418571,41.791 58.208999,41.791 58.208999,4.5814285 64.022995,4.5814285 64.022995,31.860695 z M0,0 L40.929998,0 40.929998,5.8139191 5.8139191,5.8139191 5.8139191,40.929998 0,40.929998 z</Geometry>
|
||||
<Geometry x:Key="SearchGeometry">M716.6003 213.800623c-138.851102-138.915088-364.020238-138.915088-502.935326 0s-138.915088 364.084225 0 502.935326a355.573996 355.573996 0 0 0 502.935326 0 355.573996 355.573996 0 0 0 0-502.935326z m-580.359212 580.359212a465.183184 465.183184 0 1 1 657.783099 0 465.183184 465.183184 0 0 1-657.783099 0z m868.939152 211.156054a63.474789 63.474789 0 0 1-89.837303 0l-89.773316-89.837303a63.410803 63.410803 0 1 1 89.773316-89.773316l89.837303 89.773316a63.346816 63.346816 0 0 1 0 89.837303z</Geometry>
|
||||
<Geometry x:Key="UpDownGeometry">M454.464 143.68l-253.44 253.44c-12.032 12.032-12.032 31.36 0 43.392 11.968 11.968 31.36 11.968 43.328 0l237.376-237.376 237.376 237.376c11.968 11.968 31.36 11.968 43.328 0 12.032-12.032 12.032-31.36 0-43.392l-253.44-253.44C491.264 126.016 478.016 124.032 454.464 143.68zM507.968 947.648l252.48-253.376c11.968-11.968 11.968-31.36 0-43.392-11.968-11.968-31.296-11.968-43.264 0l-236.48 237.376L244.16 650.88c-11.968-11.968-31.296-11.968-43.264 0-11.968 12.032-11.968 31.424 0 43.392l252.48 253.376C465.984 960 491.136 964.48 507.968 947.648z</Geometry>
|
||||
|
||||
</ResourceDictionary>
|
109
HandyControl/Themes/Basic/Paths.xaml
Normal file
109
HandyControl/Themes/Basic/Paths.xaml
Normal file
@ -0,0 +1,109 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Geometries.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="PathBaseStyle" TargetType="{x:Type Path}">
|
||||
<Setter Property="Stretch" Value="Uniform"></Setter>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--搜索-->
|
||||
<Style x:Key="SearchPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource SearchGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--全屏返回-->
|
||||
<Style x:Key="FullScreenReturnPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource FullScreenReturnGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--全屏-->
|
||||
<Style x:Key="FullScreenPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource FullScreenGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--windows-->
|
||||
<Style x:Key="WindowsPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource WindowsGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--保存-->
|
||||
<Style x:Key="SavePathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource SaveGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--下载-->
|
||||
<Style x:Key="DownloadPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource DownloadGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--放大-->
|
||||
<Style x:Key="EnlargePathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource EnlargeGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--缩小-->
|
||||
<Style x:Key="ReducePathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource ReduceGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--向左旋转-->
|
||||
<Style x:Key="RotatePathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource RotateLeftGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--日历-->
|
||||
<Style x:Key="CalendarPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource CalendarGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--删除-->
|
||||
<Style x:Key="DeletePathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource DeleteGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--关闭-->
|
||||
<Style x:Key="ClosePathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource CloseGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--下-->
|
||||
<Style x:Key="DownPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource DownGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--时钟-->
|
||||
<Style x:Key="ClockPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource ClockGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--向左-->
|
||||
<Style x:Key="LeftPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource LeftGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--向右-->
|
||||
<Style x:Key="RightPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="RenderTransformOrigin" Value="0.5, 0.5"></Setter>
|
||||
<Setter Property="RenderTransform">
|
||||
<Setter.Value>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleY="1" ScaleX="-1"/>
|
||||
<SkewTransform AngleY="0" AngleX="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Data" Value="{StaticResource LeftGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
<!--向左-->
|
||||
<Style x:Key="UpDownPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource UpDownGeometry}"></Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
8
HandyControl/Themes/Basic/Sizes.xaml
Normal file
8
HandyControl/Themes/Basic/Sizes.xaml
Normal file
@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<system:Double x:Key="DefaultControlHeight">30</system:Double>
|
||||
<Thickness x:Key="DefaultControlPadding">12,6</Thickness>
|
||||
|
||||
</ResourceDictionary>
|
9
HandyControl/Themes/Styles/Base/BaseStyle.xaml
Normal file
9
HandyControl/Themes/Styles/Base/BaseStyle.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="BaseStyle" TargetType="{x:Type Control}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
|
||||
<Setter Property="FontSize" Value="{DynamicResource TextFontSize}"></Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
20
HandyControl/Themes/Styles/Base/ButtonBaseBaseStyle.xaml
Normal file
20
HandyControl/Themes/Styles/Base/ButtonBaseBaseStyle.xaml
Normal file
@ -0,0 +1,20 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="BaseStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="ButtonBaseBaseStyle" BasedOn="{StaticResource BaseStyle}" TargetType="{x:Type ButtonBase}">
|
||||
<Setter Property="Height" Value="{DynamicResource DefaultControlHeight}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"></Setter>
|
||||
<Setter Property="Padding" Value="{DynamicResource DefaultControlPadding}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"></Setter>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
90
HandyControl/Themes/Styles/Base/ButtonBaseStyle.xaml
Normal file
90
HandyControl/Themes/Styles/Base/ButtonBaseStyle.xaml
Normal file
@ -0,0 +1,90 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ButtonBaseBaseStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="ButtonBaseStyle" BasedOn="{StaticResource ButtonBaseBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Grid>
|
||||
<Border x:Name="border" CornerRadius="4" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="0" SnapsToDevicePixels="true">
|
||||
<!--点击时显示-->
|
||||
<Grid x:Name="PressedLayer" Visibility="Collapsed">
|
||||
<Rectangle Height="3" VerticalAlignment="Top" Fill="#1F000000" RadiusX="4" RadiusY="4">
|
||||
<Rectangle.Effect>
|
||||
<BlurEffect Radius="5"></BlurEffect>
|
||||
</Rectangle.Effect>
|
||||
</Rectangle>
|
||||
<Border CornerRadius="4" BorderBrush="#1F000000" BorderThickness="1,0">
|
||||
<Border.Effect>
|
||||
<BlurEffect Radius="3"></BlurEffect>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
<!--禁用时显示-->
|
||||
<Rectangle x:Name="EnabledLayer" Fill="#4CFFFFFF" RadiusX="4" RadiusY="4" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="PressedLayer" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="border" Property="BorderBrush" Value="#80cccccc"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter TargetName="EnabledLayer" Property="Visibility" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ButtonIconBaseStyle" BasedOn="{StaticResource ButtonBaseBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Width" Value="{DynamicResource DefaultControlHeight}"/>
|
||||
<Setter Property="BorderThickness" Value="0"></Setter>
|
||||
<Setter Property="Padding" Value="8"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Grid>
|
||||
<!--点击时显示-->
|
||||
<Ellipse x:Name="border" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Fill="{TemplateBinding Background}" SnapsToDevicePixels="true"></Ellipse>
|
||||
<Ellipse x:Name="PressedLayer" Visibility="Collapsed" Stroke="#1F000000" StrokeThickness="2">
|
||||
<Ellipse.Effect>
|
||||
<BlurEffect Radius="3"></BlurEffect>
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<Path Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconElement.Geometry}" RenderTransformOrigin="0.5,0.5">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="{Binding Path=(controls:IconElement.Angle),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</ContentControl>
|
||||
<!--禁用时显示-->
|
||||
<Ellipse x:Name="EnabledLayer" Fill="#4CFFFFFF" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsPressed" Value="true">
|
||||
<Setter TargetName="PressedLayer" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="border" Property="Stroke" Value="#80cccccc"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter TargetName="EnabledLayer" Property="Visibility" Value="Visible"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
15
HandyControl/Themes/Styles/Base/TextBlockBaseStyle.xaml
Normal file
15
HandyControl/Themes/Styles/Base/TextBlockBaseStyle.xaml
Normal file
@ -0,0 +1,15 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="TextBlockBaseStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
|
||||
<Setter Property="FontSize" Value="{DynamicResource TextFontSize}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TextBlockBoldBaseStyle" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontWeight" Value="Bold"></Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
24
HandyControl/Themes/Styles/Border.xaml
Normal file
24
HandyControl/Themes/Styles/Border.xaml
Normal file
@ -0,0 +1,24 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!--用于包裹一个区域-->
|
||||
<Style x:Key="BorderRegionStyle" TargetType="{x:Type Border}">
|
||||
<Setter Property="Padding" Value="10"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"></Setter>
|
||||
<Setter Property="BorderThickness" Value="1"></Setter>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="BorderHorizontallySplitter" TargetType="{x:Type Border}">
|
||||
<Setter Property="Width" Value="1"></Setter>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"></Setter>
|
||||
<Setter Property="Background" Value="{DynamicResource ThirdlyTextBrush}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="BorderVerticallySplitter" TargetType="{x:Type Border}">
|
||||
<Setter Property="Height" Value="1"></Setter>
|
||||
<Setter Property="VerticalAlignment" Value="Top"></Setter>
|
||||
<Setter Property="Background" Value="{DynamicResource ThirdlyTextBrush}"></Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
214
HandyControl/Themes/Styles/Button.xaml
Normal file
214
HandyControl/Themes/Styles/Button.xaml
Normal file
@ -0,0 +1,214 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base/ButtonBaseStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!--Button-->
|
||||
<Style BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkDefaultBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonPrimary" BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonSuccess" BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource SuccessBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkSuccessBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkSuccessBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonInfo" BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource InfoBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkInfoBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkInfoBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonWarning" BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource WarningBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkWarningBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkWarningBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonDanger" BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource DangerBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkDangerBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDangerBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--ButtonIcon-->
|
||||
<Style x:Key="ButtonIconTransparent" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<Path Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconElement.Geometry}" RenderTransformOrigin="0.5,0.5">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="{Binding Path=(controls:IconElement.Angle),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value=".9"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Opacity" Value=".6"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value=".2"></Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonIconDefault" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkDefaultBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonIconPrimary" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkPrimaryBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonIconSuccess" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource SuccessBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkSuccessBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkSuccessBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonIconInfo" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource InfoBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkInfoBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkInfoBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonIconWarning" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource WarningBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkWarningBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkWarningBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="ButtonIconDanger" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{DynamicResource DangerBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DarkDangerBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource DarkDangerBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="CommonButtonFeStyle" TargetType="{x:Type Button}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Foreground" Value="#bfcbd9"></Setter>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
|
||||
<Setter Property="RenderTransformOrigin" Value=".5,.5"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border x:Name="border" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="#8c939d"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Foreground" Value="#bfcbd9"></Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ButtonOpacityStyle" TargetType="{x:Type Button}">
|
||||
<Setter Property="Background" Value="{x:Null}"></Setter>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Focusable" Value="False"></Setter>
|
||||
<Setter Property="IsTabStop" Value="False"/>
|
||||
<Setter Property="BorderThickness" Value="0"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border x:Name="Chrome" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" Value=".9"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Opacity" Value=".6"></Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value=".2"></Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
123
HandyControl/Themes/Styles/Slider.xaml
Normal file
123
HandyControl/Themes/Styles/Slider.xaml
Normal file
@ -0,0 +1,123 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="ColorPickerRepeatButton" TargetType="{x:Type RepeatButton}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Focusable" Value="false"/>
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type RepeatButton}">
|
||||
<Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="ColorPickerSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Border Width="13" Height="13" Background="White" CornerRadius="6.5"></Border>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="ColorPickerSliderHorizontal" TargetType="{x:Type Slider}">
|
||||
<Grid>
|
||||
<Border Margin="7,0" Background="{TemplateBinding Background}" MaxHeight="11" CornerRadius="2"></Border>
|
||||
<Border Margin="7,0" Background="{TemplateBinding Foreground}" MaxHeight="11" CornerRadius="2">
|
||||
<Border.OpacityMask>
|
||||
<LinearGradientBrush EndPoint="0,0.5" StartPoint="1,0.5">
|
||||
<GradientStop Color="Transparent" Offset="1"/>
|
||||
<GradientStop Color="White" Offset="0"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.OpacityMask>
|
||||
</Border>
|
||||
<Track x:Name="PART_Track">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb x:Name="Thumb" Focusable="False" Height="13" Width="13" OverridesDefaultStyle="True" Template="{StaticResource ColorPickerSliderThumbTemplate}" VerticalAlignment="Center">
|
||||
<Thumb.Effect>
|
||||
<DropShadowEffect ShadowDepth="0" Opacity=".6"/>
|
||||
</Thumb.Effect>
|
||||
</Thumb>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="ColorPickerSliderVertical" TargetType="{x:Type Slider}">
|
||||
<Grid >
|
||||
<Border Margin="0,7" CornerRadius="2" MaxWidth="11" Background="{TemplateBinding Background}"></Border>
|
||||
<Border Margin="0,7" CornerRadius="2" MaxWidth="11" Background="{TemplateBinding Foreground}">
|
||||
<Border.OpacityMask>
|
||||
<LinearGradientBrush EndPoint="0,0.5" StartPoint="1,0.5">
|
||||
<GradientStop Color="Transparent" Offset="1"/>
|
||||
<GradientStop Color="White" Offset="0"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.OpacityMask>
|
||||
</Border>
|
||||
<Track x:Name="PART_Track">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
|
||||
</Track.DecreaseRepeatButton>
|
||||
<Track.IncreaseRepeatButton>
|
||||
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource ColorPickerRepeatButton}"/>
|
||||
</Track.IncreaseRepeatButton>
|
||||
<Track.Thumb>
|
||||
<Thumb x:Name="Thumb" Focusable="False" Height="13" OverridesDefaultStyle="True" Template="{StaticResource ColorPickerSliderThumbTemplate}" VerticalAlignment="Top" Width="13">
|
||||
<Thumb.Effect>
|
||||
<DropShadowEffect ShadowDepth="0" Opacity=".6"/>
|
||||
</Thumb.Effect>
|
||||
</Thumb>
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="ColorPickerSlider" TargetType="{x:Type Slider}">
|
||||
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="Foreground" Value="Transparent"></Setter>
|
||||
<Setter Property="Template" Value="{StaticResource ColorPickerSliderHorizontal}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="Template" Value="{StaticResource ColorPickerSliderVertical}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<LinearGradientBrush x:Key="ColorPickerRainbowBrush">
|
||||
<GradientStop Color="#ff0000"/>
|
||||
<GradientStop Color="#ff00ff" Offset="0.167"/>
|
||||
<GradientStop Color="#0000ff" Offset="0.334"/>
|
||||
<GradientStop Color="#00ffff" Offset="0.501"/>
|
||||
<GradientStop Color="#00ff00" Offset="0.668"/>
|
||||
<GradientStop Color="#ffff00" Offset="0.835"/>
|
||||
<GradientStop Color="#ff0000" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
<DrawingBrush x:Key="ColorPickerOpacityBrush" Viewport="0,0,12,11" ViewportUnits="Absolute" Stretch="None" TileMode="Tile">
|
||||
<DrawingBrush.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="#d0cec7">
|
||||
<GeometryDrawing.Geometry>
|
||||
<GeometryGroup>
|
||||
<RectangleGeometry Rect="0,0,6,5" />
|
||||
<RectangleGeometry Rect="6,6,6,5" />
|
||||
</GeometryGroup>
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
<GeometryDrawing Brush="#e7e7e2">
|
||||
<GeometryDrawing.Geometry>
|
||||
<RectangleGeometry Rect="0,5,12,1" />
|
||||
</GeometryDrawing.Geometry>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup>
|
||||
</DrawingBrush.Drawing>
|
||||
</DrawingBrush>
|
||||
|
||||
</ResourceDictionary>
|
31
HandyControl/Themes/Styles/Style.xaml
Normal file
31
HandyControl/Themes/Styles/Style.xaml
Normal file
@ -0,0 +1,31 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Window.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Button.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="TextBlock.xaml"></ResourceDictionary>
|
||||
<!--<ResourceDictionary Source="ToggleButton.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="TextBlock.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="CheckBox.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="RadioButton.xaml"></ResourceDictionary>-->
|
||||
<ResourceDictionary Source="Border.xaml"></ResourceDictionary>
|
||||
<!--<ResourceDictionary Source="BulletCheckBox.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Label.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ProgressBar.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ScrollViewer.xaml"></ResourceDictionary>-->
|
||||
<ResourceDictionary Source="Slider.xaml"></ResourceDictionary>
|
||||
<!--<ResourceDictionary Source="Clock.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="TreeView.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="DataGrid.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="GroupBox.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Pagination.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="TabControl.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ListBox.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ComboBox.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Loading.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ContextMenu.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="AnimationPath.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="ToolTip.xaml"></ResourceDictionary>-->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
56
HandyControl/Themes/Styles/TextBlock.xaml
Normal file
56
HandyControl/Themes/Styles/TextBlock.xaml
Normal file
@ -0,0 +1,56 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base/TextBlockBaseStyle.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!--默认样式-->
|
||||
<Style x:Key="TextBlockDefault" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}"></Style>
|
||||
<Style x:Key="TextBlockDefaultAccent" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AccentBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultPrimary" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultDanger" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource DangerBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultWarning" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource WarningBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultInfo" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource InfoBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultSuccess" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SuccessBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultSecLight" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultThiLight" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TextBlockLarge" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource LargeFontSize}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockTitle" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource HeadFontSize}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockSubTitle" BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource SubHeadFontSize}"></Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TextBlockLargeBold" BasedOn="{StaticResource TextBlockBoldBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource LargeFontSize}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockTitleBold" BasedOn="{StaticResource TextBlockBoldBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource HeadFontSize}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockSubTitleBold" BasedOn="{StaticResource TextBlockBoldBaseStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource SubHeadFontSize}"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="TextBlockDefaultBold" BasedOn="{StaticResource TextBlockBoldBaseStyle}" TargetType="{x:Type TextBlock}"></Style>
|
||||
|
||||
</ResourceDictionary>
|
9
HandyControl/Themes/Styles/Window.xaml
Normal file
9
HandyControl/Themes/Styles/Window.xaml
Normal file
@ -0,0 +1,9 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="WindowDefaultStyle" BasedOn="{x:Null}" TargetType="{x:Type Window}">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"></Setter>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"></Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
8
HandyControl/Themes/ThemesDefault.xaml
Normal file
8
HandyControl/Themes/ThemesDefault.xaml
Normal file
@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Basic/Basic.xaml"></ResourceDictionary>
|
||||
<ResourceDictionary Source="Styles/Style.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
40
HandyControl/Tools/AnimationHelper.cs
Normal file
40
HandyControl/Tools/AnimationHelper.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 包含一些常用的动画辅助方法
|
||||
/// </summary>
|
||||
public class AnimationHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建一个Thickness动画
|
||||
/// </summary>
|
||||
/// <param name="thickness"></param>
|
||||
/// <param name="milliseconds"></param>
|
||||
/// <returns></returns>
|
||||
public static ThicknessAnimation CreateAnimation(Thickness thickness = default(Thickness), double milliseconds = 200)
|
||||
{
|
||||
return new ThicknessAnimation(thickness, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
|
||||
{
|
||||
EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建一个Double动画
|
||||
/// </summary>
|
||||
/// <param name="toValue"></param>
|
||||
/// <param name="milliseconds"></param>
|
||||
/// <returns></returns>
|
||||
public static DoubleAnimation CreateAnimation(double toValue, double milliseconds = 200)
|
||||
{
|
||||
return new DoubleAnimation(toValue, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
|
||||
{
|
||||
EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
23
HandyControl/Tools/Converter/Boolean2BooleanFeConverter.cs
Normal file
23
HandyControl/Tools/Converter/Boolean2BooleanFeConverter.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Boolean2BooleanFeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
return !boolValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Boolean2VisibilityFeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value != null && (bool)value ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class BooleanArr2VisibilityConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
var arr = new List<bool>();
|
||||
foreach (var item in values)
|
||||
{
|
||||
if (item is bool boolValue)
|
||||
{
|
||||
arr.Add(boolValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
return arr.All(item => item) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
39
HandyControl/Tools/Converter/Color2ChannelAConverter.cs
Normal file
39
HandyControl/Tools/Converter/Color2ChannelAConverter.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Color2ChannelAConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is SolidColorBrush brush)
|
||||
{
|
||||
return brush.Color.A;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ColorConverter.ConvertFromString(str) is Color color)
|
||||
{
|
||||
return new SolidColorBrush(color);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return parameter;
|
||||
}
|
||||
return parameter;
|
||||
}
|
||||
return parameter;
|
||||
}
|
||||
}
|
||||
}
|
40
HandyControl/Tools/Converter/Color2HexStrConverter.cs
Normal file
40
HandyControl/Tools/Converter/Color2HexStrConverter.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Color2HexStrConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is SolidColorBrush brush)
|
||||
{
|
||||
var color = brush.Color;
|
||||
return color.A < 255 ? $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}" : $"#{color.R:X2}{color.G:X2}{color.B:X2}";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ColorConverter.ConvertFromString(str) is Color color)
|
||||
{
|
||||
return new SolidColorBrush(color);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new SolidColorBrush(default(Color));
|
||||
}
|
||||
return new SolidColorBrush(default(Color));
|
||||
}
|
||||
return new SolidColorBrush(default(Color));
|
||||
}
|
||||
}
|
||||
}
|
20
HandyControl/Tools/Converter/IsNullConverter.cs
Normal file
20
HandyControl/Tools/Converter/IsNullConverter.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class IsNullConverter : IValueConverter
|
||||
{
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value == null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new InvalidOperationException("IsNullConverter can only be used OneWay.");
|
||||
}
|
||||
}
|
||||
}
|
52
HandyControl/Tools/Converter/Long2FileSizeConverter.cs
Normal file
52
HandyControl/Tools/Converter/Long2FileSizeConverter.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Long2FileSizeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null) return "未知大小";
|
||||
if (value is long intValue)
|
||||
{
|
||||
if (intValue < 0)
|
||||
{
|
||||
return "未知大小";
|
||||
}
|
||||
if (intValue < 1024)
|
||||
{
|
||||
return $"{intValue} B";
|
||||
}
|
||||
if (intValue < 1048576)
|
||||
{
|
||||
return $"{intValue / 1024.0:0.00} KB";
|
||||
}
|
||||
if (intValue < 1073741824)
|
||||
{
|
||||
return $"{intValue / 1048576.0:0.00} MB";
|
||||
}
|
||||
if (intValue < 1099511627776)
|
||||
{
|
||||
return $"{intValue / 1073741824.0:0.00} GB";
|
||||
}
|
||||
if (intValue < 1125899906842624)
|
||||
{
|
||||
return $"{intValue / 1099511627776.0:0.00} TB";
|
||||
}
|
||||
if (intValue < 1152921504606847000)
|
||||
{
|
||||
return $"{intValue / 1125899906842624.0:0.00} PB";
|
||||
}
|
||||
return "过大";
|
||||
}
|
||||
return "未知";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
16
HandyControl/Tools/Converter/Object2BooleanConverter.cs
Normal file
16
HandyControl/Tools/Converter/Object2BooleanConverter.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Object2BooleanConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => !(value is null);
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
20
HandyControl/Tools/Converter/Source2ImageConverter.cs
Normal file
20
HandyControl/Tools/Converter/Source2ImageConverter.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class Source2ImageConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value != null ? new Uri(value.ToString(), UriKind.Relative) : null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value != null && (Visibility)value == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
20
HandyControl/Tools/Converter/String2VisibilityConverter.cs
Normal file
20
HandyControl/Tools/Converter/String2VisibilityConverter.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class String2VisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.IsNullOrEmpty((string)value) ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value != null && (Visibility)value == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
20
HandyControl/Tools/Converter/String2VisibilityFeConverter.cs
Normal file
20
HandyControl/Tools/Converter/String2VisibilityFeConverter.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class String2VisibilityFeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.IsNullOrEmpty((string)value) ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value != null && (Visibility)value == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
29
HandyControl/Tools/Converter/TreeViewItemMarginConverter.cs
Normal file
29
HandyControl/Tools/Converter/TreeViewItemMarginConverter.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public class TreeViewItemMarginConverter: IValueConverter
|
||||
{
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var left = 0.0;
|
||||
UIElement element = value as TreeViewItem;
|
||||
while (element != null && element.GetType() != typeof(TreeView))
|
||||
{
|
||||
element = (UIElement)VisualTreeHelper.GetParent(element);
|
||||
if (element is TreeViewItem)
|
||||
left += 19.0;
|
||||
}
|
||||
return new Thickness(left, 0, 0, 0);
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
33
HandyControl/Tools/Extension/ColorExtension.cs
Normal file
33
HandyControl/Tools/Extension/ColorExtension.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Media;
|
||||
|
||||
|
||||
namespace HandyControl.Tools.Extension
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色扩展类
|
||||
/// </summary>
|
||||
public static class ColorExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 将颜色转换为10进制表示(rgb顺序颠倒)
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
public static int ToInt32(this Color color) => color.R << 16 | color.G << 8 | color.B;
|
||||
|
||||
/// <summary>
|
||||
/// 将颜色转换为10进制表示(rgb顺序颠倒)
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
public static int ToInt32Reverse(this Color color) => color.R | color.G << 8 | color.B << 18;
|
||||
|
||||
internal static List<byte> ToList(this Color color) => new List<byte>
|
||||
{
|
||||
color.R,
|
||||
color.G,
|
||||
color.B
|
||||
};
|
||||
}
|
||||
}
|
45
HandyControl/Tools/Extension/UIElementExtension.cs
Normal file
45
HandyControl/Tools/Extension/UIElementExtension.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace HandyControl.Tools.Extension
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class UIElementExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示元素
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
public static void Show(this UIElement element)
|
||||
{
|
||||
element.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示元素
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
/// <param name="show"></param>
|
||||
public static void Show(this UIElement element, bool show)
|
||||
{
|
||||
element.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不现实元素,但保留空间
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
public static void Hide(this UIElement element)
|
||||
{
|
||||
element.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 不显示元素,且不保留空间
|
||||
/// </summary>
|
||||
/// <param name="element"></param>
|
||||
public static void Collapse(this UIElement element)
|
||||
{
|
||||
element.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
96
HandyControl/Tools/RegularJudgment.cs
Normal file
96
HandyControl/Tools/RegularJudgment.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using HandyControl.Data.Enum;
|
||||
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 包含一些正则验证操作
|
||||
/// </summary>
|
||||
public static class RegularJudgment
|
||||
{
|
||||
private static readonly RegularPatterns RegularPatterns = new RegularPatterns();
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串格式是否符合某种要求
|
||||
/// </summary>
|
||||
/// <param name="str">需要判断的字符串</param>
|
||||
/// <param name="pattern">正则表达式</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsKindOf(this string str, string pattern)
|
||||
{
|
||||
return Regex.IsMatch(str, pattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串是否满足指定的格式
|
||||
/// </summary>
|
||||
/// <param name="text">需要判断的字符串</param>
|
||||
/// <param name="textType">指定格式的文本</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsKindOf(this string text, TextType textType)
|
||||
{
|
||||
if (textType == TextType.Common) return true;
|
||||
return Regex.IsMatch(text,
|
||||
RegularPatterns.GetValue(System.Enum.GetName(typeof(TextType), textType) + "Pattern").ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串格式是否为电子邮件
|
||||
/// </summary>
|
||||
/// <param name="email">需要判断的Email字符串</param>
|
||||
/// <returns>方法返回布尔值</returns>
|
||||
public static bool IsEmail(this string email)
|
||||
{
|
||||
return Regex.IsMatch(email, RegularPatterns.MailPattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串格式是否为指定类型的IP地址
|
||||
/// </summary>
|
||||
/// <param name="ip">需要判断的IP字符串</param>
|
||||
/// <param name="ipType">指定的IP类型</param>
|
||||
/// <returns>方法返回布尔值</returns>
|
||||
public static bool IsIp(this string ip, IpType ipType)
|
||||
{
|
||||
switch (ipType)
|
||||
{
|
||||
case IpType.A: return Regex.IsMatch(ip, RegularPatterns.IpAPattern);
|
||||
case IpType.B: return Regex.IsMatch(ip, RegularPatterns.IpBPattern);
|
||||
case IpType.C: return Regex.IsMatch(ip, RegularPatterns.IpCPattern);
|
||||
case IpType.D: return Regex.IsMatch(ip, RegularPatterns.IpDPattern);
|
||||
case IpType.E: return Regex.IsMatch(ip, RegularPatterns.IpEPattern);
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串格式是否为IP地址
|
||||
/// </summary>
|
||||
/// <param name="ip">需要判断的IP字符串</param>
|
||||
/// <returns>方法返回布尔值</returns>
|
||||
public static bool IsIp(this string ip)
|
||||
{
|
||||
return Regex.IsMatch(ip, RegularPatterns.IpPattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串格式是否为单个汉字
|
||||
/// </summary>
|
||||
/// <param name="str">需要判断的单个汉字字符串</param>
|
||||
/// <returns>方法返回布尔值</returns>
|
||||
public static bool IsChinese(this string str)
|
||||
{
|
||||
return Regex.IsMatch(str, RegularPatterns.ChinesePattern);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断字符串格式是否为url
|
||||
/// </summary>
|
||||
/// <param name="str">需要判断的url字符串</param>
|
||||
/// <returns>方法返回布尔值</returns>
|
||||
public static bool IsUrl(this string str)
|
||||
{
|
||||
return Regex.IsMatch(str, RegularPatterns.UrlPattern);
|
||||
}
|
||||
}
|
||||
}
|
152
HandyControl/Tools/RegularPatterns.cs
Normal file
152
HandyControl/Tools/RegularPatterns.cs
Normal file
@ -0,0 +1,152 @@
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 包含一些正则验证所需要的字符串
|
||||
/// </summary>
|
||||
public sealed class RegularPatterns
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="propertyName"></param>
|
||||
/// <returns></returns>
|
||||
public object GetValue(string propertyName)
|
||||
{
|
||||
return GetType().GetField(propertyName).GetValue(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 邮件正则匹配表达式
|
||||
/// </summary>
|
||||
public const string MailPattern = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
|
||||
|
||||
/// <summary>
|
||||
/// 手机号正则匹配表达式
|
||||
/// </summary>
|
||||
public const string PhonePattern = @"^((13[0-9])|(15[^4,\d])|(18[0,5-9]))\d{8}$";
|
||||
|
||||
/// <summary>
|
||||
/// IP正则匹配
|
||||
/// </summary>
|
||||
public const string IpPattern =
|
||||
@"^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
|
||||
|
||||
/// <summary>
|
||||
/// A类IP正则匹配
|
||||
/// </summary>
|
||||
public const string IpAPattern =
|
||||
@"^(12[0-6]|1[0-1]\d|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
|
||||
|
||||
/// <summary>
|
||||
/// B类IP正则匹配
|
||||
/// </summary>
|
||||
public const string IpBPattern =
|
||||
@"^(19[0-1]|12[8-9]|1[3-8]\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
|
||||
|
||||
/// <summary>
|
||||
/// C类IP正则匹配
|
||||
/// </summary>
|
||||
public const string IpCPattern =
|
||||
@"^(19[2-9]|22[0-3]|2[0-1]\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
|
||||
|
||||
/// <summary>
|
||||
/// D类IP正则匹配
|
||||
/// </summary>
|
||||
public const string IpDPattern =
|
||||
@"^(22[4-9]|23\d\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
|
||||
|
||||
/// <summary>
|
||||
/// E类IP正则匹配
|
||||
/// </summary>
|
||||
public const string IpEPattern =
|
||||
@"^(25[0-5]|24\d\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
|
||||
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
|
||||
|
||||
/// <summary>
|
||||
/// 汉字正则匹配
|
||||
/// </summary>
|
||||
public const string ChinesePattern = @"^[\u4e00-\u9fa5]$";
|
||||
|
||||
/// <summary>
|
||||
/// Url正则匹配
|
||||
/// </summary>
|
||||
public const string UrlPattern = @"((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?";
|
||||
|
||||
/// <summary>
|
||||
/// 数字正则匹配
|
||||
/// </summary>
|
||||
public const string NumberPattern = @"^\d$";
|
||||
|
||||
/// <summary>
|
||||
/// 计算性质数字正则匹配
|
||||
/// </summary>
|
||||
public const string DigitsPattern = @"^[+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$";
|
||||
|
||||
/// <summary>
|
||||
/// 正整数正则匹配
|
||||
/// </summary>
|
||||
public const string PIntPattern = @"^[1-9]\d*$";
|
||||
|
||||
/// <summary>
|
||||
/// 负整数正则匹配
|
||||
/// </summary>
|
||||
public const string NIntPattern = @"^-[1-9]\d*$ ";
|
||||
|
||||
/// <summary>
|
||||
/// 整数正则匹配
|
||||
/// </summary>
|
||||
public const string IntPattern = @"^-?[1-9]\d*$";
|
||||
|
||||
/// <summary>
|
||||
/// 非负整数正则匹配
|
||||
/// </summary>
|
||||
public const string NnIntPattern = @"^[1-9]\d*|0$";
|
||||
|
||||
/// <summary>
|
||||
/// 非正整数正则匹配
|
||||
/// </summary>
|
||||
public const string NpIntPattern = @"^-[1-9]\d*|0$";
|
||||
|
||||
/// <summary>
|
||||
/// 正浮点数正则匹配
|
||||
/// </summary>
|
||||
public const string PDoublePattern = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$";
|
||||
|
||||
/// <summary>
|
||||
/// 负浮点数正则匹配
|
||||
/// </summary>
|
||||
public const string NDoublePattern = @"^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$";
|
||||
|
||||
/// <summary>
|
||||
/// 浮点数正则匹配
|
||||
/// </summary>
|
||||
public const string DoublePattern = @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$";
|
||||
|
||||
/// <summary>
|
||||
/// 非负浮点数正则匹配
|
||||
/// </summary>
|
||||
public const string NnDoublePattern = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$";
|
||||
|
||||
/// <summary>
|
||||
/// 非正浮点数正则匹配
|
||||
/// </summary>
|
||||
public const string NpDoublePattern = @"^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$";
|
||||
}
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
<Application x:Class="HandyControlDemo.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:HandyControlDemo"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/ThemesDefault.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
15
HandyControlDemo/Data/Model/CellGateInfo.cs
Normal file
15
HandyControlDemo/Data/Model/CellGateInfo.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HandyControlDemo.Data.Model
|
||||
{
|
||||
public class CellGateInfo
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Parent { get; set; }
|
||||
|
||||
public List<CellGateInfo> InfoList { get; set; }
|
||||
}
|
||||
}
|
17
HandyControlDemo/Data/Model/CellGateRecord.cs
Normal file
17
HandyControlDemo/Data/Model/CellGateRecord.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControlDemo.Data.Model
|
||||
{
|
||||
public class CellGateRecord
|
||||
{
|
||||
public string CellGateId { get; set; }
|
||||
|
||||
public string PersonId { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public string Direction { get; set; }
|
||||
|
||||
public string DeviceId { get; set; }
|
||||
}
|
||||
}
|
@ -55,6 +55,8 @@
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Data\Model\CellGateInfo.cs" />
|
||||
<Compile Include="Data\Model\CellGateRecord.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
@ -65,5 +67,11 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HandyControl\HandyControl.csproj">
|
||||
<Project>{dc966e3d-bcff-4652-98cf-070e5494749a}</Project>
|
||||
<Name>HandyControl</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -3,10 +3,853 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:HandyControlDemo"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
xmlns:model="clr-namespace:HandyControlDemo.Data.Model"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
UseLayoutRounding="True"
|
||||
Style="{StaticResource WindowDefaultStyle}"
|
||||
WindowState="Maximized"
|
||||
Title="MainWindow"
|
||||
Name="MyWindow"
|
||||
d:DesignHeight="800"
|
||||
d:DesignWidth="1400">
|
||||
<Grid Margin="32" Grid.IsSharedSizeScope="True">
|
||||
<ScrollViewer>
|
||||
<StackPanel Name="StackPanelMain">
|
||||
<!--按钮-->
|
||||
<Border Visibility="Collapsed" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="按钮"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(Button)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1">
|
||||
<WrapPanel ItemWidth="160" ItemHeight="130">
|
||||
<StackPanel>
|
||||
<Button Content="默认" Margin="5"></Button>
|
||||
<Button IsEnabled="False" Content="默认" Margin="5"></Button>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="主要" Margin="5" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
<Button IsEnabled="False" Content="主要" Margin="5" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ButtonPrimary"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="成功" Margin="5" Style="{StaticResource ButtonSuccess}"></Button>
|
||||
<Button IsEnabled="False" Content="成功" Margin="5" Style="{StaticResource ButtonSuccess}"></Button>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ButtonSuccess"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="信息" Margin="5" Style="{StaticResource ButtonInfo}"></Button>
|
||||
<Button IsEnabled="False" Content="信息" Margin="5" Style="{StaticResource ButtonInfo}"></Button>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ButtonInfo"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="警告" Margin="5" Style="{StaticResource ButtonWarning}"></Button>
|
||||
<Button IsEnabled="False" Content="警告" Margin="5" Style="{StaticResource ButtonWarning}"></Button>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ButtonWarning"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Content="危险" Margin="5" Style="{StaticResource ButtonDanger}"></Button>
|
||||
<Button IsEnabled="False" Content="危险" Margin="5" Style="{StaticResource ButtonDanger}"></Button>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ButtonDanger"></TextBlock>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
<WrapPanel ItemWidth="160" ItemHeight="130">
|
||||
<StackPanel>
|
||||
<Button Margin="5" Style="{StaticResource ButtonIconDefault}" controls:IconElement.Angle="45" controls:IconElement.Geometry="{StaticResource DeleteGeometry}"></Button>
|
||||
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonIconDefault}" controls:IconElement.Geometry="{StaticResource DeleteGeometry}"></Button>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ButtonIconPrimary(DeleteGeometry)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Margin="5" Style="{StaticResource ButtonIconPrimary}" controls:IconElement.Geometry="{StaticResource ClockGeometry}"></Button>
|
||||
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonIconPrimary}" controls:IconElement.Geometry="{StaticResource ClockGeometry}"></Button>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ButtonIconPrimary(ClockGeometry)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Margin="5" Style="{StaticResource ButtonIconSuccess}" controls:IconElement.Geometry="{StaticResource CalendarGeometry}"></Button>
|
||||
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonIconSuccess}" controls:IconElement.Geometry="{StaticResource CalendarGeometry}"></Button>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ButtonIconPrimary(CalendarGeometry)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Margin="5" Style="{StaticResource ButtonIconInfo}" controls:IconElement.Geometry="{StaticResource DownGeometry}"></Button>
|
||||
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonIconInfo}" controls:IconElement.Geometry="{StaticResource DownGeometry}"></Button>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ButtonIconPrimary(DownGeometry)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Margin="5" Style="{StaticResource ButtonIconWarning}" controls:IconElement.Geometry="{StaticResource LeftGeometry}"></Button>
|
||||
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonIconWarning}" controls:IconElement.Geometry="{StaticResource LeftGeometry}"></Button>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ButtonIconPrimary(LeftGeometry)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<Button Margin="5" Style="{StaticResource ButtonIconDanger}" controls:IconElement.Geometry="{StaticResource DeleteGeometry}"></Button>
|
||||
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonIconDanger}" controls:IconElement.Geometry="{StaticResource DeleteGeometry}"></Button>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ButtonIconPrimary(DeleteGeometry)"></TextBlock>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!--切换按钮-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="切换按钮"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(ToggleButton)"></TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Grid.Column="1" ItemWidth="160" ItemHeight="130">
|
||||
<StackPanel>
|
||||
<ToggleButton IsChecked="True" Content="默认" Margin="5"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Content="默认" Margin="5"></ToggleButton>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton IsChecked="True" Content="主要" Margin="5" Style="{StaticResource ToggleButtonPrimary}"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Content="主要" Margin="5" Style="{StaticResource ToggleButtonPrimary}"></ToggleButton>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ToggleButtonPrimary"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton IsChecked="True" Content="成功" Margin="5" Style="{StaticResource ToggleButtonSuccess}"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Content="成功" Margin="5" Style="{StaticResource ToggleButtonSuccess}"></ToggleButton>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ToggleButtonSuccess"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton Content="信息" Margin="5" Style="{StaticResource ToggleButtonInfo}"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Content="信息" Margin="5" Style="{StaticResource ToggleButtonInfo}"></ToggleButton>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ToggleButtonInfo"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton Content="警告" Margin="5" Style="{StaticResource ToggleButtonWarning}"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Content="警告" Margin="5" Style="{StaticResource ToggleButtonWarning}"></ToggleButton>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ToggleButtonWarning"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton Content="危险" Margin="5" Style="{StaticResource ToggleButtonDanger}"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Content="危险" Margin="5" Style="{StaticResource ToggleButtonDanger}"></ToggleButton>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ToggleButtonDanger"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton Margin="5" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource DeleteGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource DownGeometry}"></ToggleButton>
|
||||
<ToggleButton IsEnabled="False" Margin="5" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource DeleteGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource DownGeometry}"></ToggleButton>
|
||||
<TextBlock TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Style="{StaticResource TextBlockDefault}" Text="ToggleButtonIconTransparent"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<ToggleButton Height="30" IsChecked="True" Margin="5" Style="{StaticResource ToggleButtonSwitch}"></ToggleButton>
|
||||
<ToggleButton Height="30" Margin="5" IsEnabled="False" Style="{StaticResource ToggleButtonSwitch}"></ToggleButton>
|
||||
<TextBlock Style="{StaticResource TextBlockDefault}" Text="ToggleButtonSwitch"></TextBlock>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--开关-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="开关"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(BulletCheckBox)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="50,0,0,0" Orientation="Horizontal">
|
||||
<controls:BulletCheckBox IsChecked="True" ></controls:BulletCheckBox>
|
||||
<controls:BulletCheckBox Margin="5,0" IsEnabled="False"></controls:BulletCheckBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--复选框-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="复选框"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(CheckBox)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="50,0,0,0" Grid.Column="1">
|
||||
<CheckBox Content="刷卡"></CheckBox>
|
||||
<CheckBox IsChecked="True" Margin="5,0" Content="人脸"></CheckBox>
|
||||
<CheckBox IsEnabled="False" Margin="5,0" Content="RFID"></CheckBox>
|
||||
<CheckBox IsEnabled="False" IsChecked="True" Margin="5,0" Content="指纹"></CheckBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--单选框-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="单选框"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(RadioButton)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="50,0,0,0" Grid.Column="1">
|
||||
<RadioButton Content="刷卡"/>
|
||||
<RadioButton IsChecked="True" Margin="5,0" Content="人脸"></RadioButton>
|
||||
<RadioButton Margin="5,0" Content="RFID"></RadioButton>
|
||||
<RadioButton IsEnabled="False" Margin="5,0" Content="指纹"></RadioButton>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--滑动条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="滑动条"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(Slider)"></TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Grid.Column="1" Margin="0,0,0,50">
|
||||
<StackPanel Margin="50,0,0,0" HorizontalAlignment="Left">
|
||||
<Slider Width="300"></Slider>
|
||||
<Slider Margin="0,20,0,0" Value="50" Maximum="100" IsEnabled="False" Width="300"></Slider>
|
||||
<Slider Margin="0,20,0,0" TickFrequency="5" TickPlacement="BottomRight" Minimum="1" Maximum="50" Value="25" IsSelectionRangeEnabled="True" />
|
||||
<Slider Margin="0,20,0,0" IsEnabled="False" TickFrequency="5" TickPlacement="BottomRight" Minimum="1" Maximum="50" Value="25" IsSelectionRangeEnabled="True" />
|
||||
<Slider Margin="0,20,0,0" TickFrequency="5" TickPlacement="Both" Minimum="1" Maximum="50" Value="25" IsSelectionRangeEnabled="True" />
|
||||
<Slider Margin="0,20,0,0" Minimum="0" Maximum="100" Style="{StaticResource HzDiscreteSlider}" Value="50" />
|
||||
<TextBlock Margin="0,10,0,0" Style="{StaticResource TextBlockDefault}" Text="HzDiscreteSlider"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="30,0,0,0">
|
||||
<Slider TickFrequency="5" Height="260" TickPlacement="BottomRight" Orientation="Vertical" Minimum="1" Maximum="50" />
|
||||
<Slider Margin="20,0,0,0" TickFrequency="25" TickPlacement="TopLeft" Orientation="Vertical" Minimum="1" Value="25" Maximum="50" IsEnabled="False" />
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--进度条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="进度条"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(ProgressBar)"></TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Margin="50,0,0,0" Grid.Column="1" ItemWidth="600">
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,30">
|
||||
<StackPanel Width="400">
|
||||
<ProgressBar Value="20"></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarSuccess}" Margin="0,10,0,0" Value="40"></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarInfo}" Margin="0,10,0,0" Value="60"></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarWarning}" Margin="0,10,0,0" Value="80"></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarDanger}" Margin="0,10,0,0" Value="100" Maximum="200"></ProgressBar>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10,0,0,0" Width="200" HorizontalAlignment="Left">
|
||||
<TextBlock Padding="0,2,0,3" Style="{StaticResource TextBlockDefault}" Text=""></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarSuccess" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarInfo" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarWarning" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarDanger" HorizontalAlignment="Left"></TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,30">
|
||||
<StackPanel Width="400">
|
||||
<ProgressBar Style="{StaticResource ProgressBarPrimaryStripe}" Value="120" Maximum="200" ></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarSuccessStripe}" Margin="0,10,0,0" Value="60" Maximum="200" ></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarInfoStripe}" Margin="0,10,0,0" Value="50" Maximum="200" ></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarWarningStripe}" Margin="0,10,0,0" Value="180" Maximum="200" ></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarDangerStripe}" Margin="0,10,0,0" Value="110" Maximum="200" ></ProgressBar>
|
||||
<ProgressBar Style="{StaticResource ProgressBarPlayer}" Margin="0,18,0,0" Value="110" Maximum="200" ></ProgressBar>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10,0,0,0" Width="200" HorizontalAlignment="Left">
|
||||
<TextBlock Padding="0,2,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarPrimaryStripe" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarSuccessStripe" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarInfoStripe" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarWarningStripe" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarDangerStripe" HorizontalAlignment="Left"></TextBlock>
|
||||
<TextBlock Padding="0,12,0,3" Style="{StaticResource TextBlockDefault}" Text="ProgressBarPlayer" HorizontalAlignment="Left"></TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--加载条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="加载条"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel VerticalAlignment="Center" Margin="50,0,0,0" Grid.Column="1">
|
||||
<controls:LoadingLine></controls:LoadingLine>
|
||||
<controls:LoadingLine Margin="0,30" Style="{StaticResource LoadingLineLarge}"></controls:LoadingLine>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<controls:LoadingCircle></controls:LoadingCircle>
|
||||
<Border VerticalAlignment="Center" Background="{DynamicResource PrimaryBrush}" CornerRadius="10">
|
||||
<controls:LoadingCircle Style="{StaticResource LoadingCircleLight}" Margin="10"></controls:LoadingCircle>
|
||||
</Border>
|
||||
<controls:LoadingCircle Margin="30,0,0,0" Style="{StaticResource LoadingCircleLarge}"></controls:LoadingCircle>
|
||||
<Border Background="{DynamicResource PrimaryBrush}" CornerRadius="10">
|
||||
<controls:LoadingCircle Margin="10" Style="{StaticResource LoadingCircleLargeLight}"></controls:LoadingCircle>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--SVG动画-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="SVG动画"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">(AnimationPath)</TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="50,0,0,0">
|
||||
<Border Height="100" Width="100" Background="Transparent" ToolTip="Logo">
|
||||
<controls:AnimationPath PathLength="350" Data="F1M920,623C923.727,628.962 921,646.695 921,655 921,682.664 921,710.336 921,738 921,768.082 925.328,811.315 918,836 903.862,883.627 872.578,912.609 823,925 813.58,927.354 800.912,926 790,926 767.669,926 745.331,926 723,926 696.003,926.333 668.997,926.667 642,927 601.671,927 561.329,927 521,927 511.584,927 480.763,929.566 475,926 475.667,926 476.333,926 477,926 483.623,917.068 502.194,908.526 512,902 537.933,884.74 564.176,867.097 590,849 666.329,795.509 744.738,743.551 821,690 845.895,672.519 871.434,656.242 896,639 903.897,633.458 913.504,629.899 920,623z M161,333C161,396.327 161,459.673 161,523 157.661,528.384 160,556.215 160,565 160,601.996 160,639.004 160,676 160.333,676 160.667,676 161,676 174.342,663.888 197.037,656.728 213,647 251.63,623.46 292.921,603.803 332,580 455.577,504.729 586.124,439.5 711,366 711,451.658 711,537.342 711,623 655.006,657.996 598.994,693.003 543,728 543,708.002 543,687.998 543,668 539.168,661.838 542,643.538 542,635 542,606.336 542,577.664 542,549 541.333,549 540.667,549 540,549 531.558,559.313 511.639,568.253 500,576 470.305,595.763 439.912,615.758 409,635 399.327,641.021 389.295,646.291 380,652 376.954,653.871 365.55,657.766 364,660 364,721.994 364,784.006 364,846 361.366,850.185 363,861.861 363,868 363,887.522 362.608,909.076 364,927 304.339,927 244.661,927 185,927 155.131,927 118.163,931.003 93,924 72.952,918.421 56.64,908.992 42,898 37.287,894.461 33.589,888.783 30,884 18.537,868.723 8.706,853.747 3,832 0.121,821.029 1,808.166 1,795 1,774.335 1,753.665 1,733 1,634.01 1,534.99 1,436 16.683,427.173 31.044,415.485 46,406 67.518,392.354 88.817,380.09 110,366 121.134,358.595 132.308,351.379 144,344 149.539,340.504 153.923,335.03 161,333z M297,148C297.666,148 298.333,148 299,148 299,157.999 299,168.001 299,178 288.141,183.381 279.071,192.507 269,199 269,193.001 269,186.999 269,181 267.459,178.688 267.881,172.895 268,169 275.398,164.769 292.094,154.399 297,148z M361,136C361.667,136 362.333,136 363,136 363,151.998 363,168.002 363,184 347.002,195.332 330.998,206.668 315,218 315,201.668 315,185.332 315,169 325.719,163.746 334.552,154.646 344,148 349.675,144.008 357.064,141.645 361,136z M378,72C381.577,77.586 379.134,95.09 379,103 368.668,110.333 358.332,117.667 348,125 348,114.668 348,104.332 348,94 355.788,89.259 372.765,78.885 378,72z M109,1C220.322,1 331.678,1 443,1 443,1.333 443,1.667 443,2 295.681,103.323 148.319,204.677 1,306 1,241.34 1,176.66 1,112 2,106.001 3,99.999 4,94 7.621,81.746 11.748,69.075 18,59 30.169,39.39 49.956,20.521 72,11 80.332,8.334 88.667,5.666 97,3 101.135,1.865 105.885,2.958 109,1z M785.335,-0.209C801.393,-0.362 816.839,0.388 829,4 848.591,9.819 864.504,19.116 879,30 885.416,34.817 890.236,42.411 895,49 904.823,62.586 913.037,77.087 918,96 920.879,106.971 920,119.834 920,133 920,153.665 920,174.335 920,195 920,294.323 920,393.677 920,493 902.967,501.124 887.43,514.691 872,525 857.054,534.986 842.227,543.382 827,553 804.534,567.19 782.954,584.202 760,598 760,492.677 760,387.323 760,282 759.667,282 759.333,282 759,282 750.937,289.213 739.498,292.212 730,298 706.024,312.612 680.407,325.08 656,340 592.381,378.892 524.569,413.05 461,452 446.205,461.065 430.832,466.969 416,476 370.102,503.948 321.304,527.723 275,556 257.871,566.46 239.59,575.3 222,586 216.108,589.584 210.273,594.894 203,597 203,500.01 203,402.99 203,306 214.025,300.639 223.306,291.808 233,285 248.573,274.063 264.173,264.541 280,254 287.314,249.129 294.267,241.121 303,238 303,249.665 303,261.334 303,273 303.333,273 303.667,273 304,273 309.016,266.75 317.334,263.673 324,259 330.355,254.545 336.644,248.486 343,244 345.294,242.381 350.57,241.244 352,239 352,227.001 352,214.999 352,203 360.806,198.733 367.79,191.964 376,187 376,260.326 376,333.674 376,407 376.333,407 376.667,407 377,407 380.078,403.361 384.796,402.602 389,400 400.641,392.794 412.901,386.419 425,379 451.17,362.953 477.055,345.752 502,329 509.827,323.743 539.22,309.277 540,300 542.664,295.611 539.712,286.961 541,281 543.448,269.669 541.561,254.333 544,243 544,236.667 544,230.333 544,224 547.791,206.454 544.222,184.549 548,167 548,161.001 548,154.999 548,149 550.285,138.428 550.377,123.216 551,112 551,105.334 551,98.666 551,92 553.491,80.469 550.25,66.732 553,54 556.428,38.131 555.92,18.392 556,1 616.66,1 677.339,1 738,1 752.607,1 769.277,-0.056 785.335,-0.209z"></controls:AnimationPath>
|
||||
</Border>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--gif图片-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="gif图片"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">(GifImage)</TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="50,0,0,0">
|
||||
<controls:GifImage Height="100" Width="100" Stretch="Uniform" Source="/Resources/police_car.gif"></controls:GifImage>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--图片浏览-->
|
||||
<!--<Border Visibility="Visible" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="图片浏览"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">(ImageBrowser)</TextBlock>
|
||||
</StackPanel>
|
||||
<Button Click="ButtonImageBrowser_OnClick" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="50,5,5,5" Content="点击打开图片浏览器" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--颜色拾取器-->
|
||||
<Border Visibility="Visible" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="颜色拾取器"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">(ColorPicker)</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left" Margin="50,5,5,5">
|
||||
<Button Click="ButtonColor_OnClick" Name="ButtonColor" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,5,5,5" Content="点击弹出颜色拾取器" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
<Button Click="ButtonColorPreset_OnClick" Name="ButtonColorPreset" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,5,5,5" Content="点击弹出颜色拾取器,同时预设为蓝色" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
|
||||
<TextBlock Name="BlockColor" Margin="20,0,0,0" Style="{StaticResource TextBlockTitle}"></TextBlock>
|
||||
</StackPanel>
|
||||
<Popup StaysOpen="False" AllowsTransparency="True" Name="PopupColor" Grid.Column="1" VerticalOffset="1" Placement="Bottom" PlacementTarget="{Binding ElementName=ButtonColor}">
|
||||
<controls:ColorPicker x:Name="ColorPicker" Canceled="ColorPicker_OnCanceled" ColorSelected="ColorPicker_OnColorSelected"></controls:ColorPicker>
|
||||
</Popup>
|
||||
</Grid>
|
||||
</Border>
|
||||
<!-- 轮播-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="轮播"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">(Carousel)</TextBlock>
|
||||
</StackPanel>
|
||||
<controls:Carousel AutoRun="True" Width="600" Height="330" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="50,5,5,5" >
|
||||
<Image Width="600" Stretch="UniformToFill" Source="Resources/1.jpg"></Image>
|
||||
<Image Width="300" Stretch="UniformToFill" Source="Resources/2.jpg"></Image>
|
||||
<Grid Width="600">
|
||||
<Image Stretch="UniformToFill" Source="Resources/3.jpg"></Image>
|
||||
<TextBlock Text="示例文本" Style="{StaticResource TextBlockDefault}" FontSize="100" FontWeight="Bold" Foreground="White"></TextBlock>
|
||||
</Grid>
|
||||
<Image Width="600" Stretch="UniformToFill" Source="Resources/4.jpg"></Image>
|
||||
<Image Width="600" Stretch="UniformToFill" Source="Resources/5.jpg"></Image>
|
||||
</controls:Carousel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--时间条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="时间条"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">(TimeBar)</TextBlock>
|
||||
</StackPanel>
|
||||
<controls:TimeBar BorderThickness="0" Background="{StaticResource PrimaryBrush}" Grid.Column="1" Width="600" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="50,5,5,5" ></controls:TimeBar>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--输入-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="输入"></TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel controls:InfoControl.TitleWidth="280" Grid.Column="1" ItemWidth="500" Margin="0,0,0,10">
|
||||
<controls:InfoComboBox DisplayMemberPath="Id" SelectedValuePath="Id" ItemsSource="{Binding FruitList,ElementName=MyWindow}" Margin="0,0,0,30" HorizontalAlignment="Stretch" Title="下拉框(必填) InfoComboBox" PlaceHolder="请选择一种水果" ErrorStr="请选择一种水果"></controls:InfoComboBox>
|
||||
<controls:InfoComboBox DisplayMemberPath="Name" SelectedValuePath="Id" IsEditable="True" ItemsSource="{Binding FruitList,ElementName=MyWindow}" Margin="0,0,0,30" HorizontalAlignment="Stretch" IsNeedly="False" Title="下拉框 InfoComboBox" PlaceHolder="请选择一种水果">
|
||||
--><!--<sys:String>苹果</sys:String>
|
||||
<sys:String>香蕉</sys:String>
|
||||
<sys:String>橘子</sys:String>
|
||||
<sys:String>菠萝</sys:String>
|
||||
<sys:String>葡萄</sys:String>--><!--
|
||||
</controls:InfoComboBox>
|
||||
<controls:InfoTextBox Margin="0,0,0,30" HorizontalAlignment="Stretch" Title="文本框(必填) InfoTextBox" PlaceHolder="请输入一种水果" ErrorStr="请输入一种水果"></controls:InfoTextBox>
|
||||
<controls:InfoTextBox TitleAlignment="Top" Margin="0,0,0,30" HorizontalAlignment="Stretch" IsNeedly="False" Title="文本框 InfoTextBox" PlaceHolder="请输入一种水果"></controls:InfoTextBox>
|
||||
<controls:InfoPasswordBox PasswordChar="❤" TitleAlignment="Top" Margin="0,0,0,30" HorizontalAlignment="Stretch" IsNeedly="False" Title="密码框 InfoPasswordBox" PlaceHolder="请输入密码"></controls:InfoPasswordBox>
|
||||
<controls:InfoDatePicker TitleAlignment="Top" Margin="0,0,0,30" HorizontalAlignment="Stretch" Title="日期选择(必填) InfoDatePicker" PlaceHolder="请选择日期" ErrorStr="请选择日期"></controls:InfoDatePicker>
|
||||
<controls:InfoDatePicker Margin="0,0,0,30" IsNeedly="False" HorizontalAlignment="Stretch" Title="日期选择 InfoDatePicker" PlaceHolder="请选择日期"></controls:InfoDatePicker>
|
||||
<controls:InfoTimePicker IsNeedly="False" Margin="0,0,0,30" HorizontalAlignment="Stretch" Title="时间选择 InfoTimePicker" PlaceHolder="请选择一个时间" ErrorStr="请选择一个时间"></controls:InfoTimePicker>
|
||||
<controls:InfoDateTimePicker IsNeedly="False" Margin="0,0,0,30" HorizontalAlignment="Stretch" Title="日期时间选择 InfoDateTimePicker" PlaceHolder="请选择一个时间" ErrorStr="请选择一个时间"></controls:InfoDateTimePicker>
|
||||
<controls:InfoNumericUpDown IsNeedly="False" Margin="0,0,0,30" HorizontalAlignment="Stretch" Title="数值选择控件 InfoNumericUpDown"></controls:InfoNumericUpDown>
|
||||
<ComboBox SelectedIndex="0" Text="原生ComboBox" Margin="280,0,0,30">
|
||||
<ComboBoxItem Content="原生ComboBox"></ComboBoxItem>
|
||||
<ComboBoxItem Content="苹果"></ComboBoxItem>
|
||||
<ComboBoxItem Content="香蕉"></ComboBoxItem>
|
||||
<ComboBoxItem Content="橘子"></ComboBoxItem>
|
||||
<ComboBoxItem Content="菠萝"></ComboBoxItem>
|
||||
<ComboBoxItem Content="葡萄"></ComboBoxItem>
|
||||
</ComboBox>
|
||||
<ComboBox IsEditable="True" Text="原生可编辑ComboBox" Margin="280,0,0,30">
|
||||
<ComboBoxItem Content="原生可编辑ComboBox"></ComboBoxItem>
|
||||
<ComboBoxItem Content="苹果"></ComboBoxItem>
|
||||
<ComboBoxItem Content="香蕉"></ComboBoxItem>
|
||||
<ComboBoxItem Content="橘子"></ComboBoxItem>
|
||||
<ComboBoxItem Content="菠萝"></ComboBoxItem>
|
||||
<ComboBoxItem Content="葡萄"></ComboBoxItem>
|
||||
</ComboBox>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--树状视图-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="树状视图"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(TreeView)"></TextBlock>
|
||||
</StackPanel>
|
||||
<TreeView HorizontalAlignment="Left" Width="300" Height="300" Margin="50,0,0,0" Grid.Column="1" Name="TreeViewMain">
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate DataType="{x:Type model:CellGateInfo}" ItemsSource="{Binding InfoList}">
|
||||
<TextBlock Text="{Binding Name}"></TextBlock>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
</TreeView>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--列表框-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="列表框"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(ListBox)"></TextBlock>
|
||||
</StackPanel>
|
||||
<ListBox HorizontalAlignment="Left" Width="300" Height="300" Margin="50,0,0,0" Grid.Column="1" Name="ListBoxMain">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}"></TextBlock>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--数据表格-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="数据表格"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(DataGrid)"></TextBlock>
|
||||
</StackPanel>
|
||||
<DataGrid HorizontalAlignment="Left" Width="300" Height="300" Name="DataGridMain" Grid.Column="1" Margin="50,0,0,0">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Width="1*" Binding="{Binding PersonId}" Header="姓名"/>
|
||||
<DataGridTextColumn Width="1*" Binding="{Binding DeviceId}" Header="类型"/>
|
||||
<DataGridTextColumn Width="1*" Binding="{Binding Direction}" Header="方向"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--组合框-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="组合框"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(GroupBox)"></TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Grid.Column="1" Margin="50,0,0,0">
|
||||
<GroupBox Style="{StaticResource GroupBoxDefault}" Margin="0,0,10,10" Width="400" Height="300" Header="默认样式">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Text="内容"></TextBlock>
|
||||
</GroupBox>
|
||||
<GroupBox Margin="0,0,10,10" Width="400" Height="300" Header="标题不带背景(GroupBoxNoBackground)">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Text="内容"></TextBlock>
|
||||
</GroupBox>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--标签控件-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="标签控件"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(TabControl)"></TextBlock>
|
||||
</StackPanel>
|
||||
<Border Style="{StaticResource BorderRegionStyle}" Grid.Column="1" Padding="0" Margin="50,0,0,0">
|
||||
<TabControl>
|
||||
<TabItem Header="标题1">
|
||||
<Border Background="{DynamicResource PrimaryBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容1"></TextBlock>
|
||||
</Border>
|
||||
</TabItem>
|
||||
<TabItem Header="标题2">
|
||||
<Border Background="{DynamicResource SuccessBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容2"></TextBlock>
|
||||
</Border>
|
||||
</TabItem>
|
||||
<TabItem Header="标题3">
|
||||
<Border Background="{DynamicResource InfoBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容3"></TextBlock>
|
||||
</Border>
|
||||
</TabItem>
|
||||
<TabItem Header="标题4">
|
||||
<Border Background="{DynamicResource WarningBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容4"></TextBlock>
|
||||
</Border>
|
||||
</TabItem>
|
||||
<TabItem Header="标题5">
|
||||
<Border Background="{DynamicResource DangerBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容5"></TextBlock>
|
||||
</Border>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--可拖动的TabControl-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="可拖动的TabControl"></TextBlock>
|
||||
</StackPanel>
|
||||
<controls:TabControl SelectedIndex="2" BorderThickness="1" OpenEffect="True" BorderBrush="{DynamicResource BorderBrush}" Grid.Column="1" Margin="50,0,0,0">
|
||||
<controls:TabItem Header="标题1">
|
||||
<Border Background="{DynamicResource PrimaryBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容1"></TextBlock>
|
||||
</Border>
|
||||
</controls:TabItem>
|
||||
<controls:TabItem Header="标题2">
|
||||
<Border Background="{DynamicResource SuccessBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容2"></TextBlock>
|
||||
</Border>
|
||||
</controls:TabItem>
|
||||
<controls:TabItem Header="标题3">
|
||||
<Border Background="{DynamicResource InfoBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容3"></TextBlock>
|
||||
</Border>
|
||||
</controls:TabItem>
|
||||
<controls:TabItem Header="标题4">
|
||||
<Border Background="{DynamicResource WarningBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容4"></TextBlock>
|
||||
</Border>
|
||||
</controls:TabItem>
|
||||
<controls:TabItem Header="标题5">
|
||||
<Border Background="{DynamicResource DangerBrush}" Height="200">
|
||||
<TextBlock Style="{StaticResource TextBlockLargeBold}" Foreground="{DynamicResource TextIconBrush}" Text="内容5"></TextBlock>
|
||||
</Border>
|
||||
</controls:TabItem>
|
||||
</controls:TabControl>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--步骤条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="步骤条"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(Steps)"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="50,0,0,0">
|
||||
<controls:Steps x:Name="StepsExample">
|
||||
<controls:Steps.Items>
|
||||
<sys:String>描述描述描述描述1</sys:String>
|
||||
<sys:String>描述描述描述描述2</sys:String>
|
||||
<sys:String>描述描述描述描述3</sys:String>
|
||||
<sys:String>描述描述描述描述4</sys:String>
|
||||
</controls:Steps.Items>
|
||||
</controls:Steps>
|
||||
<StackPanel Margin="0,30,0,0" HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button Click="ButtonStepPrec_OnClick" Content="上一步" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
<Button Click="ButtonStepNext_OnClick" Margin="10,0,0,0" Content="下一步" Style="{StaticResource ButtonPrimary}"></Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--页码条-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="页码条"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(Pagination)"></TextBlock>
|
||||
</StackPanel>
|
||||
<controls:Pagination Margin="50,0,0,0" MaxPageCount="10" Grid.Column="1"></controls:Pagination>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--上下文菜单-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="上下文菜单"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}" Text="(ContextMenu)"></TextBlock>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="1" Background="Transparent">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="11111111111">
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111">
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
<MenuItem Header="11111111111"></MenuItem>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
<controls:ContextMenuButton Margin="50,0,30,0" HorizontalAlignment="Left" Content="点击弹出树状上下文菜单" Style="{StaticResource ButtonPrimary}">
|
||||
<controls:ContextMenuButton.Menu>
|
||||
<controls:TreeContextMenu Name="ButtonContextMenu">
|
||||
<controls:TreeContextMenu.ItemTemplate>
|
||||
<HierarchicalDataTemplate DataType="{x:Type model:CellGateInfo}" ItemsSource="{Binding InfoList}">
|
||||
<TextBlock Text="{Binding Name}"></TextBlock>
|
||||
</HierarchicalDataTemplate>
|
||||
</controls:TreeContextMenu.ItemTemplate>
|
||||
</controls:TreeContextMenu>
|
||||
</controls:ContextMenuButton.Menu>
|
||||
</controls:ContextMenuButton>
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource TextBlockDefault}" Text="或者在空白区域右键弹出普通上下文菜单"></TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--特殊文本-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="特殊文本"></TextBlock>
|
||||
<TextBlock Style="{StaticResource TextBlockTitle}">
|
||||
(FormatedText、
|
||||
<LineBreak/>
|
||||
StrokeableLabel)
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="50,0,0,0">
|
||||
<controls:FormatedText Text="纵向文本" FontSize="30" Margin="0,0,30,0" TextOrientation="Vertical"></controls:FormatedText>
|
||||
<controls:FormatedText Text="横向文本" FontSize="30" Margin="0,0,30,0"></controls:FormatedText>
|
||||
<controls:FormatedText Text="文字间隔示例" FontSize="30" Margin="0,0,30,0" StretchSize="28" FontWeight="Bold"></controls:FormatedText>
|
||||
<controls:StrokeableLabel Text="带边线文本" FontSize="30" StrokeThickness="2" Stroke="{DynamicResource PrimaryBrush}" FontWeight="Bold"/>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
<!--字体-->
|
||||
<!--<Border Visibility="Collapsed" Margin="0,10,0,0" Style="{StaticResource BorderRegionStyle}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Header"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,5,0,0" Style="{StaticResource TextBlockTitle}" Text="字体"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="50,0,0,30">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockLargeBold" Style="{DynamicResource TextBlockLargeBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockLarge" Style="{DynamicResource TextBlockLarge}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockHeaderBold" Style="{DynamicResource TextBlockTitleBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockHeader" Style="{DynamicResource TextBlockTitle}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockSubHeaderBold" Style="{DynamicResource TextBlockSubTitleBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockSubHeader" Style="{DynamicResource TextBlockSubTitle}"></TextBlock>
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultBold" Style="{DynamicResource TextBlockDefaultBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefault" Style="{DynamicResource TextBlockDefault}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultAccent" Style="{DynamicResource TextBlockDefaultAccent}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultSecLight" Style="{DynamicResource TextBlockDefaultSecLight}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultThiLight" Style="{DynamicResource TextBlockDefaultThiLight}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultPrimary" Style="{DynamicResource TextBlockDefaultPrimary}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultDanger" Style="{DynamicResource TextBlockDefaultDanger}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultWarning" Style="{DynamicResource TextBlockDefaultWarning}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultInfo" Style="{DynamicResource TextBlockDefaultInfo}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="TextBlockDefaultSuccess" Style="{DynamicResource TextBlockDefaultSuccess}"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10,0,0,0">
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="标题标题标题标题标题标题标题标题标题标题" Style="{DynamicResource TextBlockLargeBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="标题标题标题标题标题标题标题标题标题标题" Style="{DynamicResource TextBlockLarge}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="标题标题标题标题标题标题标题标题标题标题标题标题" Style="{DynamicResource TextBlockTitleBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="标题标题标题标题标题标题标题标题标题标题标题标题" Style="{DynamicResource TextBlockTitle}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="子标题子标题子标题子标题子标题子标题子标题子标题子标题子标题" Style="{DynamicResource TextBlockSubTitleBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="子标题子标题子标题子标题子标题子标题子标题子标题子标题子标题" Style="{DynamicResource TextBlockSubTitle}"></TextBlock>
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultBold}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefault}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultAccent}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultSecLight}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultThiLight}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultPrimary}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultDanger}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultWarning}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultInfo}"></TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="5" Text="正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文正文" Style="{DynamicResource TextBlockDefaultSuccess}"></TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>-->
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
@ -1,13 +1,330 @@
|
||||
namespace HandyControlDemo
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
using HandyControlDemo.Data.Model;
|
||||
|
||||
namespace HandyControlDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow
|
||||
{
|
||||
public static readonly DependencyProperty FruitListProperty = DependencyProperty.Register(
|
||||
"FruitList", typeof(ObservableCollection<Fruit>), typeof(MainWindow), new PropertyMetadata(default(ObservableCollection<string>)));
|
||||
|
||||
public ObservableCollection<Fruit> FruitList
|
||||
{
|
||||
get => (ObservableCollection<Fruit>)GetValue(FruitListProperty);
|
||||
set => SetValue(FruitListProperty, value);
|
||||
}
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
foreach (var border in StackPanelMain.Children.OfType<Border>())
|
||||
{
|
||||
border.Show();
|
||||
}
|
||||
|
||||
var listZ = new List<CellGateInfo>();
|
||||
|
||||
for (int i = 1; i <= 40; i++)
|
||||
{
|
||||
var itemC = new CellGateInfo();
|
||||
var listC = new List<CellGateInfo>();
|
||||
itemC.Name = $"{i}幢";
|
||||
for (int j = 1; j <= 2; j++)
|
||||
{
|
||||
var itemF = new CellGateInfo();
|
||||
var listF = new List<CellGateInfo>();
|
||||
itemF.Name = $"{itemC.Name}{j}单元";
|
||||
for (int k = 1; k <= 10; k++)
|
||||
{
|
||||
for (int l = 1; l <= 4; l++)
|
||||
{
|
||||
var itemR = new CellGateInfo
|
||||
{
|
||||
Name = $"{itemF.Name}{k}0{l}室"
|
||||
};
|
||||
listF.Add(itemR);
|
||||
}
|
||||
}
|
||||
itemF.InfoList = listF;
|
||||
listC.Add(itemF);
|
||||
}
|
||||
itemC.InfoList = listC;
|
||||
listZ.Add(itemC);
|
||||
}
|
||||
|
||||
//TreeViewMain.ItemsSource = listZ;
|
||||
//ListBoxMain.ItemsSource = listZ;
|
||||
//ButtonContextMenu.ItemsSource = listZ;
|
||||
|
||||
var showRecords = new List<CellGateRecord>
|
||||
{
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-1),
|
||||
CellGateId = "1幢1单元A单元门",
|
||||
PersonId = "宋立才",
|
||||
DeviceId = "刷卡",
|
||||
Direction = "进"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-2),
|
||||
CellGateId = "1幢1单元A单元门",
|
||||
PersonId = "宋立才",
|
||||
DeviceId = "刷卡",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-2),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "周弘益",
|
||||
DeviceId = "人脸",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-3),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "周弘益",
|
||||
DeviceId = "人脸",
|
||||
Direction = "进"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-2),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "彭念文",
|
||||
DeviceId = "RFID",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-3),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "彭念文",
|
||||
DeviceId = "RFID",
|
||||
Direction = "进"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "王跃",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
},
|
||||
new CellGateRecord
|
||||
{
|
||||
CreateTime = DateTime.Now.AddDays(-4),
|
||||
CellGateId = "20幢2单元A单元门",
|
||||
PersonId = "赵兴隆",
|
||||
DeviceId = "指纹",
|
||||
Direction = "出"
|
||||
}
|
||||
};
|
||||
//DataGridMain.ItemsSource = showRecords;
|
||||
|
||||
FruitList = new ObservableCollection<Fruit>
|
||||
{
|
||||
new Fruit
|
||||
{
|
||||
Name = "苹果",
|
||||
Id = 0
|
||||
},
|
||||
new Fruit
|
||||
{
|
||||
Name = "香蕉",
|
||||
Id = 1
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public class Fruit
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
//private void ThemesComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
//{
|
||||
// if (sender is ComboBox comboBox && comboBox.SelectedItem is ComboBoxItem comboBoxItem &&
|
||||
// comboBoxItem.Tag is string tag)
|
||||
// {
|
||||
// var str = File.ReadAllText($"./Files/Themes/{tag}.json");
|
||||
// var jObject = JObject.Parse(str);
|
||||
// foreach (var item in jObject.Properties())
|
||||
// {
|
||||
// Resources.Remove(item.Name);
|
||||
// Resources.Add(item.Name, item.Value.ToObject<SolidColorBrush>());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void ButtonStepPrec_OnClick(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// StepsExample.Prev();
|
||||
//}
|
||||
|
||||
|
||||
//private void ButtonStepNext_OnClick(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// StepsExample.Next();
|
||||
//}
|
||||
|
||||
//private void ButtonImageBrowser_OnClick(object sender, RoutedEventArgs e)
|
||||
//{
|
||||
// var window = new ImageBrowser(new Uri("pack://application:,,,/Resources/demo.png"));
|
||||
// window.Show();
|
||||
//}
|
||||
|
||||
private void ColorPicker_OnColorSelected(object sender, FunctionEventArgs<Color> e)
|
||||
{
|
||||
BlockColor.Text = $"{e.Info}-----{e.Info.ToInt32()}";
|
||||
PopupColor.IsOpen = false;
|
||||
}
|
||||
|
||||
private void ColorPicker_OnCanceled(object sender, EventArgs e)
|
||||
{
|
||||
PopupColor.IsOpen = false;
|
||||
}
|
||||
|
||||
private void ButtonColor_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PopupColor.IsOpen = true;
|
||||
}
|
||||
|
||||
private void ButtonColorPreset_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ColorPicker.SelectedBrush = Brushes.Blue;
|
||||
PopupColor.IsOpen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user