You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NodeEditor/Controls/Node.xaml.cs

56 lines
1.3 KiB
C#

using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;
namespace NodeEditor.Controls
{
/// <summary>
/// Interaction logic for Node.xaml
/// </summary>
public partial class Node : UserControl
{
public static List<Node> Nodes { get; } = new List<Node>();
// ReSharper disable once UnusedAutoPropertyAccessor.Global
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);
}
}
}