1. add stepchanged event to stepbar
2. simplify the logic of close callback of growl 3. Make sure that the path is displayed properly when flowdirection is rtl
This commit is contained in:
1 parent
880a0eefba
commit
0baae519cb
5 files changed
+51
-12
No files matched your search
@@ -105,7 +105,7 @@ namespace HandyControl.Controls
|
||||
/// </summary>
|
||||
private DispatcherTimer _timerClose;
|
||||
|
||||
private Action<Action, bool> CloseAction { get; set; }
|
||||
private Func<bool, bool> ActionBeforeClose { get; set; }
|
||||
|
||||
public string Message
|
||||
{
|
||||
@@ -191,7 +191,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (CloseAction != null)
|
||||
if (ActionBeforeClose != null)
|
||||
{
|
||||
_staysOpen = true;
|
||||
_showCloseButton = false;
|
||||
@@ -211,7 +211,7 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 显示信息
|
||||
/// </summary>
|
||||
private static void Show(string message, string iconKey, string iconBrushKey, Action<Action, bool> closeAction = null,
|
||||
private static void Show(string message, string iconKey, string iconBrushKey, Func<bool, bool> actionBeforeClose = null,
|
||||
bool staysOpen = false, bool showCloseButton = true)
|
||||
{
|
||||
var ctl = new Growl
|
||||
@@ -221,7 +221,7 @@ namespace HandyControl.Controls
|
||||
Icon = ResourceHelper.GetResource<Geometry>(iconKey),
|
||||
IconBrush = ResourceHelper.GetResource<Brush>(iconBrushKey),
|
||||
_showCloseButton = showCloseButton,
|
||||
CloseAction = closeAction,
|
||||
ActionBeforeClose = actionBeforeClose,
|
||||
_staysOpen = staysOpen
|
||||
};
|
||||
GrowlPanel.Children.Insert(0, ctl);
|
||||
@@ -261,7 +261,7 @@ namespace HandyControl.Controls
|
||||
Show(message, "FatalGeometry", "PrimaryTextBrush", null, true, false);
|
||||
}
|
||||
|
||||
public static void Ask(string message, Action<Action, bool> closeAction) => Show(message, "AskGeometry", "AccentBrush", closeAction);
|
||||
public static void Ask(string message, Func<bool, bool> actionBeforeClose) => Show(message, "AskGeometry", "AccentBrush", actionBeforeClose);
|
||||
|
||||
private void ButtonClose_OnClick(object sender, RoutedEventArgs e) => Close();
|
||||
|
||||
@@ -287,8 +287,20 @@ namespace HandyControl.Controls
|
||||
GrowlPanel.Show();
|
||||
}
|
||||
|
||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => CloseAction?.Invoke(Close, false);
|
||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ActionBeforeClose?.Invoke(false) == true)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonOk_OnClick(object sender, RoutedEventArgs e) => CloseAction?.Invoke(Close, true);
|
||||
private void ButtonOk_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (ActionBeforeClose?.Invoke(true) == true)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ 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;
|
||||
|
||||
@@ -34,6 +35,22 @@ namespace HandyControl.Controls
|
||||
|
||||
#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) =>
|
||||
@@ -106,6 +123,10 @@ namespace HandyControl.Controls
|
||||
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)
|
||||
@@ -121,6 +142,10 @@ namespace HandyControl.Controls
|
||||
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)
|
||||
|
||||
@@ -10,5 +10,4 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyVersion("1.3.4")]
|
||||
[assembly: AssemblyFileVersion("1.3.4")]
|
||||
[assembly: AssemblyVersion("1.3.4.*")]
|
||||
@@ -8,8 +8,11 @@
|
||||
<Style x:Key="PathBaseStyle" TargetType="{x:Type Path}">
|
||||
<Setter Property="Stretch" Value="Uniform"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="FlowDirection" Value="LeftToRight"/>
|
||||
</Style>
|
||||
|
||||
<Style BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}"/>
|
||||
|
||||
<!--搜索-->
|
||||
<Style x:Key="SearchPathStyle" BasedOn="{StaticResource PathBaseStyle}" TargetType="{x:Type Path}">
|
||||
<Setter Property="Data" Value="{StaticResource SearchGeometry}"/>
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace HandyControlDemo.ViewModel
|
||||
new RelayCommand(() => Growl.Error(Properties.Langs.Lang.GrowlError))).Value;
|
||||
|
||||
public RelayCommand AskCmd => new Lazy<RelayCommand>(() =>
|
||||
new RelayCommand(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, (closeAction, b) =>
|
||||
new RelayCommand(() => Growl.Ask(Properties.Langs.Lang.GrowlAsk, isClosed =>
|
||||
{
|
||||
Growl.Info(b.ToString());
|
||||
closeAction?.Invoke();
|
||||
Growl.Info(isClosed.ToString());
|
||||
return true;
|
||||
}))).Value;
|
||||
|
||||
public RelayCommand FatalCmd => new Lazy<RelayCommand>(() =>
|
||||
|
||||
Reference in new issue
Block a user