-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorPickerExtensions.cs
More file actions
37 lines (34 loc) · 1.55 KB
/
Copy pathColorPickerExtensions.cs
File metadata and controls
37 lines (34 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Terminal.Gui.App;
using Terminal.Gui.Drawing;
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions.ViewExtensions;
/// <summary>
/// Extension methods for <see cref="ColorPicker" />.
/// </summary>
public static class ColorPickerExtensions
{
extension(ColorPicker colorPicker)
{
/// <summary>
/// Subscribes to the <see cref="ColorPicker.ValueChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="ValueChangedEventArgs{T}" /> containing old and new values.</param>
/// <returns>The <see cref="ColorPicker" /> instance.</returns>
public ColorPicker OnValueChanged(Action<ValueChangedEventArgs<Color?>> callback)
{
colorPicker.ValueChanged += (_, e) => callback(e);
return colorPicker;
}
/// <summary>
/// Subscribes to the <see cref="ColorPicker.ValueChanging" /> event.
/// Set <see cref="ValueChangingEventArgs{T}.Handled" /> to <see langword="true" /> to cancel the change.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="ValueChangingEventArgs{T}" /> containing current and proposed values.</param>
/// <returns>The <see cref="ColorPicker" /> instance.</returns>
public ColorPicker OnValueChanging(Action<ValueChangingEventArgs<Color?>> callback)
{
colorPicker.ValueChanging += (_, e) => callback(e);
return colorPicker;
}
}
}