Exemplo n.º 1
0
        public void Loaded()
        {
            ucTreeNavigator1.SelectNode("ndStations");
            lock (Data.StationNodes)
            {
                foreach (var station in Data.StationNodes)
                {
                    var flowLayoutPanelOneRow = new FlowLayoutPanel
                    {
                        //BackColor = Color.Aquamarine,
                        Margin        = new Padding(0, 3, 0, 3),
                        FlowDirection = FlowDirection.LeftToRight,
                        AutoSize      = true
                    };
                    var stationIndex = station.Index;

                    var checkBoxEnableChannel = new CheckBox
                    {
                        //BackColor = Color.Aqua,
                        Font     = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Enabled  = false,
                        Margin   = new Padding(10, 3, 0, 0),
                        Name     = "checkBox" + station.Index,
                        Size     = new Size(50, 28),
                        TabIndex = 1,
                        Text     = stationIndex.ToString("0"),
                        Checked  = station.Enable,
                        UseVisualStyleBackColor = true
                    };
                    flowLayoutPanelOneRow.Controls.Add(checkBoxEnableChannel);

                    var linkLabel = new LinkLabel
                    {
                        //BackColor = Color.Azure,
                        AutoSize  = false,
                        Dock      = DockStyle.Fill,
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Name      = "linkLabel" + station.Index,
                        Size      = new Size(120, 28),
                        TabIndex  = 2,
                        TabStop   = true,
                        Text      = station.Name,
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    linkLabel.LinkClicked += linkLabel0_LinkClicked;
                    flowLayoutPanelOneRow.Controls.Add(linkLabel);

                    var labelType = new Label
                    {
                        //BackColor = Color.Aqua,
                        Dock      = DockStyle.Fill,
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Location  = new Point(286, 40),
                        Name      = "labelType" + station.Index,
                        Size      = new Size(120, 28),
                        TabIndex  = 0,
                        Text      = station.ItThisStation ? "Публикация" : "Подписка",
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    flowLayoutPanelOneRow.Controls.Add(labelType);

                    var riserOneStateControl = new UcRiserOneState
                    {
                        //BackColor = Color.Azure,
                        Caption        = "------",
                        CaptionAtRight = false,
                        Font           = new Font("Courier New", 9.75F, FontStyle.Bold),
                        LampColorNone  = Color.Gray,
                        LampColorOff   = Color.Silver,
                        LampColorOn    = Color.Lime,
                        Margin         = new Padding(20, 1, 0, 1),
                        Name           = "riserOneStateControl" + station.Index,
                        Size           = new Size(145, 26),
                        State          = null,
                        TabIndex       = 3
                    };
                    flowLayoutPanelOneRow.Controls.Add(riserOneStateControl);

                    var stationIpAddr = station.Address != null?station.Address.ToString() : "";

                    var labIpAddr = new Label
                    {
                        //BackColor = Color.Aqua,
                        AutoSize  = false,
                        Dock      = DockStyle.Fill,
                        Font      = new Font("Lucida Console", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Name      = "labIpAddr" + station.Index,
                        Size      = new Size(126, 28),
                        TabIndex  = 5,
                        Text      = stationIpAddr,
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    flowLayoutPanelOneRow.Controls.Add(labIpAddr);

                    var labDesc = new Label
                    {
                        //BackColor = Color.Azure,
                        AutoSize  = true,
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Margin    = new Padding(20, 3, 3, 3),
                        Name      = "labDesc" + station.Index,
                        Size      = new Size(353, 28),
                        TabIndex  = 0,
                        Text      = station.Descriptor,
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    flowLayoutPanelOneRow.Controls.Add(labDesc);
                    flowLayoutPanelOneRow.SetFlowBreak(labDesc, true);

                    flowLayoutPanel1.Controls.Add(flowLayoutPanelOneRow);
                }
            }
            timerUpdate_Tick(null, null);
        }
Exemplo n.º 2
0
        private void FillControllerslGrid()
        {
            timerUpdate.Enabled = false;
            _lamps.Clear();
            foreach (var linkLabel in _linkLabels)
            {
                linkLabel.LinkClicked -= linkToControllerPage_LinkClicked;
            }
            _linkLabels.Clear();

            foreach (var checkBox in _cboxs.Values)
            {
                checkBox.CheckedChanged -= checkBox_CheckedChanged;
            }
            _cboxs.Clear();

            var channelComboItem = (ChannelComboItem)cbChannelByName.SelectedItem;

            if (channelComboItem == null)
            {
                return;
            }

            ChannelNode channel;

            lock (Data.ChannelNodes)
            {
                channel      = Data.ChannelNodes[channelComboItem.Index];
                labDesc.Text = channel.Descriptor;
            }

            var nrows = channel.Risers.Count;

            flowLayoutPanel1.Controls.Clear();

            for (var i = 0; i < nrows; i++)
            {
                var flowLayoutPanelOneRow = new FlowLayoutPanel
                {
                    Margin        = new Padding(0, 0, 0, 0),
                    Padding       = new Padding(10, 0, 0, 0),
                    FlowDirection = FlowDirection.LeftToRight,
                    //BackColor = Color.MediumPurple,
                    AutoSize = true
                };

                var checkBox = new CheckBox
                {
                    AutoSize = false,
                    Enabled  = false,
                    Font     = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                    Margin   = new Padding(3, 3, 3, 3),
                    Name     = "checkBox" + channel.Risers[i].Index,
                    Text     = channel.Risers[i].Riser.ToString("0"),
                    Size     = new Size(60, 26),
                    //BackColor = Color.MediumAquamarine,
                    TabIndex = 1,
                    UseVisualStyleBackColor = true,
                    Checked = channel.Risers[i].Active
                };

                checkBox.CheckedChanged += checkBox_CheckedChanged;

                _cboxs.Add(checkBox.Name, checkBox);

                flowLayoutPanelOneRow.Controls.Add(checkBox);

                var addr = new RiserAddress
                {
                    Channel  = channel.Index,
                    Overpass = channel.Overpass,
                    Way      = channel.Way,
                    Product  = channel.Product,
                    Riser    = channel.Risers[i].Riser
                };
                var linkToControllerPage = new LinkLabel
                {
                    AutoSize = false,
                    Font     = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                    Name     = channel.Risers[i].Name,
                    Margin   = new Padding(20, 0, 0, 0),
                    Size     = new Size(106, 28),
                    //BackColor = Color.Aquamarine,
                    TabIndex  = 2,
                    TabStop   = true,
                    Text      = channel.Risers[i].Name,
                    Tag       = addr,
                    TextAlign = ContentAlignment.MiddleLeft
                };
                linkToControllerPage.LinkClicked += linkToControllerPage_LinkClicked;

                flowLayoutPanelOneRow.Controls.Add(linkToControllerPage);

                var labelId = new Label
                {
                    Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                    Name = "labelId",
                    Size = new Size(93, 28),
                    //BackColor = Color.MediumAquamarine,
                    TabIndex  = 0,
                    Text      = channel.Risers[i].Node.ToString("0"),
                    TextAlign = ContentAlignment.MiddleCenter
                };

                flowLayoutPanelOneRow.Controls.Add(labelId);

                var linkToChannelPage = new LinkLabel
                {
                    AutoSize = false,
                    Font     = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                    Name     = "linxLabel" + channel.Index,
                    Size     = new Size(116, 28),
                    //BackColor = Color.Aquamarine,
                    TabIndex  = 2,
                    TabStop   = true,
                    Text      = channel.Name,
                    TextAlign = ContentAlignment.MiddleLeft
                };
                linkToChannelPage.LinkClicked += linkToChannelPage_LinkClicked;
                _linkLabels.Add(linkToChannelPage);

                flowLayoutPanelOneRow.Controls.Add(linkToChannelPage);

                var lampBox = new UcRiserOneState
                {
                    Caption        = "------",
                    CaptionAtRight = false,
                    Font           = new Font("Courier New", 9.75F, FontStyle.Bold),
                    LampColorNone  = Color.Gray,
                    LampColorOff   = Color.Black,
                    LampColorOn    = Color.Lime,
                    Margin         = new Padding(0, 0, 0, 0),
                    Name           = channel.Risers[i].Name,
                    Size           = new Size(129, 28),
                    //BackColor = Color.Aquamarine,
                    State    = null,
                    TabIndex = 3
                };
                _lamps.Add(lampBox.Name, lampBox);

                if (channel.Risers[i].Active)
                {
                    if (channel.Risers[i].BarometerValue >= channel.Risers[i].FailLimit)
                    {
                        lampBox.State       = true;
                        lampBox.LampColorOn = Color.Red;
                        lampBox.Caption     = "Отказ";
                    }
                    else if (channel.Risers[i].BarometerValue >= channel.Risers[i].MarginalLimit)
                    {
                        lampBox.State       = true;
                        lampBox.LampColorOn = Color.Yellow;
                        lampBox.Caption     = "Сбой";
                    }
                    else
                    {
                        lampBox.State       = true;
                        lampBox.LampColorOn = Color.Lime;
                        lampBox.Caption     = "Норма";
                    }
                }
                else
                {
                    lampBox.State   = false;
                    lampBox.Caption = "Не активен";
                }

                flowLayoutPanelOneRow.Controls.Add(lampBox);
                flowLayoutPanelOneRow.SetFlowBreak(lampBox, true);

                flowLayoutPanel1.Controls.Add(flowLayoutPanelOneRow);
            }

            timerUpdate.Enabled = true;
        }
Exemplo n.º 3
0
        public void Loaded()
        {
            ucTreeNavigator1.SelectNode("ndChannels");
            lock (Data.ChannelNodes)
            {
                foreach (var channel in Data.ChannelNodes)
                {
                    var flowLayoutPanelOneRow = new FlowLayoutPanel
                    {
                        //BackColor = Color.Aquamarine,
                        Margin        = new Padding(0, 3, 0, 3),
                        FlowDirection = FlowDirection.LeftToRight,
                        AutoSize      = true
                    };
                    var channelIndex = channel.Index + 1;

                    var checkBoxEnableChannel = new CheckBox
                    {
                        //BackColor = Color.Aqua,
                        Font     = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Enabled  = false,
                        Margin   = new Padding(10, 3, 0, 0),
                        Name     = "checkBox" + channel.Index,
                        Size     = new Size(50, 28),
                        TabIndex = 1,
                        Text     = channelIndex.ToString("0"),
                        Checked  = channel.Active,
                        UseVisualStyleBackColor = true
                    };
                    checkBoxEnableChannel.CheckedChanged += checkBox1_CheckedChanged;
                    flowLayoutPanelOneRow.Controls.Add(checkBoxEnableChannel);

                    var linkLabel = new LinkLabel
                    {
                        //BackColor = Color.Azure,
                        AutoSize  = false,
                        Dock      = DockStyle.Fill,
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Name      = "linkLabel" + channel.Index,
                        Size      = new Size(120, 28),
                        TabIndex  = 2,
                        TabStop   = true,
                        Text      = channel.Name,
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    linkLabel.LinkClicked += linkLabel0_LinkClicked;
                    flowLayoutPanelOneRow.Controls.Add(linkLabel);

                    var labelType = new Label
                    {
                        //BackColor = Color.Aqua,
                        Dock      = DockStyle.Fill,
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Location  = new Point(286, 40),
                        Name      = "labelType" + channel.Index,
                        Size      = new Size(120, 28),
                        TabIndex  = 0,
                        Text      = @"Modbus RTU",
                        TextAlign = ContentAlignment.MiddleCenter
                    };
                    flowLayoutPanelOneRow.Controls.Add(labelType);

                    var riserOneStateControl = new UcRiserOneState
                    {
                        //BackColor = Color.Azure,
                        Caption        = "------",
                        CaptionAtRight = false,
                        Font           = new Font("Courier New", 9.75F, FontStyle.Bold),
                        LampColorNone  = Color.Gray,
                        LampColorOff   = Color.Black,
                        LampColorOn    = Color.Lime,
                        Margin         = new Padding(20, 1, 0, 1),
                        Name           = "riserOneStateControl" + channel.Index,
                        Size           = new Size(130, 26),
                        State          = null,
                        TabIndex       = 3
                    };
                    flowLayoutPanelOneRow.Controls.Add(riserOneStateControl);

                    var labIpAddr = new Label
                    {
                        //BackColor = Color.Aqua,
                        AutoSize  = false,
                        Dock      = DockStyle.Fill,
                        Font      = new Font("Lucida Console", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Name      = "labIpAddr" + channel.Index,
                        Size      = new Size(116, 28),
                        TabIndex  = 5,
                        Text      = channel.LinkType == 0 ? channel.IpAddr : "",
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    flowLayoutPanelOneRow.Controls.Add(labIpAddr);

                    var labComportTuned = new Label
                    {
                        //BackColor = Color.Aqua,
                        AutoSize = false,
                        Dock     = DockStyle.Fill,
                        Font     = new Font("Lucida Console", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Name     = "labComportTuned" + channel.Index,
                        Size     = new Size(116, 28),
                        TabIndex = 5,
                        Text     = channel.LinkType == 1 ?
                                   string.Format("COM{0}:{1},{2}", channel.Comport, channel.Baudrate, channel.Parity) : "",
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    flowLayoutPanelOneRow.Controls.Add(labComportTuned);

                    var button = new Button
                    {
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Margin    = new Padding(3, 1, 14, 1),
                        Name      = "button" + channel.Index,
                        Size      = new Size(141, 28),
                        TabIndex  = 4,
                        Text      = @"Контроллеры...",
                        FlatStyle = FlatStyle.System,
                        UseVisualStyleBackColor = true
                    };
                    button.Click += button0_Click;
                    flowLayoutPanelOneRow.Controls.Add(button);

                    var labDesc = new Label
                    {
                        //BackColor = Color.Azure,
                        AutoSize  = true,
                        Font      = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 204),
                        Margin    = new Padding(3, 3, 3, 3),
                        Name      = "labDesc" + channel.Index,
                        Size      = new Size(353, 28),
                        TabIndex  = 0,
                        Text      = channel.Descriptor,
                        TextAlign = ContentAlignment.MiddleLeft
                    };
                    flowLayoutPanelOneRow.Controls.Add(labDesc);
                    flowLayoutPanelOneRow.SetFlowBreak(labDesc, true);

                    flowLayoutPanel1.Controls.Add(flowLayoutPanelOneRow);
                }
            }
            timerUpdate_Tick(null, null);
        }