Exemple #1
0
        /// <summary>
        /// Updates labels of the nodes that represent a communication line.
        /// </summary>
        public void UpdateCommLineNode(TreeNode commLineNode, CommEnvironment environment)
        {
            if (commLineNode == null)
            {
                throw new ArgumentNullException("commLineNode");
            }

            // update text of the line node
            Settings.CommLine commLine = (Settings.CommLine)((TreeNodeTag)commLineNode.Tag).RelatedObject;
            commLineNode.Text = string.Format(CommShellPhrases.CommLineNode, commLine.Number, commLine.Name);

            // remove the existing device nodes
            foreach (TreeNode lineSubNode in new ArrayList(commLineNode.Nodes))
            {
                if (lineSubNode.TagIs(CommNodeType.Device))
                {
                    lineSubNode.Remove();
                }
            }

            // add new device nodes
            foreach (Settings.KP kp in commLine.ReqSequence)
            {
                commLineNode.Nodes.Add(CreateDeviceNode(kp, environment));
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a node that represents the communication line.
        /// </summary>
        public TreeNode CreateCommLineNode(Settings.CommLine commLine, CommEnvironment environment)
        {
            string   commLineImageKey = commLine.Active ? "comm_line.png" : "comm_line_inactive.png";
            TreeNode commLineNode     = new TreeNode(string.Format(CommShellPhrases.CommLineNode,
                                                                   commLine.Number, commLine.Name))
            {
                ImageKey         = commLineImageKey,
                SelectedImageKey = commLineImageKey,
                Tag = new TreeNodeTag()
                {
                    RelatedObject = commLine,
                    NodeType      = CommNodeType.CommLine
                }
            };

            TreeNodeCollection lineSubNodes = commLineNode.Nodes;

            lineSubNodes.Add(new TreeNode(CommShellPhrases.LineParamsNode)
            {
                ImageKey         = "comm_params.png",
                SelectedImageKey = "comm_params.png",
                Tag = new TreeNodeTag()
                {
                    FormType      = typeof(FrmLineParams),
                    FormArgs      = new object[] { commLine, environment },
                    RelatedObject = commLine,
                    NodeType      = CommNodeType.LineParams
                }
            });

            lineSubNodes.Add(new TreeNode(CommShellPhrases.LineStatsNode)
            {
                ImageKey         = "comm_stats.png",
                SelectedImageKey = "comm_stats.png",
                Tag = new TreeNodeTag()
                {
                    FormType      = typeof(FrmLineStats),
                    FormArgs      = new object[] { commLine, environment },
                    RelatedObject = commLine,
                    NodeType      = CommNodeType.LineStats
                }
            });

            foreach (Settings.KP kp in commLine.ReqSequence)
            {
                lineSubNodes.Add(CreateDeviceNode(kp, commLine, environment));
            }

            return(commLineNode);
        }
Exemple #3
0
 /// <summary>
 /// Creates a node that represents the device.
 /// </summary>
 private TreeNode CreateDeviceNode(Settings.KP kp, CommEnvironment environment)
 {
     return(new TreeNode(string.Format(CommShellPhrases.DeviceNode, kp.Number, kp.Name))
     {
         ImageKey = "comm_device.png",
         SelectedImageKey = "comm_device.png",
         Tag = new TreeNodeTag()
         {
             FormType = typeof(FrmDeviceData),
             FormArgs = new object[] { kp, environment },
             RelatedObject = kp,
             NodeType = CommNodeType.Device
         }
     });
 }
        private readonly CommEnvironment environment; // the application environment

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public CommLineCommand(Settings.CommLine commLine, CommEnvironment environment)
        {
            this.commLine    = commLine ?? throw new ArgumentNullException("commLine");
            this.environment = environment ?? throw new ArgumentNullException("environment");
        }
Exemple #5
0
 /// <summary>
 /// Creates a node and a corresponding object that represents the communication line.
 /// </summary>
 public TreeNode CreateCommLineNode(CommEnvironment environment)
 {
     Settings.CommLine commLine = new Settings.CommLine();
     return(CreateCommLineNode(commLine, environment));
 }
Exemple #6
0
        /// <summary>
        /// Gets the tree nodes for the explorer.
        /// </summary>
        public TreeNode[] GetTreeNodes(Settings settings, CommEnvironment environment)
        {
            // check the arguments
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (environment == null)
            {
                throw new ArgumentNullException("environment");
            }

            environment.Validate();

            // create nodes
            List <TreeNode> nodes = new List <TreeNode>();

            nodes.Add(new TreeNode(CommShellPhrases.CommonParamsNode)
            {
                ImageKey         = "comm_params.png",
                SelectedImageKey = "comm_params.png",
                Tag = new TreeNodeTag()
                {
                    FormType = typeof(FrmCommonParams),
                    FormArgs = new object[] { settings.Params },
                    NodeType = CommNodeType.CommonParams
                }
            });

            nodes.Add(new TreeNode(CommShellPhrases.DriversNode)
            {
                ImageKey         = "comm_driver.png",
                SelectedImageKey = "comm_driver.png",
                Tag = new TreeNodeTag()
                {
                    FormType = typeof(FrmDrivers),
                    FormArgs = new object[] { environment },
                    NodeType = CommNodeType.Drivers
                }
            });

            TreeNode commLinesNode = new TreeNode(CommShellPhrases.CommLinesNode)
            {
                ImageKey         = "comm_lines.png",
                SelectedImageKey = "comm_lines.png",
                Tag = new TreeNodeTag()
                {
                    RelatedObject = settings,
                    NodeType      = CommNodeType.CommLines
                }
            };

            nodes.Add(commLinesNode);

            foreach (Settings.CommLine commLine in settings.CommLines)
            {
                commLinesNode.Nodes.Add(CreateCommLineNode(commLine, environment));
            }

            nodes.Add(new TreeNode(CommShellPhrases.StatsNode)
            {
                ImageKey         = "comm_stats.png",
                SelectedImageKey = "comm_stats.png",
                Tag = new TreeNodeTag()
                {
                    FormType = typeof(FrmStats),
                    FormArgs = new object[] { environment },
                    NodeType = CommNodeType.Stats
                }
            });

            return(nodes.ToArray());
        }