-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineExtensions.cs
More file actions
37 lines (34 loc) · 1.49 KB
/
Copy pathLineExtensions.cs
File metadata and controls
37 lines (34 loc) · 1.49 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.ViewBase;
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions.ViewExtensions;
/// <summary>
/// Extension methods for <see cref="Line" />.
/// </summary>
public static class LineExtensions
{
extension(Line line)
{
/// <summary>
/// Subscribes to the <see cref="Line.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="Line" /> instance.</returns>
public Line OnOrientationChanged(Action<EventArgs<Orientation>> callback)
{
line.OrientationChanged += (_, e) => callback(e);
return line;
}
/// <summary>
/// Subscribes to the <see cref="Line.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="Line" /> instance.</returns>
public Line OnOrientationChanging(Action<CancelEventArgs<Orientation>> callback)
{
line.OrientationChanging += (_, e) => callback(e);
return line;
}
}
}