public static void Copy(SelectedNodes nodes) { if (nodes.Count > 0) { internalClipboard.Clear(); StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); bool[] exclude = nodes.ExcludeNodesAlreadyPartOfHierarchy(); for (int i = 0; i < nodes.Count; i++ ) { if (!exclude[i]) { internalClipboard.Add(nodes[i].CloneAsDetached()); serializer.Serialize(nodes[i], str); } } var cbData = new MindMateTextDataObject(); cbData.SetData(str.ToString()); Clipboard.SetDataObject(cbData); //Clipboard.SetText(str.ToString(), TextDataFormat.Text); hasCutNode = false; if(StatusChanged != null) { StatusChanged(); } } }
public override void UpdateStatusBarForNode(SelectedNodes nodes) { var toolStrip = ((ToolStrip)statusBar); if (nodes.Count != 1) { toolStrip.Items[0].Text = nodes.Count + " nodes selected"; toolStrip.Items[1].Text = ""; toolStrip.Items[2].Text = ""; } else { MapNode node = nodes.First; if (node.Link != null && node.GetLinkType() == NodeLinkType.MindMapNode) { toolStrip.Items[0].Text = node.Tree.RootNode.Find( //TODO: Rather than traversing through the tree, a more efficient approach should be used n => node.Link.Substring(1) == n.Id ).Text + " (Internal Link)"; } else { if (node.Link != null) toolStrip.Items[0].Text = node.Link; else toolStrip.Items[0].Text = " "; //don't set it to null or "", somehow it triggers mouse move event on MapViewPanel } toolStrip.Items[1].Text = "Modified: " + node.Modified.ToString(); toolStrip.Items[2].Text = "Created: " + node.Created.ToString(); } }
public void Add_Null_NoImpact() { var s = new SelectedNodes(); s.Add(null); Assert.AreEqual(0, s.Count); }
public bool CanRemoveSelectedTreeNodes() { int count = SelectedNodes.Count(); if (count == 0) { return(false); } if (SelectedNodes.Count(node => node.IsSolution) > 0) { return(false); } int selectedFilesCount = SelectedNodes.Where(x => x.IsMissing || x.IsProject).Count(); return(count == selectedFilesCount); }
public bool CanDecompileSelectedTreeNodes() { if (!_solution.Properties.CanDecompile) { return(false); } int count = SelectedNodes.Count(); if (count == 0) { return(false); } int selectedFilesCount = SelectedItems.OfType <CompositFile>().Count(); return(count == selectedFilesCount); }
public bool CanOpenSelectedTreeNodes() { int count = SelectedNodes.Count(); if (count == 0) { return(false); } if (SelectedNodes.Count(node => node.IsSolution || node.IsProject) > 0) { return(false); } int selectedFilesCount = SelectedFiles.Where(x => x.CanOpen).Count(); return(count == selectedFilesCount); }
/// <summary> /// call grab if pointer is pointing at a gameobject that is one of the selected node /// </summary> public void GrabIfPointingAt() { if (ObjectPointer.Instance.HitInfo.collider != null) { GameObject hitObject = ObjectPointer.Instance.HitInfo.collider.gameObject; Node hitNode = null; if (Dict.TryGetValue(hitObject, out hitNode)) { if (SelectedNodes.Contains(hitNode)) { MovableFrame.transform.position = ObjectPointer.Instance.HitInfo.point; Grab(); } } } }
private void UnselectAllElements() { foreach (var node in SelectedNodes) { node.IsSelected = false; } foreach (var conn in ConnectorCollection) { conn.IsSelected = false; } SelectedNodes.Clear(); SelectedConnectors.Clear(); SelectedUiElements.Clear(); }
public void SelectNodes(List <TreeNode> nodes, bool updateAnchors = true) { SelectedNodes.Clear(); foreach (var node in nodes) { SelectedNodes.Add(node); } if (updateAnchors && SelectedNodes.Count > 0) { _anchoredNodeStart = SelectedNodes[SelectedNodes.Count - 1]; _anchoredNodeEnd = SelectedNodes[SelectedNodes.Count - 1]; } Invalidate(); }
public void DrawNodes() { var defaultColor = Handles.color; foreach (var drawInfo in _nodeDrawInfos.Values) { var drawingPosition = DrawingContext.Current.ApplyScroll(drawInfo.Position); if (SelectedNodes.Contains(drawInfo)) { Handles.color = Color.yellow;; Handles.DrawSolidDisc(drawingPosition, Vector3.forward, drawInfo.Radius + SelectionRadius * DrawingContext.Current.Zoom); } Handles.color = Color.red; Handles.DrawSolidDisc(drawingPosition, Vector3.forward, drawInfo.Radius); } Handles.color = defaultColor; }
void ObservableGrepSearchResults_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { List <IGrepResult> toRemove = new List <IGrepResult>(); foreach (var node in SelectedNodes) { FormattedGrepResult item = node as FormattedGrepResult; FormattedGrepLine line = node as FormattedGrepLine; if (item != null && !this.Contains(item)) { toRemove.Add(item); } if (line != null && !this.Contains(line.Parent)) { toRemove.Add(line); } } foreach (var item in toRemove) { SelectedNodes.Remove(item); } if (e.NewItems != null) { foreach (FormattedGrepResult newEntry in e.NewItems.Cast <FormattedGrepResult>()) { string extension = Path.GetExtension(newEntry.GrepResult.FileNameDisplayed); if (extension.Length <= 1) { extension = ".na"; } if (!icons.ContainsKey(extension)) { System.Drawing.Bitmap bitmapIcon = IconHandler.IconFromExtensionShell(extension, IconSize.Small); if (bitmapIcon == null) { bitmapIcon = dnGREP.Common.Properties.Resources.na_icon; } icons[extension] = GetBitmapSource(bitmapIcon); } newEntry.Icon = icons[extension]; } } }
public void SelectNode(TreeNodeMS node, bool select) { if (!select) { SelectedNodes.Remove(node); } else if (!node.IsInSelection) { SelectedNodes.Add(node); // Make sure all ancestors of this node are expanded for (var parent = node.Parent; parent != null && !parent.IsExpanded; parent = parent.Parent) { parent.Expand(); } } node.IsInSelection = select; }
/// <summary> /// setup internal node structure /// </summary> public void Setup() { // clear selected nodes SelectedNodes.Clear(); // if there's no child object, clear dictionary and null root if (this.gameObject.transform.childCount == 0) { Root = null; return; } else // construct internal data structure and dictionary if there's a loaded object { // initialize root Root = new Node(this.transform.GetChild(0).gameObject, null, this.transform); } }
public async ValueTask OnSelectCallback(InteropNodeEventData evt) { switch (evt.Type) { case "select_node": // this.invoke_event_handle(jm.event_type.select, { evt: 'select_node', data: [], node: node.id }); var node = FindNode(evt.NodeId); await OnSelectNode.InvokeAsync(new MindMapSingleSelectEventArgs <T> { Node = node, Selected = node is not null && SelectedNodes.Any(n => n.Id == node.Id) }); break; }
public void TryAndDelete() { foreach (UINode n in SelectedNodes) { if (UINodeParameters.Instance != null) { if (UINodeParameters.Instance.node == n.Node) { UINodeParameters.Instance.ClearView(); } } n.Dispose(); } SelectedNodes.Clear(); }
/// <summary> /// This handles unselecting nodes as required if the Ctrl key is being pushed, as well /// as trcking the beginning of Shft-Click selections. /// </summary> /// <param name="p_tndSelectNode">The node that was selected.</param> /// <returns><c>true</c> if the node selection was handled; /// <c>false</c> otherwise.</returns> private bool HandleNodeSelection(TreeNode p_tndSelectNode) { if (MultiSelect) { if (((ModifierKeys & Keys.Control) > 0) && m_tncSelectedNodes.Contains(p_tndSelectNode)) { SelectedNodes.Remove(p_tndSelectNode); return(true); } if (ModifierKeys != Keys.Shift) { m_tndFirst = p_tndSelectNode; } } return(false); }
/// <summary> /// Calculate the nodes and noodles that fall within the selction area /// </summary> /// <param name="IsClick">true if the user clicked without dragging</param> private void UpdateSelected(bool IsClick) { SelectedNoodles.Clear(); //hit test Nodes if it wasn't just a click if (_allNodes != null) { foreach (DaggerUINode node in _allNodes) { if (!IsClick) { Rectangle noderect = new Rectangle(node.Location, node.Size); if (_parent is ScrollableControl) { // modify noderect to account for scrollbar positions noderect.Offset((_parent as ScrollableControl).AutoScrollPosition.X * -1, (_parent as ScrollableControl).AutoScrollPosition.Y * -1); } if (noderect.IntersectsWith(SelectionArea)) { SelectedNodes.Add((IDaggerUINode)node); } } } } //hit test Noodles foreach (DaggerNoodle noodle in _allNoodles) { //get the points from the noodle path PointF[] pathpoints = noodle.path.PathPoints; //check each segment to see if it intersects with the selction area for (int i = 0; i < pathpoints.Length - 1; i++) { if (lineRectangleIntersection(SelectionArea, pathpoints[i], pathpoints[i + 1])) { SelectedNoodles.Add(noodle); break; } } } }
public void SelectAllElements() { SelectedElements.EnabledCalc = false; SelectedNodes.EnabledCalc = false; foreach(BaseElement element in Elements) { if (!(element is ConnectorElement)) SelectedElements.Add(element); if (element is NodeElement) SelectedNodes.Add(element); } SelectedElements.EnabledCalc = true; SelectedNodes.EnabledCalc = true; }
public void AddSelectedNode(Node node) { node.IsSelected = true; SelectedNodes.Add(node); if (SelectedEdgePart != null) { SelectedEdgePart.IsSelected = false; } if (SelectedEdgeBreak != null) { SelectedEdgeBreak.IsSelected = false; } SelectedEdgePart = null; SelectedEdgeBreak = null; SelectionChanged(); }
private void ChildNodes_ItemsRemoved(object sender, ObservableListModified <DarkTreeNode> e) { if (supressNodeEvents) { return; } foreach (var node in e.Items) { if (SelectedNodes.Contains(node)) { SelectedNodes.Remove(node); } UnhookNodeEvents(node); } UpdateNodes(); }
/// <summary> /// Raises the <see cref="TreeView.ItemDrag"/> event. /// </summary> /// <remarks> /// This starts the drag operation of item in the tree view. /// </remarks> /// <param name="e">A <see cref="ItemDragEventArgs"/> that describes the event arguments.</param> protected override void OnItemDrag(ItemDragEventArgs e) { base.OnItemDrag(e); List <FileSystemTreeNode> lstAffectedNodes = new List <FileSystemTreeNode>(); if (SelectedNodes.Contains((FileSystemTreeNode)e.Item)) { foreach (FileSystemTreeNode tndNode in SelectedNodes) { lstAffectedNodes.Add(tndNode); } } else { lstAffectedNodes.Add((FileSystemTreeNode)e.Item); } DoDragDrop(lstAffectedNodes, DragDropEffects.Move); }
/// <summary> /// ノードドラッグ中 /// </summary> private void NodeItem_Dragging(object sender, NodeDraggingEventArgs e) { // フォーカス取得 Focus(); var ctrl = e.OriginalSource as NodeControl; if (ctrl == null) { return; } // // 以下無駄が多いので仮 // // 選択されていなければ選択状態にする foreach (var a in e.Nodes) { NodeListItem item = PART_NodeList_.FindAssociatedNodeItem(a); if (!item.IsSelected) { // Ctrlが押されていない場合セレクションリストをクリア if ((Keyboard.Modifiers & ModifierKeys.Control) == 0) { SelectedNodes.Clear(); } item.IsSelected = true; } else { } } // 選択中オブジェクトに移動値を加算する // TODO:毎回検索するのが無駄なのでキャッシュする foreach (var n in SelectedNodes) { NodeListItem item = PART_NodeList_.FindAssociatedNodeItem(n); Canvas.SetLeft(item, Canvas.GetLeft(item) + e.HorizontalChange); Canvas.SetTop(item, Canvas.GetTop(item) + e.VerticalChange); } }
private void OnMouseUp(object sender, MouseButtonEventArgs mouseButtonEventArgs) { if (MouseMode == MouseMode.SelectionRectangle && Children.Contains(_selectionZone)) { Children.Remove(_selectionZone); SelectedNodes.Clear(); for (var index = 0; index < Nodes.Count; index++) { var node = Nodes[index]; if (node.IsSelected) { SelectedNodes.Add(node); } } MouseMode = MouseMode.Nothing; } if (MouseMode == MouseMode.ResizingComment) { TempComment.Cursor = Cursors.Arrow; TempComment = null; } HideLinkingPossiblity(); Cursor = Cursors.Arrow; if (WireMode == WireMode.FirstPortSelected && (TemExecPort != null || TemObjectPort != null)) { NodesTree.Show(); MouseMode = MouseMode.Nothing; WireMode = WireMode.Nothing; } else { Children.Remove(TempConn); MouseMode = MouseMode.Nothing; WireMode = WireMode.Nothing; } _mouseEffect.Show(this, Colors.DarkGray); Task.Factory.StartNew(() => { Thread.Sleep(300); Application.Current.Dispatcher.BeginInvoke(new Action(() => { _mouseEffect.Remove(this); })); }); }
public void Paste() { try { SelectedNodes.Clear(); var dummyList = Cipher.DeSerializeFromString <List <NodeProperties> >(Clipboard.GetText()); for (var index = dummyList.Count - 1; index >= 0; index--) { var copiednode = dummyList[index]; var typename = copiednode.Name; Node newNode = null; foreach (var node in Hub.LoadedExternalNodes) { if (node.ToString() != typename) { continue; } newNode = node.Clone(); AddNode(newNode, copiednode.X, copiednode.Y); newNode.DeSerializeData(copiednode.InputData, copiednode.OutputData); break; } if (newNode != null) { continue; } var type = Type.GetType(typename); try { var instance = Activator.CreateInstance(type, this, false); AddNode(instance as Node, copiednode.X, copiednode.Y); } catch (Exception) { //Ignored } } } catch { //ignored } }
protected override void OnDrawNode(DrawTreeNodeEventArgs e) { if (!bNoRedraw) { if (e.State == TreeNodeStates.Focused) { e.Graphics.FillRectangle(SystemBrushes.Window, e.Node.Bounds); if (ModifierKeys != Keys.Shift && ModifierKeys != Keys.Control) { ClearSelectedNodes(); } SelectNode(e.Node); OnAfterSelect(new TreeViewEventArgs(e.Node)); } Rectangle bounds = e.Node.Bounds; if (bounds.Top == 0 && bounds.Left == 0 && bounds.Height == 0 && bounds.Width == 0) { return; } e.DrawDefault = false; try { SizeF textsize = e.Graphics.MeasureString(e.Node.Name, Font); Brush brush = SystemBrushes.Window; int rightWidth = e.Node.Bounds.Width + 17; if (SelectedNodes.Contains(e.Node)) { brush = SystemBrushes.MenuHighlight; rightWidth = (int)Math.Round(textsize.Width, 0) + 4; } Rectangle selectRect = new Rectangle(e.Node.Bounds.Left - 1 - (e.Node.ImageIndex > 0 ? 0 : 16), e.Node.Bounds.Top, rightWidth, e.Node.Bounds.Height); e.Graphics.FillRectangle(brush, selectRect); e.Graphics.DrawString(e.Node.Name, Font, SystemBrushes.WindowText, e.Node.Bounds.Left - (e.Node.ImageIndex > 0 ? 0 : 16), e.Node.Bounds.Top + 2); } catch (Exception ex) { throw ex; } } }
/// <summary> /// release all selected object and put them back to their original structure /// </summary> public void Release() { Node[] selectedArray = SelectedNodes.ToArray(); for (int i = 0; i < selectedArray.Length; i++) { if (selectedArray [i].Childs.Count > 0) { foreach (var child in selectedArray[i].Childs) { child.GameObject.transform.SetParent(selectedArray [i].GameObject.transform); } } if (selectedArray [i].Parent == null) { selectedArray [i].GameObject.transform.SetParent(this.transform); } else { selectedArray [i].GameObject.transform.SetParent(selectedArray [i].Parent.GameObject.transform); } Snap(selectedArray [i]); } /*foreach (var obj in SelectedNodes) * { * Snap (obj); * if (obj.Childs.Count > 0) * { * foreach (var child in obj.Childs) * { * child.GameObject.transform.SetParent(obj.GameObject.transform); * } * } * * if (obj.Parent == null) * obj.GameObject.transform.SetParent(this.transform); * else * obj.GameObject.transform.SetParent(obj.Parent.GameObject.transform); * }*/ }
public void DeleteElement(BaseElement el) { if ((el == null) || (el is ConnectorElement)) { return; } //Delete link if (el is BaseLinkElement) { var lnk = (BaseLinkElement)el; DeleteLink(lnk); return; } //Delete node if (el is NodeElement) { var conn = ((NodeElement)el); foreach (var elconn in conn.Connectors) { for (var i = elconn.Links.Count - 1; i >= 0; i--) { var lnk = (BaseLinkElement)elconn.Links[i]; DeleteLink(lnk); } } if (SelectedNodes.Contains(el)) { SelectedNodes.Remove(el); } } if (SelectedElements.Contains(el)) { SelectedElements.Remove(el); } Elements.Remove(el); OnAppearancePropertyChanged(new EventArgs()); }
/// <summary> /// Raises the <see cref="TreeView.AfterSelect"/> event. /// </summary> /// <remarks> /// This handles the selection and unselection of nodes. /// </remarks> /// <param name="e">A <see cref="TreeViewEventArgs"/> describing the event arguments.</param> protected override void OnAfterSelect(TreeViewEventArgs e) { if (MultiSelect) { if (((ModifierKeys & Keys.Control) > 0)) { if (!SelectedNodes.Contains(e.Node)) { SelectedNodes.Add(e.Node); } else { SelectedNodes.Remove(e.Node); } } else { if (((ModifierKeys & Keys.Shift) > 0) && (m_tndFirst != null)) { SelectedNodes.Clear(); SelectedNodes.AddRange(FindPath(m_tndFirst, e.Node)); } else { if (SelectedNodes.Count > 0) { SelectedNodes.Clear(); } SelectedNodes.Add(e.Node); } } } base.OnAfterSelect(e); if (!MultiSelect) { if (!SelectedNodes.Contains(e.Node)) { SelectedNodes.Clear(); SelectedNodes.Add(e.Node); } } }
/// <summary> /// select the specified node /// </summary> public void Select(Node node) { if (node.Locked) { return; } node.Selected = true; if (node.HasMesh) { node.GameObject.GetComponent <Renderer>().material = new Material(HighlightMaterial); } if (!SelectedNodes.Contains(node)) { SelectedNodes.Add(node); } if (OnSelectEvent != null) { OnSelectEvent.Invoke(node); } }
private void Drag_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { var element = (FrameworkElement)sender; var node = element.DataContext as Node; if (node == null) { return; } var data = SelectedNodes.ToList(); if (!data.Any(d => d.Header.Equals(node.Header, StringComparison.OrdinalIgnoreCase))) { data.Add(node); } var dragEfect = CopyMode ? DragDropEffects.Copy : DragDropEffects.Move; DragDrop.DoDragDrop(element, data.ToArray(), dragEfect); e.Handled = false; }
public void DeleteElement(BaseElement element) { if ((element != null) && !(element is ConnectorElement)) { //Delete link if (element is BaseLinkElement) { var linkElement = (BaseLinkElement)element; DeleteLink(linkElement); return; } //Delete node if (element is NodeElement) { var conn = (NodeElement)element; foreach (var connectorElement in conn.Connectors) { for (var i = connectorElement.Links.Count - 1; i >= 0; i--) { var linkElement = (BaseLinkElement)connectorElement.Links[i]; DeleteLink(linkElement); } } if (SelectedNodes.Contains(element)) { SelectedNodes.Remove(element); } } if (SelectedElements.Contains(element)) { SelectedElements.Remove(element); } _elements.Remove(element); OnAppearancePropertyChanged(new EventArgs()); } }
/// <summary> /// Try and restore the selection. /// First, look for the object in the same position /// Second, find the object in the maximal sub tree where it appeared only once /// Finally, just select one of the parents /// </summary> private void RestoreSelection() { List <VirtualTreeNode> newSelectedNodes = new List <VirtualTreeNode>(); foreach (VirtualTreeNode.PersistenceInfo info in _persistedSelectionInfo) { VirtualTreeNode match; // First, look for the object in the same position if (TryExactMatch(info.Path, out match) >= info.Path.Count) { TryToSelectNode(newSelectedNodes, match); continue; } // Second, find the object in the maximal sub tree where it appeared only once if (TryExactMatch(info.PathToMaximalSubTree, out match) >= info.PathToMaximalSubTree.Count) { match = FindNodeIn(match, info.Tag); if (match != null) { // since node has moved, make sure it's visible. match.EnsureVisible(); TryToSelectNode(newSelectedNodes, match); } } } if (newSelectedNodes.Count == 0) { foreach (VirtualTreeNode.PersistenceInfo info in _persistedSelectionInfo) { // Finally, just select one of the parents TryToSelectNode(newSelectedNodes, ClosestMatch(info.Path)); break; } } // restore selection SelectedNodes.SetContents(newSelectedNodes); }
protected void UpdateSelection() { // Remove any nodes from the selection that may have been // removed from the tree. var selectedNodes = SelectedNodes.ToArray(); foreach (var node in selectedNodes) { if (node.TreeView == null) { SelectedNodes.Remove(node); } } // If any nodes were removed from the selection, reset the // anchor node to the selected node. if (selectedNodes.Length != SelectedNodes.Count) { _anchorNode = (TreeNodeMS)SelectedNode; } }
public MapTree() { selectedNodes = new SelectedNodes(); }
public static void Cut(SelectedNodes nodes) { if(nodes.Count > 0) { internalClipboard.Clear(); StringBuilder str = new StringBuilder(); MapTextSerializer serializer = new MapTextSerializer(); bool[] exclude = nodes.ExcludeNodesAlreadyPartOfHierarchy(); for (int i = 0; i < nodes.Count; i++) { if(!exclude[i]) { internalClipboard.Add(nodes[i]); } } internalClipboard.ForEach(n => { serializer.Serialize(n, str); n.Detach(); }); var cbData = new MindMateTextDataObject(); cbData.SetData(str.ToString()); Clipboard.SetDataObject(cbData); hasCutNode = true; if (StatusChanged != null) { StatusChanged(); } } }
public void SelectedNodes() { var s = new SelectedNodes(); Assert.AreEqual(0, s.Count); }
private void SelectedNodes_NodeDeselected(MapNode node, SelectedNodes selectedNodes) { if (TaskSelectionChanged == null) return; if (node.IsTaskComplete()) { TaskSelectionChanged(node, new TaskSelectionEventArgs() { ChangeType = TaskSelectionChange.Deselected }); } }
internal void OnMainMenuOpening(Plugins.MainMenuLocation menu, SelectedNodes selectedNodes) { }
void MapView_nodeSelected(Model.MapNode node, SelectedNodes selectedNodes) { UpdateStatusBarForNode(selectedNodes); }
public abstract void UpdateStatusBarForNode(SelectedNodes nodes);
internal void OnMapNodeContextMenuOpening(SelectedNodes selectedNodes) { for(int i = 0; i < Plugins.Count; i++) { IPluginMapNodeContextMenu plugin = Plugins[i] as IPluginMapNodeContextMenu; if(plugin != null) { plugin.OnContextMenuOpening(selectedNodes); } } }
private void UpdateFontControl(SelectedNodes nodes) { if (nodes.Count > 0) { MapNode n = nodes.First; RichFont.Bold = n.Bold ? FontProperties.Set : FontProperties.NotSet; RichFont.Italic = n.Italic ? FontProperties.Set : FontProperties.NotSet; RichFont.Strikethrough = n.Strikeout ? FontProperties.Set : FontProperties.NotSet; RichFont.Family = n.NodeView.Font.Name; RichFont.Size = (decimal)n.NodeView.Font.Size; } //else //{ // ClearFontControl(); //} }
private void SelectedNodes_NodeSelected(MapNode node, SelectedNodes selectedNodes) { UpdateFontControl(selectedNodes); }