public bool Contains(TreeNode item) { if (item.ParentNode == null) { return(RootNodes.Contains(item)); } return(FindNode(item, RootNodes)); }
/// <summary> /// Adds a map frame as a root node, and links an event handler to update /// when the mapframe triggers an ItemChanged event. /// </summary> /// <param name="mapFrame"></param> public void AddMapFrame(IFrame mapFrame) { mapFrame.IsSelected = true; if (!RootNodes.Contains(mapFrame)) { OnIncludeMapFrame(mapFrame); } RootNodes.Add(mapFrame); RefreshNodes(); }
private void DoItemMouseDown(ItemMouseEventArgs e) { Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top); // Toggle expansion if (e.ItemBox.ExpandBox.Contains(loc)) { e.ItemBox.Item.IsExpanded = !e.ItemBox.Item.IsExpanded; ExpandBoxMouseDown?.Invoke(this, e); ResetLegend(); return; } if (e.ItemBox.Item.IsSelected) { // if we are already selected, prepare to edit in textbox _previousMouseDown = e.ItemBox; // Start dragging if (e.Button == MouseButtons.Left) { _isDragging = true; ILegendItem li = e.ItemBox.Item; while (li != null && !(li is ILayer)) { li = li.GetParentItem(); } ILayer lyr = li as ILayer; if (lyr != null && !RootNodes.Contains(lyr)) { // don't allow to drag root nodes _dragItem = BoxFromItem(lyr); } else { _isDragging = false; } } } else { // Check for textbox clicking if (e.ItemBox.Textbox.Contains(loc)) { if (ModifierKeys != Keys.Shift) { ClearSelection(); } e.ItemBox.Item.IsSelected = true; } } }
/// <summary> /// Removes the specified map frame if it is a root node. /// </summary> /// <param name="mapFrame">Map frame that gets removed.</param> /// <param name="preventRefresh">Boolean, if true, removing the map frame will not automatically force a refresh of the legend.</param> public void RemoveMapFrame(IFrame mapFrame, bool preventRefresh) { RootNodes.Remove(mapFrame); if (!RootNodes.Contains(mapFrame)) { OnExcludeMapFrame(mapFrame); } if (preventRefresh) { return; } RefreshNodes(); }
/// <summary> /// Determines whether the <see cref="Syncfusion.UI.Xaml.Grid.TreeGrid.TreeNode"/> is in view or not. /// </summary> /// <param name="node">TreeNode.</param> /// <returns> /// <b> true</b> if the node is in view; otherwise , <b>false</b>. /// </returns> public bool IsNodeInView(TreeNode node) { if (node == null || node.IsFiltered) { return(false); } if (node.ParentNode == null) { return(RootNodes.Contains(node)); } if (!node.ParentNode.IsExpanded) { return(false); } return(IsNodeInView(node.ParentNode)); }
public void AddRoot(MapNode fromNode, MapNode toNode) { if (toNode.Parent != null || !fromNode.Neighbours.Contains(toNode) || RootNodes.Contains(toNode)) { return; } RootNodes.Add(toNode); RootCost = this.CalculateRootCost(); if (fromNode.Children.Count > 0) { RootLines.Add(new List <Vector3>() { fromNode.WorldPosition, toNode.WorldPosition }); } else { var line = RootLines.FirstOrDefault(x => x.Last().Equals(fromNode.WorldPosition)); line.Add(toNode.WorldPosition); var lineStart = line.FirstOrDefault(); // Check for a switch if (lineStart.magnitude > 1) { // Get lines var connectedLines = RootLines.Where(x => x.Contains(lineStart) && x != line).ToList(); foreach (var connectedLine in connectedLines) { // Get the index of var indexOf = connectedLine.IndexOf(lineStart); var remainingLength = connectedLine.Count - indexOf; var remainingLine = connectedLine.Where(x => connectedLine.IndexOf(x) >= indexOf).ToList(); if (indexOf == 0) { continue; } if (line.Count > remainingLength) { // Do the switch connectedLine.RemoveAll(x => connectedLine.IndexOf(x) >= indexOf); connectedLine.AddRange(line); RootLines.Remove(line); RootLines.Add(remainingLine); break; } } } } toNode.Parent = fromNode; fromNode.Children.Add(toNode); toNode.OnConnectionsUpdated?.Invoke(); fromNode.OnConnectionsUpdated?.Invoke(); OnRootNodesUpdated?.Invoke(); }