#nullable enable using System.ComponentModel; namespace Terminal.Gui; /// /// A single presented in a . To create new instances use /// or . /// public class Tile { private string _title = string.Empty; /// Creates a new instance of the class. public Tile () { ContentView = new View { Width = Dim.Fill (), Height = Dim.Fill (), CanFocus = true }; #if DEBUG_IDISPOSABLE ContentView.Data = "Tile.ContentView"; #endif Title = string.Empty; MinSize = 0; } /// /// The that is contained in this . Add new child views to this /// member for multiple s within the . /// public View? ContentView { get; internal set; } /// /// Gets or Sets the minimum size you to allow when splitter resizing along parent /// direction. /// public int MinSize { get; set; } /// /// The text that should be displayed above the . This will appear over the splitter line /// or border (above the view client area). /// /// Title are not rendered for root level tiles is . public string Title { get => _title; set { if (!OnTitleChanging (_title, value)) { string old = _title; _title = value; OnTitleChanged (old, _title); return; } _title = value; } } /// Called when the has been changed. Invokes the event. /// The that is/has been replaced. /// The new to be replaced. public virtual void OnTitleChanged (string oldTitle, string newTitle) { var args = new EventArgs (in newTitle); TitleChanged?.Invoke (this, args); } /// /// Called before the changes. Invokes the event, which can be /// cancelled. /// /// The that is/has been replaced. /// The new to be replaced. /// true if an event handler cancelled the Title change. public virtual bool OnTitleChanging (string oldTitle, string newTitle) { var args = new CancelEventArgs (ref oldTitle, ref newTitle); TitleChanging?.Invoke (this, args); return args.Cancel; } /// Event fired after the has been changed. public event EventHandler? TitleChanged; /// /// Event fired when the is changing. /// can be set to true to cancel the change. /// public event EventHandler>? TitleChanging; }