using System.Collections.Generic; using System.Windows.Controls; using System.Windows.Media; namespace NodeEditor.Controls { /// /// Interaction logic for Node.xaml /// public partial class Node : UserControl { public static List Nodes { get; } = new List(); public string Desc { get; set; } public Node() { Nodes.Add(this); //Name = GetIndexOf(this).ToString(); Desc = ""; InitializeComponent(); } public Node(string name) { Nodes.Add(this); Name = name; Desc = ""; InitializeComponent(); } public Node(string name, string desc) { Nodes.Add(this); Name = name; Desc = desc; InitializeComponent(); } public static int GetIndexOf(Node node) { if (node != null) return Nodes.IndexOf(node); return -1; } public void Destroy() { var parentObject = VisualTreeHelper.GetParent(this); var parent = parentObject as Canvas; parent?.Children.Remove(this); Nodes.Remove(this); } } }