private void btn_Click(object sender, EventArgs e) { try { Button btn = sender as Button; if (null == btn) { return; } DocTreeNode docNode = btn.Tag as DocTreeNode; if (null == docNode) { return; } if (docNode.IsBranch) { if (null != BranchSelected) { BranchSelected(this, new DocumentTreeViewEventArgs(docNode)); } } else { if (null != LeafSelected) { LeafSelected(this, new DocumentTreeViewEventArgs(docNode)); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logger.Write(ex.ToString(), Category.General, Priority.High); } }
public void SelectNode(DocTreeNode docNode) { TreeNode node = FindByDocTreeNode(Nodes, docNode); SelectedNode = node; SelectedNode.EnsureVisible(); }
private DocTreeNode BuildTree(DirectoryInfo directory) { if (null == directory) { return(null); } DocTreeNode root = new DocTreeNode(config.GetDocPath(), directory); foreach (var file in directory.GetFileSystemInfos().OrderBy(i => i.Name, new FileNameComparer())) { if (file is FileInfo) { root.AppendNode(new DocTreeNode(config.GetDocPath(), file)); } else { var dnode = BuildTree((DirectoryInfo)file); if (null != dnode) { root.AppendNode(dnode); } } } return(root); }
void DocumentTreeView_AfterSelect(object sender, TreeViewEventArgs e) { try { LoadChildrens(e.Node); DocTreeNode node = e.Node.Tag as DocTreeNode; if (null == node) { return; } if (node.IsBranch && null != BranchSelected) { BranchSelected(this, new DocumentTreeViewEventArgs(node)); } else if (node.IsLeaf && null != LeafSelected) { LeafSelected(this, new DocumentTreeViewEventArgs(node)); } } catch (Pic.Data.DataException ex) { Debug.Fail(ex.ToString()); Logger.Write(ex.ToString(), Category.General, Priority.High); } catch (System.Exception ex) { Debug.Fail(ex.ToString()); Logger.Write(ex.ToString(), Category.General, Priority.High); } }
///------------------------------------------------------------------------------------------------- /// <summary> Documentation. </summary> /// <returns> Documentation in a DocTreeNode. </returns> ///------------------------------------------------------------------------------------------------- public override DocTreeNode Documentation() { DocTreeNode node = base.Documentation(); node.AddChildField("FMaxUnassuredYears", FMaxUnassuredYears.ToString()); return(node); }
public override DocTreeNode Documentation() { DocTreeNode node = base.Documentation(); node.AddChildField("FMaxDifference", FMaxDifference.ToString()); node.AddChildField("FMinGPCD", FMinGPCD.ToString()); return(node); }
///------------------------------------------------------------------------------------------------- /// <summary> Documentation. </summary> /// <returns> Documentation in a DocTreeNode. </returns> ///------------------------------------------------------------------------------------------------- public override DocTreeNode Documentation() { DocTreeNode node = base.Documentation(); node.AddChildField("FMaxDeficit", FMaxDeficit.ToString()); node.AddChildField("FMaxCreditDeficit", FMaxCreditDeficit.ToString()); return(node); }
///------------------------------------------------------------------------------------------------- /// <summary> Documentation. </summary> /// <returns> Documentation in a DocTreeNode. </returns> ///------------------------------------------------------------------------------------------------- public override DocTreeNode Documentation() { DocTreeNode node = base.Documentation(); node.AddChildField("FMaxAWS", FMaxAWS.ToString()); node.AddChildField("FMinGPCD", FMinGPCD.ToString()); node.AddChildField("FAnnualPercentDecline", FMinGPCD.ToString()); return(node); }
protected int GetSelectedImageIndex(DocTreeNode docNode) { if (docNode.IsBranch) { return(1); } if (docNode.IsLeaf) { return(2); } else { throw new Exception("Unexpected document node type"); } }
public void RefreshTree() { // turn off visual updating BeginUpdate(); // clear tree Nodes.Clear(); try { // insert root nodes List <DocTreeNode> rootNodes = DocTreeNode.getRootNodes(); if (0 == rootNodes.Count) { FormCreateBranch form = new FormCreateBranch(); if (DialogResult.OK == form.ShowDialog()) { DocTreeNodeBranch.AddNewRootNode(form.BranchName, form.BranchDescription, form.BranchImage); rootNodes = DocTreeNode.getRootNodes(); } else { return; } } foreach (DocTreeNode docNode in rootNodes) { TreeNode tnRoot = new TreeNode(docNode.Name, GetImageIndex(docNode), GetSelectedImageIndex(docNode)); Nodes.Add(tnRoot); if (docNode.IsBranch) { // add menu tnRoot.ContextMenuStrip = GetBranchMenu(); } tnRoot.Tag = docNode; LoadChildrens(tnRoot); } } catch (Exception ex) { Debug.Fail(ex.ToString()); Logger.Write(ex.ToString(), Category.General, Priority.High); } // turn on visual updating EndUpdate(); }
protected TreeNode FindByDocTreeNode(TreeNodeCollection nodeCollection, DocTreeNode docNode) { foreach (TreeNode node in nodeCollection) { DocTreeNode current = node.Tag as DocTreeNode; if (docNode == current) { return(node); } } TreeNode parentNode = FindByDocTreeNode(nodeCollection, docNode.Parent); if (null != parentNode) { LoadChildrens(parentNode); return(FindByDocTreeNode(parentNode.Nodes, docNode)); } return(null); }
protected void LoadChildrens(TreeNode tn) { DocTreeNodeBranch docNodeBranch = tn.Tag as DocTreeNodeBranch; if (null == docNodeBranch) { return; } List <DocTreeNode> childNodes = docNodeBranch.childrens; foreach (DocTreeNode docNode in childNodes) { // check if node already inserted bool found = false; foreach (TreeNode tnChild in tn.Nodes) { DocTreeNode docNodeChild = tnChild.Tag as DocTreeNode; if (docNodeChild.Id == docNode.Id) { found = true; break; } } if (found) { continue; } // insert new node TreeNode tnNew = new TreeNode(docNode.Name, GetImageIndex(docNode), GetSelectedImageIndex(docNode)); tn.Nodes.Add(tnNew); if (docNode.IsBranch) { tnNew.ContextMenuStrip = GetBranchMenu(); } else if (docNode.IsLeaf) { tnNew.ContextMenuStrip = GetLeafMenu(); } tnNew.Tag = docNode; } }
private void deleteNode(object sender, EventArgs e) { try { // get current tree node TreeNode tnNode = GetCurrentTreeNode(); // clear parent node childrens DocTreeNodeBranch parentBranch = tnNode.Parent.Tag as DocTreeNodeBranch; parentBranch.ClearChildrens(); // remove DocumentTreeNode DocTreeNode docTreeNode = tnNode.Tag as DocTreeNode; docTreeNode.delete(); // remove tree node tnNode.Remove(); } catch (Exception ex) { Debug.Fail(ex.ToString()); Logger.Write(ex.ToString(), Category.General, Priority.Highest); } }
protected int GetSelectedImageIndex(DocTreeNode docNode) { if (docNode.IsBranch) return 1; if (docNode.IsLeaf) return 2; else throw new Exception("Unexpected document node type"); }
public DocumentTreeViewEventArgs(DocTreeNode docNode) { _docNode = docNode; }
protected TreeNode FindByDocTreeNode(TreeNodeCollection nodeCollection, DocTreeNode docNode) { foreach (TreeNode node in nodeCollection) { DocTreeNode current = node.Tag as DocTreeNode; if (docNode == current) return node; } TreeNode parentNode = FindByDocTreeNode(nodeCollection, docNode.Parent); if (null != parentNode) { LoadChildrens(parentNode); return FindByDocTreeNode(parentNode.Nodes, docNode); } return null; }