Ejemplo n.º 1
0
        /// <summary>
        /// Updates the tree node that represents communication lines and its child nodes.
        /// </summary>
        public void UpdateLinesNode(TreeNode linesNode)
        {
            ArgumentNullException.ThrowIfNull(linesNode, nameof(linesNode));

            try
            {
                linesNode.TreeView?.BeginUpdate();

                // remove existing line nodes
                foreach (TreeNode lineNode in new ArrayList(linesNode.Nodes))
                {
                    lineNode.Remove();
                }

                // add new line nodes
                CommNodeTag nodeTag = (CommNodeTag)linesNode.Tag;
                CommApp     commApp = nodeTag.CommApp;

                foreach (LineConfig lineConfig in commApp.AppConfig.Lines)
                {
                    linesNode.Nodes.Add(CreateLineNode(commApp, lineConfig));
                }
            }
            finally
            {
                linesNode.TreeView?.EndUpdate();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the tree node that represents a communication line and its child nodes.
        /// </summary>
        public void UpdateLineNode(TreeNode lineNode)
        {
            ArgumentNullException.ThrowIfNull(lineNode, nameof(lineNode));

            try
            {
                lineNode.TreeView?.BeginUpdate();

                // update line text and image
                CommNodeTag nodeTag    = (CommNodeTag)lineNode.Tag;
                LineConfig  lineConfig = (LineConfig)nodeTag.RelatedObject;
                lineNode.Text = CommUtils.GetLineTitle(lineConfig);
                lineNode.SetImageKey(lineConfig.Active ? ImageKey.Line : ImageKey.LineInactive);

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

                // add new device nodes
                foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling)
                {
                    lineNode.Nodes.Add(CreateDeviceNode(nodeTag.CommApp, deviceConfig));
                }
            }
            finally
            {
                lineNode.TreeView?.EndUpdate();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates text of the tree node that represents a device.
        /// </summary>
        public static void UpdateDeviceNodeText(TreeNode deviceNode)
        {
            ArgumentNullException.ThrowIfNull(deviceNode, nameof(deviceNode));
            CommNodeTag  nodeTag      = (CommNodeTag)deviceNode.Tag;
            DeviceConfig deviceConfig = (DeviceConfig)nodeTag.RelatedObject;

            deviceNode.Text = CommUtils.GetDeviceTitle(deviceConfig);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates text of the tree node that represents a communication line.
        /// </summary>
        public static void UpdateLineNodeText(TreeNode lineNode)
        {
            ArgumentNullException.ThrowIfNull(lineNode, nameof(lineNode));
            CommNodeTag nodeTag    = (CommNodeTag)lineNode.Tag;
            LineConfig  lineConfig = (LineConfig)nodeTag.RelatedObject;

            lineNode.Text = CommUtils.GetLineTitle(lineConfig);
        }