update to v1.2.1

This commit is contained in:
NaBian committed 2018-09-11 12:00:52 +08:00
1 parent f9475c318c
commit be950fac36
75 files changed
+2810 -288

No files matched your search

@@ -0,0 +1,23 @@
using System.Windows.Controls;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
/// <summary>
/// 带上下文菜单的按钮
/// </summary>
public class ContextMenuButton : Button
{
public ContextMenu Menu { get; set; }
protected override void OnClick()
{
base.OnClick();
if (Menu != null)
{
Menu.PlacementTarget = this;
Menu.IsOpen = true;
}
}
}
}
@@ -0,0 +1,31 @@
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
/// <summary>
/// 带上下文菜单的切换按钮
/// </summary>
public class ContextMenuToggleButton : ToggleButton
{
public ContextMenu Menu { get; set; }
protected override void OnClick()
{
base.OnClick();
if (Menu != null)
{
if (IsChecked == true)
{
Menu.PlacementTarget = this;
Menu.IsOpen = true;
}
else
{
Menu.IsOpen = false;
}
}
}
}
}
+3 -2
View File
@@ -8,6 +8,7 @@
mc:Ignorable="d"
Name="UserControlMain"
Width="230"
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
UseLayoutRounding="True">
<Grid>
<Grid.RowDefinitions>
@@ -86,8 +87,8 @@
</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>
<Button Click="ButtonCancel_OnClick" Content="{x:Static langs:Lang.Cancel}" Width="80" Margin="0,0,16,0"></Button>
<Button Click="ButtonSure_OnClick" Content="{x:Static langs:Lang.Confirm}" Width="80" Style="{StaticResource ButtonPrimary}"></Button>
</StackPanel>
</Border>
</Grid>
+1 -5
View File
@@ -108,16 +108,12 @@ namespace HandyControl.Controls
GrowlPanel = panel;
var menuItem = new MenuItem
{
Header = "清空消息"
Header = Properties.Langs.Lang.Clear
};
menuItem.Click += (s, e) =>
{
foreach (var item in GrowlPanel.Children.OfType<Growl>())
{
//if (item.CloseAction != null)
//{
// item.Close();
//}
item.Close();
}
};
@@ -44,7 +44,7 @@
</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>
<TextBlock Style="{StaticResource TextBlockDefault}" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource String2VisibilityReConverter}}" 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">
@@ -56,7 +56,7 @@
</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 Padding="7" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityReConverter}}" 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>
+2 -2
View File
@@ -43,7 +43,7 @@
</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>
<TextBlock Style="{StaticResource TextBlockDefault}" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=Self},Converter={StaticResource String2VisibilityReConverter}}" 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">
@@ -54,7 +54,7 @@
</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>
<Button Padding="7" Visibility="{Binding Text,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource String2VisibilityReConverter}}" 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>
@@ -0,0 +1,225 @@
using System;
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using HandyControl.Tools.Extension;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
[TemplatePart(Name = OverflowButtonKey, Type = typeof(ContextMenuToggleButton))]
[TemplatePart(Name = HeaderPanelKey, Type = typeof(TabPanel))]
public class TabControl : System.Windows.Controls.TabControl
{
private const string OverflowButtonKey = "PART_OverflowButton";
private const string HeaderPanelKey = "PART_HeaderPanel";
private ContextMenuToggleButton _buttonOverflow;
private TabPanel _headerPanel;
/// <summary>
/// 是否为内部操作
/// </summary>
internal bool IsInternalAction;
/// <summary>
/// 是否启用动画
/// </summary>
public static readonly DependencyProperty IsEnableAnimationProperty = DependencyProperty.Register(
"IsEnableAnimation", typeof(bool), typeof(TabControl), new PropertyMetadata(default(bool)));
/// <summary>
/// 是否启用动画
/// </summary>
public bool IsEnableAnimation
{
get => (bool)GetValue(IsEnableAnimationProperty);
set => SetValue(IsEnableAnimationProperty, value);
}
/// <summary>
/// 是否可以拖动
/// </summary>
public static readonly DependencyProperty IsDraggableProperty = DependencyProperty.Register(
"IsDraggable", typeof(bool), typeof(TabControl), new PropertyMetadata(default(bool)));
/// <summary>
/// 是否可以拖动
/// </summary>
public bool IsDraggable
{
get => (bool)GetValue(IsDraggableProperty);
set => SetValue(IsDraggableProperty, value);
}
/// <summary>
/// 是否显示关闭按钮
/// </summary>
public static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.Register(
"ShowCloseButton", typeof(bool), typeof(TabControl), new PropertyMetadata(default(bool)));
/// <summary>
/// 是否显示关闭按钮
/// </summary>
public bool ShowCloseButton
{
get => (bool)GetValue(ShowCloseButtonProperty);
set => SetValue(ShowCloseButtonProperty, value);
}
/// <summary>
/// 是否将标签填充
/// </summary>
public static readonly DependencyProperty IsEnableTabFillProperty = DependencyProperty.Register(
"IsEnableTabFill", typeof(bool), typeof(TabControl), new PropertyMetadata(default(bool)));
/// <summary>
/// 是否将标签填充
/// </summary>
public bool IsEnableTabFill
{
get => (bool)GetValue(IsEnableTabFillProperty);
set => SetValue(IsEnableTabFillProperty, value);
}
/// <summary>
/// 标签宽度
/// </summary>
public static readonly DependencyProperty TabItemWidthProperty = DependencyProperty.Register(
"TabItemWidth", typeof(double), typeof(TabControl), new PropertyMetadata(200.0));
/// <summary>
/// 标签宽度
/// </summary>
public double TabItemWidth
{
get => (double)GetValue(TabItemWidthProperty);
set => SetValue(TabItemWidthProperty, value);
}
/// <summary>
/// 标签高度
/// </summary>
public static readonly DependencyProperty TabItemHeightProperty = DependencyProperty.Register(
"TabItemHeight", typeof(double), typeof(TabControl), new PropertyMetadata(30.0));
/// <summary>
/// 标签高度
/// </summary>
public double TabItemHeight
{
get => (double)GetValue(TabItemHeightProperty);
set => SetValue(TabItemHeightProperty, value);
}
/// <summary>
/// 可见的标签数量
/// </summary>
private int _itemShowCount;
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
if (_headerPanel == null)
{
IsInternalAction = false;
return;
}
if (!IsEnableTabFill)
{
_itemShowCount = (int)(ActualWidth / TabItemWidth);
_buttonOverflow.Show(Items.Count >= _itemShowCount);
}
if (IsInternalAction)
{
IsInternalAction = false;
return;
}
if (IsEnableAnimation)
{
_headerPanel.ClearValue(TabPanel.FluidMoveDurationProperty);
}
else
{
_headerPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
}
if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (UIElement item in e.NewItems)
{
item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
}
}
IsInternalAction = false;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_headerPanel = Template.FindName(HeaderPanelKey, this) as TabPanel;
if (IsEnableTabFill) return;
_buttonOverflow = Template.FindName(OverflowButtonKey, this) as ContextMenuToggleButton;
if (_buttonOverflow != null)
{
_itemShowCount = (int)(ActualWidth / TabItemWidth);
_buttonOverflow.Show(Items.Count >= _itemShowCount);
var menu = new ContextMenu
{
Placement = PlacementMode.Bottom,
PlacementTarget = _buttonOverflow
};
menu.Closed += (s, e) => _buttonOverflow.IsChecked = false;
_buttonOverflow.Menu = menu;
_buttonOverflow.Click += (s, e) =>
{
if (_buttonOverflow.IsChecked == true)
{
_buttonOverflow.Menu.Items.Clear();
foreach (TabItem item in Items)
{
var menuItem = new MenuItem
{
Header = item.Header,
Width = TabItemWidth,
IsChecked = item.IsSelected,
IsCheckable = true
};
menuItem.Click += delegate
{
_buttonOverflow.IsChecked = false;
var index = Items.IndexOf(item);
if (index >= _itemShowCount)
{
Items.Remove(item);
Items.Insert(0, item);
if (IsEnableAnimation)
{
_headerPanel.ClearValue(TabPanel.FluidMoveDurationProperty);
}
else
{
_headerPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
}
_headerPanel.ForceUpdate = true;
_headerPanel.Measure(new Size(_headerPanel.DesiredSize.Width, ActualHeight));
_headerPanel.ForceUpdate = false;
}
item.IsSelected = true;
};
_buttonOverflow.Menu.Items.Add(menuItem);
}
}
};
}
}
}
}
+304
View File
@@ -0,0 +1,304 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using HandyControl.Tools;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
[TemplatePart(Name = CloseButtonKey, Type = typeof(Button))]
public class TabItem : System.Windows.Controls.TabItem
{
private const string CloseButtonKey = "PART_CloseButton";
private Button _buttonClose;
/// <summary>
/// 动画速度
/// </summary>
private const int AnimationSpeed = 150;
/// <summary>
/// 选项卡是否处于拖动状态
/// </summary>
private static bool ItemIsDragging;
/// <summary>
/// 选项卡是否等待被拖动
/// </summary>
private bool _isWaiting;
/// <summary>
/// 拖动中的选项卡坐标
/// </summary>
private Point _dragPoint;
/// <summary>
/// 鼠标按下时选项卡位置
/// </summary>
private int _mouseDownIndex;
/// <summary>
/// 鼠标按下时选项卡横向偏移
/// </summary>
private double _mouseDownOffsetX;
/// <summary>
/// 鼠标按下时的坐标
/// </summary>
private Point _mouseDownPoint;
/// <summary>
/// 右侧可移动的最大值
/// </summary>
private double _maxMoveRight;
/// <summary>
/// 左侧可移动的最大值
/// </summary>
private double _maxMoveLeft;
/// <summary>
/// 选项卡宽度
/// </summary>
public double ItemWidth { get; internal set; }
/// <summary>
/// 选项卡拖动等待距离(在鼠标移动了超过20个像素无关单位后,选项卡才开始被拖动)
/// </summary>
private const double WaitLength = 20;
/// <summary>
/// 选项卡是否处于拖动状态
/// </summary>
private bool _isDragging;
/// <summary>
/// 选项卡是否已经被拖动
/// </summary>
private bool _isDragged;
/// <summary>
/// 目标横向位移
/// </summary>
internal double TargetOffsetX { get; set; }
/// <summary>
/// 当前编号
/// </summary>
private int _currentIndex;
/// <summary>
/// 标签容器
/// </summary>
private TabPanel _tabPanel;
/// <summary>
/// 当前编号
/// </summary>
internal int CurrentIndex
{
get => _currentIndex;
set
{
if (_currentIndex == value || value < 0) return;
var oldIndex = _currentIndex;
_currentIndex = value;
UpdateItemOffsetX(oldIndex);
}
}
private bool _isLoaded;
/// <summary>
/// 更新选项卡横向偏移
/// </summary>
/// <param name="oldIndex"></param>
private void UpdateItemOffsetX(int oldIndex)
{
if (!_isDragging) return;
var moveItem = _tabPanel.ItemDic[CurrentIndex];
moveItem.CurrentIndex -= CurrentIndex - oldIndex;
var offsetX = moveItem.TargetOffsetX;
var resultX = offsetX + (oldIndex - CurrentIndex) * ItemWidth;
_tabPanel.ItemDic[CurrentIndex] = this;
_tabPanel.ItemDic[moveItem.CurrentIndex] = moveItem;
moveItem.CreateAnimation(offsetX, resultX);
}
public TabItem()
{
Loaded += (s, e) =>
{
if (_isLoaded) return;
_tabPanel = VisualParent as TabPanel;
_isLoaded = true;
};
//CommandBindings.Add(new CommandBinding(CloseOtherCommand, (s, e) =>
//{
// var enumerator = ((IEnumerable)TabControlParent.Items).GetEnumerator();
// while (enumerator.MoveNext())
// {
// var item = enumerator.Current;
// if (!Equals(item) && item != null)
// {
// TabControlParent.Items.Remove(item);
// enumerator = ((IEnumerable)TabControlParent.Items).GetEnumerator();
// }
// }
//}));
}
private TabControl TabControlParent => new Lazy<TabControl>(() => ItemsControl.ItemsControlFromItemContainer(this) as TabControl).Value;
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
{
base.OnMouseRightButtonDown(e);
IsSelected = true;
Focus();
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_buttonClose = Template.FindName(CloseButtonKey, this) as Button;
if (_buttonClose != null)
{
_buttonClose.Click += (s, e) =>
{
if (TabControlParent.IsEnableAnimation)
{
_tabPanel.ClearValue(TabPanel.FluidMoveDurationProperty);
}
else
{
_tabPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
}
TabControlParent.IsInternalAction = true;
TabControlParent.Items.Remove(this);
};
}
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
if (TabControlParent.IsDraggable && !ItemIsDragging && !_isDragging)
{
_tabPanel.FluidMoveDuration = new Duration(TimeSpan.FromSeconds(0));
_mouseDownOffsetX = RenderTransform.Value.OffsetX;
var mx = TranslatePoint(new Point(), TabControlParent).X;
_mouseDownIndex = CalLocationIndex(mx);
_maxMoveLeft = -_mouseDownIndex * ItemWidth;
_maxMoveRight = TabControlParent.ActualWidth - ActualWidth + _maxMoveLeft;
_isDragging = true;
ItemIsDragging = true;
_isWaiting = true;
_dragPoint = e.GetPosition(TabControlParent);
_mouseDownPoint = _dragPoint;
CaptureMouse();
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (ItemIsDragging && _isDragging)
{
var subX = TranslatePoint(new Point(), TabControlParent).X;
CurrentIndex = CalLocationIndex(subX);
var p = e.GetPosition(TabControlParent);
var subLeft = p.X - _dragPoint.X;
var totalLeft = p.X - _mouseDownPoint.X;
if (Math.Abs(subLeft) <= WaitLength && _isWaiting) return;
_isWaiting = false;
_isDragged = true;
var left = subLeft + RenderTransform.Value.OffsetX;
if (totalLeft < _maxMoveLeft)
{
left = _maxMoveLeft + _mouseDownOffsetX;
}
else if (totalLeft > _maxMoveRight)
{
left = _maxMoveRight + _mouseDownOffsetX;
}
var t = new TranslateTransform(left, 0);
RenderTransform = t;
_dragPoint = p;
}
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
ReleaseMouseCapture();
if (_isDragged)
{
var subX = TranslatePoint(new Point(), TabControlParent).X;
var index = CalLocationIndex(subX);
var left = index * ItemWidth;
var offsetX = RenderTransform.Value.OffsetX;
CreateAnimation(offsetX, offsetX - subX + left, index);
}
_isDragging = false;
ItemIsDragging = false;
_isDragged = false;
}
/// <summary>
/// 创建动画
/// </summary>
internal void CreateAnimation(double offsetX, double resultX, int index = -1)
{
void AnimationCompleted()
{
RenderTransform = new TranslateTransform(resultX, 0);
if (index == -1) return;
var parent = TabControlParent;
_tabPanel.CanUpdate = false;
parent.IsInternalAction = true;
parent.Items.Remove(this);
parent.IsInternalAction = true;
parent.Items.Insert(index, this);
_tabPanel.CanUpdate = true;
_tabPanel.ForceUpdate = true;
_tabPanel.Measure(new Size(_tabPanel.DesiredSize.Width, ActualHeight));
_tabPanel.ForceUpdate = false;
Focus();
IsSelected = true;
}
TargetOffsetX = resultX;
if (!TabControlParent.IsEnableAnimation)
{
AnimationCompleted();
return;
}
var animation = AnimationHelper.CreateAnimation(resultX, AnimationSpeed);
animation.FillBehavior = FillBehavior.Stop;
animation.Completed += (s1, e1) => AnimationCompleted();
var f = new TranslateTransform(offsetX, 0);
RenderTransform = f;
f.BeginAnimation(TranslateTransform.XProperty, animation);
}
/// <summary>
/// 计算选项卡当前合适的位置编号
/// </summary>
/// <param name="left"></param>
/// <returns></returns>
private int CalLocationIndex(double left)
{
var maxIndex = TabControlParent.Items.Count - 1;
var div = (int)(left / ItemWidth);
var rest = left % ItemWidth;
var result = rest / ItemWidth > .5 ? div + 1 : div;
return result > maxIndex ? maxIndex : result;
}
}
}
@@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using HandyControl.Tools;
// ReSharper disable once CheckNamespace
namespace HandyControl.Controls
{
public class TabPanel : Panel
{
private int _itemCount;
/// <summary>
/// 是否可以更新
/// </summary>
internal bool CanUpdate = true;
/// <summary>
/// 选项卡字典
/// </summary>
internal Dictionary<int, TabItem> ItemDic = new Dictionary<int, TabItem>();
/// <summary>
/// 流式行为持续时间
/// </summary>
public static readonly DependencyProperty FluidMoveDurationProperty = DependencyProperty.Register(
"FluidMoveDuration", typeof(Duration), typeof(TabPanel), new PropertyMetadata(new Duration(TimeSpan.FromMilliseconds(200))));
/// <summary>
/// 流式行为持续时间
/// </summary>
public Duration FluidMoveDuration
{
get => (Duration)GetValue(FluidMoveDurationProperty);
set => SetValue(FluidMoveDurationProperty, value);
}
/// <summary>
/// 是否将标签填充
/// </summary>
public static readonly DependencyProperty IsEnableTabFillProperty = DependencyProperty.Register(
"IsEnableTabFill", typeof(bool), typeof(TabPanel), new PropertyMetadata(default(bool)));
/// <summary>
/// 是否将标签填充
/// </summary>
public bool IsEnableTabFill
{
get => (bool)GetValue(IsEnableTabFillProperty);
set => SetValue(IsEnableTabFillProperty, value);
}
/// <summary>
/// 标签宽度
/// </summary>
public static readonly DependencyProperty TabItemWidthProperty = DependencyProperty.Register(
"TabItemWidth", typeof(double), typeof(TabPanel), new PropertyMetadata(200.0));
/// <summary>
/// 标签宽度
/// </summary>
public double TabItemWidth
{
get => (double)GetValue(TabItemWidthProperty);
set => SetValue(TabItemWidthProperty, value);
}
/// <summary>
/// 标签高度
/// </summary>
public static readonly DependencyProperty TabItemHeightProperty = DependencyProperty.Register(
"TabItemHeight", typeof(double), typeof(TabPanel), new PropertyMetadata(30.0));
/// <summary>
/// 标签高度
/// </summary>
public double TabItemHeight
{
get => (double)GetValue(TabItemHeightProperty);
set => SetValue(TabItemHeightProperty, value);
}
/// <summary>
/// 是否可以强制更新
/// </summary>
internal bool ForceUpdate;
private Size _oldSize;
/// <summary>
/// 是否已经加载
/// </summary>
private bool _isLoaded;
protected override Size MeasureOverride(Size constraint)
{
if ((_itemCount == InternalChildren.Count || !CanUpdate) && !ForceUpdate) return _oldSize;
constraint.Height = TabItemHeight;
_itemCount = InternalChildren.Count;
var size = new Size();
ItemDic.Clear();
var count = InternalChildren.Count;
if (count == 0)
{
_oldSize.Width = 0;
return _oldSize;
}
constraint.Width += InternalChildren.Count;
var itemWidth = .0;
var arr = new int[count];
if (!IsEnableTabFill)
{
itemWidth = TabItemWidth;
}
else
{
arr = ArithmeticHelper.DivideInt2Arr((int)constraint.Width, count);
}
for (var index = 0; index < count; index++)
{
if (IsEnableTabFill)
{
itemWidth = arr[index];
}
if (InternalChildren[index] is TabItem tabItem)
{
tabItem.RenderTransform = new TranslateTransform();
tabItem.MaxWidth = itemWidth;
var rect = new Rect
{
X = size.Width - tabItem.BorderThickness.Left,
Width = itemWidth,
Height = TabItemHeight
};
Console.WriteLine(rect);
tabItem.Arrange(rect);
tabItem.ItemWidth = itemWidth - tabItem.BorderThickness.Left;
tabItem.CurrentIndex = index;
tabItem.TargetOffsetX = 0;
ItemDic[index] = tabItem;
size.Width += tabItem.ItemWidth;
}
}
size.Height = constraint.Height;
_oldSize = size;
return _oldSize;
}
public TabPanel()
{
Loaded += (s, e) =>
{
if (_isLoaded) return;
ForceUpdate = true;
Measure(new Size(DesiredSize.Width, ActualHeight));
ForceUpdate = false;
_isLoaded = true;
};
}
}
}
+1 -1
View File
@@ -40,7 +40,7 @@
<TextBlock FontSize="16" Text="{Binding SelectedTime,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},StringFormat=yyyy-MM-dd HH:mm:ss}" VerticalAlignment="Top" Margin="0,14,0,0" HorizontalAlignment="Center"></TextBlock>
</Border>
<TextBlock Visibility="{Binding ShowSpeStr,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl},Converter={StaticResource Boolean2VisibilityConverter}}" Text="{Binding SpeStr,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,14,10,0"></TextBlock>
<TextBlock Visibility="Collapsed" Name="TextBlockSelected" HorizontalAlignment="Left" Text="2017-10-16 06:29:28" VerticalAlignment="Top" Margin="0,2,0,0"></TextBlock>
<TextBlock Visibility="Collapsed" Name="TextBlockSelected" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,0,0"></TextBlock>
<Border Width="1" Background="{DynamicResource DangerBrush}"></Border>
<Canvas Name="CanvasSpe" VerticalAlignment="Bottom" Height="28" ></Canvas>
<Border PreviewMouseLeftButtonUp="BorderTop_OnPreviewMouseLeftButtonUp" MouseLeftButtonDown="BorderTop_OnMouseLeftButtonDown" Name="BorderTop" Background="Transparent" Cursor="Hand">
+10 -10
View File
@@ -23,7 +23,7 @@ namespace HandyControl.Controls
/// 刻度字符串
/// </summary>
private static readonly DependencyProperty SpeStrProperty = DependencyProperty.Register(
"SpeStr", typeof(string), typeof(TimeBar), new PropertyMetadata("间隔1小时"));
"SpeStr", typeof(string), typeof(TimeBar), new PropertyMetadata(Properties.Langs.Lang.Interval1h));
/// <summary>
/// 选中时间
@@ -150,13 +150,13 @@ namespace HandyControl.Controls
if (value < 0)
{
SpeStr = "间隔2小时";
SpeStr = Properties.Langs.Lang.Interval2h;
_speIndex = 0;
return;
}
if (value > 6)
{
SpeStr = "间隔30秒";
SpeStr = Properties.Langs.Lang.Interval30s;
_speIndex = 6;
return;
}
@@ -164,26 +164,26 @@ namespace HandyControl.Controls
switch (value)
{
case 0:
SpeStr = "间隔2小时";
SpeStr = Properties.Langs.Lang.Interval2h;
break;
case 1:
SpeStr = "间隔1小时";
SpeStr = Properties.Langs.Lang.Interval1h;
break;
case 2:
SpeStr = "间隔30分钟";
SpeStr = Properties.Langs.Lang.Interval30m;
break;
case 3:
SpeStr = "间隔10分钟";
SpeStr = Properties.Langs.Lang.Interval10m;
break;
case 4:
SpeStr = "间隔5分钟";
SpeStr = Properties.Langs.Lang.Interval5m;
break;
case 5:
SpeStr = "间隔1分钟";
SpeStr = Properties.Langs.Lang.Interval1m;
break;
case 6:
SetSpeTimeFormat("HH:mm:ss");
SpeStr = "间隔30秒";
SpeStr = Properties.Langs.Lang.Interval30s;
break;
}
_speIndex = value;
@@ -75,7 +75,7 @@
<TextBlock Text="{Binding ImgPath,ElementName=UserControlMain}" Foreground="White" Margin="10,0,0,0"></TextBlock>
<TextBlock Text="{Binding ImgSize,ElementName=UserControlMain,Converter={StaticResource Long2FileSizeConverter}}" Foreground="White" Margin="30,0,0,0"></TextBlock>
</StackPanel>
<Button WindowChrome.IsHitTestVisibleInChrome="True" Click="ButtonClose_OnClick" Background="{DynamicResource DangerBrush}" Grid.Row="0" Padding="14" controls:IconElement.Geometry="{StaticResource DeleteGeometry}" Style="{StaticResource ButtonIconTransparent}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="40" Height="40"></Button>
<Button WindowChrome.IsHitTestVisibleInChrome="True" Click="ButtonClose_OnClick" Background="Red" Grid.Row="0" Padding="14" controls:IconElement.Geometry="{StaticResource DeleteGeometry}" Style="{StaticResource ButtonIconTransparent}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="40" Height="40"></Button>
</Grid>
</Grid>
</controls:WindowBorderless>
@@ -56,7 +56,7 @@ namespace HandyControl.Controls
/// </summary>
private static readonly SaveFileDialog SaveFileDialog = new SaveFileDialog
{
Filter = "PNG图片|*.png"
Filter = $"{Properties.Langs.Lang.PngImg}|*.png"
};
public static readonly DependencyProperty ImgPathProperty = DependencyProperty.Register(
@@ -211,7 +211,7 @@ namespace HandyControl.Controls
}
catch
{
PopupWindow.ShowDialog("非法的图片路径!");
PopupWindow.ShowDialog(Properties.Langs.Lang.ErrorImgPath);
}
}
@@ -343,7 +343,7 @@ namespace HandyControl.Controls
if (Math.Abs(height - 0) < 0.001 || Math.Abs(width - 0) < 0.001)
{
PopupWindow.ShowDialog("非法的图片尺寸!");
PopupWindow.ShowDialog(Properties.Langs.Lang.ErrorImgSize);
return;
}
_imgWidHeiScale = width / height;
@@ -395,7 +395,7 @@ namespace HandyControl.Controls
private void ButtonSave_OnClick(object sender, RoutedEventArgs e)
{
SaveFileDialog.FileName = $"{DateTime.Now:yyyy年M月d日h时m分s.fff秒}";
SaveFileDialog.FileName = $"{DateTime.Now:yyyy-M-d-h-m-s.fff}";
if (SaveFileDialog.ShowDialog() == true)
{
var path = SaveFileDialog.FileName;
+39 -5
View File
@@ -38,6 +38,8 @@
<Compile Include="Controls\Attach\BorderElement.cs" />
<Compile Include="Controls\Attach\IconSwitchElement.cs" />
<Compile Include="Controls\Attach\StatusSwitchElement.cs" />
<Compile Include="Controls\Button\ContextMenuButton.cs" />
<Compile Include="Controls\Button\ContextMenuToggleButton.cs" />
<Compile Include="Controls\Carousel.xaml.cs">
<DependentUpon>Carousel.xaml</DependentUpon>
</Compile>
@@ -63,6 +65,9 @@
<Compile Include="Controls\Pagination.xaml.cs">
<DependentUpon>Pagination.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\TabControl\TabControl.cs" />
<Compile Include="Controls\TabControl\TabItem.cs" />
<Compile Include="Controls\TabControl\TabPanel.cs" />
<Compile Include="Controls\TimeBar\SpeTextBlock.cs" />
<Compile Include="Controls\TimeBar\TimeBar.xaml.cs">
<DependentUpon>TimeBar.xaml</DependentUpon>
@@ -96,12 +101,14 @@
<Compile Include="Interactivity\FluidMoveScope.cs" />
<Compile Include="Interactivity\IAttachedObject.cs" />
<Compile Include="Interactivity\Interaction.cs" />
<Compile Include="Interactivity\InvokeCommandAction.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!1.cs" />
<Compile Include="Interactivity\TriggerAction.cs" />
<Compile Include="Interactivity\TriggerActionCollection.cs" />
<Compile Include="Interactivity\TriggerBase.cs" />
@@ -110,19 +117,28 @@
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Langs\Lang.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Lang.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Langs\Lang.en.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Lang.en.resx</DependentUpon>
</Compile>
<Compile Include="Tools\AnimationHelper.cs" />
<Compile Include="Tools\ArithmeticHelper.cs" />
<Compile Include="Tools\Converter\Boolean2BooleanFeConverter.cs" />
<Compile Include="Tools\Converter\Boolean2VisibilityFeConverter.cs" />
<Compile Include="Tools\Converter\Boolean2BooleanReConverter.cs" />
<Compile Include="Tools\Converter\Boolean2VisibilityReConverter.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\String2VisibilityReConverter.cs" />
<Compile Include="Tools\Converter\TreeViewItemMarginConverter.cs" />
<Compile Include="Tools\Extension\ColorExtension.cs" />
<Compile Include="Tools\Extension\UIElementExtension.cs" />
@@ -268,6 +284,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\ContentControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\ContextMenu.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -304,6 +324,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\TabControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\TextBlock.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -332,6 +356,16 @@
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<EmbeddedResource Include="Properties\Langs\Lang.en.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Lang.en.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Langs\Lang.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Lang.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,72 @@
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
namespace HandyControl.Interactivity
{
public sealed class InvokeCommandAction : TriggerAction<DependencyObject>
{
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(InvokeCommandAction), null);
public static readonly DependencyProperty CommandParameterProperty =
DependencyProperty.Register(nameof(CommandParameter), typeof(object), typeof(InvokeCommandAction),
null);
private string _commandName;
public string CommandName
{
get
{
ReadPreamble();
return _commandName;
}
set
{
if (CommandName == value)
return;
WritePreamble();
_commandName = value;
WritePostscript();
}
}
public ICommand Command
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
public object CommandParameter
{
get => GetValue(CommandParameterProperty);
set => SetValue(CommandParameterProperty, value);
}
protected override void Invoke(object parameter)
{
if (AssociatedObject == null)
return;
var command = ResolveCommand();
if (command == null || !command.CanExecute(CommandParameter))
return;
command.Execute(CommandParameter);
}
private ICommand ResolveCommand()
{
var command = (ICommand)null;
if (Command != null)
command = Command;
else if (AssociatedObject != null)
foreach (var property in AssociatedObject.GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public))
if (typeof(ICommand).IsAssignableFrom(property.PropertyType) &&
string.Equals(property.Name, CommandName, StringComparison.Ordinal))
command = (ICommand)property.GetValue(AssociatedObject, null);
return command;
}
}
}
@@ -0,0 +1,19 @@
using System;
using System.Windows;
namespace HandyControl.Interactivity
{
public abstract class TriggerAction<T> : TriggerAction where T : DependencyObject
{
protected TriggerAction() : base(typeof(T))
{
}
#pragma warning disable 108,114
protected T AssociatedObject => (T)base.AssociatedObject;
#pragma warning restore 108,114
protected sealed override Type AssociatedObjectTypeConstraint =>
base.AssociatedObjectTypeConstraint;
}
}
+2 -2
View File
@@ -9,12 +9,12 @@ 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());
public static readonly DependencyProperty ActionsProperty = ActionsPropertyKey.DependencyProperty;
private DependencyObject _associatedObject;
private readonly Type _associatedObjectTypeConstraint;
+2 -2
View File
@@ -10,5 +10,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.1.0")]
[assembly: AssemblyFileVersion("1.2.1.0")]
+207
View File
@@ -0,0 +1,207 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace HandyControl.Properties.Langs {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Lang {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Lang() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HandyControl.Properties.Langs.Lang", typeof(Lang).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找类似 取消 的本地化字符串。
/// </summary>
public static string Cancel {
get {
return ResourceManager.GetString("Cancel", resourceCulture);
}
}
/// <summary>
/// 查找类似 清空 的本地化字符串。
/// </summary>
public static string Clear {
get {
return ResourceManager.GetString("Clear", resourceCulture);
}
}
/// <summary>
/// 查找类似 确定 的本地化字符串。
/// </summary>
public static string Confirm {
get {
return ResourceManager.GetString("Confirm", resourceCulture);
}
}
/// <summary>
/// 查找类似 错误的图片路径! 的本地化字符串。
/// </summary>
public static string ErrorImgPath {
get {
return ResourceManager.GetString("ErrorImgPath", resourceCulture);
}
}
/// <summary>
/// 查找类似 非法的图片尺寸! 的本地化字符串。
/// </summary>
public static string ErrorImgSize {
get {
return ResourceManager.GetString("ErrorImgSize", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔10分钟 的本地化字符串。
/// </summary>
public static string Interval10m {
get {
return ResourceManager.GetString("Interval10m", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔1小时 的本地化字符串。
/// </summary>
public static string Interval1h {
get {
return ResourceManager.GetString("Interval1h", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔1分钟 的本地化字符串。
/// </summary>
public static string Interval1m {
get {
return ResourceManager.GetString("Interval1m", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔2小时 的本地化字符串。
/// </summary>
public static string Interval2h {
get {
return ResourceManager.GetString("Interval2h", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔30分钟 的本地化字符串。
/// </summary>
public static string Interval30m {
get {
return ResourceManager.GetString("Interval30m", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔30秒 的本地化字符串。
/// </summary>
public static string Interval30s {
get {
return ResourceManager.GetString("Interval30s", resourceCulture);
}
}
/// <summary>
/// 查找类似 间隔5分钟 的本地化字符串。
/// </summary>
public static string Interval5m {
get {
return ResourceManager.GetString("Interval5m", resourceCulture);
}
}
/// <summary>
/// 查找类似 PNG图片 的本地化字符串。
/// </summary>
public static string PngImg {
get {
return ResourceManager.GetString("PngImg", resourceCulture);
}
}
/// <summary>
/// 查找类似 过大 的本地化字符串。
/// </summary>
public static string TooLarge {
get {
return ResourceManager.GetString("TooLarge", resourceCulture);
}
}
/// <summary>
/// 查找类似 未知 的本地化字符串。
/// </summary>
public static string Unknown {
get {
return ResourceManager.GetString("Unknown", resourceCulture);
}
}
/// <summary>
/// 查找类似 未知大小 的本地化字符串。
/// </summary>
public static string UnknownSize {
get {
return ResourceManager.GetString("UnknownSize", resourceCulture);
}
}
}
}
View File
Whitespace-only changes.
+168
View File
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Confirm" xml:space="preserve">
<value>Confirm</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="PngImg" xml:space="preserve">
<value>PNG image</value>
</data>
<data name="ErrorImgPath" xml:space="preserve">
<value>Wrong picture path</value>
</data>
<data name="ErrorImgSize" xml:space="preserve">
<value>Wrong picture size</value>
</data>
<data name="UnknownSize" xml:space="preserve">
<value>Unknown size</value>
</data>
<data name="TooLarge" xml:space="preserve">
<value>Too large</value>
</data>
<data name="Unknown" xml:space="preserve">
<value>Unknown</value>
</data>
<data name="Interval30s" xml:space="preserve">
<value>30 seconds interval</value>
</data>
<data name="Interval1m" xml:space="preserve">
<value>1 minute interval</value>
</data>
<data name="Interval5m" xml:space="preserve">
<value>5 minutes interval</value>
</data>
<data name="Interval10m" xml:space="preserve">
<value>10 minutes interval</value>
</data>
<data name="Interval30m" xml:space="preserve">
<value>30 minutes interval</value>
</data>
<data name="Interval1h" xml:space="preserve">
<value>1 hour interval</value>
</data>
<data name="Interval2h" xml:space="preserve">
<value>2 hour interval</value>
</data>
<data name="Clear" xml:space="preserve">
<value>Clear</value>
</data>
</root>
+148
View File
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Confirm" xml:space="preserve">
<value>确定</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>取消</value>
</data>
<data name="PngImg" xml:space="preserve">
<value>PNG图片</value>
</data>
<data name="ErrorImgPath" xml:space="preserve">
<value>错误的图片路径!</value>
</data>
<data name="ErrorImgSize" xml:space="preserve">
<value>非法的图片尺寸!</value>
</data>
<data name="UnknownSize" xml:space="preserve">
<value>未知大小</value>
</data>
<data name="TooLarge" xml:space="preserve">
<value>过大</value>
</data>
<data name="Unknown" xml:space="preserve">
<value>未知</value>
</data>
<data name="Interval30s" xml:space="preserve">
<value>间隔30秒</value>
</data>
<data name="Interval1m" xml:space="preserve">
<value>间隔1分钟</value>
</data>
<data name="Interval5m" xml:space="preserve">
<value>间隔5分钟</value>
</data>
<data name="Interval10m" xml:space="preserve">
<value>间隔10分钟</value>
</data>
<data name="Interval30m" xml:space="preserve">
<value>间隔30分钟</value>
</data>
<data name="Interval1h" xml:space="preserve">
<value>间隔1小时</value>
</data>
<data name="Interval2h" xml:space="preserve">
<value>间隔2小时</value>
</data>
<data name="Clear" xml:space="preserve">
<value>清空</value>
</data>
</root>
+20 -6
View File
@@ -1,9 +1,11 @@
<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>
<LinearGradientBrush x:Key="PrimaryBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource PrimaryColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkPrimaryColor}" Offset="1"/>
</LinearGradientBrush>
<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>
@@ -17,16 +19,28 @@
<SolidColorBrush x:Key="DefaultBrush" Color="{DynamicResource DefaultColor}"></SolidColorBrush>
<SolidColorBrush x:Key="DarkDefaultBrush" Color="{DynamicResource DarkDefaultColor}"></SolidColorBrush>
<SolidColorBrush x:Key="DangerBrush" Color="{DynamicResource DangerColor}"></SolidColorBrush>
<LinearGradientBrush x:Key="DangerBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource DangerColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkDangerColor}" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="DarkDangerBrush" Color="{DynamicResource DarkDangerColor}"></SolidColorBrush>
<SolidColorBrush x:Key="WarningBrush" Color="{DynamicResource WarningColor}"></SolidColorBrush>
<LinearGradientBrush x:Key="WarningBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource WarningColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkWarningColor}" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="DarkWarningBrush" Color="{DynamicResource DarkWarningColor}"></SolidColorBrush>
<SolidColorBrush x:Key="InfoBrush" Color="{DynamicResource InfoColor}"></SolidColorBrush>
<LinearGradientBrush x:Key="InfoBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource InfoColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkInfoColor}" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="DarkInfoBrush" Color="{DynamicResource DarkInfoColor}"></SolidColorBrush>
<SolidColorBrush x:Key="SuccessBrush" Color="{DynamicResource SuccessColor}"></SolidColorBrush>
<LinearGradientBrush x:Key="SuccessBrush" EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource SuccessColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkSuccessColor}" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="DarkSuccessBrush" Color="{DynamicResource DarkSuccessColor}"></SolidColorBrush>
<SolidColorBrush x:Key="AccentBrush" Color="{DynamicResource AccentColor}"></SolidColorBrush>
+10 -11
View File
@@ -1,21 +1,20 @@
<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="PrimaryColor">#73a5ff</Color>
<Color x:Key="DarkPrimaryColor">#5477f5</Color>
<Color x:Key="DangerColor">#d9534f</Color>
<Color x:Key="DarkDangerColor">#d43f3a</Color>
<Color x:Key="DangerColor">#ff8792</Color>
<Color x:Key="DarkDangerColor">#ff4c9f</Color>
<Color x:Key="WarningColor">#f0ad4e</Color>
<Color x:Key="DarkWarningColor">#eea236</Color>
<Color x:Key="WarningColor">#ffd07a</Color>
<Color x:Key="DarkWarningColor">#ff9133</Color>
<Color x:Key="InfoColor">#5bc0de</Color>
<Color x:Key="DarkInfoColor">#46b8da</Color>
<Color x:Key="InfoColor">#4dd0e1</Color>
<Color x:Key="DarkInfoColor">#00bcd4</Color>
<Color x:Key="SuccessColor">#5cb85c</Color>
<Color x:Key="DarkSuccessColor">#4cae4c</Color>
<Color x:Key="SuccessColor">#A5D6A7</Color>
<Color x:Key="DarkSuccessColor">#4CAF50</Color>
<Color x:Key="PrimaryTextColor">#212121</Color>
<Color x:Key="SecondaryTextColor">#757575</Color>
+3 -4
View File
@@ -2,14 +2,13 @@
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:Boolean2BooleanReConverter x:Key="Boolean2BooleanReConverter"/>
<converter:Boolean2VisibilityReConverter x:Key="Boolean2VisibilityReConverter"/>
<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"/>
<converter:String2VisibilityReConverter x:Key="String2VisibilityReConverter"/>
<BooleanToVisibilityConverter x:Key="Boolean2VisibilityConverter"/>
<converter:TreeViewItemMarginConverter x:Key="TreeViewItemMarginConverter"/>
<converter:Color2HexStrConverter x:Key="Color2HexStrConverter"></converter:Color2HexStrConverter>
+5 -5
View File
@@ -4,10 +4,10 @@
<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" />
<DropShadowEffect x:Key="EffectShadow1" BlurRadius="5" ShadowDepth="1" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".2" RenderingBias="Performance" po:Freeze="True" />
<DropShadowEffect x:Key="EffectShadow2" BlurRadius="8" ShadowDepth="1.5" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".2" RenderingBias="Performance" po:Freeze="True" />
<DropShadowEffect x:Key="EffectShadow3" BlurRadius="14" ShadowDepth="4.5" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".2" RenderingBias="Performance" po:Freeze="True" />
<DropShadowEffect x:Key="EffectShadow4" BlurRadius="25" ShadowDepth="8" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".2" RenderingBias="Performance" po:Freeze="True" />
<DropShadowEffect x:Key="EffectShadow5" BlurRadius="35" ShadowDepth="13" Direction="270" Color="{StaticResource MaterialDesignShadow}" Opacity=".2" RenderingBias="Performance" po:Freeze="True" />
</ResourceDictionary>
@@ -10,11 +10,12 @@
<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="BorderThickness" Value="0"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="IsTabStop" Value="False"></Setter>
</Style>
</ResourceDictionary>
@@ -30,7 +30,7 @@
<Rectangle x:Name="PART_GlowRect" Fill="{StaticResource ProgressBarIndicatorAnimatedFill}" HorizontalAlignment="Left" Margin="-100,0,0,0" Width="100"/>
</Border>
</Decorator>
<TextBlock HorizontalAlignment="Center" Foreground="{DynamicResource TextIconBrush}" Text="{Binding Value,RelativeSource={RelativeSource FindAncestor,AncestorType=ProgressBar},StringFormat={}{0} %}"></TextBlock>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource TextIconBrush}" Text="{Binding Value,RelativeSource={RelativeSource FindAncestor,AncestorType=ProgressBar},StringFormat={}{0} %}"></TextBlock>
</Grid>
</Grid>
</Grid>
+2 -1
View File
@@ -10,6 +10,7 @@
<Style BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
<Style x:Key="ButtonPrimary" BasedOn="{StaticResource ButtonBaseStyle}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
@@ -31,7 +32,6 @@
<Style x:Key="ButtonIconTransparent" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
@@ -53,6 +53,7 @@
<Style x:Key="ButtonIconDefault" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource DefaultBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
<Style x:Key="ButtonIconPrimary" BasedOn="{StaticResource ButtonIconBaseStyle}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
@@ -0,0 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type ContentControl}">
<Setter Property="Focusable" Value="False"></Setter>
</Style>
</ResourceDictionary>
+10 -10
View File
@@ -39,8 +39,8 @@
<GeometryDrawing>
<GeometryDrawing.Brush>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource PrimaryColor}" Offset="0"/>
<GradientStop Color="{DynamicResource PrimaryColor}" Offset="0.5"/>
<GradientStop Color="{DynamicResource DarkPrimaryColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkPrimaryColor}" Offset="0.5"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
@@ -101,8 +101,8 @@
<GeometryDrawing>
<GeometryDrawing.Brush>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource SuccessColor}" Offset="0"/>
<GradientStop Color="{DynamicResource SuccessColor}" Offset="0.5"/>
<GradientStop Color="{DynamicResource DarkSuccessColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkSuccessColor}" Offset="0.5"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
@@ -131,8 +131,8 @@
<GeometryDrawing>
<GeometryDrawing.Brush>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource InfoColor}" Offset="0"/>
<GradientStop Color="{DynamicResource InfoColor}" Offset="0.5"/>
<GradientStop Color="{DynamicResource DarkInfoColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkInfoColor}" Offset="0.5"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
@@ -161,8 +161,8 @@
<GeometryDrawing>
<GeometryDrawing.Brush>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource WarningColor}" Offset="0"/>
<GradientStop Color="{DynamicResource WarningColor}" Offset="0.5"/>
<GradientStop Color="{DynamicResource DarkWarningColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkWarningColor}" Offset="0.5"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
@@ -191,8 +191,8 @@
<GeometryDrawing>
<GeometryDrawing.Brush>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="{DynamicResource DangerColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DangerColor}" Offset="0.5"/>
<GradientStop Color="{DynamicResource DarkDangerColor}" Offset="0"/>
<GradientStop Color="{DynamicResource DarkDangerColor}" Offset="0.5"/>
<GradientStop Color="White" Offset="0.5"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
+2 -2
View File
@@ -18,7 +18,7 @@
<!--<ResourceDictionary Source="DataGrid.xaml"></ResourceDictionary>-->
<!--<ResourceDictionary Source="GroupBox.xaml"></ResourceDictionary>-->
<ResourceDictionary Source="Pagination.xaml"></ResourceDictionary>
<!--<ResourceDictionary Source="TabControl.xaml"></ResourceDictionary>-->
<ResourceDictionary Source="TabControl.xaml"></ResourceDictionary>
<ResourceDictionary Source="ListBox.xaml"></ResourceDictionary>
<!--<ResourceDictionary Source="ComboBox.xaml"></ResourceDictionary>-->
<ResourceDictionary Source="Loading.xaml"></ResourceDictionary>
@@ -28,7 +28,7 @@
<!--<ResourceDictionary Source="InfoBrief.xaml"></ResourceDictionary>-->
<ResourceDictionary Source="Expander.xaml"></ResourceDictionary>
<!--<ResourceDictionary Source="TextBox.xaml"></ResourceDictionary>-->
<!--<ResourceDictionary Source="ContentControl.xaml"></ResourceDictionary>-->
<ResourceDictionary Source="ContentControl.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
+107
View File
@@ -0,0 +1,107 @@
<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/Paths.xaml"></ResourceDictionary>
<ResourceDictionary Source="../Basic/Converters.xaml"></ResourceDictionary>
<ResourceDictionary Source="Button.xaml"></ResourceDictionary>
<ResourceDictionary Source="ToggleButton.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type controls:TabItem}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
<Setter Property="BorderThickness" Value="1,0,1,1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="16,0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Background="Transparent" Text="{Binding Header,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:TabItem}}"/>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TabItem}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2" BorderThickness="{TemplateBinding BorderThickness}" x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Margin="0">
<Border Margin="0,0,0,-1" x:Name="innerBorder" Background="White" Opacity="0"/>
</Border>
<ContentPresenter Grid.Column="0" x:Name="contentPresenter" ContentSource="Header" Focusable="False" HorizontalAlignment="Stretch" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center">
<ContentPresenter.OpacityMask>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Offset="1"/>
<GradientStop Color="White" Offset="0.8"/>
</LinearGradientBrush>
</ContentPresenter.OpacityMask>
</ContentPresenter>
<Button Grid.Column="1" x:Name="PART_CloseButton" Visibility="{Binding ShowCloseButton,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:TabControl},Converter={StaticResource Boolean2VisibilityConverter}}" Background="Transparent" Style="{StaticResource ButtonOpacityStyle}" Width="28">
<Path Fill="{DynamicResource PrimaryTextBrush}" Width="8" Height="8" Style="{StaticResource ClosePathStyle}"/>
</Button>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:TabControl}">
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:TabControl}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<Border Background="White" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource BorderBrush}">
<controls:TabPanel TabItemHeight="{TemplateBinding TabItemHeight}" TabItemWidth="{TemplateBinding TabItemWidth}" IsEnableTabFill="{TemplateBinding IsEnableTabFill}" Margin="0,0,-1,-1" x:Name="PART_HeaderPanel" HorizontalAlignment="Left" Background="{DynamicResource SecondaryTextBrush}" IsItemsHost="true" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1">
<interactivity:Interaction.Behaviors>
<interactivity:FluidMoveBehavior AppliesTo="Children" Duration="{Binding FluidMoveDuration,ElementName=PART_HeaderPanel}">
<interactivity:FluidMoveBehavior.EaseX>
<CubicEase EasingMode="EaseOut"/>
</interactivity:FluidMoveBehavior.EaseX>
</interactivity:FluidMoveBehavior>
</interactivity:Interaction.Behaviors>
</controls:TabPanel>
</Border>
<Border x:Name="contentPanel" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<Border Visibility="{Binding Visibility,ElementName=PART_OverflowButton}" Margin="0,-1,0,0" Grid.Row="0" Grid.Column="0" BorderThickness="1,0,0,1" BorderBrush="{DynamicResource BorderBrush}" Background="White" HorizontalAlignment="Right">
<controls:ContextMenuToggleButton x:Name="PART_OverflowButton" Visibility="Collapsed" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource DownGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}"/>
</Border>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+1 -1
View File
@@ -37,7 +37,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Visibility="{TemplateBinding IsFullScreen,Converter={StaticResource Boolean2VisibilityFeConverter}}" Background="{TemplateBinding NoUserAreaBackground}" Name="GridMenu" TextElement.Foreground="{TemplateBinding NoUserAreaForeground}">
<Grid Visibility="{TemplateBinding IsFullScreen,Converter={StaticResource Boolean2VisibilityReConverter}}" Background="{TemplateBinding NoUserAreaBackground}" Name="GridMenu" TextElement.Foreground="{TemplateBinding NoUserAreaForeground}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
+28 -3
View File
@@ -5,15 +5,40 @@ using System.Windows.Controls.Primitives;
namespace HandyControl.Tools
{
public class ArithmeticHelper
/// <summary>
/// 包含内部使用的一些简单算法
/// </summary>
internal class ArithmeticHelper
{
/// <summary>
/// 平分一个整数到一个数组中
/// </summary>
/// <param name="num"></param>
/// <param name="count"></param>
/// <returns></returns>
public static int[] DivideInt2Arr(int num, int count)
{
var arr = new int[count];
var div = num / count;
var rest = num % count;
for (int i = 0; i < count; i++)
{
arr[i] = div;
}
for (int i = 0; i < rest; i++)
{
arr[i] += 1;
}
return arr;
}
/// <summary>
/// 计算控件在窗口中的可见坐标
/// </summary>
/// <param name="element"></param>
/// <param name="showElement"></param>
/// <returns></returns>
internal static Point CalSafePoint(FrameworkElement element, FrameworkElement showElement)
public static Point CalSafePoint(FrameworkElement element, FrameworkElement showElement)
{
if (element == null || showElement == null) return default(Point);
var point = element.PointToScreen(new Point(0, 0));
@@ -33,7 +58,7 @@ namespace HandyControl.Tools
/// </summary>
/// <param name="element"></param>
/// <returns></returns>
internal static Rect GetLayoutRect(FrameworkElement element)
public static Rect GetLayoutRect(FrameworkElement element)
{
var num1 = element.ActualWidth;
var num2 = element.ActualHeight;
@@ -4,7 +4,7 @@ using System.Windows.Data;
namespace HandyControl.Tools.Converter
{
public class Boolean2BooleanFeConverter : IValueConverter
public class Boolean2BooleanReConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@@ -5,7 +5,7 @@ using System.Windows.Data;
namespace HandyControl.Tools.Converter
{
public class Boolean2VisibilityFeConverter : IValueConverter
public class Boolean2VisibilityReConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@@ -1,20 +0,0 @@
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.");
}
}
}
@@ -8,12 +8,12 @@ namespace HandyControl.Tools.Converter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return "未知大小";
if (value == null) return Properties.Langs.Lang.UnknownSize;
if (value is long intValue)
{
if (intValue < 0)
{
return "未知大小";
return Properties.Langs.Lang.UnknownSize;
}
if (intValue < 1024)
{
@@ -39,9 +39,9 @@ namespace HandyControl.Tools.Converter
{
return $"{intValue / 1125899906842624.0:0.00} PB";
}
return "过大";
return Properties.Langs.Lang.TooLarge;
}
return "未知";
return Properties.Langs.Lang.Unknown;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
@@ -5,7 +5,7 @@ using System.Windows.Data;
namespace HandyControl.Tools.Converter
{
public class String2VisibilityFeConverter : IValueConverter
public class String2VisibilityReConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
+11 -10
View File
@@ -1,17 +1,18 @@
using System.Text.RegularExpressions;
using System;
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>
@@ -22,7 +23,7 @@ namespace HandyControl.Tools
}
/// <summary>
/// 判断字符串是否满足指定的格式
/// 判断字符串是否满足指定的格式
/// </summary>
/// <param name="text">需要判断的字符串</param>
/// <param name="textType">指定格式的文本</param>
@@ -31,11 +32,11 @@ namespace HandyControl.Tools
{
if (textType == TextType.Common) return true;
return Regex.IsMatch(text,
RegularPatterns.GetValue(System.Enum.GetName(typeof(TextType), textType) + "Pattern").ToString());
RegularPatterns.GetValue(Enum.GetName(typeof(TextType), textType) + "Pattern").ToString());
}
/// <summary>
/// 判断字符串格式是否为电子邮件
/// 判断字符串格式是否为电子邮件
/// </summary>
/// <param name="email">需要判断的Email字符串</param>
/// <returns>方法返回布尔值</returns>
@@ -45,7 +46,7 @@ namespace HandyControl.Tools
}
/// <summary>
/// 判断字符串格式是否为指定类型的IP地址
/// 判断字符串格式是否为指定类型的IP地址
/// </summary>
/// <param name="ip">需要判断的IP字符串</param>
/// <param name="ipType">指定的IP类型</param>
@@ -64,7 +65,7 @@ namespace HandyControl.Tools
}
/// <summary>
/// 判断字符串格式是否为IP地址
/// 判断字符串格式是否为IP地址
/// </summary>
/// <param name="ip">需要判断的IP字符串</param>
/// <returns>方法返回布尔值</returns>
@@ -74,7 +75,7 @@ namespace HandyControl.Tools
}
/// <summary>
/// 判断字符串格式是否为单个汉字
/// 判断字符串格式是否为单个汉字
/// </summary>
/// <param name="str">需要判断的单个汉字字符串</param>
/// <returns>方法返回布尔值</returns>
@@ -84,7 +85,7 @@ namespace HandyControl.Tools
}
/// <summary>
/// 判断字符串格式是否为url
/// 判断字符串格式是否为url
/// </summary>
/// <param name="str">需要判断的url字符串</param>
/// <returns>方法返回布尔值</returns>
+38 -39
View File
@@ -1,24 +1,15 @@
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})(\]?)$";
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>
/// 手机号正则匹配表达式
@@ -26,127 +17,135 @@
public const string PhonePattern = @"^((13[0-9])|(15[^4,\d])|(18[0,5-9]))\d{8}$";
/// <summary>
/// IP正则匹配
/// 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)\."
+ @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
/// <summary>
/// A类IP正则匹配
/// A类IP正则匹配
/// </summary>
public const string IpAPattern =
@"^(12[0-6]|1[0-1]\d|[1-9]?\d)\."
@"^(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正则匹配
/// B类IP正则匹配
/// </summary>
public const string IpBPattern =
@"^(19[0-1]|12[8-9]|1[3-8]\d)\."
@"^(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正则匹配
/// C类IP正则匹配
/// </summary>
public const string IpCPattern =
@"^(19[2-9]|22[0-3]|2[0-1]\d)\."
@"^(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正则匹配
/// D类IP正则匹配
/// </summary>
public const string IpDPattern =
@"^(22[4-9]|23\d\."
@"^(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正则匹配
/// E类IP正则匹配
/// </summary>
public const string IpEPattern =
@"^(25[0-5]|24\d\."
@"^(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正则匹配
/// 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\&%_\./-~-]*)?";
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$";
/// <summary>
/// 根据属性名称使用反射来获取值
/// </summary>
/// <param name="propertyName"></param>
/// <returns></returns>
public object GetValue(string propertyName) => GetType().GetField(propertyName).GetValue(null);
}
}