Merge pull request #720 from ghost1372/patch-5
Add Confirmed and SelectedColorChanged events #673
This commit is contained in:
1 file changed
+22
-6
@@ -178,20 +178,30 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
#region Public Events
|
#region Public Events
|
||||||
|
|
||||||
|
public static readonly RoutedEvent SelectedColorChangedEvent =
|
||||||
|
EventManager.RegisterRoutedEvent("SelectedColorChanged", RoutingStrategy.Bubble,
|
||||||
|
typeof(EventHandler<FunctionEventArgs<Color>>), typeof(ColorPicker));
|
||||||
|
|
||||||
|
public event EventHandler<FunctionEventArgs<Color>> SelectedColorChanged
|
||||||
|
{
|
||||||
|
add => AddHandler(SelectedColorChangedEvent, value);
|
||||||
|
remove => RemoveHandler(SelectedColorChangedEvent, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 颜色改变事件
|
/// 颜色改变事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly RoutedEvent SelectedColorChangedEvent =
|
public static readonly RoutedEvent ConfirmedEvent =
|
||||||
EventManager.RegisterRoutedEvent("SelectedColorChanged", RoutingStrategy.Bubble,
|
EventManager.RegisterRoutedEvent("Confirmed", RoutingStrategy.Bubble,
|
||||||
typeof(EventHandler<FunctionEventArgs<Color>>), typeof(ColorPicker));
|
typeof(EventHandler<FunctionEventArgs<Color>>), typeof(ColorPicker));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 颜色改变事件
|
/// 颜色改变事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<FunctionEventArgs<Color>> SelectedColorChanged
|
public event EventHandler<FunctionEventArgs<Color>> Confirmed
|
||||||
{
|
{
|
||||||
add => AddHandler(SelectedColorChangedEvent, value);
|
add => AddHandler(ConfirmedEvent, value);
|
||||||
remove => RemoveHandler(SelectedColorChangedEvent, value);
|
remove => RemoveHandler(ConfirmedEvent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -268,6 +278,10 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
ctl.UpdateStatus(v.Color);
|
ctl.UpdateStatus(v.Color);
|
||||||
ctl.SelectedBrushWithoutOpacity = new SolidColorBrush(Color.FromRgb(v.Color.R, v.Color.G, v.Color.B));
|
ctl.SelectedBrushWithoutOpacity = new SolidColorBrush(Color.FromRgb(v.Color.R, v.Color.G, v.Color.B));
|
||||||
|
ctl.RaiseEvent(new FunctionEventArgs<Color>(SelectedColorChangedEvent, ctl)
|
||||||
|
{
|
||||||
|
Info = v.Color
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -684,10 +698,12 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonConfirm_OnClick(object sender, RoutedEventArgs e)
|
private void ButtonConfirm_OnClick(object sender, RoutedEventArgs e)
|
||||||
=> RaiseEvent(new FunctionEventArgs<Color>(SelectedColorChangedEvent, this)
|
{
|
||||||
|
RaiseEvent(new FunctionEventArgs<Color>(ConfirmedEvent, this)
|
||||||
{
|
{
|
||||||
Info = SelectedBrush.Color
|
Info = SelectedBrush.Color
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user