|
1 | 1 | using System; |
2 | 2 | using System.Drawing; |
| 3 | +using System.IO; |
3 | 4 | using System.Linq; |
4 | 5 | using System.Windows.Forms; |
5 | 6 | using ZedGraph; |
6 | | -using System.IO; |
7 | 7 |
|
8 | 8 | namespace OpenEphys.Onix1.Design |
9 | 9 | { |
@@ -74,7 +74,7 @@ public Rhs2116StimulusSequenceDialog(Rhs2116StimulusSequencePair sequence, Rhs21 |
74 | 74 | } |
75 | 75 |
|
76 | 76 | InitializeZedGraphWaveform(); |
77 | | - DrawStimulusWaveform(); |
| 77 | + DrawStimulusWaveform(false); |
78 | 78 |
|
79 | 79 | zedGraphWaveform.ZoomEvent += OnZoom_Waveform; |
80 | 80 | zedGraphWaveform.MouseMoveEvent += MouseMoveEvent; |
@@ -262,12 +262,20 @@ private double GetPeakToPeakAmplitudeInMicroAmps() |
262 | 262 | : Sequence.CurrentStepSizeuA * 1; // NB: Used to give a buffer when plotting the stimulus waveform |
263 | 263 | } |
264 | 264 |
|
265 | | - private void DrawStimulusWaveform() |
| 265 | + private void DrawStimulusWaveform(bool setZoomState = true) |
266 | 266 | { |
267 | 267 | bool plotAllContacts = ChannelDialog.SelectedContacts.All(x => x == false); |
268 | 268 |
|
269 | 269 | zedGraphWaveform.GraphPane.CurveList.Clear(); |
270 | 270 | zedGraphWaveform.GraphPane.GraphObjList.Clear(); |
| 271 | + |
| 272 | + var (XMin, XMax, YMin, YMax)= ( |
| 273 | + zedGraphWaveform.GraphPane.XAxis.Scale.Min, |
| 274 | + zedGraphWaveform.GraphPane.XAxis.Scale.Max, |
| 275 | + zedGraphWaveform.GraphPane.YAxis.Scale.Min, |
| 276 | + zedGraphWaveform.GraphPane.YAxis.Scale.Max |
| 277 | + ); |
| 278 | + |
271 | 279 | zedGraphWaveform.ZoomOutAll(zedGraphWaveform.GraphPane); |
272 | 280 |
|
273 | 281 | double peakToPeak = GetPeakToPeakAmplitudeInMicroAmps() * 1.1; |
@@ -316,19 +324,30 @@ private void DrawStimulusWaveform() |
316 | 324 | zedGraphWaveform.GraphPane.YAxis.Scale.Min = -Sequence.Stimuli.Length - 2; |
317 | 325 | zedGraphWaveform.GraphPane.YAxis.Scale.Max = 1; |
318 | 326 |
|
319 | | - zedGraphWaveform.GraphPane.YAxis.ScaleFormatEvent += (GraphPane gp, Axis axis, double val, int index) => |
| 327 | + zedGraphWaveform.GraphPane.YAxis.ScaleFormatEvent += (gp, axis, val, index) => |
320 | 328 | { |
321 | 329 | return Math.Abs(val).ToString("0"); |
322 | 330 | }; |
323 | 331 |
|
324 | | - DrawScale(); |
325 | | - |
326 | 332 | SetZoomOutBoundaries(zedGraphWaveform); |
327 | 333 |
|
328 | 334 | ZoomInBoundaryX = (ZoomOutBoundaryRight - ZoomOutBoundaryLeft) * 0.05; |
329 | 335 |
|
330 | 336 | dataGridViewStimulusTable.Refresh(); |
331 | 337 |
|
| 338 | + if (setZoomState) |
| 339 | + { |
| 340 | + zedGraphWaveform.GraphPane.XAxis.Scale.Min = XMin; |
| 341 | + zedGraphWaveform.GraphPane.XAxis.Scale.Max = XMax; |
| 342 | + zedGraphWaveform.GraphPane.YAxis.Scale.Min = YMin; |
| 343 | + zedGraphWaveform.GraphPane.YAxis.Scale.Max = YMax; |
| 344 | + } |
| 345 | + |
| 346 | + if (!CheckZoomBoundaries(zedGraphWaveform)) |
| 347 | + zedGraphWaveform.ZoomOutAll(zedGraphWaveform.GraphPane); |
| 348 | + |
| 349 | + DrawScale(); |
| 350 | + |
332 | 351 | zedGraphWaveform.AxisChange(); |
333 | 352 | zedGraphWaveform.Refresh(); |
334 | 353 | } |
|
0 commit comments