mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Tidied up docs and fixed several methods to be virtual
This commit is contained in:
@@ -38,13 +38,13 @@ namespace Terminal.Gui {
|
||||
/// Children of the current node
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IList<ITreeNode> Children {get;set;} = new List<ITreeNode>();
|
||||
public virtual IList<ITreeNode> Children {get;set;} = new List<ITreeNode>();
|
||||
|
||||
/// <summary>
|
||||
/// Text to display in tree node for current entry
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string Text {get;set;}
|
||||
public virtual string Text {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Optionally allows you to store some custom data/class here.
|
||||
@@ -730,7 +730,7 @@ namespace Terminal.Gui {
|
||||
/// Raises the <see cref="ObjectActivated"/> event
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected void OnObjectActivated(ObjectActivatedEventArgs<T> e)
|
||||
protected virtual void OnObjectActivated(ObjectActivatedEventArgs<T> e)
|
||||
{
|
||||
ObjectActivated?.Invoke(e);
|
||||
}
|
||||
|
||||
@@ -45,28 +45,20 @@ namespace UICatalog.Scenarios {
|
||||
// Your data class
|
||||
private class House : TreeNode {
|
||||
|
||||
|
||||
// Your properties
|
||||
public string Address {get;set;}
|
||||
public List<Room> Rooms {get;set;}
|
||||
|
||||
// ITreeNode member:
|
||||
public override IList<ITreeNode> Children => Rooms.Cast<ITreeNode>().ToList();
|
||||
|
||||
public IList<ITreeNode> Children => Rooms.Cast<ITreeNode>().ToList();
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return Address;
|
||||
}
|
||||
public override string Text { get => Address; set => Address = value; }
|
||||
}
|
||||
private class Room : TreeNode{
|
||||
|
||||
public string Name {get;set;}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
public override string Text{get=>Name;set{Name=value;}}
|
||||
}
|
||||
|
||||
private void LoadRooms()
|
||||
|
||||
@@ -35,35 +35,24 @@ Having to create a bunch of TreeNode objects can be a pain especially if you alr
|
||||
```csharp
|
||||
// Your data class
|
||||
private class House : TreeNode {
|
||||
|
||||
|
||||
|
||||
// Your properties
|
||||
public string Address {get;set;}
|
||||
public List<Room> Rooms {get;set;}
|
||||
|
||||
// ITreeNode member:
|
||||
public override IList<ITreeNode> Children => Rooms.Cast<ITreeNode>().ToList();
|
||||
|
||||
public IList<ITreeNode> Children => Rooms.Cast<ITreeNode>().ToList();
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return Address;
|
||||
}
|
||||
public override string Text { get => Address; set => Address = value; }
|
||||
}
|
||||
|
||||
|
||||
// Your other data class
|
||||
private class Room : TreeNode{
|
||||
|
||||
|
||||
public string Name {get;set;}
|
||||
|
||||
|
||||
// Rooms have no sub objects
|
||||
public IList<ITreeNode> Children => new List<ITreeNode>();
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
public override string Text{get=>Name;set{Name=value;}}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user