mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-12-03 04:18:01 +08:00
Update ColorPicker.cs
This commit is contained in:
parent
6dd5d4c5ff
commit
307150eeb1
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@ -178,20 +178,30 @@ namespace HandyControl.Controls
|
||||
|
||||
#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>
|
||||
public static readonly RoutedEvent SelectedColorChangedEvent =
|
||||
EventManager.RegisterRoutedEvent("SelectedColorChanged", RoutingStrategy.Bubble,
|
||||
public static readonly RoutedEvent ConfirmedEvent =
|
||||
EventManager.RegisterRoutedEvent("Confirmed", RoutingStrategy.Bubble,
|
||||
typeof(EventHandler<FunctionEventArgs<Color>>), typeof(ColorPicker));
|
||||
|
||||
/// <summary>
|
||||
/// 颜色改变事件
|
||||
/// </summary>
|
||||
public event EventHandler<FunctionEventArgs<Color>> SelectedColorChanged
|
||||
public event EventHandler<FunctionEventArgs<Color>> Confirmed
|
||||
{
|
||||
add => AddHandler(SelectedColorChangedEvent, value);
|
||||
remove => RemoveHandler(SelectedColorChangedEvent, value);
|
||||
add => AddHandler(ConfirmedEvent, value);
|
||||
remove => RemoveHandler(ConfirmedEvent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -268,6 +278,10 @@ namespace HandyControl.Controls
|
||||
}
|
||||
ctl.UpdateStatus(v.Color);
|
||||
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>
|
||||
@ -361,6 +375,8 @@ namespace HandyControl.Controls
|
||||
_isLoaded = true;
|
||||
}
|
||||
};
|
||||
|
||||
cPicker = this;
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
@ -695,10 +711,14 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
private void ButtonConfirm_OnClick(object sender, RoutedEventArgs e)
|
||||
=> RaiseEvent(new FunctionEventArgs<Color>(SelectedColorChangedEvent, this)
|
||||
{
|
||||
Info = SelectedBrush.Color
|
||||
});
|
||||
{
|
||||
RaiseEvent(new FunctionEventArgs<Color>(ConfirmedEvent, this)
|
||||
{
|
||||
Info = SelectedBrush.Color
|
||||
});
|
||||
|
||||
RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
||||
}
|
||||
|
||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
||||
|
||||
@ -731,6 +751,5 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
public bool CanDispose { get; } = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user