private void cmb_sensor_SelectedIndexChanged(object sender, EventArgs e) { var field = new string[] { "AccX", "AccY", "AccZ" }; if (cmb_sensor.Text.Contains("GYR")) { field = new string[] { "GyrX", "GyrY", "GyrZ" }; } List <(double timeus, double[] value)> allfftdata; double[] freqt; var img1 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[0]); var img2 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[1]); var img3 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[2]); var mintime = allfftdata.Min(a => a.timeus) / 1000000.0; var maxtime = allfftdata.Max(a => a.timeus) / 1000000.0; var tdelta = (maxtime - mintime); zedGraphControl1.MasterPane[0].GraphObjList.Clear(); zedGraphControl1.MasterPane[0].GraphObjList.Add(new ImageObj(img1.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[0].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[0].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[0].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[0].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[1].GraphObjList.Clear(); zedGraphControl1.MasterPane[1].GraphObjList.Add(new ImageObj(img2.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[1].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[1].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[1].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[1].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[2].GraphObjList.Clear(); zedGraphControl1.MasterPane[2].GraphObjList.Add(new ImageObj(img3.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[2].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[2].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[2].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[2].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
private void cmb_sensor_SelectedIndexChanged(object sender, EventArgs e) { var field = new string[] { "AccX", "AccY", "AccZ" }; if (cmb_sensor.Text.Contains("GYR")) { field = new string[] { "GyrX", "GyrY", "GyrZ" }; } List <(double timeus, double[] value)> allfftdata; double[] freqt; // create X Y Z var img1 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[0], min: (int)num_min.Value, max: (int)num_max.Value); var img2 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[1], min: (int)num_min.Value, max: (int)num_max.Value); var img3 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[2], min: (int)num_min.Value, max: (int)num_max.Value); var mintime = allfftdata.Min(a => a.timeus) / 1000000.0; var maxtime = allfftdata.Max(a => a.timeus) / 1000000.0; var tdelta = (maxtime - mintime); zedGraphControl1.MasterPane[0].GraphObjList.Clear(); zedGraphControl1.MasterPane[0].GraphObjList.Add(new ImageObj(img1.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[0].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[0].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[0].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[0].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[1].GraphObjList.Clear(); zedGraphControl1.MasterPane[1].GraphObjList.Add(new ImageObj(img2.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[1].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[1].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[1].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[1].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[2].GraphObjList.Clear(); zedGraphControl1.MasterPane[2].GraphObjList.Add(new ImageObj(img3.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[2].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[2].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[2].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[2].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[0].YAxis.Scale.MajorStep = 20; zedGraphControl1.MasterPane[0].YAxis.MajorGrid.IsVisible = true; zedGraphControl1.MasterPane[1].YAxis.Scale.MajorStep = 20; zedGraphControl1.MasterPane[1].YAxis.MajorGrid.IsVisible = true; zedGraphControl1.MasterPane[2].YAxis.Scale.MajorStep = 20; zedGraphControl1.MasterPane[2].YAxis.MajorGrid.IsVisible = true; Bitmap bitmap = new Bitmap(10, 10); Graphics g = Graphics.FromImage(bitmap); zedGraphControl1.MasterPane.DoLayout(g); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }