using System;
namespace Terminal.Gui;
///
/// A single presented in a . To create
/// new instances use
/// or .
///
public class Tile {
///
/// 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)) {
var old = _title;
_title = value;
OnTitleChanged (old, _title);
return;
}
_title = value;
}
}
private string _title = string.Empty;
///
/// 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 TitleEventArgs (oldTitle, newTitle);
TitleChanging?.Invoke (this, args);
return args.Cancel;
}
///
/// Event fired when the is changing. Set to
/// true to cancel the Title change.
///
public event EventHandler TitleChanging;
///
/// 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 TitleEventArgs (oldTitle, newTitle);
TitleChanged?.Invoke (this, args);
}
///
/// Event fired after the has been changed.
///
public event EventHandler TitleChanged;
///
/// Creates a new instance of the class.
///
public Tile ()
{
ContentView = new View () { Width = Dim.Fill (), Height = Dim.Fill () };
#if DEBUG_IDISPOSABLE
ContentView.Data = "Tile.ContentView";
#endif
Title = string.Empty;
MinSize = 0;
}
}