本文整理汇总了C#中System.Windows.Forms.TreeNode.GetNodeCount方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.GetNodeCount方法的具体用法?C# TreeNode.GetNodeCount怎么用?C# TreeNode.GetNodeCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNode
的用法示例。
在下文中一共展示了TreeNode.GetNodeCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetInitialExpansion
private void SetInitialExpansion(TreeNode treeNode)
{
if (_view.Tree.VisibleCount >= treeNode.GetNodeCount(true))
treeNode.ExpandAll();
else
CollapseToFixtures(treeNode);
}
示例2: FindChildNode
private static string FindChildNode(TreeNode selectedNode)
{
var nodeName = selectedNode.Text;
var amountOfNode = selectedNode.GetNodeCount(false);
if (amountOfNode > 0)
return "(" + FindChildNode(selectedNode.Nodes[1]) + nodeName + FindChildNode(selectedNode.Nodes[0]) + ")";
return nodeName;
}
示例3: FindLeafNode
string FindLeafNode(TreeNode i)
{
int k;
string ist = i.Text;
k = i.GetNodeCount(false);
if (k > 0)
return "(" + FindLeafNode(i.Nodes[1]) + ist + FindLeafNode(i.Nodes[0]) + ")";
else return ist;
}
示例4: AddTreeNodeChildren
private void AddTreeNodeChildren(TreeNode treeNode)
{
if (treeNode.GetNodeCount(false) == 0)
{
TSqlFragment parentFragment = (TSqlFragment)treeNode.Tag;
List<TSqlFragment> children = ScriptParser.GetFragmentChildren(parentFragment);
foreach (TSqlFragment f in children)
{
treeNode.Nodes.Add(CreateNewTreeNodeForFragment(f));
}
}
}
示例5: CalLeafNode
double CalLeafNode(TreeNode i)
{
int k;
string ist = i.Text;
k = i.GetNodeCount(false);
if (k > 0 && equation.Contains(ist))
switch (Convert.ToChar(ist))
{
case '+': return CalLeafNode(i.Nodes[1]) + CalLeafNode(i.Nodes[0]);
case '-': return CalLeafNode(i.Nodes[1]) - CalLeafNode(i.Nodes[0]);
case '*': return CalLeafNode(i.Nodes[1]) * CalLeafNode(i.Nodes[0]);
case '/': return CalLeafNode(i.Nodes[1]) / CalLeafNode(i.Nodes[0]);
default: return 0;
}
else return Convert.ToDouble(ist);
}
示例6: CalculateDataInNode
private double CalculateDataInNode(TreeNode selectedNode)
{
var nodeName = selectedNode.Text;
var amountOfNode = selectedNode.GetNodeCount(false);
if (amountOfNode <= 0 ||
(Plus.Contains(nodeName) && Menus.Contains(nodeName) && Muti.Contains(nodeName) &&
Div.Contains(nodeName))) return Convert.ToDouble(nodeName);
switch (Convert.ToChar(nodeName))
{
case '+': return CalculateDataInNode(selectedNode: selectedNode.Nodes[1]) + CalculateDataInNode(selectedNode.Nodes[0]);
case '-': return CalculateDataInNode(selectedNode: selectedNode.Nodes[1]) - CalculateDataInNode(selectedNode.Nodes[0]);
case '*': return CalculateDataInNode(selectedNode: selectedNode.Nodes[1]) * CalculateDataInNode(selectedNode.Nodes[0]);
case '/': return CalculateDataInNode(selectedNode: selectedNode.Nodes[1]) / CalculateDataInNode(selectedNode.Nodes[0]);
default: return 0;
}
return Convert.ToDouble(nodeName);
}
示例7: BuildSubtree
/// <summary>
/// Create the tree nodes for the given category and add them to the given nodes collection.
/// </summary>
/// <param name="group"></param>
/// <param name="nodeCollection"></param>
/// <returns></returns>
private int BuildSubtree(MarketGroup group, TreeNodeCollection nodeCollection)
{
// Total items count in this category and its subcategories
int result = 0;
// Add all subcategories
foreach (MarketGroup childGroup in group.SubGroups)
{
TreeNode node = new TreeNode
{
Text = childGroup.Name,
Tag = childGroup
};
// Add this subcategory's items count
result += BuildSubtree(childGroup, node.Nodes);
// Only add if this subcategory has children
if (node.GetNodeCount(true) > 0)
nodeCollection.Add(node);
}
// Add all items
foreach (TreeNode node in group.Items
.Where(x => UsabilityPredicate(x)
&& m_slotPredicate(x)
&& m_metaGroupPredicate(x)
&& m_fittingPredicate(x))
.Select(childItem =>
new TreeNode
{
Text = childItem.Name,
Tag = childItem
}))
{
nodeCollection.Add(node);
result++;
}
return result;
}
示例8: spomeniciTreeView_MouseDown
private void spomeniciTreeView_MouseDown(object sender, MouseEventArgs e)
{
draggedLeaf = spomeniciTreeView.GetNodeAt(e.Location);
if (draggedLeaf != null && draggedLeaf.Tag is Spomenik)
{
spomeniciTreeView.SelectedNode = draggedLeaf;
if (tutorijalMode)
{
if (draggedLeaf.GetNodeCount(true) == 0 && !((Spomenik)draggedLeaf.Tag).SpomenikPostavljenNaMapu
&& tutorijalStep == 0 && draggedLeaf == spomeniciTreeView.Nodes[0].Nodes[0])
{
Size dragSize = SystemInformation.DragSize;
mouseDownSelectionWindow = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize);
}
}
else
{
if (draggedLeaf.GetNodeCount(true) == 0 && !((Spomenik)draggedLeaf.Tag).SpomenikPostavljenNaMapu)
{
Size dragSize = SystemInformation.DragSize;
mouseDownSelectionWindow = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize);
}
else
{
mouseDownSelectionWindow = Rectangle.Empty;
}
}
}
}
示例9: setNodeImageState
/// <summary>
/// ��������չ��
/// </summary>
/// <param name="node"></param>
private void setNodeImageState(TreeNode node)
{
//�ж��ӽڵ����Ŀ
if (node.GetNodeCount(false) > 0)
{
if (node.IsExpanded)
{
node.ImageIndex = 1;
node.SelectedImageIndex = 1;
}
else
{
node.ImageIndex = 0;
node.SelectedImageIndex = 0;
}
}
else
{
node.ImageIndex = 2;
node.SelectedImageIndex = 2;
}
}
示例10: RenameMetaFile
private void RenameMetaFile(TreeNode node)
{
if (node.Text == "<пусто>")
{
return;
}
string currentMetaFilePath = GetNodePath(node);
if (currentMetaFilePath == "/")
{
MessageBox.Show(this, "Невозможно переименовать корневой каталог!", "Невозможно переименовать", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (currentMetaFilePath.StartsWith(DehaxOS.SYSTEM_DIRECTORY_PATH))
{
MessageBox.Show(this, "Невозможно переименовать файлы системы!", "Невозможно переименовать", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
EditNameForm editNameForm = new EditNameForm();
if (editNameForm.ShowDialog(this) == DialogResult.OK)
{
try
{
if (node.GetNodeCount(true) > 0)
{
_dehaxOS.RenameDirectory(currentMetaFilePath, editNameForm.NewName);
node.Text = editNameForm.NewName;
}
else
{
_dehaxOS.RenameFile(currentMetaFilePath, editNameForm.NewName);
node.Text = editNameForm.NewName;
}
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
示例11: BuildSubtree
/// <summary>
/// Create the tree nodes for the given category and add them to the given nodes collection
/// </summary>
/// <param name="cat"></param>
/// <param name="nodeCollection"></param>
/// <returns></returns>
private int BuildSubtree(BlueprintMarketGroup group, TreeNodeCollection nodeCollection)
{
// Total blueprints count in this category and its subcategories
int result = 0;
// Add all subcategories
foreach (BlueprintMarketGroup childGroup in group.SubGroups)
{
TreeNode node = new TreeNode()
{
Text = childGroup.Name
};
// Add this subcategory's blueprints count
result += BuildSubtree(childGroup, node.Nodes);
// Only add if this subcategory has children
if (node.GetNodeCount(true) > 0)
nodeCollection.Add(node);
}
// Add all blueprints
foreach (Blueprint childItem in group.Blueprints.Where(x => m_usabilityPredicate(x) && m_metaGroupPredicate(x)))
{
TreeNode node = new TreeNode()
{
Text = childItem.Name,
Tag = childItem
};
nodeCollection.Add(node);
result++;
}
return result;
}
示例12: FetchXML
/// <summary>
/// Retrieve the manifestdata.xml file and determine if any updates are available.
/// </summary>
private void FetchXML()
{
treeUpdate.Nodes.Clear();
XmlDocument objXmlDocument = new XmlDocument();
XmlDocument objXmlFileDocument = new XmlDocument();
XmlNode objXmlFileNode;
string strLastType = "";
XmlDocument objXmlLanguageDocument = new XmlDocument();
// Download the manifestdata.xml file which describes all of the files available for download and extract its nodes.
// Timeout set to 30 seconds.
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.chummergen.com/dev/chummer/manifestdata.xml");
//HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://localhost/manifestdata.xml");
objRequest.Timeout = 30000;
HttpWebResponse objResponse;
StreamReader objReader;
// Exceptions happen when the request times out or the file is not found. In either case, display a message saying the update
// information is temporarily unavailable.
try
{
objResponse = (HttpWebResponse)objRequest.GetResponse();
objReader = new StreamReader(objResponse.GetResponseStream());
}
catch
{
// Don't show the error message if we're running in silent mode.
if (!_blnSilentMode)
MessageBox.Show(LanguageManager.Instance.GetString("Message_Update_CannotConnect"), LanguageManager.Instance.GetString("Title_Update"), MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
return;
}
// Load the downloaded manifestdata.xml file.
objXmlDocument.Load(objReader);
// Download the manifestlang.xml file which describes the language content available for download.
objRequest = (HttpWebRequest)WebRequest.Create("http://www.chummergen.com/dev/chummer/manifestlang.xml");
// objRequest = (HttpWebRequest)WebRequest.Create("http://localhost/manifestlang.xml");
try
{
objResponse = (HttpWebResponse)objRequest.GetResponse();
objReader = new StreamReader(objResponse.GetResponseStream());
}
catch
{
// Don't show the error message if we're running in silent mode.
if (!_blnSilentMode)
MessageBox.Show(LanguageManager.Instance.GetString("Message_Update_CannotConnect"), LanguageManager.Instance.GetString("Title_Update"), MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
return;
}
// Merge the manifests together into a single usable XmlDocument.
objXmlLanguageDocument.Load(objReader);
XmlNodeList objXmlList = objXmlLanguageDocument.SelectNodes("/manifest/*");
foreach (XmlNode objNode in objXmlList)
{
XmlNode objImported = objXmlDocument.ImportNode(objNode, true);
objXmlDocument.DocumentElement.AppendChild(objImported);
}
XmlNodeList objXmlNodeList = objXmlDocument.SelectNodes("/manifest/file");
TreeNode nodRoot = new TreeNode();
foreach (XmlNode objXmlNode in objXmlNodeList)
{
// A new type has been found, so attach the current root node to the tree and start a new one.
if (objXmlNode["type"].InnerText != strLastType)
{
if (strLastType != "")
{
nodRoot.ExpandAll();
if (nodRoot.GetNodeCount(false) > 0)
treeUpdate.Nodes.Add(nodRoot);
nodRoot = new TreeNode();
}
nodRoot.Text = objXmlNode["type"].InnerText;
strLastType = objXmlNode["type"].InnerText;
}
// If we're on the EXE file, check the version numbers.
bool blnCreateNode = true;
if (objXmlNode["name"].InnerText.Contains(".exe"))
{
if (Convert.ToInt32(objXmlNode["version"].InnerText.Replace(".", string.Empty)) > Convert.ToInt32(Application.ProductVersion.Replace(".", string.Empty)))
blnCreateNode = true;
else
blnCreateNode = false;
}
// If we're on an XML file, check for the existing file and compare version numbers.
//.........这里部分代码省略.........
示例13: OpenMetaFile
private void OpenMetaFile(TreeNode metaFileNode)
{
if (metaFileNode.Text == "<пусто>")
{
return;
}
string metaFilePath = GetNodePath(metaFileNode);
try
{
if (metaFileNode.GetNodeCount(true) > 0)
{
Directory directory = _dehaxOS.OpenDirectory(metaFilePath);
TreeNodeCollection nodes = metaFileNode.Nodes;
nodes.Clear();
for (int i = 2; i < directory.Count; i++)
{
MetaFile metaFile = directory[i];
TreeNode node = new TreeNode(metaFile.FullName);
node.Name = metaFile.FullName;
if (metaFile is Directory)
{
node.Nodes.Add("<пусто>");
}
nodes.Add(node);
}
if (nodes.Count == 0)
{
nodes.Add("<пусто>");
}
}
else
{
byte[] data = _dehaxOS.ReadFile(metaFilePath);
string content = Encoding.ASCII.GetString(data);
TextFileEditorForm editorForm = new TextFileEditorForm();
editorForm.FileContent = content;
if (editorForm.ShowDialog(this) == DialogResult.OK)
{
content = editorForm.FileContent;
data = Encoding.ASCII.GetBytes(content);
_dehaxOS.WriteFile(metaFilePath, data);
}
}
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
示例14: UpdateNode
private static void UpdateNode( TreeNode node )
{
if ( node != null )
{
if ( node.Tag is KeyData )
node.Text = ((KeyData)node.Tag).ToString();
else if ( node.Tag is HKCategory )
node.Text = Language.GetString( (int)LocString.HotKeys + (int)((HKCategory)node.Tag) );
else if ( node.Tag is HKSubCat )
node.Text = Language.GetString( (int)LocString.HKSubOffset + (int)((HKSubCat)node.Tag) );
else if ( node.Tag is Int32 )
node.Text = Language.GetString( (int)node.Tag );
if ( node != m_Root && node.NextNode != null )
UpdateNode( node.NextNode );
if ( node.GetNodeCount(true) > 0 )
UpdateNode( node.FirstNode );
}
}
示例15: PlanToMasteryLevel
/// <summary>
/// Plans to mastery level.
/// </summary>
/// <param name="node">The node.</param>
private void PlanToMasteryLevel(TreeNode node)
{
cmiLvPlanTo.Visible = tsSeparatorPlanTo.Visible = Plan != null;
if (Plan == null)
return;
ShipSelectControl shipSelectorControl = this as ShipSelectControl;
cmiLvPlanTo.Visible = shipSelectorControl != null;
tsSeparatorPlanTo.Visible = shipSelectorControl != null && lbSearchList.Items.Count == 0;
if (shipSelectorControl == null || ((node != null) && node.GetNodeCount(true) > 0) || SelectedObject == null)
{
cmiLvPlanTo.Visible = false;
tsSeparatorPlanTo.Visible = false;
return;
}
MasteryShip masteryShip = ((Character)Plan.Character).MasteryShips.GetMasteryShipByID(SelectedObject.ID);
if (masteryShip == null)
{
cmiLvPlanTo.Enabled = false;
cmiLvPlanTo.Text = @"Plan Mastery to...";
return;
}
cmiLvPlanTo.Enabled = !Plan.WillGrantEligibilityFor(masteryShip.GetLevel(5));
cmiLvPlanTo.Text = $"Plan \"{masteryShip.Ship.Name}\" Mastery to...";
// "Plan to N" menus
for (int i = 1; i <= 5; i++)
{
SetAdditionMenuStatus(cmiLvPlanTo.DropDownItems[i - 1], masteryShip.GetLevel(i));
}
}