improve stepbar
This commit is contained in:
1 parent
bc2bd5413c
commit
dec0d37b31
27 files changed
+591
-308
No files matched your search
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
[StyleTypedProperty(Property = "ItemContainerStyle", StyleTargetType = typeof(StepBarItem))]
|
||||
[DefaultEvent("StepChanged")]
|
||||
[TemplatePart(Name = ElementProgressBarBack, Type = typeof(ProgressBar))]
|
||||
public class StepBar : ItemsControl
|
||||
{
|
||||
private ProgressBar _progressBarBack;
|
||||
|
||||
#region Constants
|
||||
|
||||
private const string ElementProgressBarBack = "PART_ProgressBarBack";
|
||||
|
||||
#endregion Constants
|
||||
|
||||
public StepBar()
|
||||
{
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => Next()));
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => Prev()));
|
||||
ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
|
||||
}
|
||||
|
||||
private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
|
||||
{
|
||||
var count = Items.Count;
|
||||
if (count > 0)
|
||||
{
|
||||
if (ItemContainerGenerator.ContainerFromIndex(0) is StepBarItem item)
|
||||
{
|
||||
item.Status = StepStatus.UnderWay;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepBarItem)
|
||||
{
|
||||
stepBarItem.Index = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item) => item is StepBarItem;
|
||||
|
||||
protected override DependencyObject GetContainerForItemOverride() => new StepBarItem();
|
||||
|
||||
/// <summary>
|
||||
/// 步骤改变事件
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent StepChangedEvent =
|
||||
EventManager.RegisterRoutedEvent("StepChanged", RoutingStrategy.Bubble,
|
||||
typeof(EventHandler<FunctionEventArgs<int>>), typeof(StepBar));
|
||||
|
||||
/// <summary>
|
||||
/// 步骤改变事件
|
||||
/// </summary>
|
||||
[Category("Behavior")]
|
||||
public event EventHandler<FunctionEventArgs<int>> StepChanged
|
||||
{
|
||||
add => AddHandler(StepChangedEvent, value);
|
||||
remove => RemoveHandler(StepChangedEvent, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty StepIndexProperty = DependencyProperty.Register(
|
||||
"StepIndex", typeof(int), typeof(StepBar), new PropertyMetadata(default(int)));
|
||||
|
||||
public int StepIndex
|
||||
{
|
||||
get => (int) GetValue(StepIndexProperty);
|
||||
protected set => SetValue(StepIndexProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DockProperty = DependencyProperty.Register(
|
||||
"Dock", typeof(Dock), typeof(StepBar), new PropertyMetadata(Dock.Top));
|
||||
|
||||
public Dock Dock
|
||||
{
|
||||
get => (Dock) GetValue(DockProperty);
|
||||
set => SetValue(DockProperty, value);
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_progressBarBack = GetTemplateChild(ElementProgressBarBack) as ProgressBar;
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
base.OnRender(drawingContext);
|
||||
|
||||
var colCount = Items.Count;
|
||||
if (_progressBarBack == null || colCount <= 0) return;
|
||||
_progressBarBack.Maximum = colCount - 1;
|
||||
_progressBarBack.Value = StepIndex;
|
||||
|
||||
if (Dock == Dock.Top || Dock == Dock.Bottom)
|
||||
{
|
||||
_progressBarBack.Width = (colCount - 1) * (ActualWidth / colCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
_progressBarBack.Height = (colCount - 1) * (ActualHeight / colCount);
|
||||
}
|
||||
}
|
||||
|
||||
public void Next()
|
||||
{
|
||||
StepIndex++;
|
||||
if (StepIndex >= Items.Count)
|
||||
{
|
||||
StepIndex = Items.Count - 1;
|
||||
return;
|
||||
}
|
||||
RaiseEvent(new FunctionEventArgs<int>(StepChangedEvent, this)
|
||||
{
|
||||
Info = StepIndex
|
||||
});
|
||||
if (ItemContainerGenerator.ContainerFromIndex(StepIndex - 1) is StepBarItem stepItemFinished)
|
||||
stepItemFinished.Status = StepStatus.Complete;
|
||||
if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem stepItemSelected)
|
||||
stepItemSelected.Status = StepStatus.UnderWay;
|
||||
_progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
|
||||
}
|
||||
|
||||
public void Prev()
|
||||
{
|
||||
StepIndex--;
|
||||
if (StepIndex < 0)
|
||||
{
|
||||
StepIndex = 0;
|
||||
return;
|
||||
}
|
||||
RaiseEvent(new FunctionEventArgs<int>(StepChangedEvent, this)
|
||||
{
|
||||
Info = StepIndex
|
||||
});
|
||||
if (ItemContainerGenerator.ContainerFromIndex(StepIndex + 1) is StepBarItem stepItemWaiting)
|
||||
stepItemWaiting.Status = StepStatus.Waiting;
|
||||
if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem stepItemSelected)
|
||||
stepItemSelected.Status = StepStatus.UnderWay;
|
||||
_progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤条单元项
|
||||
/// </summary>
|
||||
public class StepBarItem : ContentControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤编号
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IndexProperty = DependencyProperty.Register(
|
||||
"Index", typeof(int), typeof(StepBarItem), new PropertyMetadata(-1));
|
||||
|
||||
/// <summary>
|
||||
/// 步骤编号
|
||||
/// </summary>
|
||||
public int Index
|
||||
{
|
||||
get => (int) GetValue(IndexProperty);
|
||||
internal set => SetValue(IndexProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 步骤状态
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(
|
||||
"Status", typeof(StepStatus), typeof(StepBarItem), new PropertyMetadata(StepStatus.Waiting));
|
||||
|
||||
/// <summary>
|
||||
/// 步骤状态
|
||||
/// </summary>
|
||||
public StepStatus Status
|
||||
{
|
||||
get => (StepStatus) GetValue(StatusProperty);
|
||||
internal set => SetValue(StatusProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Interactivity;
|
||||
using HandyControl.Tools;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤条
|
||||
/// </summary>
|
||||
[ContentProperty("Items")]
|
||||
[TemplatePart(Name = ElementProgressBarBack, Type = typeof(ProgressBar))]
|
||||
[TemplatePart(Name = ElementUniformGridMain, Type = typeof(Panel))]
|
||||
public class StepBar : Control
|
||||
{
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// 步骤改变事件
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent StepChangedEvent =
|
||||
EventManager.RegisterRoutedEvent("StepChanged", RoutingStrategy.Bubble,
|
||||
typeof(EventHandler<FunctionEventArgs<int>>), typeof(StepBar));
|
||||
|
||||
/// <summary>
|
||||
/// 步骤改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<FunctionEventArgs<int>> StepChanged
|
||||
{
|
||||
add => AddHandler(StepChangedEvent, value);
|
||||
remove => RemoveHandler(StepChangedEvent, value);
|
||||
}
|
||||
|
||||
public StepBar()
|
||||
{
|
||||
Loaded += (s1, e1) =>
|
||||
{
|
||||
if (_isLoaded) return;
|
||||
UpdateItems(Items);
|
||||
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => Next()));
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => Prev()));
|
||||
|
||||
_isLoaded = true;
|
||||
};
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
_panelMain?.Children.Clear();
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_progressBarBack = GetTemplateChild(ElementProgressBarBack) as ProgressBar;
|
||||
_panelMain = GetTemplateChild(ElementUniformGridMain) as Panel;
|
||||
|
||||
CheckNull();
|
||||
|
||||
if (_isLoaded)
|
||||
{
|
||||
UpdateItems(Items);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckNull()
|
||||
{
|
||||
if (_panelMain == null || _progressBarBack == null) throw new Exception();
|
||||
}
|
||||
|
||||
public int StepIndex { get; private set; }
|
||||
|
||||
public List<StepItem> Items { get; set; } = new List<StepItem>();
|
||||
|
||||
private void UpdateItems(IReadOnlyCollection<StepItem> list)
|
||||
{
|
||||
if (list == null) return;
|
||||
_panelMain.Children.Clear();
|
||||
|
||||
var index = 1;
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.Index = index;
|
||||
item.IndexStr = $"{Properties.Langs.Lang.Step}{index}";
|
||||
_panelMain.Children.Add(item);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (list.FirstOrDefault() is StepItem stepItem)
|
||||
{
|
||||
stepItem.Status = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
base.OnRender(drawingContext);
|
||||
|
||||
var colCount = _panelMain.Children.Count;
|
||||
if (colCount <= 0) return;
|
||||
_progressBarBack.Width = (colCount - 1) * (ActualWidth / colCount);
|
||||
_progressBarBack.Value = 0;
|
||||
_progressBarBack.Maximum = colCount - 1;
|
||||
}
|
||||
|
||||
public void Next()
|
||||
{
|
||||
StepIndex++;
|
||||
if (StepIndex >= _panelMain.Children.Count)
|
||||
{
|
||||
StepIndex = _panelMain.Children.Count - 1;
|
||||
return;
|
||||
}
|
||||
RaiseEvent(new FunctionEventArgs<int>(StepChangedEvent, this)
|
||||
{
|
||||
Info = StepIndex
|
||||
});
|
||||
if (_panelMain.Children[StepIndex - 1] is StepItem stepItemFinished)
|
||||
stepItemFinished.Status = true;
|
||||
if (_panelMain.Children[StepIndex] is StepItem stepItemSelected)
|
||||
stepItemSelected.Status = false;
|
||||
_progressBarBack.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
|
||||
}
|
||||
|
||||
public void Prev()
|
||||
{
|
||||
StepIndex--;
|
||||
if (StepIndex < 0)
|
||||
{
|
||||
StepIndex = 0;
|
||||
return;
|
||||
}
|
||||
RaiseEvent(new FunctionEventArgs<int>(StepChangedEvent, this)
|
||||
{
|
||||
Info = StepIndex
|
||||
});
|
||||
if (_panelMain.Children[StepIndex + 1] is StepItem stepItemFinished)
|
||||
stepItemFinished.Status = null;
|
||||
if (_panelMain.Children[StepIndex] is StepItem stepItemSelected)
|
||||
stepItemSelected.Status = false;
|
||||
_progressBarBack.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤条单元项
|
||||
/// </summary>
|
||||
public class StepItem : Control
|
||||
{
|
||||
internal static readonly DependencyProperty IndexProperty = DependencyProperty.Register(
|
||||
"Index", typeof(int), typeof(StepItem), new PropertyMetadata(-1));
|
||||
|
||||
internal int Index
|
||||
{
|
||||
get => (int)GetValue(IndexProperty);
|
||||
set => SetValue(IndexProperty, value);
|
||||
}
|
||||
|
||||
internal static readonly DependencyProperty IndexStrProperty = DependencyProperty.Register(
|
||||
"IndexStr", typeof(string), typeof(StepItem), new PropertyMetadata(default(string)));
|
||||
|
||||
internal string IndexStr
|
||||
{
|
||||
get => (string)GetValue(IndexStrProperty);
|
||||
set => SetValue(IndexStrProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
|
||||
"Title", typeof(string), typeof(StepItem), new PropertyMetadata(default(string)));
|
||||
|
||||
public string Title
|
||||
{
|
||||
get => (string)GetValue(TitleProperty);
|
||||
set => SetValue(TitleProperty, value);
|
||||
}
|
||||
|
||||
private bool? _status;
|
||||
|
||||
public bool? Status
|
||||
{
|
||||
get => _status;
|
||||
set
|
||||
{
|
||||
_status = value;
|
||||
UpdateStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatus()
|
||||
{
|
||||
if (Status == true)
|
||||
{
|
||||
Foreground = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryTextBrush);
|
||||
}
|
||||
else if (Status == false)
|
||||
{
|
||||
Foreground = ResourceHelper.GetResource<Brush>(ResourceToken.PrimaryBrush);
|
||||
}
|
||||
else
|
||||
{
|
||||
Foreground = ResourceHelper.GetResource<Brush>(ResourceToken.ThirdlyTextBrush);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -18,7 +19,10 @@ namespace HandyControl.Controls
|
||||
|
||||
public TransitioningContentControl()
|
||||
{
|
||||
DefaultStyleKey = typeof(TransitioningContentControl);
|
||||
if (!DesignerProperties.GetIsInDesignMode(this))
|
||||
{
|
||||
DefaultStyleKey = typeof(TransitioningContentControl);
|
||||
}
|
||||
}
|
||||
|
||||
private Storyboard CurrentTransition
|
||||
@@ -43,6 +47,8 @@ namespace HandyControl.Controls
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
if (DesignerProperties.GetIsInDesignMode(this)) return;
|
||||
|
||||
if (IsTransitioning)
|
||||
AbortTransition();
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 步骤状态
|
||||
/// </summary>
|
||||
public enum StepStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 完成
|
||||
/// </summary>
|
||||
Complete,
|
||||
|
||||
/// <summary>
|
||||
/// 进行中
|
||||
/// </summary>
|
||||
UnderWay,
|
||||
|
||||
/// <summary>
|
||||
/// 等待中
|
||||
/// </summary>
|
||||
Waiting
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,12 @@
|
||||
<Compile Include="Controls\Loading\LoadingCircle.cs" />
|
||||
<Compile Include="Controls\Loading\LoadingLine.cs" />
|
||||
<Compile Include="Controls\InternalCanvas.cs" />
|
||||
<Compile Include="Controls\StepBar\StepBar.cs" />
|
||||
<Compile Include="Controls\StepBar\StepBarItem.cs" />
|
||||
<Compile Include="Data\Enum\InfoType.cs" />
|
||||
<Compile Include="Data\Enum\ResultType.cs" />
|
||||
<Compile Include="Data\Enum\SkinType.cs" />
|
||||
<Compile Include="Data\Enum\StepStatus.cs" />
|
||||
<Compile Include="Data\Enum\TipPlacement.cs" />
|
||||
<Compile Include="Data\GrowlInfo.cs" />
|
||||
<Compile Include="Data\OperationResult!1.cs" />
|
||||
@@ -110,8 +113,6 @@
|
||||
<Compile Include="Expression\Shapes\Arc.cs" />
|
||||
<Compile Include="Expression\Shapes\PrimitiveShape.cs" />
|
||||
<Compile Include="Tools\SingleOpenHelper.cs" />
|
||||
<Compile Include="Controls\Steps\StepBar.cs" />
|
||||
<Compile Include="Controls\Steps\StepItem.cs" />
|
||||
<Compile Include="Controls\TabControl\TabControl.cs" />
|
||||
<Compile Include="Controls\TabControl\TabItem.cs" />
|
||||
<Compile Include="Controls\TabControl\TabPanel.cs" />
|
||||
@@ -266,6 +267,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\StepBarBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles\Base\TabControlBaseStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
+19
-10
@@ -47,7 +47,7 @@ namespace HandyControl.Properties.Langs {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
@@ -78,6 +78,24 @@ namespace HandyControl.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 无法自注册复合命令 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string CannotRegisterCompositeCommandInItself {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotRegisterCompositeCommandInItself", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 不能注册同一命令两次 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string CannotRegisterSameCommandTwice {
|
||||
get {
|
||||
return ResourceManager.GetString("CannotRegisterSameCommandTwice", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 清空 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -249,15 +267,6 @@ namespace HandyControl.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 步骤 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Step {
|
||||
get {
|
||||
return ResourceManager.GetString("Step", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 提示 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -165,9 +165,6 @@
|
||||
<data name="Clear" xml:space="preserve">
|
||||
<value>Clear</value>
|
||||
</data>
|
||||
<data name="Step" xml:space="preserve">
|
||||
<value>Step</value>
|
||||
</data>
|
||||
<data name="Close" xml:space="preserve">
|
||||
<value>Close</value>
|
||||
</data>
|
||||
@@ -195,4 +192,10 @@
|
||||
<data name="FormatError" xml:space="preserve">
|
||||
<value>format error</value>
|
||||
</data>
|
||||
<data name="CannotRegisterCompositeCommandInItself" xml:space="preserve">
|
||||
<value>Cannot Register Composite Command In It self</value>
|
||||
</data>
|
||||
<data name="CannotRegisterSameCommandTwice" xml:space="preserve">
|
||||
<value>Cannot Register Same Command Twice</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -145,9 +145,6 @@
|
||||
<data name="Clear" xml:space="preserve">
|
||||
<value>清空</value>
|
||||
</data>
|
||||
<data name="Step" xml:space="preserve">
|
||||
<value>步骤</value>
|
||||
</data>
|
||||
<data name="Close" xml:space="preserve">
|
||||
<value>关闭</value>
|
||||
</data>
|
||||
@@ -175,4 +172,10 @@
|
||||
<data name="FormatError" xml:space="preserve">
|
||||
<value>格式错误</value>
|
||||
</data>
|
||||
<data name="CannotRegisterCompositeCommandInItself" xml:space="preserve">
|
||||
<value>无法自注册复合命令</value>
|
||||
</data>
|
||||
<data name="CannotRegisterSameCommandTwice" xml:space="preserve">
|
||||
<value>不能注册同一命令两次</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,134 @@
|
||||
<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="../TextBlock.xaml"/>
|
||||
<ResourceDictionary Source="../ProgressBar.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="StepBarItemBaseStyle" TargetType="controls:StepBarItem">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Status" Value="Complete">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="Status" Value="UnderWay">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="Status" Value="Waiting">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ThirdlyTextBrush}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StepBarItemHorizontalTop" BasedOn="{StaticResource StepBarItemBaseStyle}" TargetType="controls:StepBarItem">
|
||||
<Setter Property="Margin" Value="10,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:StepBarItem">
|
||||
<StackPanel>
|
||||
<Border Background="{DynamicResource RegionBrush}" 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 TemplatedParent}}"/>
|
||||
</Border>
|
||||
<ContentPresenter HorizontalAlignment="Center" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepBar}}" TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,4,0,0"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StepBarItemHorizontalBottom" BasedOn="{StaticResource StepBarItemBaseStyle}" TargetType="controls:StepBarItem">
|
||||
<Setter Property="Margin" Value="10,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:StepBarItem">
|
||||
<StackPanel>
|
||||
<ContentPresenter HorizontalAlignment="Center" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepBar}}" TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,0,0,4"/>
|
||||
<Border Background="{DynamicResource RegionBrush}" 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 TemplatedParent}}"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="StepBarItemVerticalLeft" BasedOn="{StaticResource StepBarItemBaseStyle}" TargetType="controls:StepBarItem">
|
||||
<Setter Property="Margin" Value="0, 10"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:StepBarItem">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Border Background="{DynamicResource RegionBrush}" 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 TemplatedParent}}"/>
|
||||
</Border>
|
||||
<StackPanel Margin="10,0,0,0">
|
||||
<ContentPresenter HorizontalAlignment="Left" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource FindAncestor,AncestorType=controls:StepBar}}" TextElement.Foreground="{TemplateBinding Foreground}" Margin="0,4,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ItemsPanelTemplate x:Key="StepBarHorizontalItemsPanelTemplate">
|
||||
<UniformGrid Rows="1"/>
|
||||
</ItemsPanelTemplate>
|
||||
|
||||
<ItemsPanelTemplate x:Key="StepBarVerticalItemsPanelTemplate">
|
||||
<UniformGrid Columns="1"/>
|
||||
</ItemsPanelTemplate>
|
||||
|
||||
<ControlTemplate x:Key="StepBarHorizontalTopControlTemplate" TargetType="controls:StepBar">
|
||||
<Grid>
|
||||
<ProgressBar HorizontalAlignment="Center" Name="PART_ProgressBarBack" VerticalAlignment="Top" Margin="0,10,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
|
||||
<ItemsPresenter/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="StepBarHorizontalBottomControlTemplate" TargetType="controls:StepBar">
|
||||
<Grid>
|
||||
<ProgressBar HorizontalAlignment="Center" Name="PART_ProgressBarBack" VerticalAlignment="Bottom" Margin="0,0,0,10" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}"/>
|
||||
<ItemsPresenter VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="StepBarVerticalLeftControlTemplate" TargetType="controls:StepBar">
|
||||
<Grid>
|
||||
<ProgressBar Orientation="Vertical" Width="4" HorizontalAlignment="Left" Name="PART_ProgressBarBack" VerticalAlignment="Center" Margin="10,0,0,0" Style="{StaticResource ProgressBarFlat}" Background="{DynamicResource ThirdlyTextBrush}" RenderTransformOrigin="0.5,0.5">
|
||||
<ProgressBar.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="180"/>
|
||||
</TransformGroup>
|
||||
</ProgressBar.RenderTransform>
|
||||
</ProgressBar>
|
||||
<ItemsPresenter/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="StepBarBaseStyle" TargetType="controls:StepBar">
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemHorizontalTop}"/>
|
||||
<Setter Property="Template" Value="{StaticResource StepBarHorizontalTopControlTemplate}"/>
|
||||
<Setter Property="ItemsPanel" Value="{StaticResource StepBarHorizontalItemsPanelTemplate}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Dock" Value="Left">
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemVerticalLeft}"/>
|
||||
<Setter Property="Template" Value="{StaticResource StepBarVerticalLeftControlTemplate}"/>
|
||||
<Setter Property="ItemsPanel" Value="{StaticResource StepBarVerticalItemsPanelTemplate}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="Dock" Value="Bottom">
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemHorizontalBottom}"/>
|
||||
<Setter Property="Template" Value="{StaticResource StepBarHorizontalBottomControlTemplate}"/>
|
||||
<Setter Property="ItemsPanel" Value="{StaticResource StepBarHorizontalItemsPanelTemplate}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="Dock" Value="Right">
|
||||
<Setter Property="FlowDirection" Value="RightToLeft"/>
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource StepBarItemVerticalLeft}"/>
|
||||
<Setter Property="Template" Value="{StaticResource StepBarVerticalLeftControlTemplate}"/>
|
||||
<Setter Property="ItemsPanel" Value="{StaticResource StepBarVerticalItemsPanelTemplate}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -206,11 +206,18 @@
|
||||
<Grid x:Name="TemplateRoot" SnapsToDevicePixels="true">
|
||||
<Rectangle x:Name="PART_Track" Fill="{TemplateBinding Background}" StrokeThickness="0" Stroke="{TemplateBinding BorderBrush}"/>
|
||||
<Decorator x:Name="PART_Indicator" HorizontalAlignment="Left">
|
||||
<Grid x:Name="Foreground">
|
||||
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
|
||||
</Grid>
|
||||
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
|
||||
</Decorator>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="LayoutTransform" TargetName="TemplateRoot">
|
||||
<Setter.Value>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
@@ -2,39 +2,9 @@
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="TextBlock.xaml"/>
|
||||
<ResourceDictionary Source="ProgressBar.xaml"/>
|
||||
<ResourceDictionary Source="Base/StepBarBaseStyle.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="{DynamicResource RegionBrush}" 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>
|
||||
<Style BasedOn="{StaticResource StepBarBaseStyle}" TargetType="controls:StepBar"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in new issue
Block a user