/// <summary> /// Only to be used by subclasses that sealed override the name property. /// </summary> protected CurveTreeNode(CurveTreeNode parent) { Parent = parent; Children = new ObservableCollection <CurveTreeNode>(); isVisible = true; areParentsVisible = true; }
internal void RemoveCurveOrGroup(String name) { String[] path = name.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); CurveTreeNode child; CurveTreeNode node = Root; for (int i = 0; i < path.Length - 1; i++) { if ((child = GetChildNode(node, path[i])) == null) { GearsetResources.Console.Log("Gearset", "Bender error. Curve or Group '{0}' doesn't exists.", name); return; } node = child; } // Check if the last item actually exists, and finnally remove it. String curveName = path[path.Length - 1]; if ((child = GetChildNode(node, curveName)) == null) { GearsetResources.Console.Log("Gearset", "Bender error. Curve or Group '{0}' doesn't exists.", name); return; } RemoveNodeAndCurves(child); node.Children.Remove(child); }
/// <summary> /// Only to be used by subclasses that sealed override the name property. /// </summary> protected CurveTreeNode(CurveTreeNode parent) { Parent = parent; Children = new ObservableCollection<CurveTreeNode>(); isVisible = true; areParentsVisible = true; }
static CurveTreeNode GetChildNode(CurveTreeNode node, string name) { foreach (var item in node.Children) { if (item.Name == name) { return(item); } } return(null); }
/// <summary> /// Will remove the whole subtree of nodes below the provided node (from the control). /// The provided node must be removed from the tree by the calling code. /// </summary> void RemoveNodeAndCurves(CurveTreeNode node) { for (var i = node.Children.Count - 1; i >= 0; i--) { RemoveNodeAndCurves(node.Children[i]); } var leaf = node as CurveTreeLeaf; if (leaf != null) { Control.Curves.Remove(leaf.Curve); } }
static CurveTreeLeaf FindContainerLeaf(CurveTreeNode node, Curve curve) { for (var i = node.Children.Count - 1; i >= 0; i--) { var leaf = node.Children[i] as CurveTreeLeaf; if (leaf != null && ReferenceEquals(curve, leaf.Curve.Curve)) { return(leaf); } // Call recursively on this child; leaf = FindContainerLeaf(node.Children[i], curve); if (leaf != null) { return(leaf); } } return(null); }
/// <summary> /// Adds the curve to the TreeView and also the CurveEditorControl. /// </summary> internal void AddCurve(string name, Curve curve) { // Check if the curve is already added. var container = FindContainerLeaf(Root, curve); if (container != null) { container.IsSelected = true; container.IsVisible = true; return; } // Add to tree var path = name.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); var node = Root; for (var i = 0; i < path.Length - 1; i++) { CurveTreeNode child; if ((child = GetChildNode(node, path[i])) == null) { child = new CurveTreeNode(path[i], node); node.Children.Add(child); } node = child; } // Add to control var curveName = path[path.Length - 1]; var wrapper = new CurveWrapper(curve, curveName, Control, GetColor(curveName)); Control.Curves.Add(wrapper); // Add to tree node.Children.Add(new CurveTreeLeaf(node, wrapper)); //for (int i = 0; i < 20; i++) //{ // wrapper.AddKey(new CurveKey((float)random.NextDouble(), (float)random.NextDouble())); //} }
public CurveTreeNode(String name, CurveTreeNode parent) : this(parent) { Name = name; }
public CurveTreeLeaf(CurveTreeNode parent, CurveWrapper curve) : base(parent) { Curve = curve; }
/// <summary> /// Adds the curve to the TreeView and also the CurveEditorControl. /// </summary> internal void AddCurve(string name, Curve curve) { // Check if the curve is already added. var container = FindContainerLeaf(Root, curve); if (container != null) { container.IsSelected = true; container.IsVisible = true; return; } // Add to tree String[] path = name.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries); CurveTreeNode node = Root; for (int i = 0; i < path.Length - 1; i++) { CurveTreeNode child; if ((child = GetChildNode(node, path[i])) == null) { child = new CurveTreeNode(path[i], node); node.Children.Add(child); } node = child; } // Add to control String curveName = path[path.Length - 1]; CurveWrapper wrapper = new CurveWrapper(curve, curveName, Control, GetColor(curveName)); Control.Curves.Add(wrapper); // Add to tree node.Children.Add(new CurveTreeLeaf(node, wrapper)); //for (int i = 0; i < 20; i++) //{ // wrapper.AddKey(new CurveKey((float)random.NextDouble(), (float)random.NextDouble())); //} }
/// <summary> /// Will remove the whole subtree of nodes below the provided node (from the control). /// The provided node must be removed from the tree by the calling code. /// </summary> private void RemoveNodeAndCurves(CurveTreeNode node) { for (int i = node.Children.Count - 1; i >= 0; i--) { RemoveNodeAndCurves(node.Children[i]); } CurveTreeLeaf leaf = node as CurveTreeLeaf; if (leaf != null) Control.Curves.Remove(leaf.Curve); }
private CurveTreeNode GetChildNode(CurveTreeNode node, string name) { foreach (var item in node.Children) { if (item.Name == name) return item; } return null; }
private CurveTreeLeaf FindContainerLeaf(CurveTreeNode node, Curve curve) { for (int i = node.Children.Count - 1; i >= 0; i--) { CurveTreeLeaf leaf = node.Children[i] as CurveTreeLeaf; if (leaf != null && Object.ReferenceEquals(curve, leaf.Curve.Curve)) { return leaf; } // Call recursively on this child; leaf = FindContainerLeaf(node.Children[i], curve); if (leaf != null) return leaf; } return null; }
public CurveTreeViewModel(CurveEditorControl2 control) { Control = control; Root = new CurveTreeNode(String.Empty, null); }
public CurveTreeViewModel(CurveEditorControl2 control) { Control = control; Root = new CurveTreeNode(String.Empty, null); }
public CurveTreeLeaf(CurveTreeNode parent, CurveWrapper curve) : base(parent) { Curve = curve; }
public CurveTreeNode(String name, CurveTreeNode parent) : this(parent) { Name = name; }