Here are the examples of the csharp api System.Windows.Forms.TreeNodeCollection.Add(System.Windows.Forms.TreeNode) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
630 Examples
19
Source : ModelView.cs
with GNU General Public License v3.0
from ahmed605
with GNU General Public License v3.0
from ahmed605
private void AddModelGroup(List<ModelNode> group, TreeNode node)
{
int index = 1;
foreach (var child in group)
{
TreeNode newNode = node.Nodes.Add(child.Name + " " + index);
newNode.Tag = child;
if (child.Children.Count > 0)
{
AddModelGroup(child.Children, newNode);
}
index++;
}
}
19
Source : MainForm.cs
with GNU General Public License v3.0
from ahmed605
with GNU General Public License v3.0
from ahmed605
private void CreateDirectoryNode(TreeNode node, Directory dir)
{
node.Tag = dir;
foreach (var item in dir)
{
if (item.IsDirectory)
{
Directory subdir = item as Directory;
TreeNode subnode = node.Nodes.Add(subdir.Name);
CreateDirectoryNode(subnode, subdir);
}
}
}
19
Source : TreeNodeCollection.cs
with Mozilla Public License 2.0
from ahyahy
with Mozilla Public License 2.0
from ahyahy
public new osf.TreeNode Add(object p1)
{
if (p1 is TreeNode)
{
M_TreeNodeCollection.Add((System.Windows.Forms.TreeNode)((TreeNode)p1).M_TreeNode);
System.Windows.Forms.Application.DoEvents();
return (TreeNode)p1;
}
TreeNode TreeNode1 = new TreeNode();
TreeNode1.Text = Convert.ToString(p1);
M_TreeNodeCollection.Add((System.Windows.Forms.TreeNode)((TreeNode)TreeNode1).M_TreeNode);
System.Windows.Forms.Application.DoEvents();
return TreeNode1;
}
19
Source : AccountInfo.cs
with GNU Affero General Public License v3.0
from alexander-pick
with GNU Affero General Public License v3.0
from alexander-pick
private void addNode(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList nodeList;
int i;
// Loop through the XML nodes until the leaf is reached.
// Add the nodes to the TreeView during the looping process.
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for (i = 0; i <= nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
inTreeNode.Nodes.Add(new TreeNode(xNode.Name));
tNode = inTreeNode.Nodes[i];
addNode(xNode, tNode);
}
}
else
{
// Here you need to pull the data from the XmlNode based on the
// type of node, whether attribute values are required, and so forth.
inTreeNode.Text = inXmlNode.OuterXml.Trim();
}
}
19
Source : ModelView.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
private void AddProject(Project project)
{
ModelNode projectNode = new ProjectNode(project);
Nodes.Add(projectNode);
projectNode.AfterInitialized();
SelectedNode = projectNode;
projectNode.Expand();
lblAddProject.Visible = false;
if (project.ItemCount == 1)
{
foreach (IProjecreplacedem item in project.Items)
{
IDoreplacedent doreplacedent = item as IDoreplacedent;
if (doreplacedent != null)
OnDoreplacedentOpening(new DoreplacedentEventArgs(doreplacedent));
}
}
if (project.IsUnreplacedled)
{
projectNode.EditLabel();
}
}
19
Source : TreeDialog.cs
with GNU General Public License v3.0
from alexgracianoarj
with GNU General Public License v3.0
from alexgracianoarj
protected TreeNode CreateOperationNode(TreeNode parentNode, Operation operation)
{
if (parentNode == null)
throw new ArgumentNullException("parentNode");
if (operation == null)
throw new ArgumentNullException("operation");
TreeNode child = parentNode.Nodes.Add(operation.GetUmlDescription());
int imageIndex = Icons.GetImageIndex(operation);
child.Tag = operation;
child.ImageIndex = imageIndex;
child.SelectedImageIndex = imageIndex;
child.ToolTipText = operation.ToString();
return child;
}
19
Source : DockerImages.cs
with Apache License 2.0
from aloneguid
with Apache License 2.0
from aloneguid
private void AddImages(IReadOnlyCollection<DockerImage> images, TreeNodeCollection nodes)
{
nodes.Clear();
foreach (DockerImage image in images)
{
var node = new TreeNode(image.Name)
{
Tag = image
};
nodes.Add(node);
if (image.Children?.Count > 0)
{
AddImages(image.Children, node.Nodes);
}
node.Expand();
}
}
19
Source : RepositoryTreeNode.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
internal void Preload(SvnNodeKind kind)
{
if (kind == SvnNodeKind.Directory)
{
if (Nodes.Count == 0 && _dummy == null)
{
_dummy = new RepositoryTreeNode(RawUri, true);
_dummy.Name = _dummy.Text = "<dummy>";
Nodes.Add(_dummy);
}
}
else
_loaded = true;
}
19
Source : RepositoryTreeView.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
private void SortedAddNode(TreeNodeCollection nodeCollection, RepositoryTreeNode newNode)
{
int n = 0;
foreach (RepositoryTreeNode tn in nodeCollection)
{
if (StringComparer.OrdinalIgnoreCase.Compare(tn.Text, newNode.Text) >= 0)
{
nodeCollection.Insert(n, newNode);
return;
}
n++;
}
nodeCollection.Add(newNode);
}
19
Source : FileSystemTreeView.cs
with Apache License 2.0
from AmpScm
with Apache License 2.0
from AmpScm
private TreeNode AddNode(TreeNodeCollection nodes, WCTreeNode child)
{
FileSystemTreeNode normalTreeNode = new FileSystemTreeNode(child);
normalTreeNode.Tag = child;
normalTreeNode.SelectedImageIndex = normalTreeNode.ImageIndex = child.ImageIndex;
nodes.Add(normalTreeNode);
normalTreeNode.Refresh();
FileSystemTreeNode d = new FileSystemTreeNode("DUMMY");
normalTreeNode.Nodes.Add(d);
d.Tag = DummyTag;
return normalTreeNode;
}
19
Source : CSharpClassesTab.cs
with MIT License
from AndresTraks
with MIT License
from AndresTraks
private void AddModelNode(ModelNodeDefinition modelNode, TreeNode parentTreeNode)
{
if (parentTreeNode == null)
{
parentTreeNode = clreplacedTree.Nodes.Add("global");
parentTreeNode.Expand();
}
else
{
parentTreeNode = parentTreeNode.Nodes.Add(modelNode.Name);
}
SetNodeProperties(modelNode, parentTreeNode);
foreach (var child in modelNode.Children
.OrderBy(GetNodeTypeOrder)
.ThenBy(c => c.Name))
{
AddModelNode(child, parentTreeNode);
}
}
19
Source : CppFilesTab.cs
with MIT License
from AndresTraks
with MIT License
from AndresTraks
private void RefrereplacedemNodes(IEnumerable<SourceItemDefinition> items, TreeNodeCollection nodes)
{
var existingItems = new Dictionary<SourceItemDefinition, TreeNode>();
int nodeIndex = 0;
while (nodeIndex < nodes.Count)
{
TreeNode node = nodes[nodeIndex];
var item = items.FirstOrDefault(i => i == node.Tag);
if (item != null && (showExcludedButton.Checked || !item.IsExcluded))
{
existingItems.Add(item, node);
nodeIndex++;
}
else
{
node.Remove();
}
}
foreach (SourceItemDefinition item in items)
{
if (showExcludedButton.Checked || !item.IsExcluded)
{
TreeNode node;
if (!existingItems.TryGetValue(item, out node))
{
node = nodes.Add(item.Name);
node.Tag = item;
}
SetNodeProperties(item, node);
RefrereplacedemNodes(InputFileOrder(item.Children), node.Nodes);
}
}
}
19
Source : ThingBrowserControl.cs
with GNU General Public License v3.0
from anotak
with GNU General Public License v3.0
from anotak
public void Setup()
{
// Go for all predefined categories
typelist.Nodes.Clear();
nodes = new List<TreeNode>();
foreach(ThingCategory tc in General.Map.Data.ThingCategories)
{
// Create category
TreeNode cn = typelist.Nodes.Add(tc.Name, tc.replacedle);
if((tc.Color >= 0) && (tc.Color < thingimages.Images.Count)) cn.ImageIndex = tc.Color;
cn.SelectedImageIndex = cn.ImageIndex;
foreach(ThingTypeInfo ti in tc.Things)
{
// Create thing
TreeNode n = cn.Nodes.Add(ti.replacedle);
if((ti.Color >= 0) && (ti.Color < thingimages.Images.Count)) n.ImageIndex = ti.Color;
n.SelectedImageIndex = n.ImageIndex;
n.Tag = ti;
nodes.Add(n);
}
}
doupdatenode = true;
doupdatetextbox = true;
}
19
Source : SoundEnvironmentPanel.cs
with GNU General Public License v3.0
from anotak
with GNU General Public License v3.0
from anotak
public void AddSoundEnvironment(SoundEnvironment se)
{
TreeNode topnode = new TreeNode(se.Name);
topnode.Tag = se; //mxd
TreeNode thingsnode = new TreeNode("Things (" + se.Things.Count + ")");
TreeNode linedefsnode = new TreeNode("Linedefs (" + se.Linedefs.Count + ")");
int notdormant = 0;
int iconindex = BuilderPlug.Me.DistinctColors.IndexOf(se.Color); //mxd
int topindex = iconindex; //mxd
bool nodehaswarnings = false; //mxd
thingsnode.ImageIndex = iconindex; //mxd
thingsnode.SelectedImageIndex = iconindex; //mxd
linedefsnode.ImageIndex = iconindex; //mxd
linedefsnode.SelectedImageIndex = iconindex; //mxd
// Add things
foreach(Thing t in se.Things)
{
TreeNode thingnode = new TreeNode("Thing " + t.Index);
thingnode.Tag = t;
thingnode.ImageIndex = iconindex; //mxd
thingnode.SelectedImageIndex = iconindex; //mxd
thingsnode.Nodes.Add(thingnode);
if(!BuilderPlug.ThingDormant(t))
{
notdormant++;
}
else
{
thingnode.Text += " (dormant)";
}
}
// Set the icon to warning sign and add the tooltip when there are more than 1 non-dormant things
if(notdormant > 1)
{
thingsnode.ImageIndex = warningiconindex;
thingsnode.SelectedImageIndex = warningiconindex;
topindex = warningiconindex;
foreach(TreeNode tn in thingsnode.Nodes)
{
if(!BuilderPlug.ThingDormant((Thing)tn.Tag))
{
tn.ImageIndex = warningiconindex;
tn.SelectedImageIndex = warningiconindex;
tn.ToolTipText = "More than one thing in this\nsound environment is set to be\nactive. Set all but one thing\nto dormant.";
nodewarningscount++; //mxd
nodehaswarnings = true; //mxd
}
}
}
// Add linedefs
foreach(Linedef ld in se.Linedefs)
{
bool showwarning = false;
TreeNode linedefnode = new TreeNode("Linedef " + ld.Index);
linedefnode.Tag = ld;
linedefnode.ImageIndex = iconindex; //mxd
linedefnode.SelectedImageIndex = iconindex; //mxd
if(ld.Back == null || ld.Front == null)
{
showwarning = true;
linedefnode.ToolTipText = "This line is single-sided, but has\nthe sound boundary flag set.";
}
else if(se.Sectors.Contains(ld.Front.Sector) && se.Sectors.Contains(ld.Back.Sector))
{
showwarning = true;
linedefnode.ToolTipText = "More than one thing in this\nThe sectors on both sides of\nthe line belong to the same\nsound environment.";
}
if(showwarning)
{
linedefnode.ImageIndex = warningiconindex;
linedefnode.SelectedImageIndex = warningiconindex;
linedefsnode.ImageIndex = warningiconindex;
linedefsnode.SelectedImageIndex = warningiconindex;
topindex = warningiconindex;
nodewarningscount++; //mxd
nodehaswarnings = true; //mxd
}
linedefsnode.Nodes.Add(linedefnode);
}
//mxd
if(!showwarningsonly.Checked || nodehaswarnings)
{
topnode.Nodes.Add(thingsnode);
topnode.Nodes.Add(linedefsnode);
topnode.Tag = se;
topnode.ImageIndex = topindex;
topnode.SelectedImageIndex = topindex;
// Sound environments will no be added in consecutive order, so we'll have to find
// out where in the tree to add the node
int insertionplace = 0;
foreach(TreeNode tn in soundenvironments.Nodes)
{
if(se.ID < ((SoundEnvironment)tn.Tag).ID) break;
insertionplace++;
}
soundenvironments.Nodes.Insert(insertionplace, topnode);
}
}
19
Source : SampleWizardPage.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private void GetFiles(DirectoryInfo subDirs,
TreeNode nodeToAddTo)
{
TreeNode aNode;
ListViewItem item = null;
foreach (FileInfo file in subDirs.GetFiles())
{
if (file.Name.Contains(".cs") || file.Name.Contains(".vb"))
{
aNode = new TreeNode(AddSpacesToSentence(file.Name.Replace(".cs", "").Replace(".vb", "").Replace("-", "")), 0, 0);
aNode.Tag = file;
aNode.ImageKey = "File";
aNode.ImageIndex = (rdbCSharp.Checked ? 1 : 2);
aNode.SelectedImageIndex = (rdbCSharp.Checked ? 1 : 2);
nodeToAddTo.Nodes.Add(aNode);
}
}
nodeToAddTo.ExpandAll();
}
19
Source : SampleWizardPage.cs
with MIT License
from aspose-pdf
with MIT License
from aspose-pdf
private void GetDirectories(DirectoryInfo[] subDirs,
TreeNode nodeToAddTo)
{
TreeNode aNode;
DirectoryInfo[] subSubDirs;
foreach (DirectoryInfo subDir in subDirs)
{
if (!subDir.Name.ToLower().Equals("data") && !subDir.Name.ToLower().Equals("properties"))
{
aNode = new TreeNode(AddSpacesToSentence(subDir.Name.Replace("-", "")), 0, 0);
aNode.Tag = subDir;
aNode.ImageKey = "folder";
aNode.ImageIndex = 0;
aNode.SelectedImageIndex = 0;
subSubDirs = subDir.GetDirectories();
if (subDir.GetFiles().Count() > 0)
{
GetFiles(subDir, aNode);
}
if (subSubDirs.Length != 0)
{
GetDirectories(subSubDirs, aNode);
}
aNode.ExpandAll();
nodeToAddTo.Nodes.Add(aNode);
}
}
nodeToAddTo.ExpandAll();
}
19
Source : Form1.cs
with MIT License
from Autodesk-Forge
with MIT License
from Autodesk-Forge
private async Task ShowBucketObjects(TreeNode nodeBucket)
{
nodeBucket.Nodes.Clear();
ObjectsApi objects = new ObjectsApi();
objects.Configuration.AccessToken = AccessToken;
// show objects on the given TreeNode
BucketObjects objectsList = (await objects.GetObjectsAsync((string)nodeBucket.Tag)).ToObject<BucketObjects>();
foreach (var objInfo in objectsList.Items)
{
TreeNode nodeObject = new TreeNode(objInfo.ObjectKey);
nodeObject.Tag = ((string)objInfo.ObjectId).Base64Encode();
nodeBucket.Nodes.Add(nodeObject);
}
}
19
Source : ApplicationManager.cs
with MIT License
from BizTalkCommunity
with MIT License
from BizTalkCommunity
private void AddBlankApp()
{
string appName = copyAppName(_newapplication);
TreeNode node = new TreeNode(appName);
TreeNode rootNode = tvApps.TopNode;
rootNode.Nodes.Add(node);
tvApps.SelectedNode = node;
tvApps.LabelEdit = true;
tvApps.SelectedNode.BeginEdit();
SSOConfigManager.CreateConfigStoreApplication(appName, "", ContactInfo,
AuserAcct, AdminAcct, new SSOPropBag(), new ArrayList());
InicSearchGrid();
}
19
Source : Utils.cs
with MIT License
from BizTalkCommunity
with MIT License
from BizTalkCommunity
public static void Search(TreeView tvApps, string searchText, DataGridView dgvSearch)
{
tvApps.Nodes.Clear();
TreeNode rootNode = new TreeNode("Applications");
tvApps.Nodes.Add(rootNode);
foreach (var application in SSOConfigManager.GetApplications())
{
string appUserAcct, appAdminAcct, description, contactInfo;
HybridDictionary props = SSOConfigManager.GetConfigProperties(application, out description, out contactInfo,
out appUserAcct, out appAdminAcct);
// search string in all keys and values
if (!string.IsNullOrWhiteSpace(searchText) &&
//!application.Equals(searchText, StringComparison.InvariantCultureIgnoreCase) &&
!ContainsIgnoreCase(application,searchText, StringComparison.OrdinalIgnoreCase) &&
!SSOConfigManager.SearchKeys(props, searchText) &&
!SSOConfigManager.SearchValues(props, searchText)) continue;
var node = new TreeNode(application) { ToolTipText = description };
// add node if found
rootNode.Nodes.Add(node);
}
TreeNodeCollection nodes = rootNode.Nodes;
if (nodes.Count > 0)
{
// Select the root node
tvApps.SelectedNode = nodes[0];
tvApps.SelectedNode.Expand();
LoadGrid(nodes[0].Text, dgvSearch);
tvApps.Focus();
}
}
19
Source : EntityTreeNode.cs
with MIT License
from circles-arrows
with MIT License
from circles-arrows
internal void LoadInheritance()
{
if (loadedInheritance)
return;
if (Enreplacedy.Inherits == null)
return;
var enreplacedyLookup = Model.Enreplacedies.Enreplacedy.ToDictionary(x => Guid.Parse(x.Guid));
if (Enreplacedy.Inherits != null)
{
enreplacedyLookup.TryGetValue(Guid.Parse(Enreplacedy.Inherits), out Enreplacedy parent);
while (parent != null)
{
InheritNode.Nodes.Add(new InheritedEnreplacedyTreeNode(Model, parent));
if (parent.Inherits == null)
break;
enreplacedyLookup.TryGetValue(Guid.Parse(parent.Inherits), out parent);
}
}
if (InheritNode.Nodes.Count > 0)
Nodes.Add(InheritNode);
InheritNode.Expand();
InheritNode.Checked = true;
loadedInheritance = true;
}
19
Source : EntityTreeNode.cs
with MIT License
from circles-arrows
with MIT License
from circles-arrows
internal void LoadRelationship()
{
if (loaded)
return;
foreach (Relationship rel in Relationship)
RelationshipNode.Nodes.Add(new RelationshipTreeNode(Model, rel));
if (RelationshipNode.Nodes.Count > 0)
Nodes.Add(RelationshipNode);
RelationshipNode.Expand();
RelationshipNode.Checked = true;
loaded = true;
}
19
Source : FoldersManagerForm.cs
with GNU General Public License v3.0
from ClusterM
with GNU General Public License v3.0
from ClusterM
void AddNodes(TreeNodeCollection treeNodeCollection, NesMenuCollection nesMenuCollection, List<NesMenuCollection> usedFolders = null)
{
if (usedFolders == null)
usedFolders = new List<NesMenuCollection>();
if (usedFolders.Contains(nesMenuCollection))
return;
usedFolders.Add(nesMenuCollection);
var sorted = nesMenuCollection.OrderBy(o => o.Name).OrderBy(o => (o is NesMenuFolder) ? (byte)(o as NesMenuFolder).Position : 2);
foreach (var nesElement in sorted)
{
var newNode = new TreeNode();
if (nesElement is NesMenuFolder)
{
if (usedFolders.Contains((nesElement as NesMenuFolder).ChildMenuCollection))
{
nesMenuCollection.Remove(nesElement); // We don't need any "back" folders
continue;
}
}
newNode.SelectedImageIndex = newNode.ImageIndex = getImageIndex(nesElement as INesMenuElement);
newNode.Text = nesElement.Name;
newNode.Tag = nesElement;
treeNodeCollection.Add(newNode);
if (nesElement is NesMenuFolder)
{
AddNodes(newNode.Nodes, (nesElement as NesMenuFolder).ChildMenuCollection, usedFolders);
}
}
}
19
Source : FoldersManagerForm.cs
with GNU General Public License v3.0
from ClusterM
with GNU General Public License v3.0
from ClusterM
private void KostilKostilevich(object o)
{
// This is stupid workaround for resort after renaming item, lol
if (InvokeRequired)
{
Invoke(new Action<object>(KostilKostilevich), new object[] { o });
return;
}
if (o is TreeNode)
{
var node = o as TreeNode;
var parent = node.Parent;
parent.Nodes.Remove(node);
parent.Nodes.Add(node);
treeView.SelectedNode = node;
ShowFolderStats();
}
if (o is ListViewItem)
{
var item = o as ListViewItem;
listViewContent.Items.Remove(item);
listViewContent.Items.Add(item);
var node = item.Tag as TreeNode;
var parent = node.Parent;
parent.Nodes.Remove(node);
parent.Nodes.Add(node);
}
}
19
Source : FoldersManagerForm.cs
with GNU General Public License v3.0
from ClusterM
with GNU General Public License v3.0
from ClusterM
bool MoveToFolder(IEnumerable<TreeNode> newNodes, TreeNode destinationNode, bool showDest = true)
{
if (destinationNode == null)
destinationNode = treeView.Nodes[0]; // Root
if (destinationNode.Tag is NesMiniApplication || destinationNode.Tag is NesDefaultGame)
destinationNode = destinationNode.Parent;
foreach (var newNode in newNodes)
{
if (!destinationNode.FullPath.StartsWith(newNode.FullPath + '\\') && (destinationNode != newNode.Parent))
{
Debug.WriteLine(string.Format("Drag: {0}->{1}", newNode, destinationNode));
if (newNode.Parent.Tag is NesMenuFolder)
(newNode.Parent.Tag as NesMenuFolder).ChildMenuCollection.Remove(newNode.Tag as INesMenuElement);
else if (newNode.Parent.Tag is NesMenuCollection)
(newNode.Parent.Tag as NesMenuCollection).Remove(newNode.Tag as INesMenuElement);
newNode.Parent.Nodes.Remove(newNode);
destinationNode.Nodes.Add(newNode);
if (destinationNode.Tag is NesMenuFolder)
(destinationNode.Tag as NesMenuFolder).ChildMenuCollection.Add(newNode.Tag as INesMenuElement);
else if (destinationNode.Tag is NesMenuCollection)
(destinationNode.Tag as NesMenuCollection).Add(newNode.Tag as INesMenuElement);
}
else
{
System.Media.SystemSounds.Hand.Play();
return false;
}
}
if (showDest)
treeView.SelectedNode = destinationNode;
if (treeView.SelectedNode == destinationNode)
ShowSelected();
else
foreach (var i in (from n in listViewContent.Items.Cast<ListViewItem>().ToArray() where newNodes.Contains(n.Tag as TreeNode) select n))
listViewContent.Items.Remove(i);
foreach (ListViewItem item in listViewContent.Items)
item.Selected = newNodes.Contains(item.Tag as TreeNode) || item.Tag == destinationNode;
ShowFolderStats();
return true;
}
19
Source : FoldersManagerForm.cs
with GNU General Public License v3.0
from ClusterM
with GNU General Public License v3.0
from ClusterM
void newFolder(TreeNode parent = null)
{
var newFolder = new NesMenuFolder(Resources.FolderNameNewFolder);
var folderImageIndex = getImageIndex(newFolder);
var newnode = new TreeNode(Resources.FolderNameNewFolder, folderImageIndex, folderImageIndex);
newnode.Tag = newFolder;
if (parent != null)
{
parent.Nodes.Add(newnode);
treeView.SelectedNode = newnode;
ShowSelected();
newnode.BeginEdit();
}
else if (treeView.SelectedNode != null)
{
parent = treeView.SelectedNode;
parent.Nodes.Add(newnode);
ShowFolderStats();
var item = new ListViewItem(newnode.Text, folderImageIndex);
item.Tag = newnode;
listViewContent.SelectedItems.Clear();
listViewContent.Items.Add(item);
item.BeginEdit();
}
if (parent != null)
{
if (parent.Tag is NesMenuFolder)
(parent.Tag as NesMenuFolder).ChildMenuCollection.Add(newFolder);
else if (parent.Tag is NesMenuCollection)
(parent.Tag as NesMenuCollection).Add(newFolder);
}
}
19
Source : Test.cs
with MIT License
from codewitch-honey-crisis
with MIT License
from codewitch-honey-crisis
void _AddNodes(TreeNode node,ParseNode pt)
{
var treeNode = new TreeNode();
if (null != pt.Value)
{
treeNode.Text = string.Concat(pt.Symbol, ": ", pt.Value);
treeNode.ImageIndex = ("#ERROR"==pt.Symbol)?2:1;
treeNode.SelectedImageIndex = treeNode.ImageIndex;
treeNode.Tag = pt;
node.Nodes.Add(treeNode);
treeNode.Expand();
}
else
{
treeNode.Text = pt.Symbol;
treeNode.Tag = pt;
foreach (var ptc in pt.Children) {
_AddNodes(treeNode, ptc);
}
node.Nodes.Add(treeNode);
treeNode.Expand();
}
}
19
Source : DbTreeView.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
public void BuildSchemaTree(ICatalog catalog, bool showColumns)
{
_showColumns = showColumns;
TreeViewSchema.Nodes.Clear();
treeViewSchema.ImageList = schemaImages;
if (showColumns)
{
TreeNode emptyNode = new TreeNode("None");
emptyNode.ImageIndex = (int)TreeViewIcons.field;
emptyNode.SelectedImageIndex = (int)TreeViewIcons.field;
TreeViewSchema.Nodes.Add(emptyNode);
}
TreeNode tableBaseNode = null;
#region Add Tables
TreeNode[] tableNodes = new TreeNode[catalog.Tables.Count];
TreeNode node;
for (int i = 0; i < catalog.Tables.Count; i++)
{
node = new TreeNode();
tableNodes[i] = node;
LoadTableNode(node, catalog.Tables[i]);
}
if (catalog.Tables.Count > 0)
{
Array.Sort(tableNodes, new TreeNodeComparer());
tableBaseNode = new TreeNode("Tables", tableNodes);
}
else
{
tableBaseNode = new TreeNode("Tables");
}
tableBaseNode.ImageIndex = (int)TreeViewIcons.db;
tableBaseNode.SelectedImageIndex = (int)TreeViewIcons.db;
TreeViewSchema.Nodes.Add(tableBaseNode);
#endregion
#region Add Views
TreeNode viewBaseNode;
TreeNode[] viewNodes = new TreeNode[catalog.Views.Count];
for (int i = 0; i < catalog.Views.Count; i++)
{
node = new TreeNode();
viewNodes[i] = node;
LoadViewNode(node, catalog.Views[i]);
}
if (catalog.Views.Count > 0)
{
Array.Sort(viewNodes, new TreeNodeComparer());
viewBaseNode = new TreeNode("Views", viewNodes);
}
else
{
viewBaseNode = new TreeNode("Views");
}
viewBaseNode.ImageIndex = (int)TreeViewIcons.db;
viewBaseNode.SelectedImageIndex = (int)TreeViewIcons.db;
TreeViewSchema.Nodes.Add(viewBaseNode);
#endregion
#region Add Stored Procs
TreeNode spBaseNode;
List<TreeNode> spNodes = new List<TreeNode>();
for (int i = 0; i < catalog.Procedures.Count; i++)
{
node = new TreeNode();
LoadStoredProcedureNode(node, catalog.Procedures[i]);
spNodes.Add(node);
}
if (catalog.Procedures.Count > 0)
{
spNodes.Sort(new TreeNodeComparer());
spBaseNode = new TreeNode("Stored Procedures", spNodes.ToArray());
}
else
{
spBaseNode = new TreeNode("Stored Procedures");
}
spBaseNode.ImageIndex = (int)TreeViewIcons.db;
spBaseNode.SelectedImageIndex = (int)TreeViewIcons.db;
TreeViewSchema.Nodes.Add(spBaseNode);
#endregion
}
19
Source : DbTreeView.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
void AddColumns(TreeNode node, ColumnInfoCollection cols)
{
node.Nodes.Clear();
foreach (IColumnInfo c in cols)
{
TreeNode n = new TreeNode(c.ColumnName);
n.Tag = c;
n.SelectedImageIndex = (int)TreeViewIcons.field;
n.ImageIndex = (int)TreeViewIcons.field;
if (c.IsPrimaryKey)
{
n.SelectedImageIndex = (int)TreeViewIcons.goldkey;
n.ImageIndex = (int)TreeViewIcons.goldkey;
}
node.Nodes.Add(n);
}
}
19
Source : DbTreeView.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
void AddColumns(TreeNode node, ColumnInfoCollection cols)
{
node.Nodes.Clear();
foreach (IColumnInfo c in cols)
{
TreeNode n = new TreeNode(c.ColumnName);
n.Tag = c;
n.SelectedImageIndex = (int)TvwIcons.field;
n.ImageIndex = (int)TvwIcons.field;
if (c.IsPrimaryKey)
{
n.SelectedImageIndex = (int)TvwIcons.goldkey;
n.ImageIndex = (int)TvwIcons.goldkey;
}
node.Nodes.Add(n);
}
}
19
Source : DbTreeView.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
public void BuildSchemaTree(ICatalog catalog, bool showColumns)
{
_showColumns = showColumns;
TreeViewSchema.Nodes.Clear();
tvwSchema.ImageList = schemaImages;
if (showColumns)
{
TreeNode emptyNode = new TreeNode("None");
emptyNode.ImageIndex = (int)TvwIcons.field;
emptyNode.SelectedImageIndex = (int)TvwIcons.field;
TreeViewSchema.Nodes.Add(emptyNode);
}
TreeNode tableBaseNode = null;
#region Add Tables
TreeNode[] tableNodes = new TreeNode[catalog.Tables.Count];
TreeNode node;
for (int i = 0; i < catalog.Tables.Count; i++)
{
node = new TreeNode();
tableNodes[i] = node;
LoadTableNode(node, catalog.Tables[i]);
}
if (catalog.Tables.Count > 0)
{
Array.Sort(tableNodes, new TreeNodeComparer());
tableBaseNode = new TreeNode("Tables", tableNodes);
}
else
{
tableBaseNode = new TreeNode("Tables");
}
tableBaseNode.ImageIndex = (int)TvwIcons.db;
tableBaseNode.SelectedImageIndex = (int)TvwIcons.db;
TreeViewSchema.Nodes.Add(tableBaseNode);
#endregion
#region Add Views
TreeNode viewBaseNode;
TreeNode[] viewNodes = new TreeNode[catalog.Views.Count];
for (int i = 0; i < catalog.Views.Count; i++)
{
node = new TreeNode();
viewNodes[i] = node;
LoadViewNode(node, catalog.Views[i]);
}
if (catalog.Views.Count > 0)
{
Array.Sort(viewNodes, new TreeNodeComparer());
viewBaseNode = new TreeNode("Views", viewNodes);
}
else
{
viewBaseNode = new TreeNode("Views");
}
viewBaseNode.ImageIndex = (int)TvwIcons.db;
viewBaseNode.SelectedImageIndex = (int)TvwIcons.db;
TreeViewSchema.Nodes.Add(viewBaseNode);
#endregion
#region Add Stored Procs
TreeNode spBaseNode;
List<TreeNode> spNodes = new List<TreeNode>();
for (int i = 0; i < catalog.Procedures.Count; i++)
{
node = new TreeNode();
LoadStoredProcedureNode(node, catalog.Procedures[i]);
spNodes.Add(node);
}
if (catalog.Procedures.Count > 0)
{
spNodes.Sort(new TreeNodeComparer());
spBaseNode = new TreeNode("Stored Procedures", spNodes.ToArray());
}
else
{
spBaseNode = new TreeNode("Stored Procedures");
}
spBaseNode.ImageIndex = (int)TvwIcons.db;
spBaseNode.SelectedImageIndex = (int)TvwIcons.db;
TreeViewSchema.Nodes.Add(spBaseNode);
#endregion
}
19
Source : DbTreeView.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
public void BuildSchemaTree(ICatalog catalog, bool showColumns)
{
_showColumns = showColumns;
TreeViewSchema.Nodes.Clear();
treeViewSchema.ImageList = schemaImages;
if (showColumns)
{
var emptyNode = new TreeNode("None");
emptyNode.ImageIndex = (int)TreeViewIcons.field;
emptyNode.SelectedImageIndex = (int)TreeViewIcons.field;
TreeViewSchema.Nodes.Add(emptyNode);
}
TreeNode tableBaseNode = null;
#region Add Tables
TreeNode[] tableNodes = new TreeNode[catalog.Tables.Count];
TreeNode node;
for (int i = 0; i < catalog.Tables.Count; i++)
{
node = new TreeNode();
tableNodes[i] = node;
LoadTableNode(node, catalog.Tables[i]);
}
if (catalog.Tables.Count > 0)
{
Array.Sort(tableNodes, new TreeNodeComparer());
tableBaseNode = new TreeNode("Tables", tableNodes);
}
else
{
tableBaseNode = new TreeNode("Tables");
}
tableBaseNode.ImageIndex = (int)TreeViewIcons.db;
tableBaseNode.SelectedImageIndex = (int)TreeViewIcons.db;
TreeViewSchema.Nodes.Add(tableBaseNode);
#endregion
#region Add Views
TreeNode viewBaseNode;
TreeNode[] viewNodes = new TreeNode[catalog.Views.Count];
for (int i = 0; i < catalog.Views.Count; i++)
{
node = new TreeNode();
viewNodes[i] = node;
LoadViewNode(node, catalog.Views[i]);
}
if (catalog.Views.Count > 0)
{
Array.Sort(viewNodes, new TreeNodeComparer());
viewBaseNode = new TreeNode("Views", viewNodes);
}
else
{
viewBaseNode = new TreeNode("Views");
}
viewBaseNode.ImageIndex = (int)TreeViewIcons.db;
viewBaseNode.SelectedImageIndex = (int)TreeViewIcons.db;
TreeViewSchema.Nodes.Add(viewBaseNode);
#endregion
#region Add Stored Procs
TreeNode spBaseNode;
List<TreeNode> spNodes = new List<TreeNode>();
for (int i = 0; i < catalog.Procedures.Count; i++)
{
node = new TreeNode();
LoadStoredProcedureNode(node, catalog.Procedures[i]);
spNodes.Add(node);
}
if (catalog.Procedures.Count > 0)
{
spNodes.Sort(new TreeNodeComparer());
spBaseNode = new TreeNode("Stored Procedures", spNodes.ToArray());
}
else
{
spBaseNode = new TreeNode("Stored Procedures");
}
spBaseNode.ImageIndex = (int)TreeViewIcons.db;
spBaseNode.SelectedImageIndex = (int)TreeViewIcons.db;
TreeViewSchema.Nodes.Add(spBaseNode);
#endregion
}
19
Source : DialogDocumentSelector.cs
with Apache License 2.0
from cyanide-studio
with Apache License 2.0
from cyanide-studio
private void populateDialogueTreeView(List<Dialogue> inCheckedDialogues)
{
var project = ResourcesHandler.Project;
if (project == null)
return;
dialogueTreeView.BeginUpdate();
foreach (Package package in project.ListPackages)
{
TreeNode nodePackage = dialogueTreeView.Nodes.Add(GetPackageKey(package.Name), package.Name);
nodePackage.Tag = package;
EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
}
foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
{
if (dialogue == null)
continue;
if (dialogue.Package == null)
continue;
TreeNode[] nodePackages = dialogueTreeView.Nodes.Find(GetPackageKey(dialogue.Package.Name), false);
if (nodePackages.Count() > 0)
{
TreeNode nodeParent = nodePackages[0];
string path = dialogue.GetFilePath();
string[] folders = path.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
string folderPath = "";
foreach (string folder in folders)
{
folderPath = Path.Combine(folderPath, folder);
TreeNode[] nodeFolders = nodeParent.Nodes.Find(folder, false);
if (nodeFolders.Count() > 0)
{
nodeParent = nodeFolders[0];
}
else
{
nodeParent = nodeParent.Nodes.Add(folder, folder);
nodeParent.Tag = new Folder() { Path = folderPath };
EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder);
}
}
TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName());
nodeDialogue.Checked = checkedDialogues.Contains(dialogue);
nodeDialogue.Tag = dialogue;
EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue);
}
}
dialogueTreeView.EndUpdate();
foreach (TreeNode node in dialogueTreeView.Nodes)
{
node.Expand();
}
}
19
Source : FormPropertiesCommon.cs
with Apache License 2.0
from cyanide-studio
with Apache License 2.0
from cyanide-studio
private void AddTreeNodeCondition(NodeCondition condition, TreeNode parent)
{
TreeNode treeNodeAttribute = parent.Nodes.Add(condition.GetTreeText());
treeNodeAttribute.ContextMenuStrip = menuAttributes;
treeNodeAttribute.Tag = condition;
if (condition is NodeConditionGroup)
{
EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.LisreplacedemConditionGroup);
foreach (NodeCondition subCondition in ((NodeConditionGroup)condition).Conditions)
{
AddTreeNodeCondition(subCondition, treeNodeAttribute);
}
}
else
{
EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.LisreplacedemCondition);
}
parent.ExpandAll();
}
19
Source : FormPropertiesCommon.cs
with Apache License 2.0
from cyanide-studio
with Apache License 2.0
from cyanide-studio
private void AddTreeNodeAction(NodeAction action)
{
TreeNode treeNodeAttribute = treeNodeRootActions.Nodes.Add(action.GetTreeText());
treeNodeAttribute.ContextMenuStrip = menuAttributes;
treeNodeAttribute.Tag = action;
EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.LisreplacedemAction);
treeNodeRootActions.ExpandAll();
}
19
Source : FormPropertiesCommon.cs
with Apache License 2.0
from cyanide-studio
with Apache License 2.0
from cyanide-studio
private void AddTreeNodeFlag(NodeFlag flag)
{
TreeNode treeNodeAttribute = treeNodeRootFlags.Nodes.Add(flag.GetTreeText());
treeNodeAttribute.ContextMenuStrip = menuAttributes;
treeNodeAttribute.Tag = flag;
EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.LisreplacedemFlag);
treeNodeRootFlags.ExpandAll();
}
19
Source : PanelProjectExplorer.cs
with Apache License 2.0
from cyanide-studio
with Apache License 2.0
from cyanide-studio
public void ResyncFile(Dialogue dialogue, bool focus)
{
if (dialogue == null)
return;
if (dialogue.Package == null)
{
EditorCore.LogError("Unable to show a Dialogue without Package in project explorer : " + dialogue.GetName());
return;
}
TreeNode[] nodePackages = tree.Nodes.Find(GetPackageKey(dialogue.Package.Name), false);
if (nodePackages.Count() > 0)
{
TreeNode nodeParent = nodePackages[0];
string path = dialogue.GetFilePath();
string[] folders = path.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
string folderPath = "";
foreach (string folder in folders)
{
folderPath = Path.Combine(folderPath, folder);
TreeNode[] nodeFolders = nodeParent.Nodes.Find(folder, false);
if (nodeFolders.Count() > 0)
{
nodeParent = nodeFolders[0];
}
else
{
nodeParent = nodeParent.Nodes.Add(folder, folder);
nodeParent.Tag = new Folder() { Path = folderPath };
nodeParent.ContextMenuStrip = menuFolder;
EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder);
}
}
TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName());
nodeDialogue.ContextMenuStrip = menuDoreplacedent;
EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue);
nodeDialogue.Tag = dialogue;
if (focus)
nodeDialogue.EnsureVisible();
}
else
{
EditorCore.LogError("Unable to show a Dialogue with unknown Package in project explorer : " + dialogue.GetName() + " in " + dialogue.Package.Name);
}
}
19
Source : SettingDialog.cs
with MIT License
from d-mod
with MIT License
from d-mod
private void AddConfig(Type type) {
if (!typeof(AbstractSettingPane).IsreplacedignableFrom(type)) {
return;
}
var control = type.CreateInstance(Connector) as AbstractSettingPane;
var parentArray = tree.Nodes.Find(control.Parent, false);
TreeNode parentNode = null;
if (parentArray.Length > 0) {
parentNode = parentArray[0];
} else {
parentNode = tree.Nodes.Add(Language[control.Parent]);
parentNode.Name = control.Parent;
}
TreeNode childrenNode = null;
if (control.Name == null) {
childrenNode = parentNode;
} else {
var name = Language[control.Name];
var childrenArray = parentNode.Nodes.Find(name, false);
if (childrenArray.Length > 0) {
childrenNode = childrenArray[0];
} else {
childrenNode = parentNode.Nodes.Add(name);
}
}
Dictionary[childrenNode] = control;
}
19
Source : TaskBrowserDialog.cs
with MIT License
from dahall
with MIT License
from dahall
private void LoadChildren(TreeNode p)
{
foreach (var item in ((TaskFolder)p.Tag).SubFolders)
{
TreeNode n = p.Nodes.Add(item.Path, item.Name, 1, 1);
n.Tag = item;
LoadChildren(n);
}
if (ShowTasks)
{
foreach (var t in ((TaskFolder)p.Tag).Tasks)
{
TreeNode tn = p.Nodes.Add(t.Path, t.Name, 2, 2);
tn.Tag = t;
}
}
}
19
Source : TSMMCMockup.cs
with MIT License
from dahall
with MIT License
from dahall
private static void LoadChildren(TreeNode p)
{
foreach (var item in ((TaskFolder)p.Tag).SubFolders)
{
var n = p.Nodes.Add(null, item.Name, 3, 3);
n.Tag = item;
LoadChildren(n);
}
}
19
Source : FormMain.cs
with Microsoft Public License
from dandrejvv
with Microsoft Public License
from dandrejvv
private void FillreplacedemblyReferences(IEnumerable<Binary> dependencies, TreeNode treeNode = null)
{
foreach (var binary in dependencies)
{
if(hideGACreplacedembliesToolStripMenuItem.Checked && binary.IsSystemBinary) continue;
string replacedemblyName = showreplacedemblyFullNameToolStripMenuItem.Checked
? binary.FullName
: binary.DisplayName;
TreeNode node = new TreeNode(replacedemblyName);
node.Tag = binary;
if (treeNode == null)
{
dependencyTreeView.Nodes.Add(node);
}
else
{
if (!FindNodeParent(treeNode, replacedemblyName))
{
treeNode.Nodes.Add(node);
}
else
{
Trace.WriteLine(String.Format("{0} is already a parent of {1}", replacedemblyName, treeNode.Name));
}
}
if (replacedemblyInformationLoader.Systemreplacedemblies.Where(p => replacedemblyName.StartsWith(p)).Count() == 0)
{
node.Nodes.Add(new TreeNode(Loading));
}
}
}
19
Source : Form1.cs
with MIT License
from dathlin
with MIT License
from dathlin
private void Form1_Load(object sender, EventArgs e)
{
// 加载配置,如果存在的话
string saveStr = Settings1.Default.Connects;
if (!string.IsNullOrEmpty(saveStr))
{
ClreplacedNetSettings[] settings = JArray.Parse(saveStr).ToObject<ClreplacedNetSettings[]>();
TreeNode root = treeView1.Nodes[0];
foreach (var m in settings)
{
string name = $"{m.IpAddress} [{m.IpPort}]";
TreeNode node = new TreeNode(name);
node.Tag = new HslCommunication.Enthernet.NetSimplifyClient(
m.IpAddress,
int.Parse(m.IpPort))
{
ConnectTimeOut = int.Parse(m.TimeOut),
Token = new Guid(m.Token),
};
node.ToolTipText = m.Guid;
root.Nodes.Add(node);
}
root.Expand();
List = new List<ClreplacedNetSettings>(settings);
}
if (List == null) List = new List<ClreplacedNetSettings>();
}
19
Source : FormConfiguration.cs
with MIT License
from dathlin
with MIT License
from dathlin
private void FormConfiguration_Load(object sender, EventArgs e)
{
Text = UserLocalization.Localization.SettingsText;
treeView1.AfterSelect += TreeView1_AfterSelect;
TreeNode treeNodeSystem = treeView1.Nodes[0];
treeNodeSystem.Text = UserLocalization.Localization.SettingsSystem;
treeNodeSystem.Nodes.Add("General", UserLocalization.Localization.SettingsGeneral);
treeNodeSystem.Nodes.Add("Factory", UserLocalization.Localization.SettingsAccountFactory);
treeNodeSystem.Nodes.Add("Client", UserLocalization.Localization.SettingsTrustClient);
treeNodeSystem.Nodes.Add("Roles", UserLocalization.Localization.SettingsRolereplacedign);
treeNodeSystem.Expand();
}
19
Source : FormNodeSetting.cs
with Apache License 2.0
from dathlin
with Apache License 2.0
from dathlin
private void modbustcpclientToolStripMenuItem_Click( object sender, EventArgs e )
{
// 新增了Modbus-Tcp客户端
TreeNode node = treeView1.SelectedNode;
if (node.Tag is NodeClreplaced nodeClreplaced)
{
if (nodeClreplaced.NodeType == NodeClreplacedInfo.NodeClreplaced)
{
// 允许添加设备
using (NodeSettings.FormModbusTcp formNode = new NodeSettings.FormModbusTcp( new NodeModbusTcpClient( ) ))
{
if (formNode.ShowDialog( ) == DialogResult.OK)
{
formNode.ModbusTcpNode.Name = GetUniqueName( node, formNode.ModbusTcpNode.Name );
TreeNode nodeNew = new TreeNode( formNode.ModbusTcpNode.Name );
nodeNew.ImageKey = "Module_648";
nodeNew.SelectedImageKey = "Module_648";
nodeNew.Tag = formNode.ModbusTcpNode;
node.Nodes.Add( nodeNew );
node.Expand( );
isNodeSettingsModify = true;
}
}
}
}
}
19
Source : FormNodeSetting.cs
with Apache License 2.0
from dathlin
with Apache License 2.0
from dathlin
private void 新增RequestToolStripMenuItem_Click( object sender, EventArgs e )
{
// 新增了Modbus-Tcp客户端
TreeNode node = treeView1.SelectedNode;
if (node.Tag is DeviceNode deviceNode)
{
// 允许添加请求
using (RequestSettings.FormRequest formNode = new RequestSettings.FormRequest( new DeviceRequest( ) ))
{
if (formNode.ShowDialog( ) == DialogResult.OK)
{
formNode.DeviceRequest.Name = GetUniqueName( node, formNode.DeviceRequest.Name );
TreeNode nodeNew = new TreeNode( formNode.DeviceRequest.Name );
nodeNew.ImageKey = "usbcontroller";
nodeNew.SelectedImageKey = "usbcontroller";
nodeNew.Tag = formNode.DeviceRequest;
node.Nodes.Add( nodeNew );
node.Expand( );
isNodeSettingsModify = true;
}
}
}
}
19
Source : FormNodeSetting.cs
with Apache License 2.0
from dathlin
with Apache License 2.0
from dathlin
private void TreeNodeRender( TreeNode treeNode, XElement element )
{
foreach (XElement item in element.Elements( ))
{
if (item.Name == "NodeClreplaced")
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "Clreplaced_489";
node.SelectedImageKey = "Clreplaced_489";
NodeClreplaced nodeClreplaced = new NodeClreplaced( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
TreeNodeRender( node, item );
}
else if (item.Name == "DeviceNode")
{
int type = int.Parse( item.Attribute( "DeviceType" ).Value );
TreeNode deviceNode = new TreeNode( item.Attribute( "Name" ).Value );
if (type == DeviceNode.ModbusTcpClient)
{
deviceNode.ImageKey = "Module_648";
deviceNode.SelectedImageKey = "Module_648";
NodeModbusTcpClient modbusNode = new NodeModbusTcpClient( );
modbusNode.LoadByXmlElement( item );
deviceNode.Tag = modbusNode;
}
else if (type == DeviceNode.ModbusTcpAlien)
{
deviceNode.ImageKey = "Module_648";
deviceNode.SelectedImageKey = "Module_648";
NodeModbusTcpAline modbusAlien = new NodeModbusTcpAline( );
modbusAlien.LoadByXmlElement( item );
deviceNode.Tag = modbusAlien;
}
else if (type == DeviceNode.MelsecMcQna3E)
{
deviceNode.ImageKey = "Enum_582";
deviceNode.SelectedImageKey = "Enum_582";
NodeMelsecMc node = new NodeMelsecMc( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.Siemens)
{
deviceNode.ImageKey = "Event_594";
deviceNode.SelectedImageKey = "Event_594";
NodeSiemens node = new NodeSiemens( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.DeviceNone)
{
deviceNode.ImageKey = "Method_636";
deviceNode.SelectedImageKey = "Method_636";
NodeEmpty node = new NodeEmpty( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.Omron)
{
deviceNode.ImageKey = "HotSpot_10548_color";
deviceNode.SelectedImageKey = "HotSpot_10548_color";
NodeOmron node = new NodeOmron( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.SimplifyNet)
{
deviceNode.ImageKey = "FlagRed_16x";
deviceNode.SelectedImageKey = "FlagRed_16x";
NodeSimplifyNet node = new NodeSimplifyNet( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
treeNode.Nodes.Add( deviceNode );
foreach (XElement request in item.Elements( "DeviceRequest" ))
{
TreeNode nodeRequest = new TreeNode( request.Attribute( "Name" ).Value );
nodeRequest.ImageKey = "usbcontroller";
nodeRequest.SelectedImageKey = "usbcontroller";
DeviceRequest deviceRequest = new DeviceRequest( );
deviceRequest.LoadByXmlElement( request );
nodeRequest.Tag = deviceRequest;
deviceNode.Nodes.Add( nodeRequest );
}
}
else if (item.Name == "AlienNode")
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "server_Local_16xLG";
node.SelectedImageKey = "server_Local_16xLG";
AlienNode nodeClreplaced = new AlienNode( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
TreeNodeRender( node, item );
}
else if(item.Name == "ModbusServer")
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "server_Local_16xLG";
node.SelectedImageKey = "server_Local_16xLG";
NodeModbusServer nodeClreplaced = new NodeModbusServer( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
TreeNodeRender( node, item );
}
}
}
19
Source : FormBrowseServer.cs
with GNU Lesser General Public License v3.0
from dathlin
with GNU Lesser General Public License v3.0
from dathlin
private async void PopulateBranch(NodeId sourceId, TreeNodeCollection nodes)
{
nodes.Clear();
nodes.Add(new TreeNode("Browsering...", 7, 7));
// fetch references from the server.
TreeNode[] listNode = await Task.Run(() =>
{
ReferenceDescriptionCollection references = GetReferenceDescriptionCollection(sourceId);
List<TreeNode> list = new List<TreeNode>();
if (references != null)
{
// process results.
for (int ii = 0; ii < references.Count; ii++)
{
ReferenceDescription target = references[ii];
TreeNode child = new TreeNode(Utils.Format("{0}", target));
child.Tag = target;
string key = GetImageKeyFromDescription(target, sourceId);
child.ImageKey = key;
child.SelectedImageKey = key;
// if (target.NodeClreplaced == NodeClreplaced.Object || target.NodeClreplaced == NodeClreplaced.Unspecified || expanded)
// {
// child.Nodes.Add(new TreeNode());
// }
if (!checkBox1.Checked)
{
if (GetReferenceDescriptionCollection( (NodeId)target.NodeId ).Count > 0)
{
child.Nodes.Add( new TreeNode( ) );
}
}
else
{
child.Nodes.Add( new TreeNode( ) );
}
list.Add(child);
}
}
return list.ToArray();
});
// update the attributes display.
// DisplayAttributes(sourceId);
nodes.Clear();
nodes.AddRange(listNode.ToArray());
}
19
Source : FormNodeView.cs
with GNU Lesser General Public License v3.0
from dathlin
with GNU Lesser General Public License v3.0
from dathlin
private void TreeNodeRender( TreeNode treeNode, XElement element )
{
foreach (XElement item in element.Elements( ))
{
if (item.Name == "NodeClreplaced")
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "Clreplaced_489";
node.SelectedImageKey = "Clreplaced_489";
NodeClreplaced nodeClreplaced = new NodeClreplaced( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
TreeNodeRender( node, item );
}
else if (item.Name == "DeviceNode")
{
int type = int.Parse( item.Attribute( "DeviceType" ).Value );
TreeNode deviceNode = new TreeNode( item.Attribute( "Name" ).Value );
if (type == DeviceNode.ModbusTcpClient)
{
deviceNode.ImageKey = "Module_648";
deviceNode.SelectedImageKey = "Module_648";
NodeModbusTcpClient modbusNode = new NodeModbusTcpClient( );
modbusNode.LoadByXmlElement( item );
deviceNode.Tag = modbusNode;
}
else if (type == DeviceNode.ModbusTcpAlien)
{
deviceNode.ImageKey = "Module_648";
deviceNode.SelectedImageKey = "Module_648";
NodeModbusTcpAline modbusAlien = new NodeModbusTcpAline( );
modbusAlien.LoadByXmlElement( item );
deviceNode.Tag = modbusAlien;
}
else if (type == DeviceNode.MelsecMcQna3E)
{
deviceNode.ImageKey = "Enum_582";
deviceNode.SelectedImageKey = "Enum_582";
NodeMelsecMc node = new NodeMelsecMc( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.Siemens)
{
deviceNode.ImageKey = "Event_594";
deviceNode.SelectedImageKey = "Event_594";
NodeSiemens node = new NodeSiemens( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.DeviceNone)
{
deviceNode.ImageKey = "Method_636";
deviceNode.SelectedImageKey = "Method_636";
NodeEmpty node = new NodeEmpty( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
else if (type == DeviceNode.Omron)
{
deviceNode.ImageKey = "HotSpot_10548_color";
deviceNode.SelectedImageKey = "HotSpot_10548_color";
NodeOmron node = new NodeOmron( );
node.LoadByXmlElement( item );
deviceNode.Tag = node;
}
treeNode.Nodes.Add( deviceNode );
foreach (XElement request in item.Elements( "DeviceRequest" ))
{
DeviceRequest deviceRequest = new DeviceRequest( );
deviceRequest.LoadByXmlElement( request );
string parseCode = deviceRequest.PraseRegularCode;
if (regularkeyValuePairs.ContainsKey( parseCode ))
{
foreach (RegularItemNode regularNodeItem in regularkeyValuePairs[parseCode])
{
TreeNode treeNodeRegular = new TreeNode( regularNodeItem.Name );
treeNodeRegular.ImageKey = "Operator_660";
treeNodeRegular.SelectedImageKey = "Operator_660";
treeNodeRegular.Tag = regularNodeItem;
deviceNode.Nodes.Add( treeNodeRegular );
}
}
}
}
else if (item.Name == "ServerNode")
{
int type = int.Parse( item.Attribute( "ServerType" ).Value );
if (type == ServerNode.ModbusServer)
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "server_Local_16xLG";
node.SelectedImageKey = "server_Local_16xLG";
NodeModbusServer nodeClreplaced = new NodeModbusServer( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
}
else if (type == ServerNode.AlienServer)
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "server_Local_16xLG";
node.SelectedImageKey = "server_Local_16xLG";
AlienServerNode nodeClreplaced = new AlienServerNode( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
TreeNodeRender( node, item );
}
}
else if (item.Name == "RegularNode")
{
TreeNode node = new TreeNode( item.Attribute( "Name" ).Value );
node.ImageKey = "usbcontroller";
node.SelectedImageKey = "usbcontroller";
RegularNode nodeClreplaced = new RegularNode( );
nodeClreplaced.LoadByXmlElement( item );
node.Tag = nodeClreplaced;
treeNode.Nodes.Add( node );
foreach (XElement regularItemXml in item.Elements( "RegularItemNode" ))
{
TreeNode treeNodeRegular = new TreeNode( regularItemXml.Attribute( "Name" ).Value );
treeNodeRegular.ImageKey = "Operator_660";
treeNodeRegular.SelectedImageKey = "Operator_660";
RegularItemNode regularItemNode = new RegularItemNode( );
regularItemNode.LoadByXmlElement( regularItemXml );
treeNodeRegular.Tag = regularItemNode;
node.Nodes.Add( treeNodeRegular );
}
}
}
}
19
Source : FormNodeSetting.cs
with Apache License 2.0
from dathlin
with Apache License 2.0
from dathlin
private void 类别clreplacedToolStripMenuItem_Click( object sender, EventArgs e )
{
// 新增了类别
TreeNode node = treeView1.SelectedNode;
if (node.Tag is NodeClreplaced nodeClreplaced)
{
if (nodeClreplaced.NodeType == NodeClreplacedInfo.NodeClreplaced)
{
// 允许添加类别
using (NodeSettings.FormNodeClreplaced formNode = new NodeSettings.FormNodeClreplaced( null ))
{
if (formNode.ShowDialog( ) == DialogResult.OK)
{
formNode.SelectedNodeClreplaced.Name = GetUniqueName( node, formNode.SelectedNodeClreplaced.Name );
TreeNode nodeNew = new TreeNode( formNode.SelectedNodeClreplaced.Name );
nodeNew.ImageKey = "Clreplaced_489";
nodeNew.SelectedImageKey = "Clreplaced_489";
nodeNew.Tag = formNode.SelectedNodeClreplaced;
node.Nodes.Add( nodeNew );
node.Expand( );
isNodeSettingsModify = true;
}
}
}
}
}
19
Source : FormNodeSetting.cs
with Apache License 2.0
from dathlin
with Apache License 2.0
from dathlin
private void 欧姆龙plcomronToolStripMenuItem_Click( object sender, EventArgs e )
{
// 新增了欧姆龙客户端的设备
TreeNode node = treeView1.SelectedNode;
if (node.Tag is NodeClreplaced nodeClreplaced)
{
if (nodeClreplaced.NodeType == NodeClreplacedInfo.NodeClreplaced)
{
// 允许添加设备
using (NodeSettings.FormOmron formNode = new NodeSettings.FormOmron( null ))
{
if (formNode.ShowDialog( ) == DialogResult.OK)
{
formNode.NodeOmron.Name = GetUniqueName( node, formNode.NodeOmron.Name );
TreeNode nodeNew = new TreeNode( formNode.NodeOmron.Name );
nodeNew.ImageKey = "HotSpot_10548_color";
nodeNew.SelectedImageKey = "HotSpot_10548_color";
nodeNew.Tag = formNode.NodeOmron;
node.Nodes.Add( nodeNew );
node.Expand( );
isNodeSettingsModify = true;
}
}
}
}
}
19
Source : FormNodeSetting.cs
with Apache License 2.0
from dathlin
with Apache License 2.0
from dathlin
private void 空设备toolStripMenuItem_Click( object sender, EventArgs e )
{
// 新增了空设备的客户端,用作纯节点使用
TreeNode node = treeView1.SelectedNode;
if (node.Tag is NodeClreplaced nodeClreplaced)
{
if (nodeClreplaced.NodeType == NodeClreplacedInfo.NodeClreplaced)
{
// 允许添加设备
using (NodeSettings.FormEmpty formNode = new NodeSettings.FormEmpty( null ))
{
if (formNode.ShowDialog( ) == DialogResult.OK)
{
formNode.NodeEmpty.Name = GetUniqueName( node, formNode.NodeEmpty.Name );
TreeNode nodeNew = new TreeNode( formNode.NodeEmpty.Name );
nodeNew.ImageKey = "Method_636";
nodeNew.SelectedImageKey = "Method_636";
nodeNew.Tag = formNode.NodeEmpty;
node.Nodes.Add( nodeNew );
node.Expand( );
isNodeSettingsModify = true;
}
}
}
}
}
See More Examples