Files
Terminal.Gui/ReactiveExample/ViewExtensions.cs
2024-07-28 12:23:09 +01:00

25 lines
719 B
C#

using System;
using Terminal.Gui;
namespace ReactiveExample;
public static class ViewExtensions
{
public static (Window MainView, TOut LastControl) AddControl<TOut> (this Window view, Action<TOut> action)
where TOut : View, new()
{
TOut result = new ();
action (result);
view.Add (result);
return (view, result);
}
public static (Window MainView, TOut LastControl) AddControlAfter<TOut> (this (Window MainView, View LastControl) view, Action<View, TOut> action)
where TOut : View, new()
{
TOut result = new ();
action (view.LastControl, result);
view.MainView.Add (result);
return (view.MainView, result);
}
}