本文整理汇总了C#中System.Windows.Forms.TreeNode.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.GetHashCode方法的具体用法?C# TreeNode.GetHashCode怎么用?C# TreeNode.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNode
的用法示例。
在下文中一共展示了TreeNode.GetHashCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlToTreeView
/// <summary>
/// Eine vorher Exportierte Xml Datei wieder in ein TreeView importieren
/// </summary>
/// <param name="path">Der Quellpfad der Xml Datei</param>
/// <param name="treeView">Ein TreeView in dem der Inhalt der Xml Datei wieder angezeigt werden soll</param>
/// <exception cref="FileNotFoundException">gibt an das die Datei nicht gefunden werden konnte</exception>
public void XmlToTreeView(String path, TreeView treeView) {
xmlDocument = new XmlDocument();
xmlDocument.Load(path);
treeView.Nodes.Clear();
ElementList = new ArrayList();
TreeNode treeNode;
treeNode = new TreeNode("skin");
treeView.Nodes.Add(treeNode);
rootNode = treeNode.GetHashCode();
sElementList element = new sElementList(rootNode, 0, treeNode, xmlDocument.DocumentElement/*.ParentNode*/);
ElementList.Add(element);
XmlRekursivImport(treeNode.Nodes, xmlDocument.DocumentElement.ChildNodes);
}
示例2: XmlRekursivImport
private void XmlRekursivImport(TreeNodeCollection elem, XmlNodeList xmlNodeList) {
TreeNode treeNode;
foreach (XmlNode myXmlNode in xmlNodeList) {
//if (myXmlNode.Attributes != null)
{
if (myXmlNode.Name == "output" || myXmlNode.Name == "colors" || myXmlNode.Name == "fonts" || myXmlNode.Name == "windowstyle")
continue;
if(myXmlNode.Name == "#whitespace")
continue;
String name = myXmlNode.Name;
if (myXmlNode.Attributes != null && myXmlNode.Attributes["name"] != null)
name += " - " + myXmlNode.Attributes["name"].Value;
String ext = XmlElementStringLookup(myXmlNode.Name);
if (ext.Length > 0)
{
if (myXmlNode.Attributes != null && myXmlNode.Attributes[ext] != null)
name += " : " + myXmlNode.Attributes[ext].Value;
else
name += " " + myXmlNode.Value;
}
treeNode = new TreeNode(name/*Attributes["value"].Value*/);
if (myXmlNode.ChildNodes.Count > 0)
{
XmlRekursivImport(treeNode.Nodes, myXmlNode.ChildNodes);
}
elem.Add(treeNode);
sElementList element = new sElementList(treeNode.GetHashCode(), treeNode.Parent.GetHashCode(), treeNode, myXmlNode);
ElementList.Add(element);
}
}
}
示例3: IsTreeNodeDisabled
/// <summary>
/// Checks if the TreeNode supplied is disabled or not.
/// Note that passing in null as the TreeNode will result in false being returned.
/// Note that being disabled means that BackColor and ForeColor has changed to give the TreeNode the appearance of being disabled.
/// A whole TreeView can be disabled without the particular TreeNode supplied to this function returning true (as in being disabled).
/// </summary>
/// <param name="tn">TreeNode that should be checked if it is disabled or not.</param>
/// <returns>True if supplied TreeNode is disabled or false otherwise.</returns>
public bool IsTreeNodeDisabled(TreeNode tn)
{
bool bRetVal = false;
if(tn != null)
{
if(htDisabledTreeNodes != null)
{
if(htDisabledTreeNodes.Contains(tn.GetHashCode()))
{
bRetVal = true;
}
}
}
return bRetVal;
}
示例4: GetDisabledMWTreeNodeWrapper
/// <summary>
/// Get the MWTreeNodeWrapper that contains the supplied TreeNode if it exists in the Disabled MWTreeNodeWrapper Hashtable.
/// </summary>
/// <param name="tn">TreeNode for which to return an MWTreeNodeWrapper.</param>
/// <returns>The MWTreeNodeWrapper that contains the supplied TreeNode if it exists in the Disabled MWTreeNodeWrapper Hashtable or null otherwise.</returns>
public MWTreeNodeWrapper GetDisabledMWTreeNodeWrapper(TreeNode tn)
{
MWTreeNodeWrapper mwtnw = null;
if(IsTreeNodeDisabled(tn))
{
mwtnw = htDisabledTreeNodes[tn.GetHashCode()] as MWTreeNodeWrapper;
}
return mwtnw;
}
示例5: ChangeForeColor
/// <summary>
/// Change the ForeColor of a TreeNode.
/// This method handles selected as well as unselected TreeNodes.
/// </summary>
/// <param name="tn">TreeNode to change the ForeColor of.</param>
/// <param name="cForeColor">Color to change the supplied TreeNode's ForeColor to.</param>
public void ChangeForeColor(TreeNode tn, Color cForeColor)
{
if(tn != null)
{
if(this.IsTreeNodeSelected(tn))
{
MWTreeNodeWrapper mwtnw = this.SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper;
if(mwtnw != null)
{
mwtnw.ForeColor = cForeColor;
if( !this.Enabled && !this.UseExtendedDisabledColors ||
this.Enabled && (this.Focused || !this.HideSelection) ||
this.Enabled && !this.Focused && this.HideSelection)
{
mwtnw.Node.ForeColor = cForeColor;
}
}
}
else
{
if(!this.Enabled)
{
MWTreeNodeWrapper mwtnw = GetDisabledMWTreeNodeWrapper(tn);
if(mwtnw != null)
{
mwtnw.Enable();
htDisabledTreeNodes.Remove(tn.GetHashCode());
}
tn.ForeColor = cForeColor;
DisableNode(tn);
}
else
{
tn.ForeColor = cForeColor;
}
}
}
}
示例6: SelNodesRemove
/// <summary>
/// Remove a TreeNode to the SelNodes property.
/// </summary>
/// <param name="tn">TreeNode to remove from the SelNodes property.</param>
/// <param name="bTriggerEvents">True if calling this method should raise the OnBeforeSelNodesRemove and OnAfterSelNodesRemove events or false otherwise.</param>
/// <returns>True if the TreeNode is actually removed or false otherwise.</returns>
private bool SelNodesRemove(TreeNode tn, bool bTriggerEvents)
{
bool bRetVal = false;
if(this.IsTreeNodeSelected(tn))
{
MWCancelEventArgs e = new MWCancelEventArgs(this.SelNodes, tn);
if(bTriggerEvents)
{
OnBeforeSelNodesRemove(e);
}
if(!e.Cancel)
{
MWTreeNodeWrapper.Deselect(this.SelNodes[tn.GetHashCode()] as MWTreeNodeWrapper);
this.SelNodes.Remove(tn.GetHashCode());
if(bTriggerEvents)
{
OnAfterSelNodesRemove(new MWControlSuite.MWPropertyEventArgs(tn));
}
bRetVal = true;
}
}
return bRetVal;
}
示例7: EnableNode
/// <summary>
/// Enable TreeNode supplied.
/// </summary>
/// <param name="tn">TreeNode to enable.</param>
private void EnableNode(TreeNode tn)
{
MWTreeNodeWrapper mwtnw = GetDisabledMWTreeNodeWrapper(tn);
if(mwtnw != null)
{
EnableNode(mwtnw);
htDisabledTreeNodes.Remove(tn.GetHashCode());
}
}
示例8: DeleteNode
/// <summary>
/// Delete the supplied TreeNode from the SelNodes property, the CheckedNodes property and/or the SelNode property.
/// </summary>
/// <param name="tn">TreeNode to delete.</param>
private void DeleteNode(TreeNode tn)
{
foreach(TreeNode tnChild in tn.Nodes)
{
DeleteNode(tnChild);
}
if(tn != null)
{
if(IsTreeNodeSelected(tn))
{
if(this.SelNodes != null)
{
this.SelNodes.Remove(tn.GetHashCode());
}
}
if(IsTreeNodeChecked(tn))
{
if(this.CheckedNodes != null)
{
this.CheckedNodes.Remove(tn.GetHashCode());
}
}
if(this.SelNode != null && this.SelNode == tn)
{
this.SelNode = null;
}
}
}
示例9: SelectNode
/// <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>
/// <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>
public bool SelectNode(TreeNode tn, bool bChangeSelNode)
{
bool bRetVal = false;
if (tn != null)
{
switch (MultiSelect)
{
case TreeViewMultiSelect.NoMulti:
if (SelNodes.Count > 1)
{
ClearSelNodes();
}
SelectedNode = tn;
SelNodeInt = SelectedNode;
break;
case TreeViewMultiSelect.Multi:
if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
{
if (SelNodes == null)
{
SelNodes = new Hashtable();
}
SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));
HighlightNode(tn);
}
if (bChangeSelNode)
{
ChangeSelNode(tn);
}
break;
case TreeViewMultiSelect.MultiSameBranchAndLevel:
if (SelNodes != null && SelNodes.Count > 0)
{
TreeNode tnGrandParentSelNodes = null;
int iLevel = 0;
foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
{
tnGrandParentSelNodes = GetTreeNodeGrandParent(mwtnw.Node);
iLevel = GetTreeNodeLevel(mwtnw.Node);
break;
}
if (GetTreeNodeGrandParent(tn) == tnGrandParentSelNodes && GetTreeNodeLevel(tn) == iLevel)
{
if (!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
{
SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));
HighlightNode(tn);
}
}
else if (IsSelectNodeRegExSatisfied(tn.Text))
{
ClearSelNodes();
SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));
HighlightNode(tn);
}
}
else if (IsSelectNodeRegExSatisfied(tn.Text))
{
if (SelNodes == null)
{
SelNodes = new Hashtable();
}
SelNodes.Add(tn.GetHashCode(), new MWTreeNodeWrapper(tn));
HighlightNode(tn);
}
if (bChangeSelNode)
{
ChangeSelNode(tn);
}
break;
case TreeViewMultiSelect.MultiSameBranch:
if (SelNodes != null && SelNodes.Count > 0)
{
TreeNode tnGrandParentSelNodes = null;
foreach (MWTreeNodeWrapper mwtnw in SelNodes.Values)
//.........这里部分代码省略.........
示例10: IsTreeNodeSelected
/// <summary>
/// Checks if the TreeNode supplied is selected or not.
/// Note that passing in null as the TreeNode will result in false being returned.
/// </summary>
/// <param name="tn">TreeNode that should be checked if it is selected or not.</param>
/// <returns>True if supplied TreeNode is selected or false otherwise.</returns>
public bool IsTreeNodeSelected(TreeNode tn)
{
bool bRetVal = false;
if (tn != null)
{
if (MultiSelect == TreeViewMultiSelect.NoMulti)
{
if (SelectedNode == tn)
{
bRetVal = true;
}
}
else
{
if (SelNodes != null)
{
if (SelNodes.Contains(tn.GetHashCode()))
{
bRetVal = true;
}
}
}
}
return bRetVal;
}
示例11: HighlightPickedGeometryNode
/// <summary>
/// Function used to update the background color of the selected node in the treeview
/// </summary>
public bool HighlightPickedGeometryNode(TreeNode ViewNode, GeometryNode node)
{
if (ViewNode == null)
return false;
if (ViewNode.Text == "GeometryNode")
{
int key = ViewNode.GetHashCode();
List<PropertyValue> pvlist = (List<PropertyValue>)PropertyValueTable[key];
foreach (PropertyValue pv in pvlist)
{
if (pv.Property == "ID" && pv.Value == node.ID.ToString())
{
ViewNode.BackColor = System.Drawing.Color.Blue;
return true;
}
}
}
foreach (TreeNode ChildNode in ViewNode.Nodes)
{
if (HighlightPickedGeometryNode(ChildNode, node))
return true;
}
return false;
}
示例12: EvenInorderTraverseTree
/// <summary>
/// Recursive Function for drawing the SceneGraph tree structure.
/// </summary>
private Pair EvenInorderTraverseTree(TreeNode Head, int depth, int[] index, Graphics formgraphics, Pen mypen, SolidBrush myBrush, float NodeWidth, float NodeHeight, float WidthBetweenNodes, float HeightBetweenNodes, float XOffset, float YOffset, bool textEnabled)
{
int max;
// Determing the x-coordinate (index[depth]) at the current depth by examining the x-coordinate values at [depth-1] and [depth+1]
if (depth > 0)
{
max = index[depth - 1] - 1;
}
else
{
max = index[depth];
}
max = (max < index[depth]) ? index[depth] : max;
max = (max < index[depth + 1]) ? index[depth + 1] : max;
index[depth] = max + 1;
// High and low variables are used to store the extremities of the subtree starting from the current node.
int high, low;
if (Head.Nodes.Count > 0)
{
low = 10000; high = -1;
}
else
{
low = index[depth]; high = index[depth];
}
Pair[] retval = new Pair[Head.Nodes.Count];
int counter = 0;
foreach (TreeNode child in Head.Nodes)
{
retval[counter] = EvenInorderTraverseTree(child, depth + 1, index, formgraphics, mypen, myBrush, NodeWidth, NodeHeight, WidthBetweenNodes, HeightBetweenNodes, XOffset, YOffset, textEnabled);
if (retval[counter].end > high)
high = retval[counter].end;
if (retval[counter].start < low)
low = retval[counter].start;
counter++;
}
// update the index[depth] (current x-coordinate)
index[depth] = (high + low) / 2;
mypen.Color = System.Drawing.Color.Black;
for (int i = 0; i < counter; i++)
formgraphics.DrawLine(mypen, new PointF(((high + low) / 2 * WidthBetweenNodes) + XOffset + NodeWidth / 2, (depth * HeightBetweenNodes) + YOffset + NodeHeight), new PointF(((retval[i].start + retval[i].end) / 2 * WidthBetweenNodes) + XOffset + NodeWidth / 2, ((depth + 1) * HeightBetweenNodes) + YOffset));
// highlighting the node, if it is the currentselected node
if (Head == CurrentSelectedTreeNode)
{
myBrush.Color = System.Drawing.Color.Black;
formgraphics.FillRectangle(myBrush, ((high + low) / 2 * WidthBetweenNodes) + XOffset, (depth * HeightBetweenNodes) + YOffset, NodeWidth, NodeHeight);
}
// Coloring the nodes based on the node types
myBrush.Color = SGNodeDefaultColor;
for (int i = 0; i < SGNodeNames.Length; i++)
{
if (Head.Text.StartsWith(SGNodeNames[i]))
{
myBrush.Color = SGNodeColors[i];
break;
}
}
// if the node is either invisible (red) or currently selected node (blue) then use similar coloring of the geometry nodes even for the corresponding graphical display nodes
if (Head.BackColor == System.Drawing.Color.Red || Head.BackColor == System.Drawing.Color.Blue)
{
myBrush.Color = Head.BackColor;
}
formgraphics.FillEllipse(myBrush, ((high + low) / 2 * WidthBetweenNodes) + XOffset, (depth * HeightBetweenNodes) + YOffset, NodeWidth, NodeHeight);
// writing the string "NodeName(NodeID)" on the graphical display node
if (textEnabled)
{
string nodeString = "";
int key = Head.GetHashCode();
string nodeName = "", nodeID = null;
List<PropertyValue> pvlist = (List<PropertyValue>)PropertyValueTable[key];
foreach (PropertyValue pv in pvlist)
{
if (pv.Property == "Name")
{
nodeName = pv.Value;
}
if (pv.Property == "ID")
{
nodeID = pv.Value;
}
}
nodeString = nodeName;
if (nodeID != null)
nodeString += "(" + nodeID + ")";
if (nodeString != "")
{
float FontSize = 8.0f;
Font stringFont = new Font(FontFamily.GenericSansSerif, FontSize);
//.........这里部分代码省略.........
示例13: EncapsulationCwTree
public void EncapsulationCwTree()
{
foreach (KeyValuePair<string, IList<BinInformation>> pair in base.m_anaCWFile.CWFileInfo.CellBinInfoDic)
{
TreeNode child = this.m_MeasurementNode.ChildNode(pair.Key);
if (child == null)
{
child = new TreeNode(pair.Key);
this.m_MeasurementNode.AddChildNodeToParent(this.m_MeasurementNode.RootNode, child);
}
TreeNode node2 = new TreeNode(base.m_anaCWFile.CWFileInfo.FileName);
MeasurementView.IDCreator++;
node2.Tag = MeasurementView.IDCreator;
string text = base.m_anaCWFile.CWFileInfo.FileName + node2.GetHashCode();
base.m_anaCWFile.CWFileInfo.FileNameIdentifier = text;
node2.Name = text;
this.m_MeasurementNode.AddChildNodeToParent(child, node2);
CWFileInformation item = new CWFileInformation();
item.FileNameIdentifier = text;
item.FileName = base.m_anaCWFile.CWFileInfo.FileName;
item.BinInfoHeader = base.m_anaCWFile.CWFileInfo.BinInfoHeader;
item.CellBinInfoDic.Add(pair.Key, pair.Value);
item.CellInfo = base.m_anaCWFile.CWFileInfo.CellInfo;
item.AntennaPara = base.m_anaCWFile.CWFileInfo.AntennaPara;
this.m_cwFileInfoList.Add(item);
base.m_AddedTreeNodes.Add(node2);
}
}
示例14: PreserveNodeColors
/// <summary>
/// Preserves the nodes color.
/// </summary>
/// <param name="tn">Node to check.</param>
private void PreserveNodeColors(TreeNode tn)
{
if (tn == null)
return;
if (!htblSelectedNodesOrigColors.ContainsKey(tn.GetHashCode()))
{
htblSelectedNodesOrigColors.Add(tn.GetHashCode(), new Color[] { tn.BackColor, tn.ForeColor });
}
}
示例15: CatListRecurse
private void CatListRecurse(XmlTextReader aReader, Object aRootNode)
{
String inner = aReader.ReadInnerXml();
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
XmlParserContext ctxt = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
XmlTextReader reader2 = new XmlTextReader(inner, XmlNodeType.Element, ctxt);
TreeNode node;
while (reader2.Read()) {
if (reader2.NodeType == XmlNodeType.Element) {
switch (reader2.LocalName) {
case "panel":
// Tree node with children. Retrieve label and id. Label is
// used for visual presentation, id is hashed against node
// and is used as a key when looking for which panel to
// load.
String[] values = new String[2] {"", ""};
String[] names = new String[2] {"label", "id"};
for (int i = 0; i < names.Length; ++i) {
if (reader2.MoveToAttribute(names[i]) &&
reader2.ReadAttributeValue())
values[i] = reader2.Value;
reader2.MoveToElement();
}
node = new TreeNode(values[0], 0, 0);
if (aRootNode is TreeView) {
TreeView rootView = aRootNode as TreeView;
rootView.Nodes.Add(node);
}
else if (aRootNode is TreeNode) {
TreeNode rootNode = aRootNode as TreeNode;
rootNode.Nodes.Add(node);
}
mNodes.Add(node.GetHashCode(), values[1]);
CatListRecurse(reader2, node);
break;
}
}
}
}