當前位置: 首頁>>代碼示例>>C#>>正文


C# TreeView.Invalidate方法代碼示例

本文整理匯總了C#中System.Windows.Forms.TreeView.Invalidate方法的典型用法代碼示例。如果您正苦於以下問題:C# TreeView.Invalidate方法的具體用法?C# TreeView.Invalidate怎麽用?C# TreeView.Invalidate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.TreeView的用法示例。


在下文中一共展示了TreeView.Invalidate方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RefreshModTree

        void RefreshModTree(TreeView treeView, string[] modList)
        {
            treeView.Nodes.Clear();
            Dictionary<string, TreeNode> nodes;
            nodes = modList.Where(x => allMods[x].Standalone).ToDictionary(x => x, x => new TreeNode(x));
            string[] rootMods = modList.Where(x => allMods[x].Standalone).ToArray();
            string[] remaining = modList.Except(nodes.Keys).ToArray();

            while (remaining.Length > 0)
            {
                bool progress = false;
                List<string> toRemove = new List<string>();
                foreach (string s in remaining)
                {
                    var n = new TreeNode(s);
                    if (allMods[s].Requires == null) continue;
                    if (!nodes.ContainsKey(allMods[s].Requires)) continue;
                    nodes[allMods[s].Requires].Nodes.Add(n);
                    nodes.Add(s, n);
                    toRemove.Add(s);
                    progress = true;
                }

                if (!progress)
                    break;
                remaining = remaining.Except(toRemove).ToArray();
            }

            foreach (string s in rootMods)
                treeView.Nodes.Add(nodes[s]);

            if (remaining.Length > 0)
            {
                var n = new TreeNode("<Unspecified Dependency>");
                n.ForeColor = SystemColors.GrayText;
                var m = new TreeNode("<Missing Dependency>");
                m.ForeColor = SystemColors.GrayText;

                foreach (var s in remaining)
                {
                    if (allMods[s].Requires == null)
                        n.Nodes.Add(new TreeNode(s) { ForeColor = SystemColors.GrayText });
                    else if (!nodes.ContainsKey(allMods[s].Requires))
                        m.Nodes.Add(new TreeNode(s) { ForeColor = SystemColors.GrayText });
                }

                treeView.Nodes.Add(n);
                treeView.Nodes.Add(m);
            }

            treeView.Invalidate();
        }
開發者ID:geckosoft,項目名稱:OpenRA,代碼行數:52,代碼來源:ConfigureModsDialog.cs

示例2: HandleCheckBoxNodes

//		private void UndoLastSelectedNode()
//		{
//			if (m_lastSelectedTreeNode != null)
//			{
//				if (IsTerminalNode(m_lastSelectedTreeNode))
//				{
//					m_lastSelectedTreeNode.Chosen = false;
//					m_lastSelectedTreeNode.ImageIndex = m_lastSelectedTreeNode.SelectedImageIndex = (int)ImageKind.radio;
//				}
//			}
//		}
		private void HandleCheckBoxNodes(TreeView tv, FeatureTreeNode tn)
		{
			//UndoLastSelectedNode();
			if (IsTerminalNode(tn))
			{
				tn.Chosen = true;
				tn.ImageIndex = tn.SelectedImageIndex = (int)ImageKind.radioSelected;
				if (tn.Parent != null)
				{
					FeatureTreeNode sibling = (FeatureTreeNode)tn.Parent.FirstNode;
					while (sibling != null)
					{
						if (IsTerminalNode(sibling) && sibling != tn)
						{
							sibling.Chosen = false;
							sibling.ImageIndex = sibling.SelectedImageIndex = (int)ImageKind.radio;
						}
						sibling = (FeatureTreeNode)sibling.NextNode;
					}
				}
				tv.Invalidate();
			}
//			m_lastSelectedTreeNode = tn;
		}
開發者ID:sillsdev,項目名稱:FieldWorks,代碼行數:35,代碼來源:FeatureStructureTreeView.cs

示例3: RefreshModTree

        void RefreshModTree(TreeView treeView, string[] modList)
        {
            treeView.Nodes["ModsNode"].Nodes.Clear();
            Dictionary<string, TreeNode> nodes;
            nodes = modList.Where(x => allMods[x].Standalone).ToDictionary(x => x,
                x => new TreeNode(allMods[x].Title) { Name = x });
            string[] rootMods = modList.Where(x => allMods[x].Standalone).ToArray();
            Stack<string> remaining = new Stack<string>(modList.Except(nodes.Keys));

            bool progress = true;
            while (remaining.Count > 0 && progress)
            {
                progress = false;
                string s = remaining.Pop();
                var n = new TreeNode(allMods[s].Title) { Name = s };
                if (allMods[s].Requires == null) { remaining.Push(s); continue; }
                if (!nodes.ContainsKey(allMods[s].Requires)) { remaining.Push(s); continue; }
                nodes[allMods[s].Requires].Nodes.Add(n);
                nodes.Add(s, n);
                progress = true;
            }

            foreach (string s in rootMods)
                treeView.Nodes["ModsNode"].Nodes.Add(nodes[s]);

            if (remaining.Count > 0)
            {
                var unspecified = new TreeNode("<Unspecified Dependency>") { ForeColor = SystemColors.GrayText };
                var missing = new TreeNode("<Missing Dependency>") { ForeColor = SystemColors.GrayText };

                foreach (var s in remaining)
                {
                    if (allMods[s].Requires == null)
                        unspecified.Nodes.Add(new TreeNode(allMods[s].Title)
                        { ForeColor = SystemColors.GrayText, Name = s });
                    else if (!nodes.ContainsKey(allMods[s].Requires))
                        missing.Nodes.Add(new TreeNode(allMods[s].Title)
                        { ForeColor = SystemColors.GrayText, Name = s });
                }
                string brokenKey = "BrokenModsNode";
                if (treeView.Nodes[brokenKey] != null)
                    treeView.Nodes.RemoveByKey(brokenKey);
                treeView.Nodes.Add(brokenKey, "Broken Mods");
                treeView.Nodes[brokenKey].Nodes.Add(unspecified);
                treeView.Nodes[brokenKey].Nodes.Add(missing);
            }
            treeView.Nodes["ModsNode"].ExpandAll();
            treeView.Invalidate();

            string responseString = UtilityProgram.CallSimpleResponse("--settings-value", SupportDir, "Game.Mods");

            if (Util.IsError(ref responseString))
                treeView.SelectedNode = treeView.Nodes["ModsNode"].Nodes["ra"];
            else
                treeView.SelectedNode = treeView.Nodes["ModsNode"].Nodes[responseString];
        }
開發者ID:patthoyts,項目名稱:OpenRA,代碼行數:56,代碼來源:Launcher.cs

示例4: HandleCheckBoxNodes

		protected virtual void HandleCheckBoxNodes(TreeView tv, TreeNode tn)
		{
			UndoLastSelectedNode();
			if (m_fTerminalsUseCheckBoxes)
			{
				if (IsTerminalNode(tn))
				{
					MasterInflectionFeature mif = tn.Tag as MasterInflectionFeature;
					if (tn.Checked)
					{
						if (mif == null || !mif.InDatabase)
						{
							tn.Checked = false;
							tn.ImageIndex = tn.SelectedImageIndex = (int)ImageKind.checkBox;
						}
					}
					else
					{
						tn.Checked = true;
						tn.ImageIndex = tn.SelectedImageIndex = (int)ImageKind.checkedBox;
						if (mif != null)
						{
							string sId = XmlUtils.GetOptionalAttributeValue(mif.Node, "id");
							if (FsFeatureSystem.HasSymbolicValue(m_cache, sId))
							{
								// we want to set all other sisters that are in the database
								TreeNode sibling = tn.Parent.FirstNode;
								while (sibling != null)
								{
									if (IsTerminalNode(sibling) && sibling != tn)
									{
										mif = sibling.Tag as MasterInflectionFeature;
										if (mif != null)
										{
											sId = XmlUtils.GetOptionalAttributeValue(mif.Node, "id");
											if (FsFeatureSystem.HasSymbolicValue(m_cache, sId))
											{
												sibling.Checked = true;
												sibling.ImageIndex =
													sibling.SelectedImageIndex = (int)ImageKind.checkedBox;
											}
										}
									}
									sibling = sibling.NextNode;
								}
							}
						}
					}
					tv.Invalidate();
				}
			}
			else
			{
				if (IsTerminalNode(tn))
				{
					tn.Checked = true;
					tn.ImageIndex = tn.SelectedImageIndex = (int)ImageKind.radioSelected;
					if (tn.Parent != null)
					{
						TreeNode sibling = tn.Parent.FirstNode;
						while (sibling != null)
						{
							if (IsTerminalNode(sibling) && sibling != tn)
							{
								sibling.Checked = false;
								sibling.ImageIndex = sibling.SelectedImageIndex = (int)ImageKind.radio;
							}
							sibling = sibling.NextNode;
						}
					}
					tv.Invalidate();
				}
				m_lastSelectedTreeNode = tn;
			}
		}
開發者ID:sillsdev,項目名稱:WorldPad,代碼行數:75,代碼來源:GlossListTreeView.cs

示例5: Initialize


//.........這裏部分代碼省略.........
				{
					try
					{
						m_oMenuService.RemoveCommand(m_oOldCmdCopy);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.RemoveCommand(m_oOldCmdPaste);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.AddCommand(m_oNewCmdCopy);
					}
					catch
					{
					}
					try
					{
						m_oMenuService.AddCommand(m_oNewCmdPaste);
					}
					catch
					{
					}

					TreeViewDesigner.MenuAdded = true;
				}

				m_oTreeView.Invalidate();

				#region action menus

				#region node menu

				m_oActionMenuNode = new ActionMenuNative();
				m_oActionMenuNode.Width = 170;
				m_oActionMenuNode.Title = "Node Action Menu";

				ActionMenuGroup oMenuGroup = m_oActionMenuNode.AddMenuGroup("Editing");
				oMenuGroup.Expanded = true;
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Node");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete Node");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Add Panel");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Clear Content");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Delete TreeView");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Copy");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Paste");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "-");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Properties");
				oMenuGroup = m_oActionMenuNode.AddMenuGroup("Arranging");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Expand");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Collapse");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Top");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Bottom");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Up");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Down");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Left");
				m_oActionMenuNode.AddMenuItem(oMenuGroup, "Move Right");
				oMenuGroup = m_oActionMenuNode.AddMenuGroup("Color Schemes");
開發者ID:ChrisMoreton,項目名稱:Test3,代碼行數:67,代碼來源:TreeViewDesigner.cs


注:本文中的System.Windows.Forms.TreeView.Invalidate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。