Ejemplo n.º 1
0
        private void btn_StartConnection_Click(object sender, EventArgs e)
        {
            btn_StartConnection.Checked = true;
            btn_StartConnection.Enabled = false;
            btn_StopConnection.Checked  = false;
            btn_StopConnection.Enabled  = true;

l1:
            if (PathTxt == null)
            {
                try
                {
                    serialPort1.BaudRate = int.Parse(cmb_BaundRate.Text);
                    serialPort1.PortName = cmb_PortName.Text;
                    try
                    {
                        serialPort1.Open();
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        DialogResult res =
                            MessageBox.Show(ex.Message, "Ошибка подключения", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                        if (res == DialogResult.Retry)
                        {
                            goto l1;
                        }
                    }
                }
                catch (IOException ex)
                {
                    DialogResult res =
                        MessageBox.Show(ex.Message, "Ошибка подключения к порту", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
                    if (res == DialogResult.Retry)
                    {
                        goto l1;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            ActiveConnection    = true;
            RTgraph.placeToDraw = pc;
            LastPlot            = pc;
            RTgraph.SetPlaceToDrawSize(pc.Width, pc.Height);
            Thread.Sleep(1000);
            tmr_WorkingTime.Start();
            DrawRTGraphAsync();
        }
Ejemplo n.º 2
0
 public void ResizePlot(PictureBox picture)
 {
     if (gr != null)
     {
         gr.SetPlaceToDrawSize(picture.Width, picture.Height);
     }
 }
Ejemplo n.º 3
0
        //очистить все добавленые кривые
        private void btn_DeleteCurves_Click(object sender, EventArgs e)
        {
            graph.GraphCurves.Clear();
            Graphics g = pictureBox1.CreateGraphics();

            g.Clear(pictureBox1.BackColor);
            g.Dispose();
            g = null;

            addGraph?.ResetParams();
            graph.placeToDraw = pictureBox1;
            graph.SetPlaceToDrawSize(graph.placeToDraw.Width, graph.placeToDraw.Height);
            graph.Config.StepOX          = 30;
            graph.Config.StepOY          = 25;
            graph.Config.PriceForPointOX = graph.Config.PriceForPointOY = 1;
        }