本文整理汇总了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();
}
示例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;
}
示例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];
}
示例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;
}
}
示例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");