本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.ContainsKey方法的具体用法?C# TreeNodeCollection.ContainsKey怎么用?C# TreeNodeCollection.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.ContainsKey方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckNodeIfPathExists
static void CheckNodeIfPathExists(TreeNodeCollection nodes, string path)
{
var parts = path.Split(new[]{'\\'}, 2);
var key = parts[0];
if (!nodes.ContainsKey(key)) return;
if (parts.Length == 1)
nodes[key].Checked = true;
else
{
nodes[key].Expand();
CheckNodeIfPathExists(nodes[key].Nodes, parts[1]);
}
}
示例2: populateTreeControl
private void populateTreeControl(XmlNode document, TreeNodeCollection nodes)
{
// Dictionary<string, TreeNode> aNodeNames = new Dictionary<string, TreeNode>();
foreach (System.Xml.XmlNode node in document.ChildNodes)
{
string text = node.Name;
if (text == cstrExtraWhitespace)
continue;
text = String.Format(cstrElementFormat, text);
if (node.Value != null)
text += String.Format(" = [{0}]", node.Value);
TreeNode thisBranch = null;
string strPrefix = String.IsNullOrEmpty(node.Prefix) ? cstrDefaultNameSpaceAbrev : node.Prefix;
if (!nodes.ContainsKey(node.Name))
{
thisBranch = nodes.Add(node.Name, text); // do it once
thisBranch.Tag = strPrefix;
if (!m_mapPrefix2NamespaceURI.ContainsKey(strPrefix) && !String.IsNullOrEmpty(node.NamespaceURI))
m_mapPrefix2NamespaceURI.Add(strPrefix, node.NamespaceURI);
}
else
{
thisBranch = nodes[node.Name];
System.Diagnostics.Debug.Assert(strPrefix == (string)thisBranch.Tag);
}
// if there are any attributes for this branch/node, then put them in as children
if ((node.Attributes != null) && (node.Attributes.Count > 0))
{
foreach (XmlAttribute attr in node.Attributes)
{
TreeNodeCollection tc = thisBranch.Nodes;
if (!tc.ContainsKey(attr.Name))
{
int nNumAttrs = GetAttrCount(tc);
string strAttrKeyValue = String.Format("{0}[{1}] = [{2}] ", cstrAttributeLabel, attr.Name, attr.Value);
TreeNode newAttr = thisBranch.Nodes.Insert(nNumAttrs, attr.Name, strAttrKeyValue);
}
}
}
// iterate to the children of thisBranch
populateTreeControl(node, thisBranch.Nodes);
}
}
示例3: Checker
public bool Checker(TreeNodeCollection nodes, string key, ref string path)
{
bool result = false;
if (nodes.Count > 0)
if (!nodes.ContainsKey(key))
foreach (TreeNode node in nodes)
{
path += " " + node.Name;
bool t = Checker(node.Nodes, key, ref path);
if (t) { result = t; break; }
else path = path.Remove(path.Length - 1 - node.Name.Length);
}
else { result = true; path += " " + key; }
else result= false;
return result;
}
示例4: BuildTree
private void BuildTree(DirectoryInfo directoryInfo, TreeNodeCollection addInMe)
{
TreeNode curNode = null;
if (addInMe.ContainsKey(directoryInfo.FullName) == false)
curNode = addInMe.Add(directoryInfo.FullName, directoryInfo.Name);
else
curNode = addInMe.Find(directoryInfo.FullName, false)[0];
foreach (FileInfo file in directoryInfo.GetFiles())
{
if (curNode.Nodes.ContainsKey(file.FullName) == false)
{
curNode.Nodes.Add(file.FullName, file.Name);
}
}
foreach (DirectoryInfo subdir in directoryInfo.GetDirectories())
{
BuildTree(subdir, curNode.Nodes);
}
}
示例5: checkNodeIfPathExists
private void checkNodeIfPathExists(TreeNodeCollection nodes, string path)
{
var parts = path.Split(new char[] { '\\' }, 2);
var key = parts[0];
if (nodes.ContainsKey(key))
{
if (parts.Length == 1)
{
nodes[key].Checked = true;
}
else
{
nodes[key].Expand();
checkNodeIfPathExists(nodes[key].Nodes, parts[1]);
}
}
}
示例6: FillSubNodes
private void FillSubNodes(TreeNodeCollection nodes, PropertyInfo fileInfo)
{
// Удаляем из полного пути путь к указанной директории для перебора поддиректорий
var nameDirs = fileInfo.FullName.Remove(0, _workDirLength).TrimStart('\\', '/').Split('\\', '/');
if (string.IsNullOrEmpty(nameDirs[0]))
{
// Игнорируем дерикторию указанную для перебора поддиректорий
return;
}
foreach (var name in nameDirs)
{
// Если в коллекции узлов нет указанного узла, то добавляем
if (!nodes.ContainsKey(name))
{
var indexImg = fileInfo.IsFile ? 2 : 0;
var indexSelectImg = fileInfo.IsFile ? 3 : 1;
TreeNode node = new TreeNode(name, indexImg, indexSelectImg)
{
Name = name,
Tag = fileInfo
};
nodes.Add(node);
}
else // иначе - переходим на дочерний уровень
{
nodes = nodes[name].Nodes;
}
}
}
示例7: addCategoryToTreeNodeCollection
private static void addCategoryToTreeNodeCollection(String sCategoryText, String sCategoryName,
ref TreeNodeCollection tncTargetTreeNodeCollection,
Object oTreeNodeTag)
{
if (sCategoryName == "")
return;
if (false == tncTargetTreeNodeCollection.ContainsKey(sCategoryName))
{
tncTargetTreeNodeCollection.Add(O2Forms.newTreeNode(sCategoryText, sCategoryName, 1, oTreeNodeTag));
}
tncTargetTreeNodeCollection = tncTargetTreeNodeCollection[sCategoryName].Nodes;
}
示例8: GetOrCreateNode
private static TreeNode GetOrCreateNode(TreeNodeCollection parentNodes, string key) {
TreeNode node = null;
if (parentNodes.ContainsKey(key)) {
node = parentNodes[key];
} else {
node = parentNodes.Add(key, key);
}
return node;
}
示例9: GetNode
TreeNode GetNode(string key, TreeNodeCollection nodes)
{
TreeNode n = null;
if (nodes.ContainsKey(key))
n = nodes[key];
else
{
foreach (TreeNode tn in nodes)
{
n = GetNode(key, tn.Nodes);
if (n != null) break;
}
}
return n;
}
示例10: CreateNodes
private void CreateNodes(TreeNodeCollection treeNodeCollection, string[] parts, int index, ref string parent)
{
if (!treeNodeCollection.ContainsKey(parts[index]))
{
string extension = Path.GetExtension(parts[index]);
ResourceTreeNode node;
switch (extension)
{
case "":
node = new FolderTreeNode();
node.Text = Path.ChangeExtension(parts[index], null);
node.Name = parts[index];
string path = string.Empty;
for (int i = 0; i <= index; i++)
path = Path.Combine(path, parts[i]);
node.Path = Path.Combine(parent, path);
treeNodeCollection.Add(node);
break;
case Sunfish.Tag.Path.Extension:
node = new ClassTreeNode();
node.Text = Path.ChangeExtension(parts[index], null);
node.Name = parts[index];
path = string.Empty;
foreach (string s in parts)
path = Path.Combine(path, s);
node.Path = Path.Combine(parent, path);
treeNodeCollection.Add(node);
break;
}
}
if (parts.Length > index + 1)
CreateNodes(treeNodeCollection[treeNodeCollection.IndexOfKey(parts[index])].Nodes, parts, index + 1, ref parent);
}
示例11: FindNode
public TreeNode FindNode(TreeNodeCollection nodes, string key)
{
if (nodes.ContainsKey(key)) return nodes[key];
else return null;
}