private static void SetNodeStyle(TreeNode Node) { int nNodeCount = 0; if (Node.Nodes.Count != 0) { foreach (TreeNode tnTemp in Node.Nodes) { if (tnTemp.Checked == true) nNodeCount++; } if (nNodeCount == Node.Nodes.Count) { Node.Checked = true; Node.ExpandAll(); Node.ForeColor = Color.Black; } else if (nNodeCount == 0) { Node.Checked = false; Node.Collapse(); Node.ForeColor = Color.Black; } else { Node.Checked = true; Node.ForeColor = Color.Gray; } } //当前节点选择完后,判断父节点的状态,调用此方法递归。 if (Node.Parent != null) SetNodeStyle(Node.Parent); }
private void RenderLevel(XmlNode xmlNode) { TreeNode newTreeNode; newTreeNode = new TreeNode(this.GetText(xmlNode)); if (this.SelectedNode == null) { this.Nodes.Add(newTreeNode); } else { this.SelectedNode.Nodes.Add(newTreeNode); } foreach (XmlNode childXmlNode in xmlNode) { if (!(childXmlNode is XmlWhitespace)) { this.SelectedNode = newTreeNode; this.RenderLevel(childXmlNode); if (childXmlNode is XmlText) { newTreeNode.Collapse(); } else { newTreeNode.Expand(); } } } }
public void AddLazyNode(TreeNode parent, TreeNode node) { node.Nodes.Add(GetLoadingNode()); if (parent == null) Nodes.Add(node); else parent.Nodes.Add(node); node.Collapse(); }
public override void Attach(TreeNode myNode) { myNode.Tag = this; myNode.SelectedImageKey = myNode.ImageKey = "BlockWeb"; myNode.Text = myWeb.Id + " @ " + myWeb.Address; addTempNode(myNode); myNode.Collapse(); myNodes.Add(myNode); }
private void ResetTree() { foreach (object obj in nodelist) { System.Windows.Forms.TreeNode tn = (System.Windows.Forms.TreeNode)obj; tn.BackColor = System.Drawing.Color.White; if (tn.IsExpanded) { tn.Collapse(); } } }
private void Populate(AssemblySet set) { _nodesTreeView.Nodes.Clear(); foreach (var asm in set) { var node = new TreeNode(asm.Name); node.Tag = asm.Load(); node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); _nodesTreeView.Nodes.Add(node); } }
private void addNode(TreeNode parent, string name, object val) { string strVal = val == null ? "null" : val.ToString(); if (strVal.Length > 20) strVal = strVal.Substring(0, 20) + "..."; TreeNode node = new TreeNode(name + " (" + strVal + ")"); if (val != null && val.GetType() != typeof(string) && !val.GetType().IsValueType) { node.Nodes.Add("ready-to-be-expanded-kafası"); node.Collapse(); node.Tag = val; } if (parent == null) tree.Nodes.Add(node); else parent.Nodes.Add(node); }
public static void CollapseAll(System.Windows.Forms.TreeNode Nodes, TreeNode tn) { if (Nodes != null && Nodes.Nodes != null && Nodes.Nodes.Count > 0) { //Nodes = Nodes.Nodes[0]; for (int i = 0; i < Nodes.Nodes.Count; i++) { System.Windows.Forms.TreeNode checknode = Nodes.Nodes[i]; tn.Expanded = false; if (tn != null) { Nodes.Collapse(); //checknode } //tn.GetChildNode(checknode.Text).Expanded = true; if (tn != null && tn.GetChildNode(checknode.Text) != null) { ExpandAll(checknode, tn.GetChildNode(checknode.Text)); } } } }
public int FillChild(TreeNode parent, string ID) { DataSet ds = PDataset("SELECT * FROM world.tree WHERE ParentID = " + ID); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { TreeNode child = new TreeNode(); child.Text = dr["Name"].ToString().Trim(); string temp = dr["ID"].ToString(); child.Collapse(); parent.Nodes.Add(child); FillChild(child, temp); } return 0; } else { return 0; } }
private void PVNode(TreeNode nParent, VPL.Execute.TreeNode Node, bool ShowName) { nParent.Collapse(); TreeNode nd; if (ShowName) { nd = nParent.Nodes.Add(string.Format("{0} = {1}", Node.Name, Node.Item.ToString())); } else { nd = nParent.Nodes.Add(Node.Item.ToString()); } if (Node._Children != null) { nd.Tag = Node; nd.Nodes.Add("<Enumerating>"); } else { nd.Tag = Node.Item; } }
// 填充全部内容 int Fill(LibraryChannel channel_param, TreeNode node, out string strError) { strError = ""; TreeNodeCollection children = null; if (node == null) children = this.Nodes; else children = node.Nodes; if (string.IsNullOrEmpty(this.Lang)) this.Lang = "zh"; LibraryChannel channel = null; TimeSpan old_timeout = new TimeSpan(0); if (channel_param != null) channel = channel_param; else { channel = this.CallGetChannel(true); old_timeout = channel.Timeout; channel.Timeout = new TimeSpan(0, 5, 0); } bool restoreLoading = IsLoading(node); try { string start_path = GetNodePath(node); { DirItemLoader loader = new DirItemLoader(channel, null, start_path, "", this.Lang); children.Clear(); foreach (ResInfoItem item in loader) { TreeNode nodeNew = new TreeNode(item.Name, item.Type, item.Type); nodeNew.Tag = item; if (item.HasChildren) SetLoading(nodeNew); if (EnabledIndices != null && StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false) nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor); if (HideIndices != null && StringUtil.IsInList(nodeNew.ImageIndex, HideIndices) == true) continue; children.Add(nodeNew); } } // 在根级追加 '!' 下的 dp2library 本地文件或目录 if (string.IsNullOrEmpty(start_path)) { ResInfoItem item = new ResInfoItem(); item.Name = "!"; item.Type = 4; item.HasChildren = true; TreeNode nodeNew = new TreeNode(item.Name, item.Type, item.Type); nodeNew.Tag = item; if (item.HasChildren) SetLoading(nodeNew); if (EnabledIndices != null && StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false) nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor); if (HideIndices != null && StringUtil.IsInList(nodeNew.ImageIndex, HideIndices) == true) { } else children.Add(nodeNew); } restoreLoading = false; // 防止 finally 复原 return 0; } catch(ChannelException ex) { strError = ex.Message; return -1; #if NO if (ex.ErrorCode == ErrorCode.AccessDenied) { strError = ex.Message; return -1; } strError = "Fill() 过程出现异常: " + ExceptionUtil.GetExceptionText(ex); return -1; #endif } catch (Exception ex) { strError = "Fill() 过程出现异常: " + ExceptionUtil.GetExceptionText(ex); return -1; } finally { if (channel_param == null) { channel.Timeout = old_timeout; this.CallReturnChannel(channel, true); } if (restoreLoading) { SetLoading(node); if (node != null) node.Collapse(); } } }
/*Init ActionsTreeView*/ private void InitActionsTreeView(Role pRole) { trwActionItems.Nodes.Clear(); TreeNode root = new TreeNode(MultiLanguageStrings.GetString(Ressource.FrmRoles, "action_item.Text")); trwActionItems.Nodes.Add(root); string prev = ""; TreeNode mainNode = null; foreach (KeyValuePair<ActionItemObject, bool> _action in pRole.GetSortedActionItems()) { if (!string.Equals(prev, _action.Key.ClassName)) { mainNode = new TreeNode(_action.Key.ClassName) {Tag = _action.Key}; mainNode.Collapse(); root.Nodes.Add(mainNode); prev = _action.Key.ClassName; } TreeNode childNode = new TreeNode(_action.Key.MethodName) { Tag = _action.Key, Checked = _action.Value }; mainNode.Nodes.Add(childNode); } root.Expand(); Invalidate(); }
private TreeNode FillChildNodes(TreeNode pParent, ToolStripMenuItem pMenuItem, Role pRole) { if (!pMenuItem.HasDropDownItems) { MenuObject menuObject; var lastChildNode = AddMenuItemFromMenu(pMenuItem, out menuObject); if (menuObject != null) lastChildNode.Checked = pRole.IsMenuAllowed(menuObject); return lastChildNode; } foreach (Object tsmi in pMenuItem.DropDownItems) { if (!(tsmi is ToolStripMenuItem)) continue; ToolStripMenuItem tsmiMenu = (ToolStripMenuItem)tsmi; MenuObject menuObject; var childNode = AddMenuItemFromMenu(tsmiMenu, out menuObject); if (menuObject == null) continue; childNode.Checked = pRole.IsMenuAllowed(menuObject); childNode.Collapse(true); FillChildNodes(childNode, tsmiMenu, pRole); pParent.Nodes.Add(childNode); pParent.Collapse(true); } return pParent; }
/// <summary> /// Thread-safe method for collapsing a TreeNode in the control /// </summary> /// <param name="node"></param> public void CollapseNode(TreeNode node) { if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { CollapseNode(node); }); else if (!node.IsExpanded) node.Collapse(); }
private void treeEffects_MouseDown(object sender, MouseEventArgs e) { m_node = treeEffects.GetNodeAt(e.X, e.Y); if (m_node != null) { // Is this a group? if (m_node.Nodes.Count > 0 && e.Clicks == 1) { if (m_node.IsExpanded) { m_node.Collapse(); } else { m_node.Expand(); } } else { if ((e.Button == MouseButtons.Left) && (e.Clicks == 1)) _beginDragDrop = true; else _beginDragDrop = false; } } }
private void FillTree(Element element, TreeNode parentNode) { var node = new TreeNode {Text = element.GetDisplayName(), Tag = element}; ApplyImage(node); ApplyErrors(node); parentNode.Nodes.Add(node); if (!element.HideChildren()) { element.AllChildren.OrderBy(childElement => childElement.Excluded).ThenBy( childElement => childElement.GetSortPriority()).ThenBy(childElement => childElement.GetType().Name). ThenBy(childElement => childElement.GetDisplayName()).ToList().ForEach( childElement => FillTree(childElement, node)); } if (element.GetDefaultExpanded()) node.Expand(); else node.Collapse(); }
private void RecursiveAddGroup(TreeNode tnParent, PwGroup pgContainer, PwGroup pgFind, ref TreeNode tnFound) { if(pgContainer == null) return; TreeNodeCollection tnc; if(tnParent == null) tnc = m_tvGroups.Nodes; else tnc = tnParent.Nodes; PwDatabase pd = m_docMgr.ActiveDatabase; foreach(PwGroup pg in pgContainer.Groups) { bool bExpired = (pg.Expires && (pg.ExpiryTime <= m_dtCachedNow)); string strName = pg.Name; // + GetGroupSuffixText(pg); int nIconID = ((!pg.CustomIconUuid.Equals(PwUuid.Zero)) ? ((int)PwIcon.Count + pd.GetCustomIconIndex(pg.CustomIconUuid)) : (int)pg.IconId); if(bExpired) nIconID = (int)PwIcon.Expired; TreeNode tn = new TreeNode(strName, nIconID, nIconID); tn.Tag = pg; UIUtil.SetGroupNodeToolTip(tn, pg); if(pd.RecycleBinEnabled && pg.Uuid.Equals(pd.RecycleBinUuid) && (m_fontItalicTree != null)) tn.NodeFont = m_fontItalicTree; else if(bExpired && (m_fontExpired != null)) tn.NodeFont = m_fontExpired; tnc.Add(tn); RecursiveAddGroup(tn, pg, pgFind, ref tnFound); if(tn.Nodes.Count > 0) { if((tn.IsExpanded) && (!pg.IsExpanded)) tn.Collapse(); else if((!tn.IsExpanded) && (pg.IsExpanded)) tn.Expand(); } if(pg == pgFind) tnFound = tn; } }
private void Populate(TreeNode treeNode, TypeDefinition tag) { foreach (var evt in tag.Events.Where(x => !x.IsSpecialName)) { var node = new TreeNode(evt.Name); node.Tag = evt; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } foreach (var property in tag.Properties.Where(x => !x.IsSpecialName)) { var node = new TreeNode(property.Name); node.Tag = property; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } foreach (var field in tag.Fields.Where(x => !x.IsSpecialName)) { var node = new TreeNode(field.Name); node.Tag = field; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } foreach (var field in tag.Methods.Where(x => !x.IsSpecialName)) { var node = new TreeNode(field.Name); node.Tag = field; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } }
private void SetupSceneTree() { treeScene.Nodes.Clear();//clear the old TreeNode scenenode = new TreeNode("Scene"); treeScene.Nodes.Add(scenenode); TreeNode selNode = null; foreach (Object3d obj in UVDLPApp.Instance().Engine3D.m_objects) { if(obj.tag == Object3d.OBJ_NORMAL) { TreeNode objnode = new TreeNode(obj.Name); objnode.Tag = obj; scenenode.Nodes.Add(objnode); if (obj == UVDLPApp.Instance().SelectedObject) // expand this node { //objnode.BackColor = Color.LightBlue; //treeScene.SelectedNode = objnode; selNode = objnode; } if (obj.m_supports.Count > 0) //if object has supports, create a node for them { TreeNode supnode = new TreeNode("Supports"); objnode.Nodes.Add(supnode); supnode.Collapse(); foreach (Object3d sup in obj.m_supports) { TreeNode tn = new TreeNode(sup.Name); tn.Tag = sup; supnode.Nodes.Add(tn); } } } } if (selNode != null) selNode.BackColor = Color.Green; scenenode.Expand(); treeScene.SelectedNode = selNode; }
protected override void WndProc(ref Message m) { if (m.Msg == 0x0014) // 禁掉清除背景消息 { return; } if (m.Msg == 0x0201)//单击 { int wparam = m.LParam.ToInt32(); Point point = new Point( LOWORD(wparam), HIWORD(wparam)); //point = PointToClient(point); TreeNode tn = this.GetNodeAt(point); if (tn == null) { base.WndProc(ref m); return; } if (tn.Level == 0) { if (tn.IsExpanded) { tn.Collapse(); } else { tn.Expand(); } m.Result = IntPtr.Zero; return; } else { base.WndProc(ref m); //tn.IsSelected = true; //this.SelectedNode = tn; } } else if (m.Msg == 0x0203)//双击 { int wparam = m.LParam.ToInt32(); Point point = new Point( LOWORD(wparam), HIWORD(wparam)); //point = PointToClient(point); TreeNode tn = this.GetNodeAt(point); if (tn == null) { base.WndProc(ref m); return; } if (tn.Level == 0) { m.Result = IntPtr.Zero; return; } else { base.WndProc(ref m); } } else if (m.Msg == 0x0200)//鼠标移动 { try { int wparam = m.LParam.ToInt32(); Point point = new Point( LOWORD(wparam), HIWORD(wparam)); //point = PointToClient(point); TreeNode tn = this.GetNodeAt(point); if (tn == null) { this.SelectedNode = null; base.WndProc(ref m); return; } this.SelectedNode = tn; } catch { } } else if (m.Msg == 0x02A3)//鼠标移出 WM_MOUSELEAVE = $02A3; { this.SelectedNode = null; base.WndProc(ref m); return; } else { base.WndProc(ref m); } //WM_LBUTTONDOWN = $0201 //WM_LBUTTONDBLCLK = $0203; }
/// <summary> /// The tree view CollapseAll method doesn't seem to work in /// this test environment. This replaces it. /// </summary> private void CollapseAll( TreeNode node ) { node.Collapse(); CollapseAll( node.Nodes ); }
public SourceTree() { InitializeComponent(); _dics.Add(TreeNodeType.TABLE, "表"); _dics.Add(TreeNodeType.TRIGGER, "触发器"); _dics.Add(TreeNodeType.SEQUENCE, "序列"); _dics.Add(TreeNodeType.FUNCTION, "函数"); _dics.Add(TreeNodeType.PROCEDURE, "存储过程"); _dics.Add(TreeNodeType.JAVASOURCE, "Java资源"); _dics.Add(TreeNodeType.JOB, "事务"); _dics.Add(TreeNodeType.VIEW, "视图"); foreach (var item in _dics) { TreeNode node = new TreeNode(item.Value); node.Tag = item.Key; node.ToolTipText = "点击后加载"; this.tvSourceTree.Nodes.Add(node); node.Collapse(); } //this.tvSourceTree.ExpandAll(); }
/// <summary> /// Deselect TreeNode supplied. /// Note that all selected TreeNodes can be found in the SelNodes property and the most recently selected TreeNode can be found in the SelNode property. /// </summary> /// <param name="tn">TreeNode to deselect.</param> /// <param name="bChangeSelNode">True if the SelNode property should be changed when deselecting the TreeNode.</param> /// <param name="bTriggerSelNodesAddRemoveEvents">True if calling this method should make the SelNodesAdd/SelNodesRemove methods raise the OnBeforeSelNodesAdd/OnBeforeSelNodesRemove and OnAfterSelNodesAdd/OnAfterSelNodesRemove events or false otherwise.</param> /// <returns>True if the TreeNode supplied was successfully removed from the SelNodes property.</returns> protected bool DeselectNode(TreeNode tn, bool bChangeSelNode, bool bTriggerSelNodesAddRemoveEvents) { bool bRetVal = false; bool bDeselectNode = false; if(!this.Enabled) { //EnableNodes() could be called, but the call to EnableNode(tn) should work. //EnableNodes(); EnableNode(tn); } if(tn != null && this.SelNodes.Count > 0 && IsTreeNodeSelected(tn)) { if( this.MultiSelect == TreeViewMultiSelect.MultiPathToParent || this.MultiSelect == TreeViewMultiSelect.MultiPathToParents || this.MultiSelect == TreeViewMultiSelect.SinglePathToParent || this.MultiSelect == TreeViewMultiSelect.SinglePathToParents) { if(tn.Nodes.Count == 0 || !IsAnyChildTreeNodeSelected(tn)) { bDeselectNode = true; } } else { bDeselectNode = true; } } if(!this.AllowNoSelNode && this.SelNodes.Count == 1) { bDeselectNode = false; } if(bDeselectNode) { this.SelNodesRemove(tn, bTriggerSelNodesAddRemoveEvents); if(!IsTreeNodeSelected(tn)) { bRetVal = true; } } if(bChangeSelNode) { if(bChangeSelNode && tn != null) { if(tn.IsExpanded && this.CollapseTreeNodeOnDeselect) { tn.Collapse(); } else if(this.ExpandTreeNodeOnDeselect) { tn.Expand(); } } if(this.SelNode != null) { bRetVal = true; } this.SelNodeInt = null; } if(!this.Enabled) { //DisableNodes() could be called, but the call to DisableNode(tn) should work. //DisableNodes(); DisableNode(tn); } return bRetVal; }
private void CollapseAll(TreeNode node) { if (node == null) return; node.Collapse(); foreach (TreeNode n in node.Nodes) {CollapseAll(n);} }
internal TreeNode MakeTreeNodeFromChannel(Channel channel) { TreeNode treeNode = new TreeNode(channel.Name); treeNode.Tag = channel; channel.Tag = treeNode; if (channel is ChannelFolder) { ChannelFolder channelFolder = channel as ChannelFolder; if (channelFolder.Expanded) treeNode.Expand(); else treeNode.Collapse(); } AdjustTVLogo(channel); return treeNode; }
/// <summary> /// Affichage du TreeView Final /// </summary> public void doDisplay() { Log.Info("Affichage de l'arborescence finale"); string txtAbsent = ""; treeView.Nodes.Clear(); lblNbFiles.Text = _nbcopiedFiles.ToString("D5"); lblNbTotal.Text = _nbTotalFiles.ToString("D5"); string pathRoot = p_applClass.RootDir; TreeNode nodSchool = treeView.Nodes.Add(pathRoot); /// On fait un affichage du LAB complet (c'est à dire tout le brut) TreeNode nodLab = new TreeNode(p_applClass.Param.ExportDirectory); int _cptPhoto = 0; // On balaye les classes classiques for (int _indClass = 0; _indClass < p_nbClass; _indClass++) { string _className = p_applClass.School.ListClass[_indClass].nameClass; int _idClass = p_applClass.School.ListClass[_indClass].idClass; _cptPhoto = 0; string _absent = this.getNbAbsents(_idClass.ToString() + Constantes.cstIndividu); txtAbsent += "Classe : " + _className + _absent + Environment.NewLine; foreach (string _eleveAbsent in this.getListAbsents(_idClass.ToString() + Constantes.cstIndividu)) { txtAbsent += "-->" + _eleveAbsent + Environment.NewLine; } // On crée le noeud correspondant à la classe TreeNode nodClass = new TreeNode(_className); // On charge le répertoire contenant les images INDIV string _dirIndiv = pathRoot + "\\" + p_applClass.Param.ExportDirectory + "\\" + _className + "\\" + p_applClass.Param.IndivDirectory; TreeNode nodIndiv = new TreeNode(p_applClass.Param.IndivDirectory + _absent); _cptPhoto += this.countFile(_dirIndiv, nodIndiv); // On compte les fichiers dans le répertoire nodClass.Nodes.Add(nodIndiv); // On charge le répertoire contenant les images GROUPES string _dirGroup = pathRoot + "\\" + p_applClass.Param.ExportDirectory + "\\" + _className + "\\" + p_applClass.Param.GroupDirectory; TreeNode nodGroup = new TreeNode(p_applClass.Param.GroupDirectory); _cptPhoto += this.countFile(_dirGroup, nodGroup); // On compte les fichiers dans le répertoire nodClass.Nodes.Add(nodGroup); nodLab.Nodes.Add(nodClass); if (_cptPhoto == 0) { nodClass.Collapse(); } else { nodClass.ExpandAll(); } System.Threading.Thread.Sleep(100); txtAbsent += Environment.NewLine; } _cptPhoto = 0; // On traite la classe FRATRIE // On crée le noeud correspondant à la classe TreeNode nodFratrie = new TreeNode("Fratries"); // On charge le répertoire contenant les images GROUP string _dirFratIndiv = pathRoot + "\\" + p_applClass.Param.ExportDirectory + "\\" + Constantes.cstFratrie + "\\" + p_applClass.Param.IndivDirectory; _cptPhoto += this.countFile(_dirFratIndiv, nodFratrie); // On compte les fichiers dans le répertoire if (_cptPhoto == 0) { nodFratrie.Collapse(); } else { nodFratrie.ExpandAll(); } nodLab.Nodes.Add(nodFratrie); nodLab.Expand(); nodSchool.Nodes.Add(nodLab); /// On parcours la sélection du photographe TreeNode nodSelection = new TreeNode(p_applClass.Param.SelectDirectory); int _cptSelectPhoto = 0; // On balaye les classes classiques for (int _indClass = 0; _indClass < p_nbClass; _indClass++) { string _className = p_applClass.School.ListClass[_indClass].nameClass; int _idClass = p_applClass.School.ListClass[_indClass].idClass; _cptSelectPhoto = 0; // On crée le noeud correspondant à la classe TreeNode nodClass = new TreeNode(_className); // On charge le répertoire contenant les images INDIV string _dirIndiv = pathRoot + "\\" + p_applClass.Param.SelectDirectory + "\\" + p_applClass.Param.IndivDirectory + "\\" + _className; TreeNode nodIndiv = new TreeNode(p_applClass.Param.IndivDirectory); _cptSelectPhoto += this.countFile(_dirIndiv, nodIndiv); // On compte les fichiers dans le répertoire nodClass.Nodes.Add(nodIndiv); // On charge le répertoire contenant les images GROUPES string _dirGroup = pathRoot + "\\" + p_applClass.Param.SelectDirectory + "\\" + p_applClass.Param.GroupDirectory + "\\" + _className; TreeNode nodGroup = new TreeNode(p_applClass.Param.GroupDirectory); _cptSelectPhoto += this.countFile(_dirGroup, nodGroup); // On compte les fichiers dans le répertoire nodClass.Nodes.Add(nodGroup); nodSelection.Nodes.Add(nodClass); if (_cptSelectPhoto == 0) { nodClass.Collapse(); } else { nodClass.ExpandAll(); } System.Threading.Thread.Sleep(100); } _cptSelectPhoto = 0; // On traite la classe FRATRIE // On crée le noeud correspondant à la classe TreeNode nodSelectFratrie = new TreeNode(Constantes.cstFratrie); // On charge le répertoire contenant les images INDIV string _dirSelectFratIndiv = pathRoot + "\\" + p_applClass.Param.SelectDirectory + "\\" + p_applClass.Param.IndivDirectory + "\\" + Constantes.cstFratrie; _cptSelectPhoto += this.countFile(_dirSelectFratIndiv, nodSelectFratrie); // On compte les fichiers dans le répertoire if (_cptSelectPhoto == 0) { nodSelectFratrie.Collapse(); } else { nodSelectFratrie.ExpandAll(); } nodSelection.Nodes.Add(nodSelectFratrie); nodSelection.Expand(); nodSchool.Nodes.Add(nodSelection); nodSchool.Expand(); this.createAbsentFile(txtAbsent); }
private void Populate(TreeNode treeNode, AssemblyDefinition tag) { foreach (var module in tag.Modules) { var node = new TreeNode(module.Name); node.Tag = module; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } }
/// <summary> /// Select TreeNode supplied. /// Note that all selected TreeNodes can be found in the SelNodes property and the most recently selected TreeNode can be found in the SelNode property. /// </summary> /// <param name="tn">TreeNode to select.</param> /// <param name="bChangeSelNode">True if the SelNode property should be changed when selecting the TreeNode.</param> /// <param name="bTriggerSelNodesAddRemoveEvents">True if calling this method should make the SelNodesAdd/SelNodesRemove methods raise the OnBeforeSelNodesAdd/OnBeforeSelNodesRemove and OnAfterSelNodesAdd/OnAfterSelNodesRemove events or false otherwise.</param> /// <param name="bTriggerSelNodeEvents">True if calling this method should make the SelNodeInt property raise the OnBeforeSelNodeChanged/OnAfterSelNodeChanged events or false otherwise.</param> /// <returns>True if the SelNode property was changed to the TreeNode supplied (even if the SelNode property was already set to the TreeNode supplied before this method was called).</returns> protected bool SelectNode(TreeNode tn, bool bChangeSelNode, bool bTriggerSelNodesAddRemoveEvents, bool bTriggerSelNodeEvents) { bool bRetVal = false; if(tn != null) { if(!this.Enabled) { //EnableNodes() could be called, but the call to EnableNode(tn) should work. //EnableNodes(); EnableNode(tn); } #region Switch-statement switch(this.MultiSelect) { case TreeViewMultiSelect.NoMulti: if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.ClearSelNodes(bTriggerSelNodesAddRemoveEvents); this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.Multi: case TreeViewMultiSelect.MultiAllDescendants: if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.MultiSameBranchAndLevel: if(this.SelNodes != null && this.SelNodes.Count > 0) { TreeNode tnGrandParentSelNodes = null; int iLevel = 0; foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values) { tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node); iLevel = GetTreeNodeLevel(mwtnw.Node); break; } if(GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes && GetTreeNodeLevel(tn) == iLevel) { if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.MultiSameBranch: if(this.SelNodes != null && this.SelNodes.Count > 0) { TreeNode tnGrandParentSelNodes = null; foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values) { tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node); break; } if(GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes) { if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.MultiSameLevel: if(this.SelNodes != null && this.SelNodes.Count > 0) { int iLevel = 0; foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values) { iLevel = GetTreeNodeLevel(mwtnw.Node); break; } if(GetTreeNodeLevel(tn) == iLevel) { if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.MultiPathToParents: case TreeViewMultiSelect.MultiPathToParent: if(this.SelNodes != null && this.SelNodes.Count > 0) { TreeNode tnGrandParentSelNodes = null; foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values) { tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node); break; } if(GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes || this.MultiSelect == TreeViewMultiSelect.MultiPathToParents) { if(!IsTreeNodeSelected(tn)) { int iTNLevel = GetTreeNodeLevel(tn); TreeNode tnTNGrandParent = GetTreeNodeGrandParent(tn); int iMaxLevel = 0; foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values) { iMaxLevel = Math.Max(iMaxLevel, GetTreeNodeLevel(mwtnw.Node)); } if(iMaxLevel < iTNLevel) { if(this.MultiSelect == TreeViewMultiSelect.MultiPathToParent) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); } else if(this.MultiSelect == TreeViewMultiSelect.MultiPathToParents) { DeselectBranch(tnTNGrandParent, true, true); } } else { foreach(TreeNode tnRoot in this.Nodes) { if(GetTreeNodeGrandParent(tn) == tnRoot) { ArrayList al = new ArrayList(); foreach(MWTreeNodeWrapper mwtnw in this.SelNodes.Values) { if(tnRoot == GetTreeNodeGrandParent(mwtnw.Node)) { int iLevel = GetTreeNodeLevel(mwtnw.Node); if(iLevel > iTNLevel) { al.Add(mwtnw.Node); } } } for(int i = 0; i < al.Count; i++) { DeselectNode(al[i] as TreeNode, false, bTriggerSelNodesAddRemoveEvents); } } } } if(IsSelectNodeRegExSatisfied(tn.Text)) { this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } tnTemp = tnTemp.Parent; } } } else { TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(IsSelectNodeRegExSatisfied(tn.Text)) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } } tnTemp = tnTemp.Parent; } } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } tnTemp = tnTemp.Parent; } } } else if(IsSelectNodeRegExSatisfied(tn.Text)) { if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } tnTemp = tnTemp.Parent; } } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.SinglePathToParent: if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } tnTemp = tnTemp.Parent; } } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; case TreeViewMultiSelect.SinglePathToParents: if(this.SelNodes != null && this.SelNodes.Count > 0) { int iTNLevel = GetTreeNodeLevel(tn); TreeNode tnTNGrandParent = GetTreeNodeGrandParent(tn); foreach(TreeNode tnRoot in this.Nodes) { if(GetTreeNodeGrandParent(tn) == tnRoot) { if(IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelBranch(tnRoot); if(!IsTreeNodeSelected(tn)) { this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } tnTemp = tnTemp.Parent; } } break; } } } else { if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text)) { ClearSelNodes(bTriggerSelNodesAddRemoveEvents); if(this.SelNodes == null) { this.SelNodes = new Hashtable(); } if(!IsTreeNodeSelected(tn)) { this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents); } TreeNode tnTemp = tn; while(tnTemp.Parent != null) { if(!IsTreeNodeSelected(tnTemp.Parent)) { this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents); } tnTemp = tnTemp.Parent; } } } if(bChangeSelNode) { ChangeSelNode(tn, bTriggerSelNodeEvents); } break; default: //Execution should never end up here! break; } #endregion Switch-statement if(this.SelNode == tn) { bRetVal = true; } if(bChangeSelNode && tn != null) { if(tn.IsExpanded && this.CollapseTreeNodeOnSelect) { tn.Collapse(); } else if(this.ExpandTreeNodeOnSelect) { tn.Expand(); } } if(!this.Enabled) { //DisableNodes() could be called, but the call to DisableNode(tn) should work. //DisableNodes(); DisableNode(tn); } else if(!bActive) { DeactivateSelNode(tn); } } return bRetVal; }
private void Populate(TreeNode treeNode, ModuleDefinition tag) { if (treeNode.Parent.Tag is AssemblyDefinition) // Namespace { var namespaces = new HashSet<string>(); foreach (var type in tag.Types) { if (!string.IsNullOrEmpty(type.Namespace) && namespaces.Add(type.Namespace)) { var node = new TreeNode(type.Namespace); node.Tag = tag; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } else { var node = new TreeNode(type.Name); node.Tag = type; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } } } else // Type within namespace. { foreach (var type in tag.Types.Where(x => x.Namespace == treeNode.Text)) { var node = new TreeNode(type.Name); node.Tag = type; node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding. node.Collapse(); treeNode.Nodes.Add(node); } } }
private void ReExpandNodeUp(TreeNode treeNode) { if (treeNode != null) { if (treeNode.IsExpanded) { treeNode.Collapse(); treeNode.Expand(); SelectedNode = treeNode; OnAfterSelect(new TreeViewEventArgs(SelectedNode)); } else { ReExpandNodeUp(treeNode.Parent); } } }
/// <summary> /// Build a tree view of commit nodes using hints from repo commit groups. /// Commit nodes have Tags containing absolute paths to files, /// while the relative paths (with respect to repo root) are simply in the Text. /// </summary> public static TreeNode BuildCommitsView(ClassRepo repo, List<string> list) { repo.Commits.Rebuild(list); // Step 1: Build the default list with all files under this status class TreeNode root = new TreeNode("Pending Changelists"); root.Tag = "root"; // Tag of the root node foreach (var c in repo.Commits.Bundle) { var commitNode = new TreeNode(GetCommitNodeText(c)) { Tag = c }; if (c.IsCollapsed) commitNode.Collapse(); foreach (var f in c.Files) { var tn = new TreeNode(f) { Tag = f }; commitNode.Nodes.Add(tn); } root.Nodes.Add(commitNode); } root.ExpandAll(); return root; }
private void CheckNode(TreeNode node, bool check) { if (0 < node.Nodes.Count) { if (node.Checked) { node.Expand(); } else { node.Collapse(); } foreach (TreeNode t in node.Nodes) { t.Checked = check; CheckNode(t, check); } } }
private void HideSubhierarchyPermanently(TreeNode root) { Debug.Assert(root.Tag is Node); var node = (Node) root.Tag; _hidden.Add(node, root); root.ImageIndex = root.SelectedImageIndex = 4; root.Collapse(); UpdateFilters(); UpdateHiddenNodesInfoPanel(); }
private void RemoveAt(int index, bool update) { TreeNode removed = nodes [index]; TreeNode prev = GetPrevNode(removed); TreeNode new_selected = null; bool re_set_selected = false; bool visible = removed.IsVisible; TreeView tree_view = TreeView; if (tree_view != null) { tree_view.RecalculateVisibleOrder(prev); if (removed == tree_view.SelectedNode) { if (removed.IsExpanded) { removed.Collapse(); // Fix Xamarin Bugzilla 5010. } re_set_selected = true; OpenTreeNodeEnumerator oe = new OpenTreeNodeEnumerator(removed); if (oe.MoveNext() && oe.MoveNext()) { new_selected = oe.CurrentNode; } else { oe = new OpenTreeNodeEnumerator(removed); oe.MovePrevious(); new_selected = oe.CurrentNode == removed ? null : oe.CurrentNode; } } } Array.Copy(nodes, index + 1, nodes, index, count - index - 1); count--; nodes[count] = null; if (nodes.Length > OrigSize && nodes.Length > (count * 2)) { Shrink(); } if (tree_view != null && re_set_selected) { tree_view.SelectedNode = new_selected; } TreeNode parent = removed.parent; removed.parent = null; if (update && tree_view != null && visible) { tree_view.RecalculateVisibleOrder(prev); tree_view.UpdateScrollBars(false); tree_view.UpdateBelow(parent); } OnUIACollectionChanged(CollectionChangeAction.Remove, removed); }
// 递归 public int Fill(TreeNode node) { TreeNodeCollection children = null; if (node == null) { children = this.Nodes; } else { children = node.Nodes; } int i; // 填充根 if (node == null) { children.Clear(); TreeNode nodeNew = new TreeNode(this.ServerUrl, ResTree.RESTYPE_SERVER, ResTree.RESTYPE_SERVER); ResTree.SetLoading(nodeNew); NodeInfo nodeinfo = new NodeInfo(); nodeinfo.TreeNode = nodeNew; nodeinfo.Expandable = true; nodeinfo.DefElement = GetDefElementString(nodeNew.ImageIndex); nodeinfo.NodeState |= NodeState.Object; nodeNew.Tag = nodeinfo; if (EnabledIndices != null && StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false) nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor); children.Add(nodeNew); return 0; } // 根以下的节点类型 ResPath respath = new ResPath(node); string strPath = respath.Path; //if (node != null) // strPath = TreeViewUtil.GetPath(node); this.channel = Channels.GetChannel(this.ServerUrl); Debug.Assert(channel != null, "Channels.GetChannel() 异常"); ResInfoItem [] items = null; string strError = ""; DigitalPlatform.Stop stop = null; if (stopManager != null) { stop = new DigitalPlatform.Stop(); stop.Register(this.stopManager, true); // 和容器关联 stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在列目录: " + this.ServerUrl + "?" + strPath); stop.BeginLoop(); } long lRet = channel.DoDir(strPath, this.Lang, null, // 不需要列出全部语言的名字 out items, out strError); if (stopManager != null) { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); stop.Unregister(); // 和容器关联 } this.channel = null; if (lRet == -1) { try { MessageBox.Show(this, "Channel::DoDir() Error: " + strError); } catch { // this可能已经不存在 return -1; } if (node != null) { ResTree.SetLoading(node); // 出错的善后处理,重新出现+号 node.Collapse(); } return -1; } if (items != null) { children.Clear(); for(i=0;i<items.Length;i++) { // 忽略from类型节点 if (items[i].Type == ResTree.RESTYPE_FROM) continue; TreeNode nodeNew = new TreeNode(items[i].Name, items[i].Type, items[i].Type); NodeInfo nodeinfo = new NodeInfo(); nodeinfo.TreeNode = nodeNew; nodeinfo.Expandable = items[i].HasChildren; nodeinfo.DefElement = GetDefElementString(nodeNew.ImageIndex); nodeinfo.NodeState |= NodeState.Object; nodeinfo.Style = items[i].Style; nodeNew.Tag = nodeinfo; if (items[i].HasChildren) ResTree.SetLoading(nodeNew); if (EnabledIndices != null && StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false) nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor); children.Add(nodeNew); } } return 0; }