-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollSliderExtensions.cs
More file actions
71 lines (65 loc) · 3.31 KB
/
Copy pathScrollSliderExtensions.cs
File metadata and controls
71 lines (65 loc) · 3.31 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions.ViewExtensions;
/// <summary>
/// Extension methods for <see cref="ScrollSlider" />.
/// </summary>
public static class ScrollSliderExtensions
{
extension(ScrollSlider scrollSlider)
{
/// <summary>
/// Subscribes to the <see cref="ScrollSlider.OrientationChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="EventArgs{T}" /> containing the new <see cref="Orientation" />.</param>
/// <returns>The <see cref="ScrollSlider" /> instance.</returns>
public ScrollSlider OnOrientationChanged(Action<EventArgs<Orientation>> callback)
{
scrollSlider.OrientationChanged += (_, e) => callback(e);
return scrollSlider;
}
/// <summary>
/// Subscribes to the <see cref="ScrollSlider.OrientationChanging" /> event.
/// Set <see cref="CancelEventArgs{T}.Cancel" /> to <see langword="true" /> to cancel the change.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CancelEventArgs{T}" /> containing the proposed <see cref="Orientation" />.</param>
/// <returns>The <see cref="ScrollSlider" /> instance.</returns>
public ScrollSlider OnOrientationChanging(Action<CancelEventArgs<Orientation>> callback)
{
scrollSlider.OrientationChanging += (_, e) => callback(e);
return scrollSlider;
}
/// <summary>
/// Subscribes to the <see cref="ScrollSlider.PositionChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="EventArgs{T}" /> containing the new position.</param>
/// <returns>The <see cref="ScrollSlider" /> instance.</returns>
public ScrollSlider OnPositionChanged(Action<EventArgs<int>> callback)
{
scrollSlider.PositionChanged += (_, e) => callback(e);
return scrollSlider;
}
/// <summary>
/// Subscribes to the <see cref="ScrollSlider.PositionChanging" /> event.
/// Set <see cref="CancelEventArgs{T}.Cancel" /> to <see langword="true" /> to cancel the change.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CancelEventArgs{T}" /> containing the proposed position.</param>
/// <returns>The <see cref="ScrollSlider" /> instance.</returns>
public ScrollSlider OnPositionChanging(Action<CancelEventArgs<int>> callback)
{
scrollSlider.PositionChanging += (_, e) => callback(e);
return scrollSlider;
}
/// <summary>
/// Subscribes to the <see cref="ScrollSlider.Scrolled" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="EventArgs{T}" /> containing the scroll position.</param>
/// <returns>The <see cref="ScrollSlider" /> instance.</returns>
public ScrollSlider OnScrolled(Action<EventArgs<int>> callback)
{
scrollSlider.Scrolled += (_, e) => callback(e);
return scrollSlider;
}
}
}