Update ColorPicker.cs
This commit is contained in:
1 parent
6dd5d4c5ff
commit
307150eeb1
1 file changed
+30
-11
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -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>
|
||||||
@@ -361,6 +375,8 @@ namespace HandyControl.Controls
|
|||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cPicker = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnApplyTemplate()
|
public override void OnApplyTemplate()
|
||||||
@@ -695,10 +711,14 @@ 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
|
||||||
|
});
|
||||||
|
|
||||||
|
RaiseEvent(new RoutedEventArgs(CanceledEvent));
|
||||||
|
}
|
||||||
|
|
||||||
private void ButtonCancel_OnClick(object sender, RoutedEventArgs e) => 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;
|
public bool CanDispose { get; } = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user