コード例 #1
0
ファイル: ExplorerBuilder.cs プロジェクト: zhangjianqi/scada
 /// <summary>
 /// Defines context menus of the node and its child nodes.
 /// </summary>
 /// <remarks>The method works for communication line.</remarks>
 public void SetContextMenus(TreeNode parentNode)
 {
     foreach (TreeNode treeNode in TreeViewUtils.IterateNodes(parentNode))
     {
         if (treeNode.Tag is TreeNodeTag tag)
         {
             if (tag.NodeType == CommNodeType.CommLines || tag.NodeType == CommNodeType.CommLine)
             {
                 treeNode.ContextMenuStrip = contextMenus.CommLineMenu;
             }
             else if (tag.NodeType == CommNodeType.Device)
             {
                 treeNode.ContextMenuStrip = contextMenus.DeviceMenu;
             }
         }
     }
 }
コード例 #2
0
ファイル: CommShell.cs プロジェクト: zuoyangithub/scada
        /// <summary>
        /// Updates the text of the node and its subnodes.
        /// </summary>
        public void UpdateNodeText(TreeNode startNode)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }

            foreach (TreeNode treeNode in TreeViewUtils.IterateNodes(startNode))
            {
                if (treeNode.Tag is TreeNodeTag tag)
                {
                    if (tag.NodeType == CommNodeType.CommLine && tag.RelatedObject is Settings.CommLine commLine)
                    {
                        treeNode.Text = string.Format(CommShellPhrases.CommLineNode, commLine.Number, commLine.Name);
                    }
                    else if (tag.NodeType == CommNodeType.Device && tag.RelatedObject is Settings.KP kp)
                    {
                        treeNode.Text = string.Format(CommShellPhrases.DeviceNode, kp.Number, kp.Name);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Fills the instance node, creating child nodes.
        /// </summary>
        public void FillInstanceNode(TreeNode instanceNode)
        {
            LiveInstance liveInstance = (LiveInstance)((TreeNodeTag)instanceNode.Tag).RelatedObject;
            Instance     instance     = liveInstance.Instance;

            try {
                treeView.BeginUpdate();
                instanceNode.Nodes.Clear();

                // create Server nodes
                if (instance.ServerApp.Enabled)
                {
                    TreeNode serverNode = TreeViewUtils.CreateNode(AppPhrases.ServerNode, "server.png");
                    serverNode.Tag = new TreeNodeTag {
                        RelatedObject = instance.ServerApp,
                        NodeType      = AppNodeType.ServerApp
                    };
                    serverNode.Nodes.AddRange(serverShell.GetTreeNodes(
                                                  instance.ServerApp.Settings, liveInstance.ServerEnvironment));
                    instanceNode.Nodes.Add(serverNode);
                }

                // create Communicator nodes
                if (instance.CommApp.Enabled)
                {
                    TreeNode commNode = TreeViewUtils.CreateNode(AppPhrases.CommNode, "comm.png");
                    commNode.Tag = new TreeNodeTag {
                        RelatedObject = instance.CommApp,
                        NodeType      = AppNodeType.CommApp
                    };
                    commNode.Nodes.AddRange(commShell.GetTreeNodes(
                                                instance.CommApp.Settings, liveInstance.CommEnvironment));

                    foreach (TreeNode treeNode in TreeViewUtils.IterateNodes(commNode.Nodes))
                    {
                        if (treeNode.Tag is TreeNodeTag tag &&
                            (tag.NodeType == CommNodeType.CommLines || tag.NodeType == CommNodeType.CommLine))
                        {
                            treeNode.ContextMenuStrip = contextMenus.CommLineMenu;
                        }
                    }

                    instanceNode.Nodes.Add(commNode);
                }

                // create Webstation nodes
                if (instance.WebApp.Enabled)
                {
                    TreeNode webNode = TreeViewUtils.CreateNode(AppPhrases.WebNode, "chrome.png");
                    webNode.ContextMenuStrip = contextMenus.DirectoryMenu;
                    webNode.Tag = new TreeNodeTag {
                        RelatedObject = instance.WebApp,
                        NodeType      = AppNodeType.WebApp
                    };
                    instanceNode.Nodes.Add(webNode);

                    TreeNode emptyNode = TreeViewUtils.CreateNode(AppPhrases.EmptyNode, "empty.png");
                    webNode.Nodes.Add(emptyNode);
                }
            } finally {
                treeView.EndUpdate();
            }
        }