refactor some controls

TimeBar, Steps, PopupWindow, Growl, Carousel
This commit is contained in:
NaBian committed 2018-10-11 19:54:56 +08:00
1 parent 3dab3b6571
commit 3e726d3eb1
35 files changed
+979 -634

No files matched your search

-78
View File
@@ -1,78 +0,0 @@
2018.10.09 Version 1.3.2
* new style
- add TabControl
* fixed bug
- ColorPicker's text is gone.
2018.10.09 Version 1.3.1
* new style
- add TextBox
- add ComboBox
- add PasswordBox
- add DataPicker
- add TimePicker
* other
- add TextBlockDemo
- add CirclePanelDemo
2018.10.03 Version 1.3.0
* new controls
- add Clock
- add TimePicker
- add CirclePanel
* new style
- add Calendar
- add DataPicker
2018.09.18 Version 1.2.2
* new controls
- add StepBar
* other
- update HandyControlDemo UI
2018.09.04 Version 1.2.1
* new controls
- add TabControl
- add ContextMenuButton
- add ContextMenuToggleButton
* other
- update HandyControlDemo UI
- Localization
2018.09.04 Version 1.2.0
* new controls
- add Growl
- add AnimationPath
- add TransitioningContentControl
* new style
- add ProgressBar
- add TreeView
* other
- update HandyControlDemo UI
- the ScrollViewer will auto hidden
2018.08.31 Version 1.1.2
* new controls
- add CompareSlider
2018.08.30 Version 1.1.1
* new controls
- add ScrollViewer
2018.08.27 Version 1.1.0
* new controls
- add WindowBorderless
- add ImageBrowser
- add PopupWindow
* new styles
- add Menu
- add Window
@@ -1,25 +1,75 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Markup; using System.Windows.Markup;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading; using System.Windows.Threading;
using HandyControl.Interactivity;
using HandyControl.Tools; using HandyControl.Tools;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
/// <summary> /// <summary>
/// Carousel.xaml 的交互逻辑 /// 轮播控件
/// </summary> /// </summary>
[DefaultProperty("Items")] [DefaultProperty("Items")]
[ContentProperty("Items")] [ContentProperty("Items")]
public partial class Carousel [TemplatePart(Name = ElementPanelPage, Type = typeof(Panel))]
[TemplatePart(Name = ElementItemsControl, Type = typeof(ItemsPresenter))]
public class Carousel : ListBox
{ {
#region Constants
private const string ElementPanelPage = "PART_PanelPage";
private const string ElementItemsControl = "PART_ItemsControl";
#endregion Constants
#region Data
private Panel _panelPage;
private bool _appliedTemplate;
private ItemsPresenter _itemsControl;
#endregion Data
public override void OnApplyTemplate()
{
_appliedTemplate = false;
_panelPage?.RemoveHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonPages_OnClick));
base.OnApplyTemplate();
_itemsControl = GetTemplateChild(ElementItemsControl) as ItemsPresenter;
_panelPage = GetTemplateChild(ElementPanelPage) as Panel;
CheckNull();
_panelPage.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ButtonPages_OnClick));
_appliedTemplate = true;
Update();
}
private void Update()
{
TimerSwitch(AutoRun);
UpdatePageButtons();
}
private void CheckNull()
{
if (_itemsControl == null || _panelPage == null) throw new Exception();
}
public static readonly DependencyProperty AutoRunProperty = DependencyProperty.Register( public static readonly DependencyProperty AutoRunProperty = DependencyProperty.Register(
"AutoRun", typeof(bool), typeof(Carousel), new PropertyMetadata(default(bool), (o, args) => "AutoRun", typeof(bool), typeof(Carousel), new PropertyMetadata(default(bool), (o, args) =>
{ {
@@ -30,14 +80,6 @@ namespace HandyControl.Controls
public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register( public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register(
"Interval", typeof(TimeSpan), typeof(Carousel), new PropertyMetadata(TimeSpan.FromSeconds(2))); "Interval", typeof(TimeSpan), typeof(Carousel), new PropertyMetadata(TimeSpan.FromSeconds(2)));
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
"ItemsSource", typeof(IEnumerable), typeof(Carousel), new PropertyMetadata(default(IEnumerable),
(o, args) =>
{
var ctl = (Carousel)o;
ctl.UpdatePageButtons();
}));
public static readonly DependencyProperty ExtendWidthProperty = DependencyProperty.Register( public static readonly DependencyProperty ExtendWidthProperty = DependencyProperty.Register(
"ExtendWidth", typeof(double), typeof(Carousel), new PropertyMetadata(default(double))); "ExtendWidth", typeof(double), typeof(Carousel), new PropertyMetadata(default(double)));
@@ -56,7 +98,7 @@ namespace HandyControl.Controls
set => SetValue(IsCenterProperty, value); set => SetValue(IsCenterProperty, value);
} }
private int _pageIndex = -1; private int _pageIndex;
private Button _selectedButton; private Button _selectedButton;
@@ -66,11 +108,20 @@ namespace HandyControl.Controls
public Carousel() public Carousel()
{ {
InitializeComponent(); CommandBindings.Add(new CommandBinding(ControlCommands.Prev, ButtonPrev_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Next, ButtonNext_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Selected, ButtonPages_OnClick));
Loaded += (s, e) => UpdatePageButtons(); Loaded += (s, e) => UpdatePageButtons();
} }
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
UpdatePageButtons();
}
/// <summary> /// <summary>
/// 是否自动跳转 /// 是否自动跳转
/// </summary> /// </summary>
@@ -109,19 +160,12 @@ namespace HandyControl.Controls
} }
} }
public IEnumerable ItemsSource
{
get => (IEnumerable)GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
public ItemCollection Items => ListBoxMain.Items;
/// <summary> /// <summary>
/// 计时器开关 /// 计时器开关
/// </summary> /// </summary>
private void TimerSwitch(bool run) private void TimerSwitch(bool run)
{ {
if (!_appliedTemplate) return;
if (run) if (run)
{ {
_updateTimer = new DispatcherTimer _updateTimer = new DispatcherTimer
@@ -133,9 +177,12 @@ namespace HandyControl.Controls
} }
else else
{ {
_updateTimer.Tick -= UpdateTimer_Tick; if (_updateTimer != null)
_updateTimer.Stop(); {
_updateTimer = null; _updateTimer.Tick -= UpdateTimer_Tick;
_updateTimer.Stop();
_updateTimer = null;
}
} }
} }
@@ -150,34 +197,35 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
public void UpdatePageButtons(int? index = null) public void UpdatePageButtons(int? index = null)
{ {
if (!_appliedTemplate) return;
if (index == null) if (index == null)
{ {
var count = Items.Count; var count = Items.Count;
_widthList.Clear(); _widthList.Clear();
_widthList.Add(0); _widthList.Add(0);
var width = .0; var width = .0;
foreach (FrameworkElement item in ListBoxMain.Items) foreach (FrameworkElement item in Items)
{ {
item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
width += item.DesiredSize.Width; width += item.DesiredSize.Width;
_widthList.Add(width); _widthList.Add(width);
} }
ListBoxMain.Width = _widthList.Last() + ExtendWidth; _itemsControl.Width = _widthList.Last() + ExtendWidth;
PanelPage.Children.Clear(); _panelPage.Children.Clear();
for (var i = 0; i < count; i++) for (var i = 0; i < count; i++)
PanelPage.Children.Add(CreatePateButton()); _panelPage.Children.Add(CreatePateButton());
if (count > 0) if (count > 0)
{ {
var button = PanelPage.Children[0]; var button = _panelPage.Children[0];
button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button)); button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button));
} }
} }
else else
{ {
if (index >= 0 && index < PanelPage.Children.Count) if (index >= 0 && index < _panelPage.Children.Count)
{ {
var button = PanelPage.Children[(int)index]; var button = _panelPage.Children[(int)index];
button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button)); button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent, button));
UpdateItemsPosition(); UpdateItemsPosition();
} }
@@ -189,17 +237,18 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
private void UpdateItemsPosition() private void UpdateItemsPosition()
{ {
if (Items.Count == 0 || PageIndex == -1) return; if (!_appliedTemplate) return;
if (Items.Count == 0) return;
if (!IsCenter) if (!IsCenter)
{ {
ListBoxMain.BeginAnimation(MarginProperty, _itemsControl.BeginAnimation(MarginProperty,
AnimationHelper.CreateAnimation(new Thickness(-_widthList[PageIndex], 0, 0, 0))); AnimationHelper.CreateAnimation(new Thickness(-_widthList[PageIndex], 0, 0, 0)));
} }
else else
{ {
var ctl = (FrameworkElement)Items[PageIndex]; var ctl = (FrameworkElement)Items[PageIndex];
var ctlWidth = ctl.DesiredSize.Width; var ctlWidth = ctl.DesiredSize.Width;
ListBoxMain.BeginAnimation(MarginProperty, _itemsControl.BeginAnimation(MarginProperty,
AnimationHelper.CreateAnimation( AnimationHelper.CreateAnimation(
new Thickness(-_widthList[PageIndex] + (ActualWidth - ctlWidth) / 2, 0, 0, 0))); new Thickness(-_widthList[PageIndex] + (ActualWidth - ctlWidth) / 2, 0, 0, 0)));
} }
@@ -241,19 +290,13 @@ namespace HandyControl.Controls
_selectedButton = e.OriginalSource as Button; _selectedButton = e.OriginalSource as Button;
if (_selectedButton != null && _selectedButton.Content is Border border) if (_selectedButton != null && _selectedButton.Content is Border border)
border.Background = TryFindResource("PrimaryBrush") as Brush; border.Background = TryFindResource("PrimaryBrush") as Brush;
var index = PanelPage.Children.IndexOf(_selectedButton); var index = _panelPage.Children.IndexOf(_selectedButton);
if (index != -1) if (index != -1)
PageIndex = index; PageIndex = index;
} }
private void ButtonPrev_OnClick(object sender, RoutedEventArgs e) private void ButtonPrev_OnClick(object sender, RoutedEventArgs e) => PageIndex--;
{
PageIndex--;
}
private void ButtonNext_OnClick(object sender, RoutedEventArgs e) private void ButtonNext_OnClick(object sender, RoutedEventArgs e) => PageIndex++;
{
PageIndex++;
}
} }
} }
-44
View File
@@ -1,44 +0,0 @@
<UserControl x:Class="HandyControl.Controls.Carousel"
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"
mc:Ignorable="d"
BorderThickness="1"
Background="Transparent"
Name="UserControlMain"
BorderBrush="{StaticResource BorderBrush}"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="GridTop" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="FrameworkElement.MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="GridTop" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>
<Grid ClipToBounds="True">
<ListBox HorizontalAlignment="Left" Name="ListBoxMain" BorderThickness="0" ItemsSource="{Binding ItemsSource,ElementName=UserControlMain}" Style="{StaticResource StackPanelListBox}"/>
<Grid Name="GridTop" Opacity="0">
<Button Click="ButtonPrev_OnClick" Name="ButtonPrev" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,0" Style="{StaticResource ButtonCustom}">
<Border Width="50" Height="100" Background="#44000000" CornerRadius="2">
<Path Margin="16" Fill="White" Style="{StaticResource LeftPathStyle}"/>
</Border>
</Button>
<Button Click="ButtonNext_OnClick" Name="ButtonNext" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,30,0" Style="{StaticResource ButtonCustom}">
<Border Width="50" Height="100" Background="#44000000" CornerRadius="2">
<Path Margin="16" Fill="White" Style="{StaticResource RightPathStyle}"/>
</Border>
</Button>
</Grid>
<StackPanel Button.Click="ButtonPages_OnClick" Name="PanelPage" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,20"/>
</Grid>
</UserControl>
@@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Threading; using System.Windows.Threading;
@@ -12,10 +13,66 @@ using HandyControl.Tools.Extension;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
/// <summary> /// <summary>
/// Growl.xaml 的交互逻辑 /// 消息提醒
/// </summary> /// </summary>
public partial class Growl [TemplatePart(Name = ElementPanelMore, Type = typeof(Panel))]
[TemplatePart(Name = ElementGridMain, Type = typeof(Grid))]
[TemplatePart(Name = ElementButtonClose, Type = typeof(Button))]
public class Growl : Control
{ {
#region Constants
private const string ElementPanelMore = "PART_PanelMore";
private const string ElementGridMain = "PART_GridMain";
private const string ElementButtonClose = "PART_ButtonClose";
#endregion Constants
#region Data
private Panel _panelMore;
private Grid _gridMain;
private Button _buttonClose;
private bool _showCloseButton;
private bool _staysOpen;
#endregion Data
public Growl()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Close, ButtonClose_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancel_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick));
MouseEnter += Growl_MouseEnter;
MouseLeave += Growl_MouseLeave;
}
private void Growl_MouseLeave(object sender, MouseEventArgs e) => _buttonClose.Collapse();
private void Growl_MouseEnter(object sender, MouseEventArgs e) => _buttonClose.Show(_showCloseButton);
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_panelMore = GetTemplateChild(ElementPanelMore) as Panel;
_gridMain = GetTemplateChild(ElementGridMain) as Grid;
_buttonClose = GetTemplateChild(ElementButtonClose) as Button;
CheckNull();
Update();
}
private void CheckNull()
{
if (_panelMore == null || _gridMain == null || _buttonClose == null) throw new Exception();
}
/// <summary> /// <summary>
/// 最大计数 /// 最大计数
/// </summary> /// </summary>
@@ -48,8 +105,6 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
private DispatcherTimer _timerClose; private DispatcherTimer _timerClose;
public Growl() => InitializeComponent();
private Action<Action, bool> CloseAction { get; set; } private Action<Action, bool> CloseAction { get; set; }
public string Message public string Message
@@ -134,6 +189,25 @@ namespace HandyControl.Controls
collection.Add(behavior); collection.Add(behavior);
} }
private void Update()
{
if (CloseAction != null)
{
_staysOpen = true;
_showCloseButton = false;
_panelMore.IsEnabled = true;
_panelMore.Show();
}
var transform = new TranslateTransform
{
X = MaxWidth
};
_gridMain.RenderTransform = transform;
transform.BeginAnimation(TranslateTransform.XProperty, AnimationHelper.CreateAnimation(0));
if (!_staysOpen) StartTimer();
}
/// <summary> /// <summary>
/// 显示信息 /// 显示信息
/// </summary> /// </summary>
@@ -145,27 +219,12 @@ namespace HandyControl.Controls
Message = message, Message = message,
Time = DateTime.Now, Time = DateTime.Now,
Icon = ResourceHelper.GetResource<Geometry>(iconKey), Icon = ResourceHelper.GetResource<Geometry>(iconKey),
IconBrush = ResourceHelper.GetResource<Brush>(iconBrushKey) IconBrush = ResourceHelper.GetResource<Brush>(iconBrushKey),
_showCloseButton = showCloseButton,
CloseAction = closeAction,
_staysOpen = staysOpen
}; };
if (!showCloseButton) ctl.Triggers.Clear();
if (closeAction != null)
{
staysOpen = true;
ctl.Triggers.Clear();
ctl.PanelMore.IsEnabled = true;
ctl.PanelMore.Show();
ctl.CloseAction = closeAction;
}
var transform = new TranslateTransform
{
X = ctl.MaxWidth
};
ctl.GridMain.RenderTransform = transform;
GrowlPanel.Children.Insert(0, ctl); GrowlPanel.Children.Insert(0, ctl);
transform.BeginAnimation(TranslateTransform.XProperty, AnimationHelper.CreateAnimation(0));
if (!staysOpen) ctl.StartTimer();
} }
/// <summary> /// <summary>
@@ -213,7 +272,7 @@ namespace HandyControl.Controls
{ {
_timerClose?.Stop(); _timerClose?.Stop();
var transform = new TranslateTransform(); var transform = new TranslateTransform();
GridMain.RenderTransform = transform; _gridMain.RenderTransform = transform;
var animation = AnimationHelper.CreateAnimation(MaxWidth); var animation = AnimationHelper.CreateAnimation(MaxWidth);
animation.Completed += delegate { GrowlPanel.Children.Remove(this); }; animation.Completed += delegate { GrowlPanel.Children.Remove(this); };
transform.BeginAnimation(TranslateTransform.XProperty, animation); transform.BeginAnimation(TranslateTransform.XProperty, animation);
-61
View File
@@ -1,61 +0,0 @@
<UserControl x:Class="HandyControl.Controls.Growl"
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:langs="clr-namespace:HandyControl.Properties.Langs"
mc:Ignorable="d"
MinHeight="60"
Name="UserControlThis"
Width="320"
Margin="0,0,0,10"
MaxWidth="320">
<UserControl.Triggers>
<EventTrigger RoutedEvent="UserControl.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Button.Visibility)" Storyboard.TargetName="ButtonClose">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="UserControl.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Button.Visibility)" Storyboard.TargetName="ButtonClose">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>
<Grid Name="GridMain" RenderTransformOrigin="0.5,0.5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.ColumnSpan="3" Grid.RowSpan="2" Effect="{StaticResource EffectShadow2}" Background="#E5DEDEDE" CornerRadius="8" Width="320"/>
<Path Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="0,15,0,0" Width="30" Height="30" Data="{Binding Icon,ElementName=UserControlThis}" Stretch="Uniform" Fill="{Binding IconBrush,ElementName=UserControlThis}"/>
<StackPanel Grid.Row="0" Grid.Column="1" Margin="0,12,10,10">
<TextBlock Text="{Binding Message,ElementName=UserControlThis}" Style="{StaticResource TextBlockDefault}" HorizontalAlignment="Left" TextWrapping="Wrap"/>
<TextBlock Text="{Binding Time,ElementName=UserControlThis,StringFormat=yyyy/MM/dd HH:mm:ss}" Style="{StaticResource TextBlockDefault}" Foreground="{StaticResource SecondaryTextBrush}" HorizontalAlignment="Left" Margin="0,4,0,0"/>
</StackPanel>
<Button Grid.Row="0" Visibility="Collapsed" Margin="11,0" Name="ButtonClose" Click="ButtonClose_OnClick" Grid.Column="2" Background="Transparent" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center" HorizontalAlignment="Center" Width="18" Height="18">
<Path Data="{StaticResource ErrorGeometry}" Stretch="Uniform" Fill="{StaticResource SecondaryTextBrush}"/>
</Button>
<StackPanel Name="PanelMore" IsEnabled="False" Visibility="Collapsed" Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="3" Height="28" Grid.Column="0">
<Button Click="ButtonCancel_OnClick" Style="{StaticResource ButtonCustom}" Width="160">
<TextBlock Text="{x:Static langs:Lang.Cancel}" HorizontalAlignment="Center" Foreground="{StaticResource DangerBrush}"/>
</Button>
<Button Click="ButtonOk_OnClick" Style="{StaticResource ButtonCustom}" Width="160">
<TextBlock Text="{x:Static langs:Lang.Confirm}" HorizontalAlignment="Center" Foreground="{StaticResource PrimaryBrush}"/>
</Button>
</StackPanel>
</Grid>
</UserControl>
+102 -9
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
@@ -11,8 +12,40 @@ namespace HandyControl.Controls
{ {
private double _totalVerticalOffset; private double _totalVerticalOffset;
private double _totalHorizontalOffset;
private bool _isRunning; private bool _isRunning;
/// <summary>
/// 滚动方向
/// </summary>
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
"Orientation", typeof(Orientation), typeof(ScrollViewer), new PropertyMetadata(Orientation.Vertical));
/// <summary>
/// 滚动方向
/// </summary>
public Orientation Orientation
{
get => (Orientation) GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
/// <summary>
/// 是否响应鼠标滚轮操作
/// </summary>
public static readonly DependencyProperty CanMouseWheelProperty = DependencyProperty.Register(
"CanMouseWheel", typeof(bool), typeof(ScrollViewer), new PropertyMetadata(true));
/// <summary>
/// 是否响应鼠标滚轮操作
/// </summary>
public bool CanMouseWheel
{
get => (bool) GetValue(CanMouseWheelProperty);
set => SetValue(CanMouseWheelProperty, value);
}
protected override void OnMouseWheel(MouseWheelEventArgs e) protected override void OnMouseWheel(MouseWheelEventArgs e)
{ {
if (!IsEnableInertia) if (!IsEnableInertia)
@@ -22,27 +55,63 @@ namespace HandyControl.Controls
} }
e.Handled = true; e.Handled = true;
if (!_isRunning) if (!CanMouseWheel) return;
if (Orientation == Orientation.Vertical)
{ {
_totalVerticalOffset = VerticalOffset; if (!_isRunning)
CurrentVerticalOffset = VerticalOffset; {
_totalVerticalOffset = VerticalOffset;
CurrentVerticalOffset = VerticalOffset;
}
_totalVerticalOffset = Math.Min(Math.Max(0, _totalVerticalOffset - e.Delta), ScrollableHeight);
ScrollToVerticalOffsetInternal(_totalVerticalOffset);
} }
_totalVerticalOffset = Math.Min(Math.Max(0, _totalVerticalOffset - e.Delta), ScrollableHeight); else
var animation = AnimationHelper.CreateAnimation(_totalVerticalOffset, 500); {
if (!_isRunning)
{
_totalHorizontalOffset = HorizontalOffset;
CurrentHorizontalOffset = HorizontalOffset;
}
_totalHorizontalOffset = Math.Min(Math.Max(0, _totalHorizontalOffset - e.Delta), ScrollableWidth);
ScrollToHorizontalOffsetInternal(_totalHorizontalOffset);
}
}
internal void ScrollToVerticalOffsetInternal(double offset, double milliseconds = 500)
{
var animation = AnimationHelper.CreateAnimation(offset, milliseconds);
animation.EasingFunction = new CubicEase animation.EasingFunction = new CubicEase
{ {
EasingMode = EasingMode.EaseOut EasingMode = EasingMode.EaseOut
}; };
animation.FillBehavior = FillBehavior.Stop; animation.FillBehavior = FillBehavior.Stop;
animation.Completed += (s,e1)=> animation.Completed += (s, e1) =>
{ {
CurrentVerticalOffset = _totalVerticalOffset; CurrentVerticalOffset = offset;
_isRunning = false; _isRunning = false;
}; };
_isRunning = true; _isRunning = true;
BeginAnimation(CurrentVerticalOffsetProperty, animation); BeginAnimation(CurrentVerticalOffsetProperty, animation);
} }
internal void ScrollToHorizontalOffsetInternal(double offset, double milliseconds = 500)
{
var animation = AnimationHelper.CreateAnimation(offset, milliseconds);
animation.EasingFunction = new CubicEase
{
EasingMode = EasingMode.EaseOut
};
animation.FillBehavior = FillBehavior.Stop;
animation.Completed += (s, e1) =>
{
CurrentHorizontalOffset = offset;
_isRunning = false;
};
_isRunning = true;
BeginAnimation(CurrentHorizontalOffsetProperty, animation);
}
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) => protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) =>
IsPenetrating ? null : base.HitTestCore(hitTestParameters); IsPenetrating ? null : base.HitTestCore(hitTestParameters);
@@ -100,9 +169,9 @@ namespace HandyControl.Controls
/// 当前垂直滚动偏移 /// 当前垂直滚动偏移
/// </summary> /// </summary>
private static readonly DependencyProperty CurrentVerticalOffsetProperty = DependencyProperty.Register( private static readonly DependencyProperty CurrentVerticalOffsetProperty = DependencyProperty.Register(
"CurrentVerticalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(default(double), CurrentVerticalOffsetChangedCallback)); "CurrentVerticalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(default(double), OnCurrentVerticalOffsetChanged));
private static void CurrentVerticalOffsetChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnCurrentVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
if (d is ScrollViewer ctl && e.NewValue is double v) if (d is ScrollViewer ctl && e.NewValue is double v)
{ {
@@ -119,5 +188,29 @@ namespace HandyControl.Controls
get => (double) GetValue(CurrentVerticalOffsetProperty); get => (double) GetValue(CurrentVerticalOffsetProperty);
set => SetValue(CurrentVerticalOffsetProperty, value); set => SetValue(CurrentVerticalOffsetProperty, value);
} }
/// <summary>
/// 当前水平滚动偏移
/// </summary>
public static readonly DependencyProperty CurrentHorizontalOffsetProperty = DependencyProperty.Register(
"CurrentHorizontalOffset", typeof(double), typeof(ScrollViewer), new PropertyMetadata(default(double), OnCurrentHorizontalOffsetChanged));
private static void OnCurrentHorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ScrollViewer ctl && e.NewValue is double v)
{
ctl.ScrollToHorizontalOffset(v);
Console.WriteLine(v);
}
}
/// <summary>
/// 当前水平滚动偏移
/// </summary>
public double CurrentHorizontalOffset
{
get => (double) GetValue(CurrentHorizontalOffsetProperty);
set => SetValue(CurrentHorizontalOffsetProperty, value);
}
} }
} }
@@ -1,5 +1,8 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Markup; using System.Windows.Markup;
@@ -11,17 +14,28 @@ using HandyControl.Tools;
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
/// <summary> /// <summary>
/// Steps.xaml 的交互逻辑 /// 步骤条
/// </summary> /// </summary>
[ContentProperty("Items")] [ContentProperty("Items")]
public partial class StepBar [TemplatePart(Name = ElementProgressBarBack, Type = typeof(ProgressBar))]
[TemplatePart(Name = ElementUniformGridMain, Type = typeof(Panel))]
public class StepBar : Control
{ {
private bool _isLoaded; private bool _isLoaded;
private ProgressBar _progressBarBack;
private Panel _panelMain;
#region Constants
private const string ElementProgressBarBack = "PART_ProgressBarBack";
private const string ElementUniformGridMain = "PART_UniformGridMain";
#endregion Constants
public StepBar() public StepBar()
{ {
InitializeComponent();
Loaded += (s1, e1) => Loaded += (s1, e1) =>
{ {
if (_isLoaded) return; if (_isLoaded) return;
@@ -34,6 +48,21 @@ namespace HandyControl.Controls
}; };
} }
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_progressBarBack = GetTemplateChild(ElementProgressBarBack) as ProgressBar;
_panelMain = GetTemplateChild(ElementUniformGridMain) as Panel;
CheckNull();
}
private void CheckNull()
{
if (_panelMain == null || _progressBarBack == null) throw new Exception();
}
public int StepIndex { get; private set; } public int StepIndex { get; private set; }
public List<StepItem> Items { get; set; } = new List<StepItem>(); public List<StepItem> Items { get; set; } = new List<StepItem>();
@@ -41,14 +70,14 @@ namespace HandyControl.Controls
private void UpdateItems(IReadOnlyCollection<StepItem> list) private void UpdateItems(IReadOnlyCollection<StepItem> list)
{ {
if (list == null) return; if (list == null) return;
UniformGridMain.Children.Clear(); _panelMain.Children.Clear();
var index = 1; var index = 1;
foreach (var item in list) foreach (var item in list)
{ {
item.Index = index; item.Index = index;
item.IndexStr = $"{Properties.Langs.Lang.Step}{index}"; item.IndexStr = $"{Properties.Langs.Lang.Step}{index}";
UniformGridMain.Children.Add(item); _panelMain.Children.Add(item);
index++; index++;
} }
@@ -62,26 +91,26 @@ namespace HandyControl.Controls
{ {
base.OnRender(drawingContext); base.OnRender(drawingContext);
var colCount = UniformGridMain.Children.Count; var colCount = _panelMain.Children.Count;
if (colCount <= 0) return; if (colCount <= 0) return;
ProgressBarBack.Width = (colCount - 1) * (ActualWidth / colCount); _progressBarBack.Width = (colCount - 1) * (ActualWidth / colCount);
ProgressBarBack.Value = 0; _progressBarBack.Value = 0;
ProgressBarBack.Maximum = colCount - 1; _progressBarBack.Maximum = colCount - 1;
} }
public void Next() public void Next()
{ {
StepIndex++; StepIndex++;
if (StepIndex >= UniformGridMain.Children.Count) if (StepIndex >= _panelMain.Children.Count)
{ {
StepIndex = UniformGridMain.Children.Count - 1; StepIndex = _panelMain.Children.Count - 1;
return; return;
} }
if (UniformGridMain.Children[StepIndex - 1] is StepItem stepItemFinished) if (_panelMain.Children[StepIndex - 1] is StepItem stepItemFinished)
stepItemFinished.Status = true; stepItemFinished.Status = true;
if (UniformGridMain.Children[StepIndex] is StepItem stepItemSelected) if (_panelMain.Children[StepIndex] is StepItem stepItemSelected)
stepItemSelected.Status = false; stepItemSelected.Status = false;
ProgressBarBack.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex)); _progressBarBack.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
} }
public void Prev() public void Prev()
@@ -92,11 +121,11 @@ namespace HandyControl.Controls
StepIndex = 0; StepIndex = 0;
return; return;
} }
if (UniformGridMain.Children[StepIndex + 1] is StepItem stepItemFinished) if (_panelMain.Children[StepIndex + 1] is StepItem stepItemFinished)
stepItemFinished.Status = null; stepItemFinished.Status = null;
if (UniformGridMain.Children[StepIndex] is StepItem stepItemSelected) if (_panelMain.Children[StepIndex] is StepItem stepItemSelected)
stepItemSelected.Status = false; stepItemSelected.Status = false;
ProgressBarBack.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex)); _progressBarBack.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
} }
} }
} }
-11
View File
@@ -1,11 +0,0 @@
<UserControl x:Class="HandyControl.Controls.StepBar"
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"
mc:Ignorable="d">
<Grid>
<ProgressBar HorizontalAlignment="Center" Name="ProgressBarBack" VerticalAlignment="Top" Margin="0,10,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
<UniformGrid Name="UniformGridMain" Rows="1"/>
</Grid>
</UserControl>
@@ -1,19 +1,16 @@
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using HandyControl.Tools;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
/// <summary> /// <summary>
/// StepItem.xaml 的交互逻辑 /// 步骤条单元项
/// </summary> /// </summary>
public partial class StepItem public class StepItem : Control
{ {
public StepItem()
{
InitializeComponent();
}
internal static readonly DependencyProperty IndexProperty = DependencyProperty.Register( internal static readonly DependencyProperty IndexProperty = DependencyProperty.Register(
"Index", typeof(int), typeof(StepItem), new PropertyMetadata(-1)); "Index", typeof(int), typeof(StepItem), new PropertyMetadata(-1));
@@ -28,7 +25,7 @@ namespace HandyControl.Controls
internal string IndexStr internal string IndexStr
{ {
get => (string) GetValue(IndexStrProperty); get => (string)GetValue(IndexStrProperty);
set => SetValue(IndexStrProperty, value); set => SetValue(IndexStrProperty, value);
} }
@@ -57,15 +54,15 @@ namespace HandyControl.Controls
{ {
if (Status == true) if (Status == true)
{ {
Foreground = TryFindResource("PrimaryTextBrush") as Brush; Foreground = ResourceHelper.GetResource<Brush>("PrimaryTextBrush");
} }
else if (Status == false) else if (Status == false)
{ {
Foreground = TryFindResource("PrimaryBrush") as Brush; Foreground = ResourceHelper.GetResource<Brush>("PrimaryBrush");
} }
else else
{ {
Foreground = TryFindResource("ThirdlyTextBrush") as Brush; Foreground = ResourceHelper.GetResource<Brush>("ThirdlyTextBrush");
} }
} }
} }
-17
View File
@@ -1,17 +0,0 @@
<UserControl x:Class="HandyControl.Controls.StepItem"
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"
mc:Ignorable="d"
Foreground="{DynamicResource ThirdlyTextBrush}"
Name="UserControlMain"
Margin="10,0">
<StackPanel>
<Border Background="White" HorizontalAlignment="Center" CornerRadius="12" BorderThickness="2" BorderBrush="{Binding Foreground,ElementName=UserControlMain}" Height="24" MinWidth="24">
<TextBlock Foreground="{Binding Foreground,ElementName=UserControlMain}" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Index,ElementName=UserControlMain}"/>
</Border>
<TextBlock Margin="0,10,0,0" Foreground="{Binding Foreground,ElementName=UserControlMain}" Style="{StaticResource TextBlockSubTitleBold}" Text="{Binding IndexStr,ElementName=UserControlMain}"/>
<TextBlock Foreground="{Binding Foreground,ElementName=UserControlMain}" Margin="0,4,0,0" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Title,ElementName=UserControlMain}"/>
</StackPanel>
</UserControl>
@@ -1,41 +1,90 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using HandyControl.Data; using HandyControl.Data;
using HandyControl.Interactivity;
using HandyControl.Tools;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
namespace HandyControl.Controls namespace HandyControl.Controls
{ {
/// <summary> /// <summary>
/// TimeBar.xaml 的交互逻辑 /// 时间条
/// </summary> /// </summary>
public partial class TimeBar [TemplatePart(Name = ElementBorderTop, Type = typeof(Border))]
[TemplatePart(Name = ElementTextBlockMove, Type = typeof(TextBlock))]
[TemplatePart(Name = ElementTextBlockSelected, Type = typeof(TextBlock))]
[TemplatePart(Name = ElementCanvasSpe, Type = typeof(Canvas))]
public class TimeBar : Control
{ {
#region Constants
private const string ElementBorderTop = "PART_BorderTop";
private const string ElementTextBlockMove = "PART_TextBlockMove";
private const string ElementTextBlockSelected = "PART_TextBlockSelected";
private const string ElementCanvasSpe = "PART_CanvasSpe";
#endregion Constants
#region Data
private Border _borderTop;
private TextBlock _textBlockMove;
private TextBlock _textBlockSelected;
private Canvas _canvasSpe;
#endregion Data
/// <summary> /// <summary>
/// 是否显示刻度字符串 /// 是否显示刻度字符串
/// </summary> /// </summary>
public static readonly DependencyProperty ShowSpeStrProperty = DependencyProperty.Register( public static readonly DependencyProperty ShowSpeStrProperty = DependencyProperty.Register(
"ShowSpeStr", typeof(bool), typeof(TimeBar), new PropertyMetadata(default(bool))); "ShowSpeStr", typeof(bool), typeof(TimeBar), new PropertyMetadata(default(bool)));
public static readonly DependencyProperty TimeFormatProperty = DependencyProperty.Register(
"TimeFormat", typeof(string), typeof(TimeBar), new PropertyMetadata("yyyy-MM-dd HH:mm:ss"));
public string TimeFormat
{
get => (string) GetValue(TimeFormatProperty);
set => SetValue(TimeFormatProperty, value);
}
/// <summary> /// <summary>
/// 刻度字符串 /// 刻度字符串
/// </summary> /// </summary>
private static readonly DependencyProperty SpeStrProperty = DependencyProperty.Register( internal static readonly DependencyProperty SpeStrProperty = DependencyProperty.Register(
"SpeStr", typeof(string), typeof(TimeBar), new PropertyMetadata(Properties.Langs.Lang.Interval1h)); "SpeStr", typeof(string), typeof(TimeBar), new PropertyMetadata(Properties.Langs.Lang.Interval1h));
/// <summary> /// <summary>
/// 选中时间 /// 选中时间
/// </summary> /// </summary>
private static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register( internal static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register(
"SelectedTime", typeof(DateTime), typeof(TimeBar)); "SelectedTime", typeof(DateTime), typeof(TimeBar), new PropertyMetadata(default(DateTime), OnSelectedTimeChanged));
private static void OnSelectedTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is TimeBar timeBar && timeBar._textBlockSelected != null)
{
timeBar._textBlockSelected.Text = ((DateTime) e.NewValue).ToString(timeBar.TimeFormat);
}
}
/// <summary> /// <summary>
/// 时间改变事件 /// 时间改变事件
/// </summary> /// </summary>
public static readonly RoutedEvent TimeChangedEvent = public static readonly RoutedEvent TimeChangedEvent =
EventManager.RegisterRoutedEvent("ButtonCloseClick", RoutingStrategy.Bubble, EventManager.RegisterRoutedEvent("TimeChanged", RoutingStrategy.Bubble,
typeof(EventHandler<FunctionEventArgs<DateTime>>), typeof(TimeBar)); typeof(EventHandler<FunctionEventArgs<DateTime>>), typeof(TimeBar));
/// <summary> /// <summary>
@@ -104,11 +153,48 @@ namespace HandyControl.Controls
public TimeBar() public TimeBar()
{ {
InitializeComponent();
_starTime = DateTime.Now; _starTime = DateTime.Now;
SelectedTime = new DateTime(_starTime.Year, _starTime.Month, _starTime.Day, 0, 0, 0); SelectedTime = new DateTime(_starTime.Year, _starTime.Month, _starTime.Day, 0, 0, 0);
_starTime = SelectedTime; _starTime = SelectedTime;
SizeChanged += TimeBar_OnSizeChanged;
MouseMove += TimeBar_OnMouseMove;
}
public override void OnApplyTemplate()
{
if (_borderTop != null)
{
_borderTop.MouseLeftButtonDown -= BorderTop_OnMouseLeftButtonDown;
_borderTop.PreviewMouseLeftButtonUp -= BorderTop_OnPreviewMouseLeftButtonUp;
}
base.OnApplyTemplate();
_borderTop = GetTemplateChild(ElementBorderTop) as Border;
_textBlockMove = GetTemplateChild(ElementTextBlockMove) as TextBlock;
_textBlockSelected = GetTemplateChild(ElementTextBlockSelected) as TextBlock;
_canvasSpe = GetTemplateChild(ElementCanvasSpe) as Canvas;
CheckNull();
_borderTop.MouseLeftButtonDown += BorderTop_OnMouseLeftButtonDown;
_borderTop.PreviewMouseLeftButtonUp += BorderTop_OnPreviewMouseLeftButtonUp;
var behavior = new MouseDragElementBehaviorEx
{
LockY = true,
};
behavior.DragBegun += DragElementBehavior_OnDragBegun;
behavior.Dragging += MouseDragElementBehavior_OnDragging;
behavior.DragFinished += MouseDragElementBehavior_OnDragFinished;
var collection = Interaction.GetBehaviors(_borderTop);
collection.Add(behavior);
_textBlockSelected.Text = SelectedTime.ToString(TimeFormat);
}
private void CheckNull()
{
if (_borderTop == null || _textBlockMove == null|| _textBlockSelected == null || _canvasSpe == null) throw new Exception();
} }
/// <summary> /// <summary>
@@ -123,7 +209,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 刻度字符串 /// 刻度字符串
/// </summary> /// </summary>
private string SpeStr internal string SpeStr
{ {
get => (string)GetValue(SpeStrProperty); get => (string)GetValue(SpeStrProperty);
set => SetValue(SpeStrProperty, value); set => SetValue(SpeStrProperty, value);
@@ -132,7 +218,7 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 选中时间 /// 选中时间
/// </summary> /// </summary>
private DateTime SelectedTime internal DateTime SelectedTime
{ {
get => (DateTime)GetValue(SelectedTimeProperty); get => (DateTime)GetValue(SelectedTimeProperty);
set => SetValue(SelectedTimeProperty, value); set => SetValue(SelectedTimeProperty, value);
@@ -286,7 +372,7 @@ namespace HandyControl.Controls
private void MouseDragElementBehavior_OnDragging(object sender, MouseEventArgs e) private void MouseDragElementBehavior_OnDragging(object sender, MouseEventArgs e)
{ {
_isDragging = true; _isDragging = true;
_tempOffsetX = BorderTop.RenderTransform.Value.OffsetX; _tempOffsetX = _borderTop.RenderTransform.Value.OffsetX;
SelectedTime = _mouseDownTime - SelectedTime = _mouseDownTime -
TimeSpan.FromMilliseconds(_tempOffsetX / _itemWidth * _timeSpeList[_speIndex]); TimeSpan.FromMilliseconds(_tempOffsetX / _itemWidth * _timeSpeList[_speIndex]);
@@ -297,8 +383,8 @@ namespace HandyControl.Controls
private void MouseDragElementBehavior_OnDragFinished(object sender, MouseEventArgs e) private void MouseDragElementBehavior_OnDragFinished(object sender, MouseEventArgs e)
{ {
_tempOffsetX = 0; _tempOffsetX = 0;
_totalOffsetX = (_totalOffsetX + BorderTop.RenderTransform.Value.OffsetX) % ActualWidth; _totalOffsetX = (_totalOffsetX + _borderTop.RenderTransform.Value.OffsetX) % ActualWidth;
BorderTop.RenderTransform = new TranslateTransform(); _borderTop.RenderTransform = new TranslateTransform();
RaiseEvent(new FunctionEventArgs<DateTime>(TimeChangedEvent, this) RaiseEvent(new FunctionEventArgs<DateTime>(TimeChangedEvent, this)
{ {
Info = SelectedTime Info = SelectedTime
@@ -306,15 +392,12 @@ namespace HandyControl.Controls
_isDragging = false; _isDragging = false;
} }
private void DragElementBehavior_OnDragBegun(object sender, MouseEventArgs e) private void DragElementBehavior_OnDragBegun(object sender, MouseEventArgs e) => _mouseDownTime = SelectedTime;
{
_mouseDownTime = SelectedTime;
}
private void TimeBar_OnSizeChanged(object sender, SizeChangedEventArgs e) private void TimeBar_OnSizeChanged(object sender, SizeChangedEventArgs e)
{ {
_speBlockList.Clear(); _speBlockList.Clear();
CanvasSpe.Children.Clear(); _canvasSpe.Children.Clear();
_speCount = (int)(ActualWidth / 800 * 9) | 1; _speCount = (int)(ActualWidth / 800 * 9) | 1;
@@ -335,7 +418,7 @@ namespace HandyControl.Controls
TimeFormat = "HH:mm" TimeFormat = "HH:mm"
}; };
_speBlockList.Add(block); _speBlockList.Add(block);
CanvasSpe.Children.Add(block); _canvasSpe.Children.Add(block);
} }
if (_speIndex == 6) if (_speIndex == 6)
SetSpeTimeFormat("HH:mm:ss"); SetSpeTimeFormat("HH:mm:ss");
@@ -356,16 +439,13 @@ namespace HandyControl.Controls
var p = Mouse.GetPosition(this); var p = Mouse.GetPosition(this);
var mlliseconds = (p.X - ActualWidth / 2) / _itemWidth * _timeSpeList[_speIndex]; var mlliseconds = (p.X - ActualWidth / 2) / _itemWidth * _timeSpeList[_speIndex];
if (double.IsInfinity(mlliseconds)) return; if (double.IsInfinity(mlliseconds)) return;
TextBlockSelected.Text = mlliseconds < 0 _textBlockMove.Text = mlliseconds < 0
? (SelectedTime - TimeSpan.FromMilliseconds(-mlliseconds)).ToString("yyyy-MM-dd HH:mm:ss") ? (SelectedTime - TimeSpan.FromMilliseconds(-mlliseconds)).ToString(TimeFormat)
: (SelectedTime + TimeSpan.FromMilliseconds(mlliseconds)).ToString("yyyy-MM-dd HH:mm:ss"); : (SelectedTime + TimeSpan.FromMilliseconds(mlliseconds)).ToString(TimeFormat);
TextBlockSelected.Margin = new Thickness(p.X - TextBlockSelected.ActualWidth / 2, 2, 0, 0); _textBlockMove.Margin = new Thickness(p.X - _textBlockMove.ActualWidth / 2, 2, 0, 0);
} }
private void BorderTop_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) private void BorderTop_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) => _borderTopIsMouseLeftButtonDown = true;
{
_borderTopIsMouseLeftButtonDown = true;
}
private void BorderTop_OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) private void BorderTop_OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{ {
@@ -1,52 +0,0 @@
<UserControl x:Class="HandyControl.Controls.TimeBar"
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:tools="clr-namespace:HandyControl.Tools"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
mc:Ignorable="d"
UseLayoutRounding="True"
BorderThickness="0,1,0,0"
Foreground="White"
Background="Black"
MouseMove="TimeBar_OnMouseMove"
SizeChanged="TimeBar_OnSizeChanged"
Height="60"
Name="MyUserControl"
BorderBrush="#232323">
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.MouseEnter" SourceName="MyUserControl">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="TextBlockSelected">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="FrameworkElement.MouseLeave" SourceName="MyUserControl">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="TextBlockSelected">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</UserControl.Triggers>
<Grid>
<Border BorderThickness="0,0,0,4" BorderBrush="White" VerticalAlignment="Top" Height="52">
<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"/>
</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 Visibility="Collapsed" Name="TextBlockSelected" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,0,0"/>
<Border Width="1" Background="{DynamicResource DangerBrush}"/>
<Canvas Name="CanvasSpe" VerticalAlignment="Bottom" Height="28" />
<Border PreviewMouseLeftButtonUp="BorderTop_OnPreviewMouseLeftButtonUp" MouseLeftButtonDown="BorderTop_OnMouseLeftButtonDown" Name="BorderTop" Background="Transparent" Cursor="Hand">
<interactivity:Interaction.Behaviors>
<tools:MouseDragElementBehaviorEx LockY="True" x:Name="DragElementBehavior" DragBegun="DragElementBehavior_OnDragBegun" DragFinished="MouseDragElementBehavior_OnDragFinished" Dragging="MouseDragElementBehavior_OnDragging"/>
</interactivity:Interaction.Behaviors>
</Border>
</Grid>
</UserControl>
@@ -1,7 +1,9 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using HandyControl.Interactivity;
using HandyControl.Tools; using HandyControl.Tools;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
@@ -10,18 +12,62 @@ namespace HandyControl.Controls
/// <summary> /// <summary>
/// 弹出窗口 /// 弹出窗口
/// </summary> /// </summary>
public partial class PopupWindow [TemplatePart(Name = ElementMainBorder, Type = typeof(Border))]
[TemplatePart(Name = ElementTitleBlock, Type = typeof(TextBlock))]
public class PopupWindow : Window
{ {
#region Constants
private const string ElementMainBorder = "PART_MainBorder";
private const string ElementTitleBlock = "PART_TitleBlock";
#endregion Constants
private Border _mainBorder;
private TextBlock _titleBlock;
public override void OnApplyTemplate()
{
if (_titleBlock != null)
{
_titleBlock.MouseLeftButtonDown -= TitleBlock_OnMouseLeftButtonDown;
}
base.OnApplyTemplate();
_mainBorder = GetTemplateChild(ElementMainBorder) as Border;
_titleBlock = GetTemplateChild(ElementTitleBlock) as TextBlock;
if (_titleBlock != null)
{
_titleBlock.MouseLeftButtonDown += TitleBlock_OnMouseLeftButtonDown;
}
}
internal static readonly DependencyProperty ContentStrProperty = DependencyProperty.Register(
"ContentStr", typeof(string), typeof(PopupWindow), new PropertyMetadata(default(string)));
internal string ContentStr
{
get => (string) GetValue(ContentStrProperty);
set => SetValue(ContentStrProperty, value);
}
private bool IsDialog { get; set; } private bool IsDialog { get; set; }
public PopupWindow() public PopupWindow()
{ {
CommandBindings.Add(new CommandBinding(ControlCommands.Close, CloseButton_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Confirm, ButtonOk_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, ButtonCancle_OnClick));
Closing += (sender, args) => Closing += (sender, args) =>
{ {
if (!IsDialog) if (!IsDialog)
Owner?.Focus(); Owner?.Focus();
}; };
InitializeComponent();
try try
{ {
Owner = Application.Current.MainWindow; Owner = Application.Current.MainWindow;
@@ -32,57 +78,55 @@ namespace HandyControl.Controls
} }
} }
public PopupWindow(Window owner) : this() public PopupWindow(Window owner) : this() => Owner = owner;
{
Owner = owner;
}
private void CloseButton_OnClick(object sender, RoutedEventArgs e) private void CloseButton_OnClick(object sender, RoutedEventArgs e) => Close();
{
Close();
}
public UIElement Child public UIElement Child
{ {
get => MainBorder.Child; get => _mainBorder?.Child;
set => MainBorder.Child = value;
}
public bool ShowTitle
{
set set
{ {
if (!value) if (_mainBorder != null)
{ {
TitleGrid.Visibility = Visibility.Collapsed; _mainBorder.Child = value;
Background = Brushes.Transparent;
}
else
{
TitleGrid.Visibility = Visibility.Visible;
Background = new SolidColorBrush(Color.FromRgb(1, 1, 1));
} }
} }
} }
public static readonly DependencyProperty ShowTitleProperty = DependencyProperty.Register(
"ShowTitle", typeof(bool), typeof(PopupWindow), new PropertyMetadata(true));
public bool ShowTitle
{
get => (bool) GetValue(ShowTitleProperty);
set => SetValue(ShowTitleProperty, value);
}
public static readonly DependencyProperty ShowCancelProperty = DependencyProperty.Register( public static readonly DependencyProperty ShowCancelProperty = DependencyProperty.Register(
"ShowCancel", typeof(bool), typeof(PopupWindow), new PropertyMetadata(default(bool))); "ShowCancel", typeof(bool), typeof(PopupWindow), new PropertyMetadata(default(bool)));
public bool ShowCancel public bool ShowCancel
{ {
get => (bool)GetValue(ShowCancelProperty); get => (bool)GetValue(ShowCancelProperty);
set => SetValue(ShowCancelProperty, value); set => SetValue(ShowCancelProperty, value);
} }
public static readonly DependencyProperty ShowBorderProperty = DependencyProperty.Register(
"ShowBorder", typeof(bool), typeof(PopupWindow), new PropertyMetadata(default(bool)));
public bool ShowBorder public bool ShowBorder
{ {
set => MainBorder.BorderThickness = value ? new Thickness(1, 0, 1, 1) : new Thickness(0); get => (bool) GetValue(ShowBorderProperty);
set => SetValue(ShowBorderProperty, value);
} }
private void TitleBlock_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) private void TitleBlock_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ {
DragMove(); if (e.LeftButton == MouseButtonState.Pressed)
{
DragMove();
}
} }
public void Show(FrameworkElement element) public void Show(FrameworkElement element)
@@ -113,25 +157,25 @@ namespace HandyControl.Controls
var window = new PopupWindow var window = new PopupWindow
{ {
AllowsTransparency = true, AllowsTransparency = true,
MyStackPanel = { Visibility = Visibility.Visible }, WindowStyle = WindowStyle.None,
MyTextBlock = { Text = message }, ContentStr = message,
WindowStartupLocation = WindowStartupLocation.CenterScreen, WindowStartupLocation = WindowStartupLocation.CenterScreen,
}; };
window.Background = window.FindResource("PrimaryBrush") as SolidColorBrush; window.Background = window.FindResource("PrimaryBrush") as SolidColorBrush;
window.Show(); window.Show();
} }
public static bool? ShowDialog(string message, string title = "提示", bool showCancel = false) public static bool? ShowDialog(string message, string title = default(string), bool showCancel = false)
{ {
var window = new PopupWindow var window = new PopupWindow
{ {
AllowsTransparency = true, AllowsTransparency = true,
MyStackPanel = { Visibility = Visibility.Visible }, WindowStyle = WindowStyle.None,
MyTextBlock = { Text = message }, ContentStr = message,
IsDialog = true, IsDialog = true,
WindowStartupLocation = WindowStartupLocation.CenterScreen, WindowStartupLocation = WindowStartupLocation.CenterScreen,
ShowBorder = true, ShowBorder = true,
Title = title, Title = string.IsNullOrEmpty(title) ? Properties.Langs.Lang.Tip : title,
ShowCancel = showCancel ShowCancel = showCancel
}; };
return window.ShowDialog(); return window.ShowDialog();
@@ -161,4 +205,4 @@ namespace HandyControl.Controls
Child = null; Child = null;
} }
} }
} }
@@ -1,61 +0,0 @@
<Window x:Class="HandyControl.Controls.PopupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
WindowStyle="None"
Name="MyWindow"
MinHeight="220"
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
BorderThickness="20"
ShowInTaskbar="False"
MinWidth="300"
UseLayoutRounding="True"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight">
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
<Window.Effect>
<DropShadowEffect Opacity=".6" ShadowDepth="0" BlurRadius="15"/>
</Window.Effect>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Name="TitleGrid" Height="30" Background="{DynamicResource PrimaryBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Name="TitleBlock" Background="Transparent" MouseLeftButtonDown="TitleBlock_OnMouseLeftButtonDown" Padding="10,6" FontSize="14" Foreground="White" Text="{Binding Title,ElementName=MyWindow}" VerticalAlignment="Center" TextWrapping="Wrap" TextTrimming="WordEllipsis"/>
<Button Foreground="White" Grid.Column="1" controls:BackgroundSwitchElement.MouseHoverBackground="Red" controls:BackgroundSwitchElement.MouseDownBackground="Red" Click="CloseButton_OnClick" IsCancel="True" Name="CloseButton" IsTabStop="False" WindowChrome.IsHitTestVisibleInChrome="True" Height="28" Style="{StaticResource ButtonCustom}" Width="44" controls:IconElement.Geometry="{StaticResource CloseGeometry}" Padding="9">
<Path Fill="{Binding ElementName=CloseButton,Path=Foreground}" Style="{StaticResource ClosePathStyle}"/>
</Button>
</Grid>
<Border BorderBrush="{DynamicResource PrimaryBrush}" Name="MainBorder" Grid.Row="1">
<StackPanel>
<TextBlock Text="" MinHeight="110" Name="MyTextBlock" TextAlignment="Center" FontSize="16" Padding="32" Foreground="#252525" MaxWidth="300" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Background="White"/>
<StackPanel Name="MyStackPanel" Margin="0,0,0,32" Orientation="Horizontal" Background="White" HorizontalAlignment="Center">
<Button Name="ButtonCancle" Visibility="{Binding ShowCancel,ElementName=MyWindow,Converter={StaticResource Boolean2VisibilityConverter}}" Click="ButtonCancle_OnClick" Margin="0,0,16,0" Background="Transparent" Style="{StaticResource ButtonCustom}">
<Border BorderThickness="1" BorderBrush="{DynamicResource PrimaryBrush}" MinWidth="80" Height="30" CornerRadius="4" Background="White">
<TextBlock FontSize="16" Text="{x:Static langs:Lang.Cancel}" Foreground="{DynamicResource PrimaryBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Button>
<Button IsDefault="True" Click="ButtonOk_OnClick" Background="Transparent" Style="{DynamicResource ButtonCustom}">
<Border MinWidth="80" Height="30" CornerRadius="4" Background="{DynamicResource PrimaryBrush}">
<TextBlock FontSize="16" Text="{x:Static langs:Lang.Confirm}" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Button>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</Window>
+30 -42
View File
@@ -42,21 +42,17 @@
<Compile Include="Controls\Attach\StatusSwitchElement.cs" /> <Compile Include="Controls\Attach\StatusSwitchElement.cs" />
<Compile Include="Controls\Button\ContextMenuButton.cs" /> <Compile Include="Controls\Button\ContextMenuButton.cs" />
<Compile Include="Controls\Button\ContextMenuToggleButton.cs" /> <Compile Include="Controls\Button\ContextMenuToggleButton.cs" />
<Compile Include="Controls\Carousel.xaml.cs"> <Compile Include="Controls\Carousel.cs" />
<DependentUpon>Carousel.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\CirclePanel.cs" /> <Compile Include="Controls\CirclePanel.cs" />
<Compile Include="Controls\Clock\Clock.cs" /> <Compile Include="Controls\Clock\Clock.cs" />
<Compile Include="Controls\Clock\ClockRadioButton.cs" /> <Compile Include="Controls\Clock\ClockRadioButton.cs" />
<Compile Include="Controls\Growl.cs" />
<Compile Include="Controls\Pagination.cs" /> <Compile Include="Controls\Pagination.cs" />
<Compile Include="Controls\Picker\ColorPicker.xaml.cs"> <Compile Include="Controls\Picker\ColorPicker.xaml.cs">
<DependentUpon>ColorPicker.xaml</DependentUpon> <DependentUpon>ColorPicker.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\Attach\IconElement.cs" /> <Compile Include="Controls\Attach\IconElement.cs" />
<Compile Include="Controls\CompareSlider.cs" /> <Compile Include="Controls\CompareSlider.cs" />
<Compile Include="Controls\Growl.xaml.cs">
<DependentUpon>Growl.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ScrollViewer.cs" /> <Compile Include="Controls\ScrollViewer.cs" />
<Compile Include="Controls\Info\InfoControl.cs" /> <Compile Include="Controls\Info\InfoControl.cs" />
<Compile Include="Controls\Info\InfoNumericUpDown.xaml.cs"> <Compile Include="Controls\Info\InfoNumericUpDown.xaml.cs">
@@ -68,28 +64,20 @@
<Compile Include="Controls\Loading\LoadingBase.cs" /> <Compile Include="Controls\Loading\LoadingBase.cs" />
<Compile Include="Controls\Loading\LoadingCircle.cs" /> <Compile Include="Controls\Loading\LoadingCircle.cs" />
<Compile Include="Controls\Loading\LoadingLine.cs" /> <Compile Include="Controls\Loading\LoadingLine.cs" />
<Compile Include="Controls\Steps\StepBar.xaml.cs"> <Compile Include="Controls\Steps\StepBar.cs" />
<DependentUpon>StepBar.xaml</DependentUpon> <Compile Include="Controls\Steps\StepItem.cs" />
</Compile>
<Compile Include="Controls\Steps\StepItem.xaml.cs">
<DependentUpon>StepItem.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\TabControl\TabControl.cs" /> <Compile Include="Controls\TabControl\TabControl.cs" />
<Compile Include="Controls\TabControl\TabItem.cs" /> <Compile Include="Controls\TabControl\TabItem.cs" />
<Compile Include="Controls\TabControl\TabPanel.cs" /> <Compile Include="Controls\TabControl\TabPanel.cs" />
<Compile Include="Controls\TimeBar\SpeTextBlock.cs" /> <Compile Include="Controls\TimeBar\SpeTextBlock.cs" />
<Compile Include="Controls\TimeBar\TimeBar.xaml.cs">
<DependentUpon>TimeBar.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Picker\TimePicker.cs" /> <Compile Include="Controls\Picker\TimePicker.cs" />
<Compile Include="Controls\TimeBar\TimeBar.cs" />
<Compile Include="Controls\TransitioningContentControl.cs" /> <Compile Include="Controls\TransitioningContentControl.cs" />
<Compile Include="Controls\WatermarkTextBox.cs" /> <Compile Include="Controls\WatermarkTextBox.cs" />
<Compile Include="Controls\Window\ImageBrowser.xaml.cs"> <Compile Include="Controls\Window\ImageBrowser.xaml.cs">
<DependentUpon>ImageBrowser.xaml</DependentUpon> <DependentUpon>ImageBrowser.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\Window\PopupWindow.xaml.cs"> <Compile Include="Controls\Window\PopupWindow.cs" />
<DependentUpon>PopupWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\Window\WindowBorderless.cs" /> <Compile Include="Controls\Window\WindowBorderless.cs" />
<Compile Include="Data\BooleanBoxes.cs" /> <Compile Include="Data\BooleanBoxes.cs" />
<Compile Include="Data\ColorRange.cs" /> <Compile Include="Data\ColorRange.cs" />
@@ -169,18 +157,10 @@
<Resource Include="Resources\colorPickerBack.png" /> <Resource Include="Resources\colorPickerBack.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Controls\Carousel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Picker\ColorPicker.xaml"> <Page Include="Controls\Picker\ColorPicker.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\Growl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Info\InfoNumericUpDown.xaml"> <Page Include="Controls\Info\InfoNumericUpDown.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -189,26 +169,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\Steps\StepBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Steps\StepItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\TimeBar\TimeBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\Window\ImageBrowser.xaml"> <Page Include="Controls\Window\ImageBrowser.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Controls\Window\PopupWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Basic\Basic.xaml"> <Page Include="Themes\Basic\Basic.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -329,10 +293,18 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Styles\Carousel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Clock.xaml"> <Page Include="Themes\Styles\Clock.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Styles\ColorPicker.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\ComboBox.xaml"> <Page Include="Themes\Styles\ComboBox.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -353,6 +325,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Styles\Growl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\ListBox.xaml"> <Page Include="Themes\Styles\ListBox.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -381,6 +357,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Styles\Steps.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Style.xaml"> <Page Include="Themes\Styles\Style.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -397,6 +377,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Styles\TimeBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\TimePicker.xaml"> <Page Include="Themes\Styles\TimePicker.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -405,6 +389,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Themes\Styles\TransitioningContentControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\TreeView.xaml"> <Page Include="Themes\Styles\TreeView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -17,6 +17,16 @@ namespace HandyControl.Interactivity
/// </summary> /// </summary>
public static RoutedCommand Close { get; } = new RoutedCommand("Close", typeof(ControlCommands)); public static RoutedCommand Close { get; } = new RoutedCommand("Close", typeof(ControlCommands));
/// <summary>
/// 取消
/// </summary>
public static RoutedCommand Cancel { get; } = new RoutedCommand("Cancel", typeof(ControlCommands));
/// <summary>
/// 确定
/// </summary>
public static RoutedCommand Confirm { get; } = new RoutedCommand("Confirm", typeof(ControlCommands));
/// <summary> /// <summary>
/// 关闭所有 /// 关闭所有
/// </summary> /// </summary>
+2 -2
View File
@@ -10,5 +10,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.3.2.1")] [assembly: AssemblyVersion("1.3.2.2")]
[assembly: AssemblyFileVersion("1.3.2.1")] [assembly: AssemblyFileVersion("1.3.2.2")]
+9
View File
@@ -231,6 +231,15 @@ namespace HandyControl.Properties.Langs {
} }
} }
/// <summary>
/// 查找类似 提示 的本地化字符串。
/// </summary>
public static string Tip {
get {
return ResourceManager.GetString("Tip", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 过大 的本地化字符串。 /// 查找类似 过大 的本地化字符串。
/// </summary> /// </summary>
@@ -183,4 +183,7 @@
<data name="Pm" xml:space="preserve"> <data name="Pm" xml:space="preserve">
<value>Pm</value> <value>Pm</value>
</data> </data>
<data name="Tip" xml:space="preserve">
<value>Prompt</value>
</data>
</root> </root>
+3
View File
@@ -163,4 +163,7 @@
<data name="Pm" xml:space="preserve"> <data name="Pm" xml:space="preserve">
<value>下午</value> <value>下午</value>
</data> </data>
<data name="Tip" xml:space="preserve">
<value>提示</value>
</data>
</root> </root>
+2
View File
@@ -47,4 +47,6 @@
<SolidColorBrush x:Key="DarkAccentBrush" Color="{DynamicResource DarkAccentColor}"/> <SolidColorBrush x:Key="DarkAccentBrush" Color="{DynamicResource DarkAccentColor}"/>
<SolidColorBrush x:Key="DarkMaskBrush" Color="{DynamicResource DarkMaskColor}"/> <SolidColorBrush x:Key="DarkMaskBrush" Color="{DynamicResource DarkMaskColor}"/>
<SolidColorBrush x:Key="DarkOpacityBrush" Color="{DynamicResource DarkOpacityColor}"/>
</ResourceDictionary> </ResourceDictionary>
+1
View File
@@ -32,4 +32,5 @@
<Color x:Key="DarkAccentColor">#d43f3a</Color> <Color x:Key="DarkAccentColor">#d43f3a</Color>
<Color x:Key="DarkMaskColor">#20000000</Color> <Color x:Key="DarkMaskColor">#20000000</Color>
<Color x:Key="DarkOpacityColor">#40000000</Color>
</ResourceDictionary> </ResourceDictionary>
+53
View File
@@ -0,0 +1,53 @@
<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 Source="Button.xaml"/>
<ResourceDictionary Source="ListBox.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:Carousel" BasedOn="{StaticResource StackPanelListBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Carousel">
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="GridTop" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="FrameworkElement.MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="GridTop" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
<Grid ClipToBounds="True">
<ItemsPresenter x:Name="PART_ItemsControl" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Left"/>
<Grid Name="GridTop" Opacity="0">
<Button Command="interactivity:ControlCommands.Prev" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,0" Style="{StaticResource ButtonCustom}">
<Border Width="50" Height="100" Background="{DynamicResource DarkOpacityBrush}" CornerRadius="4">
<Path Margin="16" Fill="White" Style="{StaticResource LeftPathStyle}"/>
</Border>
</Button>
<Button Command="interactivity:ControlCommands.Next" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,30,0" Style="{StaticResource ButtonCustom}">
<Border Width="50" Height="100" Background="{DynamicResource DarkOpacityBrush}" CornerRadius="4">
<Path Margin="16" Fill="White" Style="{StaticResource RightPathStyle}"/>
</Border>
</Button>
</Grid>
<StackPanel Name="PART_PanelPage" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,20"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -0,0 +1,4 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
</ResourceDictionary>
+60
View File
@@ -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:langs="clr-namespace:HandyControl.Properties.Langs"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
<ResourceDictionary Source="../Basic/Effects.xaml"/>
<ResourceDictionary Source="TextBlock.xaml"/>
<ResourceDictionary Source="Button.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:Growl">
<Setter Property="MinHeight" Value="60"/>
<Setter Property="Width" Value="320"/>
<Setter Property="Margin" Value="10,0,0,10"/>
<Setter Property="MaxWidth" Value="320"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Growl">
<Grid Name="PART_GridMain" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<TranslateTransform X="{TemplateBinding MaxWidth}"/>
</TransformGroup>
</Grid.RenderTransform>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50"/>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.ColumnSpan="3" Grid.RowSpan="2" Effect="{StaticResource EffectShadow2}" Background="White" CornerRadius="8" Width="320"/>
<Path Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="0,15,0,0" Width="30" Height="30" Data="{TemplateBinding Icon}" Stretch="Uniform" Fill="{TemplateBinding IconBrush}"/>
<StackPanel Grid.Row="0" Grid.Column="1" Margin="0,12,10,10">
<TextBlock Text="{TemplateBinding Message}" Style="{StaticResource TextBlockDefault}" HorizontalAlignment="Left" TextWrapping="Wrap"/>
<TextBlock Text="{Binding Time,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:Growl},StringFormat=yyyy/MM/dd HH:mm:ss}" Style="{StaticResource TextBlockDefault}" Foreground="{DynamicResource SecondaryTextBrush}" HorizontalAlignment="Left" Margin="0,4,0,0"/>
</StackPanel>
<Button Grid.Row="0" Visibility="Collapsed" Margin="11,0" Name="PART_ButtonClose" Command="interactivity:ControlCommands.Close" Grid.Column="2" Background="Transparent" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center" HorizontalAlignment="Center" Width="18" Height="18">
<Path Data="{StaticResource ErrorGeometry}" Stretch="Uniform" Fill="{DynamicResource SecondaryTextBrush}"/>
</Button>
<StackPanel Name="PART_PanelMore" IsEnabled="False" Visibility="Collapsed" Orientation="Horizontal" Grid.Row="1" Grid.ColumnSpan="3" Height="28" Grid.Column="0">
<Button Command="interactivity:ControlCommands.Cancel" Style="{StaticResource ButtonCustom}" Width="160">
<TextBlock Text="{x:Static langs:Lang.Cancel}" HorizontalAlignment="Center" Foreground="{DynamicResource DangerBrush}"/>
</Button>
<Button Command="interactivity:ControlCommands.Confirm" Style="{StaticResource ButtonCustom}" Width="160">
<TextBlock Text="{x:Static langs:Lang.Confirm}" HorizontalAlignment="Center" Foreground="{DynamicResource PrimaryBrush}"/>
</Button>
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+1 -1
View File
@@ -42,7 +42,7 @@
</Style> </Style>
<ItemsPanelTemplate x:Key="StackPanelItemsPanelTemplate"> <ItemsPanelTemplate x:Key="StackPanelItemsPanelTemplate">
<StackPanel FocusVisualStyle="{x:Null}" Orientation="Horizontal"/> <StackPanel FocusVisualStyle="{x:Null}" Orientation="Horizontal" HorizontalAlignment="Left"/>
</ItemsPanelTemplate> </ItemsPanelTemplate>
<Style x:Key="StackPanelListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="{x:Type ListBox}"> <Style x:Key="StackPanelListBox" BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="{x:Type ListBox}">
@@ -56,6 +56,9 @@
</Style> </Style>
<Style TargetType="controls:Pagination"> <Style TargetType="controls:Pagination">
<Setter Property="Height" Value="40"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="controls:Pagination"> <ControlTemplate TargetType="controls:Pagination">
+40
View File
@@ -0,0 +1,40 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="TextBlock.xaml"/>
<ResourceDictionary Source="ProgressBar.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:StepItem">
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"/>
<Setter Property="Margin" Value="10,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepItem">
<StackPanel>
<Border Background="White" HorizontalAlignment="Center" CornerRadius="12" BorderThickness="2" BorderBrush="{TemplateBinding Foreground}" Height="24" MinWidth="24">
<TextBlock Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockDefaultThiLight}" Text="{Binding Index,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepItem}}"/>
</Border>
<TextBlock Margin="0,10,0,0" Foreground="{TemplateBinding Foreground}" Style="{StaticResource TextBlockSubTitleBold}" Text="{TemplateBinding IndexStr}"/>
<TextBlock Foreground="{TemplateBinding Foreground}" Margin="0,4,0,0" Style="{StaticResource TextBlockDefaultThiLight}" Text="{TemplateBinding Title}"/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="controls:StepBar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:StepBar">
<Grid>
<ProgressBar HorizontalAlignment="Center" Name="PART_ProgressBarBack" VerticalAlignment="Top" Margin="0,10,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
<UniformGrid Name="PART_UniformGridMain" Rows="1"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+6
View File
@@ -25,6 +25,12 @@
<ResourceDictionary Source="DatePicker.xaml"/> <ResourceDictionary Source="DatePicker.xaml"/>
<ResourceDictionary Source="TimePicker.xaml"/> <ResourceDictionary Source="TimePicker.xaml"/>
<ResourceDictionary Source="ContentControl.xaml"/> <ResourceDictionary Source="ContentControl.xaml"/>
<ResourceDictionary Source="Growl.xaml"/>
<ResourceDictionary Source="Steps.xaml"/>
<ResourceDictionary Source="Carousel.xaml"/>
<ResourceDictionary Source="TimeBar.xaml"/>
<ResourceDictionary Source="ColorPicker.xaml"/>
<ResourceDictionary Source="TransitioningContentControl.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
+58
View File
@@ -0,0 +1,58 @@
<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/Paths.xaml"/>
<ResourceDictionary Source="../Basic/Converters.xaml"/>
<ResourceDictionary Source="Button.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:TimeBar">
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="BorderThickness" Value="0,1,0,0"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Black"/>
<Setter Property="Height" Value="60"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:TimeBar">
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PART_TextBlockMove">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="FrameworkElement.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PART_TextBlockMove">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ControlTemplate.Triggers>
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<Grid>
<Border BorderThickness="0,0,0,4" BorderBrush="White" VerticalAlignment="Top" Height="52">
<TextBlock FontSize="16" Name="PART_TextBlockSelected" VerticalAlignment="Top" Margin="0,14,0,0" HorizontalAlignment="Center"/>
</Border>
<TextBlock Visibility="{TemplateBinding ShowSpeStr,Converter={StaticResource Boolean2VisibilityConverter}}" Text="{TemplateBinding SpeStr}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,14,10,0"/>
<TextBlock Visibility="Collapsed" Name="PART_TextBlockMove" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,0,0"/>
<Border Width="1" Background="{DynamicResource DangerBrush}"/>
<Canvas Name="PART_CanvasSpe" VerticalAlignment="Bottom" Height="28"/>
<Border Name="PART_BorderTop" Background="Transparent" Cursor="Hand"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -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">
<Style TargetType="controls:TransitioningContentControl">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Focusable" Value="False"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Transition" Value="DefaultTransition" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:TransitioningContentControl">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PresentationStates">
<VisualState x:Name="DefaultTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.500" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" From="50" To="0">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="UpTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="30" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="-30" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="DownTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="-40" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="40" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<ContentPresenter x:Name="PreviousContentPresentationSite" Content="{x:Null}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<ContentPresenter.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</ContentPresenter.RenderTransform>
</ContentPresenter>
<ContentPresenter x:Name="CurrentContentPresentationSite" Content="{x:Null}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<ContentPresenter.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</ContentPresenter.RenderTransform>
</ContentPresenter>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+71 -94
View File
@@ -1,12 +1,14 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"> xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Button.xaml"/> <ResourceDictionary Source="Button.xaml"/>
<ResourceDictionary Source="ToggleButton.xaml"/> <ResourceDictionary Source="ToggleButton.xaml"/>
<ResourceDictionary Source="../Basic/Geometries.xaml"/>
<ResourceDictionary Source="../Basic/Converters.xaml"/> <ResourceDictionary Source="../Basic/Converters.xaml"/>
<ResourceDictionary Source="../Basic/Paths.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<Style x:Key="WindowDefaultStyle" BasedOn="{x:Null}" TargetType="{x:Type Window}"> <Style x:Key="WindowDefaultStyle" BasedOn="{x:Null}" TargetType="{x:Type Window}">
@@ -126,106 +128,81 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style TargetType="controls:TransitioningContentControl"> <Style TargetType="controls:PopupWindow">
<Setter Property="IsTabStop" Value="False" /> <Setter Property="WindowStyle" Value="None"/>
<Setter Property="Focusable" Value="False"/> <Setter Property="MinHeight" Value="220"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="VerticalContentAlignment" Value="Stretch" /> <Setter Property="BorderThickness" Value="20"/>
<Setter Property="Transition" Value="DefaultTransition" /> <Setter Property="ShowInTaskbar" Value="False"/>
<Setter Property="MinWidth" Value="300"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="Background" Value="White"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Opacity=".6" ShadowDepth="0" BlurRadius="15"/>
</Setter.Value>
</Setter>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="controls:TransitioningContentControl"> <ControlTemplate TargetType="controls:PopupWindow">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"> <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PresentationStates">
<VisualState x:Name="DefaultTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.500" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" From="50" To="0">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.100" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="UpTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="30" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="-30" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="DownTransition">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="CurrentContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="-40" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="PreviousContentPresentationSite" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
<SplineDoubleKeyFrame KeyTime="00:00:00.300" Value="40" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid> <Grid>
<ContentPresenter x:Name="PreviousContentPresentationSite" Content="{x:Null}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> <Grid.RowDefinitions>
<ContentPresenter.RenderTransform> <RowDefinition Height="Auto"/>
<TransformGroup> <RowDefinition/>
<ScaleTransform /> <RowDefinition Height="Auto"/>
<SkewTransform /> </Grid.RowDefinitions>
<RotateTransform /> <Grid Name="TitleGrid" Height="30" Background="{DynamicResource PrimaryBrush}">
<TranslateTransform /> <Grid.ColumnDefinitions>
</TransformGroup> <ColumnDefinition/>
</ContentPresenter.RenderTransform> <ColumnDefinition Width="Auto"/>
</ContentPresenter> </Grid.ColumnDefinitions>
<ContentPresenter x:Name="CurrentContentPresentationSite" Content="{x:Null}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> <TextBlock Name="PART_TitleBlock" Background="Transparent" Padding="10,6" FontSize="14" Foreground="White" Text="{TemplateBinding Title}" VerticalAlignment="Center" TextWrapping="Wrap" TextTrimming="WordEllipsis"/>
<ContentPresenter.RenderTransform> <Button Margin="0,0,1,0" Background="Transparent" Name="CloseButton" Foreground="White" Grid.Column="1" controls:BackgroundSwitchElement.MouseHoverBackground="Red" controls:BackgroundSwitchElement.MouseDownBackground="Red" Command="interactivity:ControlCommands.Close" IsCancel="True" Height="28" Style="{StaticResource ButtonCustom}" Width="44" controls:IconElement.Geometry="{StaticResource CloseGeometry}" Padding="9">
<TransformGroup> <Path Fill="{Binding ElementName=CloseButton,Path=Foreground}" Style="{StaticResource ClosePathStyle}"/>
<ScaleTransform /> </Button>
<SkewTransform /> </Grid>
<RotateTransform /> <Border BorderBrush="{DynamicResource PrimaryBrush}" Name="PART_MainBorder" Grid.Row="1">
<TranslateTransform /> <StackPanel>
</TransformGroup> <TextBlock Text="{TemplateBinding ContentStr}" MinHeight="110" Name="MyTextBlock" TextAlignment="Center" FontSize="16" Padding="32" Foreground="#252525" MaxWidth="300" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Background="White"/>
</ContentPresenter.RenderTransform> <StackPanel Margin="0,0,0,32" Orientation="Horizontal" Background="White" HorizontalAlignment="Center">
</ContentPresenter> <Button Command="interactivity:ControlCommands.Cancel" Visibility="{TemplateBinding ShowCancel,Converter={StaticResource Boolean2VisibilityConverter}}" Margin="0,0,16,0" Background="Transparent" Style="{StaticResource ButtonCustom}">
<Border BorderThickness="1" BorderBrush="{DynamicResource PrimaryBrush}" MinWidth="80" Height="30" CornerRadius="4" Background="White">
<TextBlock FontSize="16" Text="{x:Static langs:Lang.Cancel}" Foreground="{DynamicResource PrimaryBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Button>
<Button IsDefault="True" Command="interactivity:ControlCommands.Confirm" Background="Transparent" Style="{StaticResource ButtonCustom}">
<Border MinWidth="80" Height="30" CornerRadius="4" Background="{DynamicResource PrimaryBrush}">
<TextBlock FontSize="16" Text="{x:Static langs:Lang.Confirm}" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Button>
</StackPanel>
</StackPanel>
</Border>
</Grid> </Grid>
</Border> </Border>
<ControlTemplate.Triggers>
<Trigger Property="ShowBorder" Value="True">
<Setter Property="BorderThickness" Value="1,0,1,1" TargetName="PART_MainBorder"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="TitleGrid"/>
<Setter Property="Background" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:.2"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>
+2 -2
View File
@@ -12,5 +12,5 @@ using System.Windows;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.3.2.1")] [assembly: AssemblyVersion("1.3.2.2")]
[assembly: AssemblyFileVersion("1.3.2.1")] [assembly: AssemblyFileVersion("1.3.2.2")]
@@ -4,7 +4,7 @@
Background="White" Background="White"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"> xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl">
<controls:TransitioningContentControl> <controls:TransitioningContentControl>
<controls:Carousel Margin="32" AutoRun="True" Width="600" Height="330" VerticalAlignment="Center"> <controls:Carousel Margin="32" IsCenter="True" AutoRun="True" Width="600" Height="330" VerticalAlignment="Center">
<Image Width="600" Stretch="UniformToFill" Source="/HandyControlDemo;component/Resources/Img/1.jpg"/> <Image Width="600" Stretch="UniformToFill" Source="/HandyControlDemo;component/Resources/Img/1.jpg"/>
<Image Width="300" Stretch="UniformToFill" Source="/HandyControlDemo;component/Resources/Img/2.jpg"/> <Image Width="300" Stretch="UniformToFill" Source="/HandyControlDemo;component/Resources/Img/2.jpg"/>
<Grid Width="600"> <Grid Width="600">
@@ -7,7 +7,7 @@
FocusManager.FocusedElement="{Binding RelativeSource={x:Static RelativeSource.Self}, Mode=OneTime}" FocusManager.FocusedElement="{Binding RelativeSource={x:Static RelativeSource.Self}, Mode=OneTime}"
Background="White"> Background="White">
<controls:TransitioningContentControl> <controls:TransitioningContentControl>
<StackPanel Margin="32" VerticalAlignment="Center" Width="600"> <StackPanel Margin="32" VerticalAlignment="Center" MaxWidth="800">
<controls:StepBar x:Name="StepBarMain"> <controls:StepBar x:Name="StepBarMain">
<controls:StepItem Title="{x:Static langs:Lang.Register}"/> <controls:StepItem Title="{x:Static langs:Lang.Register}"/>
<controls:StepItem Title="{x:Static langs:Lang.BasicInfo}"/> <controls:StepItem Title="{x:Static langs:Lang.BasicInfo}"/>