refactor ImageBrowser, add NumericUpDown, delete info controls

This commit is contained in:
NaBian committed 2018-10-12 20:03:59 +08:00
1 parent 3e726d3eb1
commit 82c6509c7a
37 files changed
+712 -965

No files matched your search

-374
View File
@@ -1,374 +0,0 @@
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
{
internal 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;
}
}
}
@@ -1,66 +0,0 @@
<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"
x:ClassModifier="internal"
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 Style="{StaticResource TextBlockDefault}" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource String2VisibilityConverter}}" Margin="0,0,10,0" Text="{Binding Title,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"/>
</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}}"/>
<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 String2VisibilityReConverter}}" VerticalAlignment="Center" Foreground="{DynamicResource ThirdlyTextBrush}"/>
<TextBox Style="{x:Null}" 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}"/>
<Button Padding="7" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityConverter}}" Focusable="True" Grid.Column="1" Name="ButtonClear" Click="ButtonClear_OnClick" Foreground="{DynamicResource ThirdlyTextBrush}" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Style="{StaticResource ButtonIcon}" Width="36" HorizontalAlignment="Right"/>
<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 ButtonIcon}" Width="36" HorizontalAlignment="Right" VerticalAlignment="Top" Height="17"/>
<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 ButtonIcon}" Width="36" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="17"/>
</Grid>
</Border>
</Grid>
</controls:InfoControl>
@@ -1,181 +0,0 @@
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;
using HandyControl.Data;
using HandyControl.Tools;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
/// <summary>
/// InfoNumericUpDown.xaml 的交互逻辑
/// </summary>
internal 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;
}), ValidateHelper.IsInRangeOfDouble);
/// <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;
}), ValidateHelper.IsInRangeOfDouble);
/// <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;
}), ValidateHelper.IsInRangeOfDouble);
/// <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), ValidateHelper.IsInRangeOfDouble);
/// <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;
}
}
}
@@ -1,62 +0,0 @@
<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"
x:ClassModifier="internal"
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 Style="{StaticResource TextBlockDefault}" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource String2VisibilityConverter}}" Margin="0,0,10,0" Text="{Binding Title,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"/>
</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}}"/>
<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 String2VisibilityReConverter}}" 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}"/>
<Button Padding="7" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityConverter}}" Focusable="True" Grid.Column="1" Name="ButtonClear" Click="ButtonClear_OnClick" Foreground="{DynamicResource ThirdlyTextBrush}" controls:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}" Style="{StaticResource ButtonIcon}" Width="36" HorizontalAlignment="Right"/>
</Grid>
</Border>
</Grid>
</controls:InfoControl>
@@ -1,45 +0,0 @@
using System.Windows;
using System.Windows.Media.Animation;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
/// <summary>
/// InfoTextBox.xaml 的交互逻辑
/// </summary>
internal 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;
};
}
}
}
+257
View File
@@ -0,0 +1,257 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using HandyControl.Data;
using HandyControl.Interactivity;
namespace HandyControl.Controls
{
/// <summary>
/// 数值选择控件
/// </summary>
[TemplatePart(Name = ElementTextBox, Type = typeof(TextBox))]
public class NumericUpDown : Control
{
#region Constants
private const string ElementTextBox = "PART_TextBox";
#endregion Constants
#region Data
private TextBox _textBox;
#endregion Data
public NumericUpDown()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => Value += Increment));
CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => Value -= Increment));
}
protected override void OnGotFocus(RoutedEventArgs e)
{
base.OnGotFocus(e);
if (_textBox != null)
{
_textBox?.Focus();
_textBox.Select(_textBox.Text.Length, 0);
}
}
public override void OnApplyTemplate()
{
if (_textBox != null)
{
_textBox.PreviewTextInput -= TextBoxValue_TextInput;
}
base.OnApplyTemplate();
_textBox = GetTemplateChild(ElementTextBox) as TextBox;
if (_textBox != null)
{
_textBox.PreviewTextInput += TextBoxValue_TextInput;
_textBox.Text = Value.ToString($"#0.{new string('0', DecimalPlaces)}");
}
}
private void TextBoxValue_TextInput(object sender, TextCompositionEventArgs e)
{
if (double.TryParse(_textBox.Text, out var value))
{
Value = value;
}
if (_textBox != null)
{
_textBox.Text = Value.ToString($"#0.{new string('0', DecimalPlaces)}");
_textBox.Select(_textBox.Text.Length, 0);
}
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
base.OnMouseWheel(e);
if (_textBox.IsFocused)
{
Value += e.Delta > 0 ? Increment : -Increment;
e.Handled = true;
}
}
protected virtual void OnValueChanged(FunctionEventArgs<double> e) => RaiseEvent(e);
/// <summary>
/// 值改变事件
/// </summary>
public static readonly RoutedEvent ValueChangedEvent =
EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
typeof(EventHandler<FunctionEventArgs<double>>), typeof(NumericUpDown));
/// <summary>
/// 值改变事件
/// </summary>
public event EventHandler<FunctionEventArgs<double>> ValueChanged
{
add => AddHandler(ValueChangedEvent, value);
remove => RemoveHandler(ValueChangedEvent, value);
}
/// <summary>
/// 当前值
/// </summary>
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
"Value", typeof(double), typeof(NumericUpDown), new PropertyMetadata(default(double), OnValueChanged, CoerceValue), IsValidDoubleValue);
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (NumericUpDown) d;
var v = (double) e.NewValue;
if (ctl._textBox != null)
{
ctl._textBox.Text = v.ToString($"#0.{new string('0', ctl.DecimalPlaces)}");
ctl._textBox.Select(ctl._textBox.Text.Length, 0);
}
ctl.OnValueChanged(new FunctionEventArgs<double>(ValueChangedEvent, ctl)
{
Info = v
});
}
private static object CoerceValue(DependencyObject d, object basevalue)
{
var ctl = (NumericUpDown)d;
var minimum = ctl.Minimum;
var num = (double)basevalue;
if (num < minimum)
{
ctl.Value = minimum;
return minimum;
}
var maximum = ctl.Maximum;
if (num > maximum)
{
ctl.Value = maximum;
}
return num > maximum ? maximum : basevalue;
}
/// <summary>
/// 当前值
/// </summary>
public double Value
{
get => (double) GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
/// <summary>
/// 最大值
/// </summary>
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(
"Maximum", typeof(double), typeof(NumericUpDown), new PropertyMetadata(100.0, OnMaximumChanged, CoerceMaximum), IsValidDoubleValue);
private static void OnMaximumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (NumericUpDown)d;
ctl.CoerceValue(MinimumProperty);
ctl.CoerceValue(ValueProperty);
}
private static object CoerceMaximum(DependencyObject d, object basevalue)
{
var minimum = ((NumericUpDown)d).Minimum;
return (double)basevalue < minimum ? minimum : basevalue;
}
/// <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(NumericUpDown), new PropertyMetadata(default(double), OnMinimumChanged, CoerceMinimum), IsValidDoubleValue);
private static void OnMinimumChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (NumericUpDown)d;
ctl.CoerceValue(MaximumProperty);
ctl.CoerceValue(ValueProperty);
}
private static object CoerceMinimum(DependencyObject d, object basevalue)
{
var maximum = ((NumericUpDown)d).Maximum;
return (double)basevalue > maximum ? maximum : basevalue;
}
/// <summary>
/// 最小值
/// </summary>
public double Minimum
{
get => (double) GetValue(MinimumProperty);
set => SetValue(MinimumProperty, value);
}
private static bool IsValidDoubleValue(object value)
{
var d = (double)value;
if (!double.IsNaN(d))
return !double.IsInfinity(d);
return false;
}
/// <summary>
/// 指示每单击一下按钮时增加或减少的数量
/// </summary>
public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register(
"Increment", typeof(double), typeof(NumericUpDown), new PropertyMetadata(1.0));
/// <summary>
/// 指示每单击一下按钮时增加或减少的数量
/// </summary>
public double Increment
{
get => (double) GetValue(IncrementProperty);
set => SetValue(IncrementProperty, value);
}
/// <summary>
/// 指示要显示的小数位数
/// </summary>
public static readonly DependencyProperty DecimalPlacesProperty = DependencyProperty.Register(
"DecimalPlaces", typeof(int), typeof(NumericUpDown), new PropertyMetadata(default(int)));
/// <summary>
/// 指示要显示的小数位数
/// </summary>
public int DecimalPlaces
{
get => (int) GetValue(DecimalPlacesProperty);
set => SetValue(DecimalPlacesProperty, value);
}
internal static readonly DependencyProperty ShowUpDownButtonProperty = DependencyProperty.Register(
"ShowUpDownButton", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(true));
internal bool ShowUpDownButton
{
get => (bool) GetValue(ShowUpDownButtonProperty);
set => SetValue(ShowUpDownButtonProperty, value);
}
}
}
+19 -6
View File
@@ -22,7 +22,20 @@
<Border Background="{Binding BackColor,ElementName=UserControlMain}"/>
<Border>
<Border.Background>
<ImageBrush ImageSource="/HandyControl;component/Resources/colorPickerBack.png"/>
<LinearGradientBrush EndPoint="0,0.5" StartPoint="1,0.5">
<GradientStop Color="White" Offset="1"/>
<GradientStop Color="Transparent"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Border>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#aa000000" Offset=".6"/>
<GradientStop Color="#22000000" Offset=".2"/>
<GradientStop Color="Transparent"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Grid>
@@ -58,21 +71,21 @@
<TextBox Padding="0" HorizontalContentAlignment="Center" Width="176" Text="{Binding SelectedBrush,ElementName=UserControlMain,Mode=TwoWay,Converter={StaticResource Color2HexStrConverter},UpdateSourceTrigger=LostFocus}" FontSize="10" MaxLength="10" Height="24" />
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="HEX" HorizontalAlignment="Center"/>
</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">
<UniformGrid controls:NumericUpDown.ValueChanged="NumericUpDownRgb_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:NumericUpDown HorizontalContentAlignment="Center" Padding="0" Tag="R" x:Name="ChannelR" Value="255" ShowUpDownButton="False" Maximum="255" Minimum="0" FontSize="10" Height="24" />
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="R" HorizontalAlignment="Center"/>
</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:NumericUpDown HorizontalContentAlignment="Center" Padding="0" Tag="G" x:Name="ChannelG" Value="255" ShowUpDownButton="False" Maximum="255" Minimum="0" FontSize="10" Height="24" />
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="G" HorizontalAlignment="Center"/>
</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:NumericUpDown HorizontalContentAlignment="Center" Padding="0" Tag="B" x:Name="ChannelB" Value="255" ShowUpDownButton="False" Maximum="255" Minimum="0" FontSize="10" Height="24" />
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="B" HorizontalAlignment="Center"/>
</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:NumericUpDown HorizontalContentAlignment="Center" Padding="0" Value="{Binding Value,ElementName=SliderOpacity,Mode=TwoWay}" ShowUpDownButton="False" Maximum="255" Minimum="0" FontSize="10" Height="24" />
<TextBlock Foreground="{StaticResource ThirdlyTextBrush}" Margin="0,6,0,0" FontSize="10" Text="A" HorizontalAlignment="Center"/>
</StackPanel>
</UniformGrid>
@@ -8,6 +8,7 @@ using System.Windows.Media;
using HandyControl.Data;
using HandyControl.Tools.Extension;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
/// <summary>
@@ -510,10 +511,10 @@ namespace HandyControl.Controls
private void ButtonSwitch_OnClick(object sender, RoutedEventArgs e) => ColorType++;
private void InfoNumericUpDownRgb_OnValueChanged(object sender, FunctionEventArgs<double> e)
private void NumericUpDownRgb_OnValueChanged(object sender, FunctionEventArgs<double> e)
{
if (!_isLoaded || !IsNeedUpdateInfo) return;
if (e.OriginalSource is InfoNumericUpDown ctl && ctl.Tag is string tag)
if (e.OriginalSource is NumericUpDown ctl && ctl.Tag is string tag)
{
var color = SelectedBrush.Color;
IsNeedUpdateInfo = false;
+1 -2
View File
@@ -31,8 +31,7 @@ namespace HandyControl.Controls
private const string ElementCanvasSpe = "PART_CanvasSpe";
#endregion Constants
#region Data
private Border _borderTop;
@@ -2,10 +2,13 @@
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using HandyControl.Interactivity;
using HandyControl.Tools;
using Microsoft.Win32;
@@ -15,40 +18,87 @@ namespace HandyControl.Controls
/// <summary>
/// 图片浏览器
/// </summary>
public partial class ImageBrowser
[TemplatePart(Name = ElementGridTop, Type = typeof(Grid))]
[TemplatePart(Name = ElementGridMain, Type = typeof(Grid))]
[TemplatePart(Name = ElementCanvasSmallImg, Type = typeof(Canvas))]
[TemplatePart(Name = ElementBorderMove, Type = typeof(Border))]
[TemplatePart(Name = ElementBorderBottom, Type = typeof(Border))]
[TemplatePart(Name = ElementImageMain, Type = typeof(Image))]
public class ImageBrowser : WindowBorderless
{
#region Constants
private const string ElementGridTop = "PART_GridTop";
private const string ElementGridMain = "PART_GridMain";
private const string ElementCanvasSmallImg = "PART_CanvasSmallImg";
private const string ElementBorderMove = "PART_BorderMove";
private const string ElementBorderBottom = "PART_BorderBottom";
private const string ElementImageMain = "PART_ImageMain";
/// <summary>
/// 缩放比间隔
/// </summary>
private const double ScaleInternal = 0.2;
#endregion Constants
#region Data
private Grid _gridTop;
private Grid _canvasMain;
private Canvas _canvasSmallImg;
private Border _borderMove;
private Border _borderBottom;
private Image _imageMain;
#endregion Data
static ImageBrowser()
{
IsFullScreenProperty.AddOwner(typeof(ImageBrowser), new PropertyMetadata(default(bool)));
}
private static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ImageContentProperty = DependencyProperty.Register(
"ImageContent", typeof(object), typeof(ImageBrowser), new PropertyMetadata(default(object)));
internal object ImageContent
{
get => GetValue(ImageContentProperty);
set => SetValue(ImageContentProperty, value);
}
internal static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register(
"ImageSource", typeof(BitmapFrame), typeof(ImageBrowser), new PropertyMetadata(default(BitmapFrame)));
private static readonly DependencyProperty ImageMarginProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ImageMarginProperty = DependencyProperty.Register(
"ImageMargin", typeof(Thickness), typeof(ImageBrowser), new PropertyMetadata(default(Thickness)));
private static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register(
"ImageWidth", typeof(double), typeof(ImageBrowser), new PropertyMetadata(default(double)));
private static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register(
"ImageHeight", typeof(double), typeof(ImageBrowser), new PropertyMetadata(default(double)));
public static readonly DependencyProperty ImageScaleProperty = DependencyProperty.Register(
"ImageScale", typeof(double), typeof(ImageBrowser), new PropertyMetadata(1.0, OnImageScaleChanged));
private static readonly DependencyProperty ScaleStrProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ScaleStrProperty = DependencyProperty.Register(
"ScaleStr", typeof(string), typeof(ImageBrowser), new PropertyMetadata("100%"));
private static readonly DependencyProperty ImageRotateProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ImageRotateProperty = DependencyProperty.Register(
"ImageRotate", typeof(double), typeof(ImageBrowser), new PropertyMetadata(default(double)));
private static readonly DependencyProperty ShowSmallImgProperty = DependencyProperty.Register(
internal static readonly DependencyProperty ShowSmallImgProperty = DependencyProperty.Register(
"ShowSmallImg", typeof(bool), typeof(ImageBrowser), new PropertyMetadata(false));
/// <summary>
@@ -182,15 +232,22 @@ namespace HandyControl.Controls
/// </summary>
private bool _isOblique;
public ImageBrowser() => InitializeComponent();
/// <summary>
/// 带一个图片路径的构造函数
/// </summary>
/// <param name="path"></param>
public ImageBrowser(string path) : this(new Uri(path))
public ImageBrowser()
{
Loaded += ImageBrowser_OnLoaded;
CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Save, ButtonSave_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Open, ButtonWindowsOpen_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Restore, ButtonActual_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Reduce, ButtonReduce_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Enlarge, ButtonEnlarge_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.RotateLeft, ButtonRotateLeft_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.RotateRight, ButtonRotateRight_OnClick));
WindowStartupLocation = WindowStartupLocation.CenterScreen;
WindowStyle = WindowStyle.None;
AllowsTransparency = true;
}
/// <summary>
@@ -215,25 +272,82 @@ namespace HandyControl.Controls
}
}
private BitmapFrame ImageSource
/// <summary>
/// 带一个图片路径的构造函数
/// </summary>
/// <param name="path"></param>
public ImageBrowser(string path) : this(new Uri(path))
{
}
public override void OnApplyTemplate()
{
if (_imageMain != null)
{
_imageMain.MouseLeftButtonDown -= ImageMain_OnMouseLeftButtonDown;
}
if (_gridTop != null)
{
_gridTop.MouseLeftButtonDown -= GridTop_OnMouseLeftButtonDown;
}
if (_canvasSmallImg != null)
{
_canvasSmallImg.MouseLeftButtonDown -= CanvasSmallImg_OnMouseLeftButtonDown;
_canvasSmallImg.MouseLeftButtonUp -= CanvasSmallImg_OnMouseLeftButtonUp;
_canvasSmallImg.MouseMove -= CanvasSmallImg_OnMouseMove;
_canvasSmallImg.MouseLeave -= CanvasSmallImg_OnMouseLeave;
}
base.OnApplyTemplate();
_gridTop = GetTemplateChild(ElementGridTop) as Grid;
_canvasMain = GetTemplateChild(ElementGridMain) as Grid;
_canvasSmallImg = GetTemplateChild(ElementCanvasSmallImg) as Canvas;
_borderMove = GetTemplateChild(ElementBorderMove) as Border;
_imageMain = GetTemplateChild(ElementImageMain) as Image;
_borderBottom = GetTemplateChild(ElementBorderBottom) as Border;
if (_imageMain != null)
{
_imageMain.MouseLeftButtonDown += ImageMain_OnMouseLeftButtonDown;
}
if (_gridTop != null)
{
_gridTop.MouseLeftButtonDown += GridTop_OnMouseLeftButtonDown;
}
if (_canvasSmallImg != null)
{
_canvasSmallImg.MouseLeftButtonDown += CanvasSmallImg_OnMouseLeftButtonDown;
_canvasSmallImg.MouseLeftButtonUp += CanvasSmallImg_OnMouseLeftButtonUp;
_canvasSmallImg.MouseMove += CanvasSmallImg_OnMouseMove;
_canvasSmallImg.MouseLeave += CanvasSmallImg_OnMouseLeave;
}
}
internal BitmapFrame ImageSource
{
get => (BitmapFrame)GetValue(ImageSourceProperty);
set => SetValue(ImageSourceProperty, value);
}
private Thickness ImageMargin
internal Thickness ImageMargin
{
get => (Thickness)GetValue(ImageMarginProperty);
set => SetValue(ImageMarginProperty, value);
}
private double ImageWidth
internal double ImageWidth
{
get => (double)GetValue(ImageWidthProperty);
set => SetValue(ImageWidthProperty, value);
}
private double ImageHeight
internal double ImageHeight
{
get => (double)GetValue(ImageHeightProperty);
set => SetValue(ImageHeightProperty, value);
@@ -245,19 +359,19 @@ namespace HandyControl.Controls
set => SetValue(ImageScaleProperty, value);
}
private string ScaleStr
internal string ScaleStr
{
get => (string)GetValue(ScaleStrProperty);
set => SetValue(ScaleStrProperty, value);
}
private double ImageRotate
internal double ImageRotate
{
get => (double)GetValue(ImageRotateProperty);
set => SetValue(ImageRotateProperty, value);
}
private bool ShowSmallImg
internal bool ShowSmallImg
{
get => (bool)GetValue(ShowSmallImgProperty);
set => SetValue(ShowSmallImgProperty, value);
@@ -282,7 +396,7 @@ namespace HandyControl.Controls
set
{
if (_showCloseButton == value) return;
GridTop.BeginAnimation(OpacityProperty,
_gridTop.BeginAnimation(OpacityProperty,
value ? AnimationHelper.CreateAnimation(1, 100) : AnimationHelper.CreateAnimation(0, 400));
_showCloseButton = value;
}
@@ -297,7 +411,7 @@ namespace HandyControl.Controls
set
{
if (_showBorderBottom == value) return;
BorderBottom.BeginAnimation(OpacityProperty,
_borderBottom?.BeginAnimation(OpacityProperty,
value ? AnimationHelper.CreateAnimation(1, 100) : AnimationHelper.CreateAnimation(0, 400));
_showBorderBottom = value;
}
@@ -359,7 +473,7 @@ namespace HandyControl.Controls
}
ImageMargin = new Thickness((ActualWidth - ImageWidth) / 2, (ActualHeight - ImageHeight) / 2, 0, 0);
_imgActualScale = ImageScale;
_imgActualScale = 1;
_imgActualMargin = ImageMargin;
}
@@ -420,20 +534,16 @@ namespace HandyControl.Controls
}
}
private void ButtonScreenChange_OnClick(object sender, RoutedEventArgs e) => WindowState = IsFullScreen ? WindowState.Maximized : WindowState.Normal;
//private void ButtonScreenChange_OnClick(object sender, RoutedEventArgs e) => WindowState = IsFullScreen ? WindowState.Maximized : WindowState.Normal;
private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close();
private void CanvasBack_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
private void GridTop_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
try
if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
catch
{
// ignored
}
}
protected override void OnMouseMove(MouseEventArgs e)
@@ -480,7 +590,7 @@ namespace HandyControl.Controls
}
else
{
var right = Math.Abs(BorderMove.Width - CanvasSmallImg.ActualWidth + BorderMove.Margin.Left);
var right = Math.Abs(_borderMove.Width - _canvasSmallImg.ActualWidth + _borderMove.Margin.Left);
if (right < 0.001)
{
marginX = ActualWidth - ImageWidth;
@@ -497,7 +607,7 @@ namespace HandyControl.Controls
}
else
{
var top = Math.Abs(BorderMove.Height - CanvasSmallImg.ActualHeight + BorderMove.Margin.Top);
var top = Math.Abs(_borderMove.Height - _canvasSmallImg.ActualHeight + _borderMove.Margin.Top);
if (top < 0.001)
{
marginY = ActualHeight - ImageHeight;
@@ -513,9 +623,8 @@ namespace HandyControl.Controls
{
base.OnMouseDoubleClick(e);
if (e.GetPosition(GridTop).Y > GridTop.ActualHeight) return;
if (e.GetPosition(_gridTop).Y > _gridTop.ActualHeight) return;
IsFullScreen = !IsFullScreen;
ButtonScreenChange_OnClick(null, null);
}
private void ImageBrowser_OnLoaded(object sender, RoutedEventArgs e)
@@ -532,7 +641,7 @@ namespace HandyControl.Controls
DragMove();
return;
}
_imgMouseDownPoint = Mouse.GetPosition(CanvasMain);
_imgMouseDownPoint = Mouse.GetPosition(_canvasMain);
_imgMouseDownMargin = ImageMargin;
_imgIsMouseLeftButtonDown = true;
e.Handled = true;
@@ -553,7 +662,7 @@ namespace HandyControl.Controls
{
if (!_borderSmallIsLoaded)
{
CanvasSmallImg.Background = new VisualBrush(ImageMain);
_canvasSmallImg.Background = new VisualBrush(_imageMain);
InitBorderSmall();
_borderSmallIsLoaded = true;
}
@@ -571,16 +680,16 @@ namespace HandyControl.Controls
/// </summary>
private void InitBorderSmall()
{
var scaleWindow = CanvasSmallImg.MaxWidth / CanvasSmallImg.MaxHeight;
var scaleWindow = _canvasSmallImg.MaxWidth / _canvasSmallImg.MaxHeight;
if (_imgWidHeiScale > scaleWindow)
{
CanvasSmallImg.Width = CanvasSmallImg.MaxWidth;
CanvasSmallImg.Height = CanvasSmallImg.Width / _imgWidHeiScale;
_canvasSmallImg.Width = _canvasSmallImg.MaxWidth;
_canvasSmallImg.Height = _canvasSmallImg.Width / _imgWidHeiScale;
}
else
{
CanvasSmallImg.Width = CanvasSmallImg.MaxHeight * _imgWidHeiScale;
CanvasSmallImg.Height = CanvasSmallImg.MaxHeight;
_canvasSmallImg.Width = _canvasSmallImg.MaxHeight * _imgWidHeiScale;
_canvasSmallImg.Height = _canvasSmallImg.MaxHeight;
}
}
@@ -594,21 +703,21 @@ namespace HandyControl.Controls
var widthMin = Math.Min(ImageWidth, ActualWidth);
var heightMin = Math.Min(ImageHeight, ActualHeight);
BorderMove.Width = widthMin / ImageWidth * CanvasSmallImg.Width;
BorderMove.Height = heightMin / ImageHeight * CanvasSmallImg.Height;
_borderMove.Width = widthMin / ImageWidth * _canvasSmallImg.Width;
_borderMove.Height = heightMin / ImageHeight * _canvasSmallImg.Height;
var marginX = -ImageMargin.Left / ImageWidth * CanvasSmallImg.Width;
var marginY = -ImageMargin.Top / ImageHeight * CanvasSmallImg.Height;
var marginX = -ImageMargin.Left / ImageWidth * _canvasSmallImg.Width;
var marginY = -ImageMargin.Top / ImageHeight * _canvasSmallImg.Height;
var marginXMax = CanvasSmallImg.Width - BorderMove.Width;
var marginYMax = CanvasSmallImg.Height - BorderMove.Height;
var marginXMax = _canvasSmallImg.Width - _borderMove.Width;
var marginYMax = _canvasSmallImg.Height - _borderMove.Height;
marginX = Math.Max(0, marginX);
marginX = Math.Min(marginXMax, marginX);
marginY = Math.Max(0, marginY);
marginY = Math.Min(marginYMax, marginY);
BorderMove.Margin = new Thickness(marginX, marginY, 0, 0);
_borderMove.Margin = new Thickness(marginX, marginY, 0, 0);
}
/// <summary>
@@ -627,7 +736,7 @@ namespace HandyControl.Controls
ImageScale = tempScale;
var posCanvas = Mouse.GetPosition(CanvasMain);
var posCanvas = Mouse.GetPosition(_canvasMain);
var posImg = new Point(posCanvas.X - _imgActualMargin.Left, posCanvas.Y - _imgActualMargin.Top);
var marginX = .5 * _scaleInternalWidth;
@@ -665,15 +774,15 @@ namespace HandyControl.Controls
var subX = ImageWidth - ActualWidth;
var subY = ImageHeight - ActualHeight;
var right = Math.Abs(BorderMove.Width - CanvasSmallImg.ActualWidth + BorderMove.Margin.Left);
var top = Math.Abs(BorderMove.Height - CanvasSmallImg.ActualHeight + BorderMove.Margin.Top);
var right = Math.Abs(_borderMove.Width - _canvasSmallImg.ActualWidth + _borderMove.Margin.Left);
var top = Math.Abs(_borderMove.Height - _canvasSmallImg.ActualHeight + _borderMove.Margin.Top);
if (Math.Abs(ImageMargin.Left) < 0.001 || right < 0.001)
{
marginActualX = _imgActualMargin.Left + BorderMove.Margin.Left / (CanvasSmallImg.ActualWidth - BorderMove.Width) * _scaleInternalWidth;
marginActualX = _imgActualMargin.Left + _borderMove.Margin.Left / (_canvasSmallImg.ActualWidth - _borderMove.Width) * _scaleInternalWidth;
}
if (Math.Abs(ImageMargin.Top) < 0.001 || top < 0.001)
{
marginActualY = _imgActualMargin.Top + BorderMove.Margin.Top / (CanvasSmallImg.ActualHeight - BorderMove.Height) * _scaleInternalHeight;
marginActualY = _imgActualMargin.Top + _borderMove.Margin.Top / (_canvasSmallImg.ActualHeight - _borderMove.Height) * _scaleInternalHeight;
}
if (subX < 0.001)
{
@@ -716,7 +825,7 @@ namespace HandyControl.Controls
/// </summary>
private void MoveImg()
{
_imgCurrentPoint = Mouse.GetPosition(CanvasMain);
_imgCurrentPoint = Mouse.GetPosition(_canvasMain);
ShowCloseButton = _imgCurrentPoint.Y < 200;
ShowBorderBottom = _imgCurrentPoint.Y > ActualHeight - 200;
@@ -769,7 +878,7 @@ namespace HandyControl.Controls
{
if (_imgSmallIsMouseLeftButtonDown)
{
_imgSmallCurrentPoint = Mouse.GetPosition(CanvasSmallImg);
_imgSmallCurrentPoint = Mouse.GetPosition(_canvasSmallImg);
var subX = _imgSmallCurrentPoint.X - _imgSmallMouseDownPoint.X;
var subY = _imgSmallCurrentPoint.Y - _imgSmallMouseDownPoint.Y;
@@ -779,9 +888,9 @@ namespace HandyControl.Controls
{
marginX = 0;
}
else if (marginX + BorderMove.Width >= CanvasSmallImg.ActualWidth)
else if (marginX + _borderMove.Width >= _canvasSmallImg.ActualWidth)
{
marginX = CanvasSmallImg.ActualWidth - BorderMove.Width;
marginX = _canvasSmallImg.ActualWidth - _borderMove.Width;
}
var marginY = _imgSmallMouseDownMargin.Top + subY;
@@ -789,22 +898,22 @@ namespace HandyControl.Controls
{
marginY = 0;
}
else if (marginY + BorderMove.Height >= CanvasSmallImg.ActualHeight)
else if (marginY + _borderMove.Height >= _canvasSmallImg.ActualHeight)
{
marginY = CanvasSmallImg.ActualHeight - BorderMove.Height;
marginY = _canvasSmallImg.ActualHeight - _borderMove.Height;
}
BorderMove.Margin = new Thickness(marginX, marginY, 0, 0);
_borderMove.Margin = new Thickness(marginX, marginY, 0, 0);
var marginActualX = (ActualWidth - ImageWidth) / 2;
var marginActualY = (ActualHeight - ImageHeight) / 2;
if (_canMoveX)
{
marginActualX = -marginX / CanvasSmallImg.ActualWidth * ImageWidth;
marginActualX = -marginX / _canvasSmallImg.ActualWidth * ImageWidth;
}
if (_canMoveY)
{
marginActualY = -marginY / CanvasSmallImg.ActualHeight * ImageHeight;
marginActualY = -marginY / _canvasSmallImg.ActualHeight * ImageHeight;
}
ImageMargin = new Thickness(marginActualX, marginActualY, 0, 0);
@@ -814,8 +923,8 @@ namespace HandyControl.Controls
private void CanvasSmallImg_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
_imgSmallMouseDownPoint = Mouse.GetPosition(CanvasSmallImg);
_imgSmallMouseDownMargin = BorderMove.Margin;
_imgSmallMouseDownPoint = Mouse.GetPosition(_canvasSmallImg);
_imgSmallMouseDownMargin = _borderMove.Margin;
_imgSmallIsMouseLeftButtonDown = true;
e.Handled = true;
}
@@ -1,81 +0,0 @@
<controls:WindowBorderless x:Class="HandyControl.Controls.ImageBrowser"
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"
x:Name="UserControlMain"
Loaded="ImageBrowser_OnLoaded"
Background="Transparent"
d:DesignHeight="500"
MinWidth="400"
MinHeight="250"
d:DesignWidth="800"
BorderThickness="1"
BorderBrush="Black"
WindowStartupLocation="CenterScreen"
AllowsTransparency="True"
WindowStyle="None">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid x:Name="CanvasMain" ClipToBounds="True" MouseLeftButtonDown="CanvasBack_OnMouseLeftButtonDown" Grid.RowSpan="2" Background="#dd000000">
<Border HorizontalAlignment="Left" VerticalAlignment="Top" Height="{Binding ImageHeight,ElementName=UserControlMain}" Width="{Binding ImageWidth,ElementName=UserControlMain}" Margin="{Binding ImageMargin,ElementName=UserControlMain}">
<Image Name="ImageMain" RenderTransformOrigin="0.5,0.5" MouseLeftButtonDown="ImageMain_OnMouseLeftButtonDown" Source="{Binding ImageSource,ElementName=UserControlMain}">
<Image.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="{Binding ImageRotate,ElementName=UserControlMain}"/>
</TransformGroup>
</Image.LayoutTransform>
</Image>
</Border>
</Grid>
<Border MouseMove="CanvasSmallImg_OnMouseMove" MouseLeftButtonUp="CanvasSmallImg_OnMouseLeftButtonUp" MouseLeftButtonDown="CanvasSmallImg_OnMouseLeftButtonDown" MouseLeave="CanvasSmallImg_OnMouseLeave" Visibility="{Binding ShowSmallImg,ElementName=UserControlMain,Converter={StaticResource Boolean2VisibilityConverter}}" Grid.Row="0" Grid.RowSpan="2" Width="252" Height="162" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#44000000" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1">
<Canvas ClipToBounds="True" Name="CanvasSmallImg" MaxWidth="250" MaxHeight="160">
<Border UseLayoutRounding="True" Name="BorderMove" Background="Transparent" Width="50" Height="70" BorderThickness="1" BorderBrush="Black">
<Border BorderThickness="1" BorderBrush="White">
</Border>
</Border>
</Canvas>
</Border>
<Border UseLayoutRounding="True" Name="BorderBottom" Opacity="0" CornerRadius="4,4,0,0" Grid.Row="1" HorizontalAlignment="Center" Background="#44000000">
<StackPanel Margin="30,10" VerticalAlignment="Center" Orientation="Horizontal">
<Button Click="ButtonSave_OnClick" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource SaveGeometry}" Padding="3"/>
<Button Click="ButtonWindowsOpen_OnClick" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource WindowsGeometry}" Padding="3"/>
<Border Margin="10,2" Style="{StaticResource BorderHorizontallySplitter}"/>
<Button Click="ButtonReduce_OnClick" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource ReduceGeometry}" Padding="3"/>
<TextBlock Margin="6,0" Text="{Binding ScaleStr,ElementName=UserControlMain}" Style="{StaticResource TextBlockSubTitle}" Foreground="{DynamicResource TextIconBrush}"/>
<Button Click="ButtonEnlarge_OnClick" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource EnlargeGeometry}" Padding="3"/>
<Button Background="Transparent" Click="ButtonActual_OnClick" Margin="6,0" Style="{StaticResource ButtonCustom}" Foreground="White">
<Border BorderThickness="1" BorderBrush="White" Padding="2">
<TextBlock Text="1:1"/>
</Border>
</Button>
<Border Margin="10,2" Style="{StaticResource BorderHorizontallySplitter}"/>
<Button Click="ButtonRotateLeft_OnClick" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3"/>
<Button Click="ButtonRotateRight_OnClick" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3" RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Button.RenderTransform>
</Button>
<ToggleButton Foreground="{StaticResource TextIconBrush}" IsChecked="{Binding IsFullScreen,ElementName=UserControlMain}" Click="ButtonScreenChange_OnClick" Margin="6,0" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource FullScreenGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource FullScreenReturnGeometry}" Padding="3"/>
</StackPanel>
</Border>
<Grid Name="GridTop" Opacity="0" Background="#44000000" MouseLeftButtonDown="CanvasBack_OnMouseLeftButtonDown" VerticalAlignment="Top" Grid.Row="0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="{Binding ImgPath,ElementName=UserControlMain}" Foreground="White" Margin="10,0,0,0"/>
<TextBlock Text="{Binding ImgSize,ElementName=UserControlMain,Converter={StaticResource Long2FileSizeConverter}}" Foreground="White" Margin="30,0,0,0"/>
</StackPanel>
<Button WindowChrome.IsHitTestVisibleInChrome="True" Click="ButtonClose_OnClick" Background="Red" Grid.Row="0" Padding="14" controls:IconElement.Geometry="{StaticResource DeleteGeometry}" Style="{StaticResource ButtonIcon}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="40" Height="40"/>
</Grid>
</Grid>
</controls:WindowBorderless>
+10 -25
View File
@@ -47,6 +47,7 @@
<Compile Include="Controls\Clock\Clock.cs" />
<Compile Include="Controls\Clock\ClockRadioButton.cs" />
<Compile Include="Controls\Growl.cs" />
<Compile Include="Controls\NumericUpDown.cs" />
<Compile Include="Controls\Pagination.cs" />
<Compile Include="Controls\Picker\ColorPicker.xaml.cs">
<DependentUpon>ColorPicker.xaml</DependentUpon>
@@ -54,13 +55,6 @@
<Compile Include="Controls\Attach\IconElement.cs" />
<Compile Include="Controls\CompareSlider.cs" />
<Compile Include="Controls\ScrollViewer.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="Controls\Loading\LoadingBase.cs" />
<Compile Include="Controls\Loading\LoadingCircle.cs" />
<Compile Include="Controls\Loading\LoadingLine.cs" />
@@ -74,9 +68,7 @@
<Compile Include="Controls\TimeBar\TimeBar.cs" />
<Compile Include="Controls\TransitioningContentControl.cs" />
<Compile Include="Controls\WatermarkTextBox.cs" />
<Compile Include="Controls\Window\ImageBrowser.xaml.cs">
<DependentUpon>ImageBrowser.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Window\ImageBrowser.cs" />
<Compile Include="Controls\Window\PopupWindow.cs" />
<Compile Include="Controls\Window\WindowBorderless.cs" />
<Compile Include="Data\BooleanBoxes.cs" />
@@ -153,26 +145,11 @@
<Compile Include="Tools\ValidateHelper.cs" />
<Compile Include="Tools\VisualStates.cs" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\colorPickerBack.png" />
</ItemGroup>
<ItemGroup>
<Page Include="Controls\Picker\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="Controls\Window\ImageBrowser.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Basic\Basic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -213,6 +190,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\NumericUpDownBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\TabControlBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -337,6 +318,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\NumericUpDown.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Pagination.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+36 -1
View File
@@ -3,10 +3,45 @@
namespace HandyControl.Interactivity
{
/// <summary>
/// 控件库使用的所有命令
/// 控件库使用的所有命令(为了统一,不使用wpf自带的命令)
/// </summary>
public static class ControlCommands
{
/// <summary>
/// 右转
/// </summary>
public static RoutedCommand RotateRight { get; } = new RoutedCommand("RotateRight", typeof(ControlCommands));
/// <summary>
/// 左转
/// </summary>
public static RoutedCommand RotateLeft { get; } = new RoutedCommand("RotateLeft", typeof(ControlCommands));
/// <summary>
/// 小
/// </summary>
public static RoutedCommand Reduce { get; } = new RoutedCommand("Reduce", typeof(ControlCommands));
/// <summary>
/// 大
/// </summary>
public static RoutedCommand Enlarge { get; } = new RoutedCommand("Enlarge", typeof(ControlCommands));
/// <summary>
/// 还原
/// </summary>
public static RoutedCommand Restore { get; } = new RoutedCommand("Restore", typeof(ControlCommands));
/// <summary>
/// 打开
/// </summary>
public static RoutedCommand Open { get; } = new RoutedCommand("Open", typeof(ControlCommands));
/// <summary>
/// 保存
/// </summary>
public static RoutedCommand Save { get; } = new RoutedCommand("Save", typeof(ControlCommands));
/// <summary>
/// 选中
/// </summary>
+2 -2
View File
@@ -10,5 +10,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.3.2.2")]
[assembly: AssemblyFileVersion("1.3.2.2")]
[assembly: AssemblyVersion("1.3.3")]
[assembly: AssemblyFileVersion("1.3.3")]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

@@ -512,7 +512,6 @@
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Height" Value="30"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
@@ -34,7 +34,6 @@
<Setter Property="SelectedDateFormat" Value="Short"/>
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="BorderThickness" Value="1"/>
@@ -0,0 +1,60 @@
<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"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Basic/Geometries.xaml"/>
<ResourceDictionary Source="../../Basic/Converters.xaml"/>
<ResourceDictionary Source="../Button.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="NumericUpDownBaseStyle" TargetType="controls:NumericUpDown">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="controls:BorderElement.CornerRadius" Value="4"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="Height" Value="30"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:NumericUpDown">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2" x:Name="border" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<TextBox Focusable="True" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Background="Transparent" x:Name="PART_TextBox" BorderThickness="0" Style="{x:Null}" Padding="{TemplateBinding Padding}" Margin="0,0,30,1" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<Button Visibility="{TemplateBinding ShowUpDownButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Prev" Padding="5,7,5,1" Margin="0,0,0,16" Focusable="False" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=border}" controls:IconElement.Geometry="{StaticResource UpGeometry}" Style="{StaticResource ButtonIcon}" Width="30" VerticalAlignment="Center" Height="14"/>
<Button Visibility="{TemplateBinding ShowUpDownButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Next" Padding="5,1,5,7" Margin="0,16,0,0" Focusable="False" Grid.Column="1" Foreground="{Binding BorderBrush,ElementName=border}" controls:IconElement.Geometry="{StaticResource DownGeometry}" Style="{StaticResource ButtonIcon}" Width="30" VerticalAlignment="Center" Height="14"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.4"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryTextBrush}"/>
</Trigger>
<Trigger Property="IsFocused" Value="true" SourceName="PART_TextBox">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource PrimaryBrush}"/>
</Trigger>
<Trigger Property="ShowUpDownButton" Value="False">
<Setter Property="Margin" TargetName="PART_TextBox" Value="0,0,0,1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -13,7 +13,6 @@
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="Height" Value="30"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
@@ -36,7 +36,6 @@
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Padding" Value="6"/>
<Setter Property="Height" Value="30"/>
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
@@ -12,7 +12,6 @@
<Setter Property="controls:BorderElement.CornerRadius" Value="4"/>
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Width" Value="240"/>
<Setter Property="Height" Value="30"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
@@ -14,9 +14,6 @@
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid>
<Border Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}"/>
<!--<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>-->
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
<Path x:Name="PathMain" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding controls:IconElement.Geometry}" RenderTransformOrigin="0.5,0.5">
+2 -2
View File
@@ -9,13 +9,13 @@
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
</Style>
<Style x:Key="BorderHorizontallySplitter" TargetType="{x:Type Border}">
<Style x:Key="BorderVerticallySplitter" TargetType="{x:Type Border}">
<Setter Property="Width" Value="1"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Background" Value="{DynamicResource ThirdlyTextBrush}"/>
</Style>
<Style x:Key="BorderVerticallySplitter" TargetType="{x:Type Border}">
<Style x:Key="BorderHorizontallySplitter" TargetType="{x:Type Border}">
<Setter Property="Height" Value="1"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Background" Value="{DynamicResource ThirdlyTextBrush}"/>
+2 -2
View File
@@ -45,11 +45,11 @@
<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>
<!--<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="{Binding Path=(controls:IconElement.Angle),RelativeSource={RelativeSource TemplatedParent}}"/>
</TransformGroup>
</Path.RenderTransform>
</Path.RenderTransform>-->
</Path>
</ContentControl>
</Border>
@@ -0,0 +1,13 @@
<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="../Basic/Converters.xaml"/>
<ResourceDictionary Source="Base/NumericUpDownBaseStyle.xaml"/>
<ResourceDictionary Source="TextBlock.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource NumericUpDownBaseStyle}" TargetType="controls:NumericUpDown"/>
</ResourceDictionary>
+1
View File
@@ -20,6 +20,7 @@
<ResourceDictionary Source="Expander.xaml"/>
<ResourceDictionary Source="TextBox.xaml"/>
<ResourceDictionary Source="ComboBox.xaml"/>
<ResourceDictionary Source="NumericUpDown.xaml"/>
<ResourceDictionary Source="PasswordBox.xaml"/>
<ResourceDictionary Source="Calendar.xaml"/>
<ResourceDictionary Source="DatePicker.xaml"/>
+79
View File
@@ -6,6 +6,8 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Button.xaml"/>
<ResourceDictionary Source="TextBlock.xaml"/>
<ResourceDictionary Source="Border.xaml"/>
<ResourceDictionary Source="ToggleButton.xaml"/>
<ResourceDictionary Source="../Basic/Converters.xaml"/>
<ResourceDictionary Source="../Basic/Paths.xaml"/>
@@ -205,4 +207,81 @@
</Style.Triggers>
</Style>
<Style TargetType="controls:ImageBrowser">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="MinWidth" Value="400"/>
<Setter Property="MinHeight" Value="250"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:ImageBrowser">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid x:Name="PART_GridMain" ClipToBounds="True" Grid.RowSpan="2" Background="#dd000000">
<Border HorizontalAlignment="Left" VerticalAlignment="Top" Height="{TemplateBinding ImageHeight}" Width="{TemplateBinding ImageWidth}" Margin="{TemplateBinding ImageMargin}">
<Image Name="PART_ImageMain" RenderTransformOrigin="0.5,0.5" Source="{TemplateBinding ImageSource}">
<Image.LayoutTransform>
<RotateTransform Angle="{Binding ImageRotate,RelativeSource={RelativeSource TemplatedParent}}"/>
</Image.LayoutTransform>
</Image>
</Border>
</Grid>
<Border Visibility="{TemplateBinding ShowSmallImg,Converter={StaticResource Boolean2VisibilityConverter}}" Grid.Row="0" Grid.RowSpan="2" Width="252" Height="162" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="{DynamicResource DarkOpacityBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
<Canvas ClipToBounds="True" Name="PART_CanvasSmallImg" MaxWidth="250" MaxHeight="160">
<Border UseLayoutRounding="True" Name="PART_BorderMove" Background="Transparent" Width="50" Height="70" BorderThickness="1" BorderBrush="Black">
<Border BorderThickness="1" BorderBrush="White"/>
</Border>
</Canvas>
</Border>
<Border UseLayoutRounding="True" Name="PART_BorderBottom" Opacity="0" CornerRadius="4,4,0,0" Grid.Row="1" HorizontalAlignment="Center" Background="{DynamicResource DarkOpacityBrush}">
<StackPanel Margin="30,10" VerticalAlignment="Center" Orientation="Horizontal">
<Button Command="interactivity:ControlCommands.Save" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource SaveGeometry}" Padding="3"/>
<Button Command="interactivity:ControlCommands.Open" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource WindowsGeometry}" Padding="3"/>
<Border Margin="10,2" Style="{StaticResource BorderVerticallySplitter}"/>
<Button Command="interactivity:ControlCommands.Reduce" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource ReduceGeometry}" Padding="3"/>
<TextBlock Margin="6,0" Text="{TemplateBinding ScaleStr}" Style="{StaticResource TextBlockSubTitle}" Foreground="{DynamicResource TextIconBrush}"/>
<Button Command="interactivity:ControlCommands.Enlarge" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource EnlargeGeometry}" Padding="3"/>
<Button Command="interactivity:ControlCommands.Restore" Background="Transparent" Margin="6,0" Style="{StaticResource ButtonCustom}" Foreground="White">
<Border BorderThickness="1" BorderBrush="White" Padding="2">
<TextBlock Text="1:1"/>
</Border>
</Button>
<Border Margin="10,2" Style="{StaticResource BorderVerticallySplitter}"/>
<Button Command="interactivity:ControlCommands.RotateLeft" CommandParameter="" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3"/>
<Button Command="interactivity:ControlCommands.RotateRight" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3" RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="1" ScaleX="-1"/>
</TransformGroup>
</Button.RenderTransform>
</Button>
<ToggleButton Foreground="{DynamicResource TextIconBrush}" IsChecked="{Binding IsFullScreen,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:ImageBrowser},Mode=TwoWay}" Margin="6,0" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource FullScreenGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource FullScreenReturnGeometry}" Padding="3"/>
</StackPanel>
</Border>
<Grid Name="PART_GridTop" Opacity="0" Background="{DynamicResource DarkOpacityBrush}" VerticalAlignment="Top" Grid.Row="0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="{TemplateBinding ImgPath}" Foreground="White" Margin="10,0,0,0"/>
<TextBlock Text="{TemplateBinding ImgSize,Converter={StaticResource Long2FileSizeConverter}}" Foreground="White" Margin="30,0,0,0"/>
</StackPanel>
<Button Command="interactivity:ControlCommands.Close" WindowChrome.IsHitTestVisibleInChrome="True" Background="Red" Grid.Row="0" Padding="14" controls:IconElement.Geometry="{StaticResource DeleteGeometry}" Style="{StaticResource ButtonIcon}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="40" Height="40"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsFullScreen" Value="True">
<Setter Property="WindowState" Value="Maximized"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
+2
View File
@@ -28,6 +28,8 @@
public static readonly string CirclePanelDemoCtl = nameof(CirclePanelDemoCtl);
public static readonly string NumericUpDownDemoCtl = nameof(NumericUpDownDemoCtl);
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
+2 -1
View File
@@ -16,7 +16,8 @@ var controlList = new List<string>
"StepBarDemoCtl",
"ClockDemoCtl",
"TimePickerDemoCtl",
"CirclePanelDemoCtl"
"CirclePanelDemoCtl",
"NumericUpDownDemoCtl"
};
var styleList = new List<string>
{
+7
View File
@@ -106,6 +106,9 @@
<Compile Include="UserControl\Controls\LoadingDemoCtl.xaml.cs">
<DependentUpon>LoadingDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\NumericUpDownDemoCtl.xaml.cs">
<DependentUpon>NumericUpDownDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\StepBarDemoCtl.xaml.cs">
<DependentUpon>StepBarDemoCtl.xaml</DependentUpon>
</Compile>
@@ -248,6 +251,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\NumericUpDownDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\StepBarDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
+2 -2
View File
@@ -12,5 +12,5 @@ using System.Windows;
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.3.2.2")]
[assembly: AssemblyFileVersion("1.3.2.2")]
[assembly: AssemblyVersion("1.3.3")]
[assembly: AssemblyFileVersion("1.3.3")]
+9
View File
@@ -330,6 +330,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 数值选择控件 的本地化字符串。
/// </summary>
public static string NumericUpDown {
get {
return ResourceManager.GetString("NumericUpDown", resourceCulture);
}
}
/// <summary>
/// 查找类似 点击打开图片浏览器 的本地化字符串。
/// </summary>
@@ -282,4 +282,7 @@
<data name="ComboBox" xml:space="preserve">
<value>ComboBox</value>
</data>
<data name="NumericUpDown" xml:space="preserve">
<value>NumericUpDown</value>
</data>
</root>
@@ -262,4 +262,7 @@
<data name="ComboBox" xml:space="preserve">
<value>组合框</value>
</data>
<data name="NumericUpDown" xml:space="preserve">
<value>数值选择控件</value>
</data>
</root>
@@ -0,0 +1,11 @@
<UserControl x:Class="HandyControlDemo.UserControl.NumericUpDownDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
Background="White">
<controls:TransitioningContentControl>
<StackPanel Margin="32">
<controls:NumericUpDown x:Name="NumericUpDown" Width="240"/>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,11 @@
// ReSharper disable once CheckNamespace
namespace HandyControlDemo.UserControl
{
public partial class NumericUpDownDemoCtl
{
public NumericUpDownDemoCtl()
{
InitializeComponent();
}
}
}
@@ -25,11 +25,12 @@
<ListBoxItem Tag="{x:Static data:MessageToken.ProgressBarDemoCtl}" Content="{x:Static langs:Lang.ProgressBar}"/>
<ListBoxItem Tag="{x:Static data:MessageToken.CalendarDemoCtl}" Content="{x:Static langs:Lang.Calendar}"/>
<ListBoxItem Tag="{x:Static data:MessageToken.DatePickerDemoCtl}" Content="{x:Static langs:Lang.DatePicker}"/>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.NaiveTabControlDemoCtl}" Content="{x:Static langs:Lang.TabControl}"/>
<ListBoxItem Tag="{x:Static data:MessageToken.NaiveTabControlDemoCtl}" Content="{x:Static langs:Lang.TabControl}"/>
</ListBox>
</TabItem>
<TabItem Header="{x:Static langs:Lang.Controls}">
<ListBox BorderThickness="0" SelectionMode="Single">
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.NumericUpDownDemoCtl}" Content="{x:Static langs:Lang.NumericUpDown}"/>
<ListBoxItem Tag="{x:Static data:MessageToken.CirclePanelDemoCtl}" Content="{x:Static langs:Lang.CirclePanel}"/>
<ListBoxItem Tag="{x:Static data:MessageToken.ClockDemoCtl}" Content="{x:Static langs:Lang.Clock}"/>
<ListBoxItem Tag="{x:Static data:MessageToken.TimePickerDemoCtl}" Content="{x:Static langs:Lang.TimePicker}"/>
@@ -47,40 +48,4 @@
</ListBox>
</TabItem>
</TabControl>
<!--<TreeView controls:ScrollViewer.IsEnableInertia="True" BorderThickness="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<command:EventToCommand Command="{Binding SwitchDemoCmd}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<TreeViewItem IsExpanded="True" Header="{x:Static langs:Lang.Styles}">
<TreeViewItem Tag="{x:Static data:MessageToken.ButtonDemoCtl}" Header="{x:Static langs:Lang.Button}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ToggleButtonDemoCtl}" Header="{x:Static langs:Lang.ToggleButton}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.TextBlockDemoCtl}" Header="{x:Static langs:Lang.TextBlock}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.TextBoxDemoCtl}" Header="{x:Static langs:Lang.TextBox}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ComboBoxDemoCtl}" Header="{x:Static langs:Lang.ComboBox}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.PasswordBoxDemoCtl}" Header="{x:Static langs:Lang.PasswordBox}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ExpanderDemoCtl}" Header="{x:Static langs:Lang.Expander}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ProgressBarDemoCtl}" Header="{x:Static langs:Lang.ProgressBar}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.CalendarDemoCtl}" Header="{x:Static langs:Lang.Calendar}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.DatePickerDemoCtl}" Header="{x:Static langs:Lang.DatePicker}"/>
<TreeViewItem Style="{StaticResource TreeViewItemNew}" Tag="{x:Static data:MessageToken.NaiveTabControlDemoCtl}" Header="{x:Static langs:Lang.TabControl}"/>
</TreeViewItem>
<TreeViewItem IsExpanded="True" Header="{x:Static langs:Lang.Controls}">
<TreeViewItem Tag="{x:Static data:MessageToken.CirclePanelDemoCtl}" Header="{x:Static langs:Lang.CirclePanel}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ClockDemoCtl}" Header="{x:Static langs:Lang.Clock}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.TimePickerDemoCtl}" Header="{x:Static langs:Lang.TimePicker}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.StepBarDemoCtl}" Header="{x:Static langs:Lang.StepBar}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.GrowlDemoCtl}" Header="{x:Static langs:Lang.Growl}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.LoadingDemoCtl}" Header="{x:Static langs:Lang.Loading}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ImageBrowserDemoCtl}" Header="{x:Static langs:Lang.ImageBrowser}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.ColorPickerDemoCtl}" Header="{x:Static langs:Lang.ColorPicker}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.CarouselDemoCtl}" Header="{x:Static langs:Lang.Carousel}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.CompareSliderDemoCtl}" Header="{x:Static langs:Lang.CompareSlider}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.TimeBarDemoCtl}" Header="{x:Static langs:Lang.TimeBar}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.PaginationDemoCtl}" Header="{x:Static langs:Lang.Pagination}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.AnimationPathDemoCtl}" Header="{x:Static langs:Lang.AnimationPath}"/>
<TreeViewItem Tag="{x:Static data:MessageToken.TabControlDemoCtl}" Header="{x:Static langs:Lang.TabControl}"/>
</TreeViewItem>
</TreeView>-->
</Border>