Exemple #1
0
        private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            int count = serialPort.BytesToRead;

            if (count > 0)
            {
                try
                {
                    //byte[] bufferBytes = new byte[count];
                    //serialPort.Read(bufferBytes, 0, count);
                    //PortBytes portBytes = new PortBytes(showTotBox);
                    //tBoxPortOut.FindForm().BeginInvoke(portBytes, bufferBytes);

                    //countLength += count;
                    //Console.WriteLine("count:" + count);
                    //Console.WriteLine("CountLength:" + countLength);
                    byte[] bufferBytes = new byte[count];
                    serialPort.Read(bufferBytes, 0, count);
                    listBytesAddOrRemove(true, bufferBytes);
                    //listBytes.Add(bufferBytes);
                    //OutPutEvent.Set();
                    //ReceviceEvent.Set();
                    //Thread showThread = new Thread(new ParameterizedThreadStart(dobufferBytes));
                    //showThread.Start(bufferBytes);
                }
                catch (Exception E)
                {
                    ERRORDelegate mySend = new ERRORDelegate(showERROR);
                    _gbox.FindForm().BeginInvoke(mySend, E.Message);
                }
            }
        }
Exemple #2
0
        void MakeSpaceFrom(GroupBox G)
        {
            Form F    = G.FindForm();
            int  disp = G.Height;
            int  y0   = G.Location.Y;

            F.SuspendLayout();
            foreach (Control C in F.Controls)
            {
                if (C.Location.Y < y0)
                {
                    continue;
                }
                if ((C.Anchor & AnchorStyles.Bottom) == 0)
                {
                    C.Location = new Point(C.Location.X, C.Location.Y - disp);
                }
                else
                {
                    if ((C.Anchor & AnchorStyles.Top) != 0)
                    {
                        C.Size     = new Size(C.Size.Width, C.Size.Height + disp);
                        C.Location = new Point(C.Location.X, C.Location.Y - disp);
                    }
                }
            }
            F.Size = new Size(F.Size.Width, F.Size.Height - disp);
            F.ResumeLayout();
        }
Exemple #3
0
        private void InitializeLUT()
        {
            if (_lutInitialized)
            {
                return;
            }
            _comboLookupTable.Items.Clear();

            _groupGWData.FindForm().Cursor = Cursors.WaitCursor;
            LutMgt mgt = new LutMgt(_dbConnection);

            string[] lutList = mgt.GetLutNames();
            _groupGWData.FindForm().Cursor = Cursors.Default;

            if (lutList == null)
            {
                return;
            }
            _lutInitialized = true;
            foreach (string lut in lutList)
            {
                _comboLookupTable.Items.Add(lut);
            }
        }
Exemple #4
0
 public PortControl(GroupBox gbox)
 {
     _gbox                           = gbox;
     tBoxPortOut                     = gbox.FindForm().Controls.Find("tboxShow", true)[0] as TextBox;
     cobxSendLine                    = gbox.FindForm().Controls.Find("cobxSendLine", true)[0] as CheckBox;
     cboxRTS                         = gbox.FindForm().Controls.Find("cboxRTS", true)[0] as CheckBox;
     cboxDTR                         = gbox.FindForm().Controls.Find("cboxDTR", true)[0] as CheckBox;
     cbbboxPort                      = _gbox.Controls.Find("cbboxPort", true)[0] as ComboBox;
     cbboxBaud                       = _gbox.Controls.Find("cbboxBaud", true)[0] as ComboBox;
     cboxHEXSend                     = gbox.FindForm().Controls.Find("cboxHEXSend", true)[0] as CheckBox;
     cboxHEXSend.Click              += CboxHEXSend_Click;
     cboxHEXReceive                  = gbox.FindForm().Controls.Find("cboxHEXReceive", true)[0] as CheckBox;
     cboxHEXReceive.Click           += CboxHEXReceive_Click;
     cboxTimeShow                    = gbox.FindForm().Controls.Find("cboxShowTime", true)[0] as CheckBox;
     cboxTimeShow.Click             += CboxTimeShow_Click;
     cboxRTS.Click                  += CboxRTS_Click;
     cboxDTR.Click                  += CboxDTR_Click;
     btnOpenOrClose                  = _gbox.Controls.Find("btnOpen", true)[0] as Button;
     cbboxBaud.SelectedValueChanged += CbboxBaud_SelectedValueChanged;
     lblR       = _gbox.FindForm().Controls.Find("lblR", true)[0] as Label;
     serialPort = new SerialPort();
 }