Пример #1
0
        public Form1()
        {
            InitializeComponent();


            Form_Update = new BackgroundWorker();
            Form_Update.WorkerSupportsCancellation = true;
            Form_Update.WorkerReportsProgress      = true;
            Form_Update.DoWork          += Form_Update_DoWork;
            Form_Update.ProgressChanged += Form_Update_ProgressChanged;

            Form_Update.RunWorkerAsync();



            is_connected = false;
            stateForm    = WorkState.Idle;
            // Dev = new Device();



            m_mbMaster = ModbusSerialMaster.CreateRtu(COM);
            m_mbMaster.Transport.ReadTimeout             = 100;
            m_mbMaster.Transport.Retries                 = 3;
            m_mbMaster.Transport.SlaveBusyUsesRetryCount = true;
            m_mbMaster.Transport.WaitToRetryMilliseconds = 100;

            m_bgwModbusUpdater = new BackgroundWorker();

            m_bgwModbusUpdater.WorkerSupportsCancellation = true;
            m_bgwModbusUpdater.WorkerReportsProgress      = true;
            m_bgwModbusUpdater.DoWork          += M_bgwModbusUpdater_DoWork;
            m_bgwModbusUpdater.ProgressChanged += M_bgwModbusUpdater_ProgressChanged;

            m_bgwModbusUpdater.RunWorkerAsync();

            Regs = new common.devices.ACID_Stend.Registers();

            myPane  = zedGraphControl1.GraphPane;
            myPane2 = DropGraph.GraphPane;
            myPane3 = IR_graph.GraphPane;
            ColorSelect.SelectedItem = "White";
            ScalSelect.SelectedItem  = "2%";
            LEDTrack.Value           = 0;
            LEDLabel.Text            = LEDTrack.Value.ToString();
            OE_check.Checked         = true;

            IRTrack.Value   = 0;
            IR_val_lbl.Text = IRTrack.Value.ToString();


            PUMPTrack.Value = 0;
            PUMPLabel.Text  = PUMPTrack.Value.ToString();

            Heater_flag = false;



            TBList.Add(PUMPTrack);


            TBList.Add(IRTrack);


            TBList.Add(LEDTrack);



            CBList.Add(ColorSelect);


            CBList.Add(ScalSelect);


            BtnList.Add(set_min_btn);


            BtnList.Add(set_red_max_btn);


            BtnList.Add(set_green_max);

            BtnList.Add(set_blue_max);

            BtnList.Add(set_white_max);


            ZGList.Add(zedGraphControl1);


            ZGList.Add(DropGraph);


            ZGList.Add(IR_graph);


            CHList.Add(Heater);
            CHList.Add(OE_check);



            EnableControl(false);
        }
Пример #2
0
        private void initTest(Wrappers.Test fromLoadTest, Test toTest)
        {
            List <Task> _listTasksInTest = new List <Task> {
            };
            Dictionary <Task, List <Title> > _RTBInTask             = new Dictionary <Task, List <Title> > {
            };
            Dictionary <Task, List <PictureBoxScalable> > _PBInTask = new Dictionary <Task, List <PictureBoxScalable> > {
            };
            Dictionary <Task, List <TextContainer> > _TBInTask      = new Dictionary <Task, List <TextContainer> > {
            };
            List <Panel> _listPanelTasks = new List <Panel> {
            };

            //Dictionary<Task, List<Label>> _listTBLabels = new Dictionary<Task, List<Label>> { };

            foreach (Task paneltask in fromLoadTest.Tasks)
            {
                //int textBoxNumber = 0;
                _RTBInTask.Add(paneltask, new List <Title> {
                });
                _PBInTask.Add(paneltask, new List <PictureBoxScalable> {
                });
                _TBInTask.Add(paneltask, new List <TextContainer> {
                });
                //_listTBLabels.Add(paneltask, new List<Label> { });

                _listTasksInTest.Add(paneltask);


                //foreach (TaskElement taskElem in paneltask.TaskElements)
                //{
                //    if (taskElem.Type.Equals("System.Windows.Forms.TextBox"))
                //    {

                //        textBoxNumber++;

                //    }
                //}

                foreach (TaskElement taskElem in paneltask.TaskElements)
                {
                    if (taskElem.Type.Equals("System.Windows.Forms.RichTextBox"))
                    {
                        Title bufTitle = new Title(taskElem.Name)
                        {
                            Instance =
                            {
                                Height   = taskElem.Height,
                                Width    = taskElem.Width,
                                Location = taskElem.Point,
                                Text     = taskElem.Text,
                                Font     = new System.Drawing.Font("Microsoft Sans Serif", 15.75F,
                                                                   System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
                                                                   ((byte)(204))),
                            }
                        };
                        _RTBInTask[paneltask].Add(bufTitle);
                    }

                    if (taskElem.Type.Equals("System.Windows.Forms.PictureBox"))
                    {
                        using (var stream = File.Open(new DynamicParams().GetPath() + "/" + taskElem.Media,
                                                      FileMode.Open))
                        {
                            var binaryFormatter = new BinaryFormatter();
                            var image           = ((SerializablePicture)binaryFormatter.Deserialize(stream)).Picture;


                            PictureBoxScalable bufPBS = new PictureBoxScalable(taskElem.Name)
                            {
                                Instance =
                                {
                                    Size     = new Size(taskElem.Width, taskElem.Height),
                                    Image    = image,
                                    Location = taskElem.Point
                                }
                            };
                            _PBInTask[paneltask].Add(bufPBS);
                        }
                    }

                    if (taskElem.Type.Equals("System.Windows.Forms.TextBox"))
                    {
                        TextContainer bufTC = new TextContainer(taskElem.Name)
                        {
                            Instance =
                            {
                                Height   = taskElem.Height,
                                Width    = taskElem.Width,
                                Location = taskElem.Point,
                                Text     = taskElem.Answer,
                                TabIndex = taskElem.Index
                            }
                        };
                        _TBInTask[paneltask].Insert(0, bufTC);


                        //textBoxNumber--;
                    }
                }
            }

            foreach (Task task in _listTasksInTest)
            {
                var indexLabel = 1;
                var buf1       = new Panel
                {
                    BackColor = System.Drawing.SystemColors.ControlDark,
                    Location  = new System.Drawing.Point(0, 0),
                    Name      = task.Name,
                    Size      = new System.Drawing.Size(1110, 618),
                    TabIndex  = 0
                };
                _listPanelTasks.Add(buf1);

                //Добавление панели с заданием

                var panelQestionFoo = new Panel();
                panelQestionFoo.BackColor  = System.Drawing.SystemColors.GradientInactiveCaption;
                panelQestionFoo.Location   = new System.Drawing.Point(5, 5);
                panelQestionFoo.Name       = "panelQuestion";
                panelQestionFoo.Size       = new System.Drawing.Size(761, 610);
                panelQestionFoo.TabIndex   = 0;
                panelQestionFoo.AutoScroll = true;

                panelQestionFoo.AllowDrop  = true;
                panelQestionFoo.DragEnter += new DragEventHandler(toTest.panelQuestion_DragEnter);
                panelQestionFoo.DragDrop  += new DragEventHandler(toTest.panelQuestion_DragDrop);

                toTest.createPasteFunc(panelQestionFoo);

                foreach (PictureBoxScalable pb in _PBInTask[task])
                {
                    pb.SetParent(panelQestionFoo);
                    panelQestionFoo.Controls.Add(pb.Instance);
                    ControlMover.Add(pb.Instance);
                    pb.Instance.SizeMode = PictureBoxSizeMode.StretchImage;
                }


                int j = _TBInTask[task].Count;
                foreach (TextContainer tb in _TBInTask[task])
                {
                    tb.Instance.Name = "System.Windows.Forms.TextBox, Text: " + j;
                    tb.SetParent(panelQestionFoo);
                    tb.AddAnswerTitle(tb.Instance.TabIndex);
                    panelQestionFoo.Controls.Add(tb.Instance);
                    tb.Instance.BringToFront();
                    ControlMover.Add(tb.Instance);

                    indexLabel++;


                    TBList.Add(tb.Instance);
                    j--;
                }

                foreach (Title rtb in _RTBInTask[task])
                {
                    rtb.SetParent(panelQestionFoo);
                    panelQestionFoo.Controls.Add(rtb.Instance);
                    ControlMover.Add(rtb.Instance);
                    rtb.Instance.BringToFront();
                }


                _listPanelTasks[_listPanelTasks.Count - 1].Controls.Add(panelQestionFoo);
                toTest.Controls.Find("panelMiddle", true)[0].Controls.Add(_listPanelTasks[_listPanelTasks.Count - 1]);

                PanelWrapper bufPW = new PanelWrapper();
                bufPW.Entity       = _listPanelTasks[_listPanelTasks.Count - 1];
                bufPW.Identifier   = indexLabel;
                bufPW.PictureIndex = _PBInTask[task].Count;
                indexLabel++;

                LinkLabel bufLL = toTest.createLinkLabel(_listPanelTasks.Count - 1);

                bufPW.Entity.Name = bufLL.Text;

                toTest.ListPanelsTasks.Add(bufLL, bufPW);
                toTest.LinkLabelButtonDel.Add(bufLL, toTest.createButtonDelTask(_listPanelTasks.Count - 1));


                PanelWrapper bufPW2 = new PanelWrapper();
                bufPW2.Entity = panelQestionFoo;
                toTest._currentPanelQuestion = bufPW2;
            }


            Control currentPanelListOfTasks = toTest.Controls.Find("panelListOfTasks", true)[0];


            toTest.ListPanelsTasks.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);
            toTest.LinkLabelButtonDel.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);

            currentPanelListOfTasks.Controls.Remove(currentPanelListOfTasks.Controls[1]);
            currentPanelListOfTasks.Controls.Remove(currentPanelListOfTasks.Controls[1]);

            //toTest.ListPanelsTasks.Remove((LinkLabel)currentPanelListOfTasks.Controls[1]);


            toTest._currentTask =
                toTest.ListPanelsTasks[(LinkLabel)(toTest.Controls.Find("panelListOfTasks", true)[0].Controls[1])];
            toTest._currentPanelQuestion.Entity =
                (Panel)toTest._currentTask.Entity.Controls.Find("panelQuestion", true)[0];


            //foreach (TextBox tb in TBList)
            //{
            //    tb.Move += moveTBWithLB;
            //}
        }