private void DrawRTGraph() { Stopwatch watch = new Stopwatch(); watch.Start(); Time = 0; //время работы цикла string[] el = null; //массив элементов значений double value = 0; //последнее значение в массиве while (ActiveConnection) { if (PathTxt != null) { FileStream input = new FileStream(PathTxt, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); using (StreamReader reader = new StreamReader(input)) { el = reader.ReadToEnd().Split(' '); if (el[el.Length - 1] == " " || el[el.Length - 1] == string.Empty) { MessageBox.Show("Ошибка формата передачи данных: \" \"num", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } value = double.Parse(el[el.Length - 1]); } } else if (PathTxt == null) { try { string param = serialPort1.ReadLine().Replace('.', ','); value = double.Parse(param); } catch (IOException) { return; } } double k = Math.Round(RTgraph.Config.StepOX / 40.0, 4); ShiftOX += (int)(0.1 * RTgraph.Config.StepOX / RTgraph.Config.PriceForPointOX); double x = RTgraph.ImiganaryCenter.X - 0.1 * RTgraph.Config.StepOX / RTgraph.Config.PriceForPointOX; RTgraph.ImiganaryCenter = new Point((int)x, RTgraph.ImiganaryCenter.Y); RTgraph.ValuePairs.Add(Time, value); RTgraph.DrawDiagram(); Time = watch.Elapsed.TotalMilliseconds / 1000; Thread.Sleep(WaitTime); } watch.Stop(); }
private void Timer_Tick(object sender, EventArgs e) { gr.DrawDiagram(); }
int value; //величина, на которую происзодит изменение private void ChangeParams(Param param, int value) { if (param == Param.StepOX) { graph.Config.StepOX += value; } if (param == Param.StepOY) { graph.Config.StepOY += value; } if (param == Param.RCenterPosX) { graph.RealCenter = new Point(graph.RealCenter.X + value, graph.RealCenter.Y); ShiftOX += value; } if (param == Param.RCenterPosY) { graph.RealCenter = new Point(graph.RealCenter.X, graph.RealCenter.Y + value); ShiftOY += value; } graph.DrawDiagram(); }