public static void SetNodeToolTip(MouseEventArgs e, ToolTip tTip) { try { if (!Settings.Default.ShowDescriptionTooltipsInTree) { return; } //Find the node under the mouse. TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); if (new_node == null || new_node.Equals(SetNodeToolTip_old_node)) { return; } SetNodeToolTip_old_node = new_node; //See if we have a node. if (SetNodeToolTip_old_node == null) { tTip.SetToolTip(_TreeView, ""); } else { //Get this node's object data. if (ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) { tTip.SetToolTip(_TreeView, ((ConnectionInfo)SetNodeToolTip_old_node.Tag).Description); } } } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SetNodeToolTip failed" + Environment.NewLine + ex.Message, true); } }
public static void Sort(TreeNode treeNode, SortOrder sorting) { if (TreeView == null) { return; } TreeView.BeginUpdate(); if (treeNode == null) { if (TreeView.Nodes.Count > 0) { treeNode = TreeView.Nodes[0]; } else { return; } } else if (ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Connection) { treeNode = treeNode.Parent; if (treeNode == null) { return; } } Sort(treeNode, new TreeNodeSorter(sorting)); TreeView.EndUpdate(); }
private static void FinishRenameSelectedContainerNode(string newName) { Container.ContainerInfo containerInfo = SelectedNode.Tag as Container.ContainerInfo; if (containerInfo != null) { ConnectionTreeNode.RenameNode(containerInfo.ConnectionInfo, newName); } }
private void UpdateParentReferenceWhenParentIsRoot() { if (ConnectionTreeNode.GetNodeType(_nodeBeingMoved.Parent) == TreeNodeType.Root) { ((Parent)_nodeBeingMoved.Tag).Parent = null; ((Inheritance)_nodeBeingMoved.Tag).Inheritance.DisableInheritance(); } }
private void UpdateParentReferenceWhenParentIsAContainer() { if (ConnectionTreeNode.GetNodeType(_nodeBeingMoved.Parent) == TreeNodeType.Container) { ((Parent)_nodeBeingMoved.Tag).Parent = (ContainerInfo)_nodeBeingMoved.Parent.Tag; ((Inheritance)_nodeBeingMoved.Tag).Inheritance.EnableInheritance(); } }
private void AddNodeToNewLocation(TreeNode targetNode) { //If there is no targetNode add dropNode to the bottom of //the TreeView root nodes, otherwise add it to the end of //the dropNode child nodes if (ConnectionTreeNode.GetNodeType(targetNode) == TreeNodeType.Root | ConnectionTreeNode.GetNodeType(targetNode) == TreeNodeType.Container) { targetNode.Nodes.Insert(0, _nodeBeingMoved); } else { targetNode.Parent.Nodes.Insert(targetNode.Index + 1, _nodeBeingMoved); } }
private static bool SelectedNodeIsAValidDeletionTarget() { bool validDeletionTarget = true; if (SelectedNode == null) { validDeletionTarget = false; } else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) { validDeletionTarget = false; Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "The root item cannot be deleted!"); } return(validDeletionTarget); }
public static void DeleteSelectedNode() { try { if (!SelectedNodeIsAValidDeletionTarget()) { return; } if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) { if (ConnectionTreeNode.IsEmpty(SelectedNode)) { if (UserConfirmsEmptyFolderDeletion()) { SelectedNode.Remove(); } } else { if (UserConfirmsNonEmptyFolderDeletion()) { TreeView.BeginUpdate(); SelectedNode.Nodes.Clear(); SelectedNode.Remove(); TreeView.EndUpdate(); } } } else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Connection) { if (UserConfirmsConnectionDeletion()) { SelectedNode.Remove(); } } else { Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); } } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Deleting selected node failed" + Environment.NewLine + ex.Message, true); } }
private bool WeAreAllowedToMoveThisNode(TreeNode targetNode) { bool weShouldMoveThisNode = true; if (_nodeBeingMoved == targetNode) { weShouldMoveThisNode = false; } if (ConnectionTreeNode.GetNodeType(_nodeBeingMoved) == TreeNodeType.Root) { weShouldMoveThisNode = false; } if (_nodeBeingMoved == targetNode.Parent) { weShouldMoveThisNode = false; } return(weShouldMoveThisNode); }