// intIndex is the index into the intermediate node types // to consider user for adding this node protected void AddLogicalNode(IBrowserNode child, int intIndex) { BrowserTreeNode childNode = (BrowserTreeNode)child; // See if we have an intermediate node type if (childNode._intermediateNodeTypes != null && intIndex < childNode._intermediateNodeTypes.Count) { AddChildToIntermediate(childNode, (IntermediateNodeType)childNode. _intermediateNodeTypes[intIndex], intIndex); } else { ((TreeListView)TreeView).Add(Nodes, childNode); } // Update the logical tree only when the child is // added to the first level intermediate node if (intIndex == 0) { childNode._logicalParent = this; _logicalNodes.Add(childNode); childNode.AddedToTree(); } }
// Returns false if something went wrong public override bool Paste(IBrowserNode node, bool isCopy) { try { // Save the object, cuz it may get removed if this is a cut Object cutCopyObj = ((ObjectTreeNode)node).Obj; // First, remove the old object from its parent. This is // necessary to handle things like moving controls; they // will be upset if they are added to another node without // first removing them from the previous one. if (!isCopy) { node.RemoveLogicalNode(); } if (AddObject(cutCopyObj) == null) { return(false); } } catch (Exception ex) { ErrorDialog.Show(ex, "Exception during paste", MessageBoxIcon.Error); return(false); } return(true); }
protected override void OnBeforeExpand(TreeViewCancelEventArgs e) { if (e.Node is IBrowserNode) { try { IBrowserNode node = (IBrowserNode)e.Node; // Expansion could take a while Cursor save = Cursor.Current; Cursor.Current = Cursors.WaitCursor; // Allow the expansion to be cancelled // Do select processing on expansion as well //BeginUpdate(); if (node.ExpandNode()) { e.Cancel = true; } //EndUpdate(); Cursor.Current = save; } catch (Exception ex) { ErrorDialog.Show(ex, "(this is a bug, please report) " + "Exception on node expand", MessageBoxIcon.Error); } } base.OnBeforeExpand(e); }
internal void TreeNodePopupPaste(object sender, EventArgs e) { ((IBrowserNode)SelectedNode).Paste(_cutCopyNode, _isCopy); if (!_isCopy) { _cutCopyNode = null; } }
internal void TreeNodePopupDelete(object sender, EventArgs e) { IBrowserNode node = (IBrowserNode)SelectedNode; if (node != null) { node.RemoveLogicalNode(); } }
/// <summary> /// Builds the root and first-level of the tree /// </summary> /// <param name="treeView"></param> /// <param name="dataRoot"></param> private void BuildTreeView(TreeView treeView, IBrowserNode dataRoot) { treeView.Nodes.Clear(); if (dataRoot != null) { TreeNode treeRoot = new TreeNode(dataRoot.DisplayName); treeRoot.Tag = dataRoot; treeView.Nodes.Add(treeRoot); BuildNextTreeLevel(treeRoot); } }
/// <summary> /// Builds the root and first-level of the tree /// </summary> /// <param name="treeView"></param> /// <param name="dataRoot"></param> private void BuildTreeView(TreeView treeView, IBrowserNode dataRoot) { treeView.Nodes.Clear(); if (dataRoot != null) { TreeNode treeRoot = new TreeNode(dataRoot.DisplayName); treeRoot.Tag = dataRoot; treeView.Nodes.Add(treeRoot); BuildNextTreeLevel(treeRoot); } }
/// <summary> /// Called to build subsequent levels of the tree as they are expanded /// </summary> /// <param name="treeNode"></param> private void BuildNextTreeLevel(TreeNode treeNode) { IBrowserNode dataNode = (IBrowserNode)treeNode.Tag; foreach (IBrowserNode dataChild in dataNode.ChildNodes) { TreeNode treeChild = new TreeNode(dataChild.DisplayName); treeChild.Tag = dataChild; treeChild.ForeColor = dataChild.Enabled ? treeNode.TreeView.ForeColor : Color.DimGray; treeNode.Nodes.Add(treeChild); } }
protected void AddChild(IBrowserNode child) { _childNodes.Add(child); }
internal void TreeNodePopupCopy(object sender, EventArgs e) { _cutCopyNode = (IBrowserNode)SelectedNode; _isCopy = true; }
public virtual bool Paste(IBrowserNode node, bool isCopy) { throw new Exception("Paste not implemented"); }
public void AddLogicalNode(IBrowserNode child) { AddLogicalNode(child, 0); }
public void AddLogicalNode(IBrowserNode child) { AddLogicalNode(child, 0); }
protected void AddChild(IBrowserNode child) { _childNodes.Add(child); }
internal void TreeNodePopupPaste(object sender, EventArgs e) { ((IBrowserNode)SelectedNode).Paste(_cutCopyNode, _isCopy); if (!_isCopy) _cutCopyNode = null; }
internal void TreeNodePopupCopy(object sender, EventArgs e) { _cutCopyNode = (IBrowserNode)SelectedNode; _isCopy = true; }
public virtual bool Paste(IBrowserNode node, bool isCopy) { throw new Exception("Paste not implemented"); }
// Returns false if something went wrong public override bool Paste(IBrowserNode node, bool isCopy) { try { // Save the object, cuz it may get removed if this is a cut Object cutCopyObj = ((ObjectTreeNode)node).Obj; // First, remove the old object from its parent. This is // necessary to handle things like moving controls; they // will be upset if they are added to another node without // first removing them from the previous one. if (!isCopy) node.RemoveLogicalNode(); if (AddObject(cutCopyObj) == null) return false; } catch (Exception ex) { ErrorDialog.Show(ex, "Exception during paste", MessageBoxIcon.Error); return false; } return true; }
// intIndex is the index into the intermediate node types // to consider user for adding this node protected void AddLogicalNode(IBrowserNode child, int intIndex) { BrowserTreeNode childNode = (BrowserTreeNode)child; // See if we have an intermediate node type if (childNode._intermediateNodeTypes != null && intIndex < childNode._intermediateNodeTypes.Count) { AddChildToIntermediate(childNode, (IntermediateNodeType)childNode. _intermediateNodeTypes[intIndex], intIndex); } else { ((TreeListView)TreeView).Add(Nodes, childNode); } // Update the logical tree only when the child is // added to the first level intermediate node if (intIndex == 0) { childNode._logicalParent = this; _logicalNodes.Add(childNode); childNode.AddedToTree(); } }