diff --git a/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.Designer.cs b/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.Designer.cs index dc5bacf..885b5da 100644 --- a/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.Designer.cs +++ b/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.Designer.cs @@ -50,6 +50,8 @@ private void InitializeComponent() this.zedGraphWaveform = new ZedGraph.ZedGraphControl(); this.tabPageTable = new System.Windows.Forms.TabPage(); this.dataGridViewStimulusTable = new System.Windows.Forms.DataGridView(); + this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); + this.button1 = new System.Windows.Forms.Button(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.statusStrip.SuspendLayout(); this.menuStrip.SuspendLayout(); @@ -60,6 +62,7 @@ private void InitializeComponent() this.tabPageWaveform.SuspendLayout(); this.tabPageTable.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewStimulusTable)).BeginInit(); + this.flowLayoutPanel2.SuspendLayout(); this.SuspendLayout(); // // buttonCancel @@ -124,7 +127,7 @@ private void InitializeComponent() this.panelProbe.Location = new System.Drawing.Point(698, 2); this.panelProbe.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.panelProbe.Name = "panelProbe"; - this.panelProbe.Size = new System.Drawing.Size(445, 209); + this.panelProbe.Size = new System.Drawing.Size(445, 167); this.panelProbe.TabIndex = 0; // // menuStrip @@ -153,20 +156,20 @@ private void InitializeComponent() this.openFileToolStripMenuItem, this.saveFileToolStripMenuItem}); this.stimulusWaveformToolStripMenuItem.Name = "stimulusWaveformToolStripMenuItem"; - this.stimulusWaveformToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.stimulusWaveformToolStripMenuItem.Size = new System.Drawing.Size(178, 22); this.stimulusWaveformToolStripMenuItem.Text = "Stimulus Waveform"; // // openFileToolStripMenuItem // this.openFileToolStripMenuItem.Name = "openFileToolStripMenuItem"; - this.openFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.openFileToolStripMenuItem.Size = new System.Drawing.Size(124, 22); this.openFileToolStripMenuItem.Text = "Open File"; this.openFileToolStripMenuItem.Click += new System.EventHandler(this.MenuItemLoadFile_Click); // // saveFileToolStripMenuItem // this.saveFileToolStripMenuItem.Name = "saveFileToolStripMenuItem"; - this.saveFileToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveFileToolStripMenuItem.Size = new System.Drawing.Size(124, 22); this.saveFileToolStripMenuItem.Text = "Save File"; this.saveFileToolStripMenuItem.Click += new System.EventHandler(this.MenuItemSaveFile_Click); // @@ -177,28 +180,30 @@ private void InitializeComponent() this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 451F)); this.tableLayoutPanel1.Controls.Add(this.groupBoxDefineStimuli, 1, 1); this.tableLayoutPanel1.Controls.Add(this.panelProbe, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 3); this.tableLayoutPanel1.Controls.Add(this.panelWaveform, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel2, 0, 2); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 24); this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowCount = 4; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 308F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(1146, 563); this.tableLayoutPanel1.TabIndex = 8; // // groupBoxDefineStimuli // this.groupBoxDefineStimuli.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBoxDefineStimuli.Location = new System.Drawing.Point(698, 215); + this.groupBoxDefineStimuli.Location = new System.Drawing.Point(698, 173); this.groupBoxDefineStimuli.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.groupBoxDefineStimuli.Name = "groupBoxDefineStimuli"; this.groupBoxDefineStimuli.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.groupBoxDefineStimuli.Size = new System.Drawing.Size(445, 304); + this.tableLayoutPanel1.SetRowSpan(this.groupBoxDefineStimuli, 2); + this.groupBoxDefineStimuli.Size = new System.Drawing.Size(445, 346); this.groupBoxDefineStimuli.TabIndex = 0; this.groupBoxDefineStimuli.TabStop = false; this.groupBoxDefineStimuli.Text = "Define Stimuli"; @@ -223,7 +228,7 @@ private void InitializeComponent() this.panelWaveform.Location = new System.Drawing.Point(3, 3); this.panelWaveform.Name = "panelWaveform"; this.tableLayoutPanel1.SetRowSpan(this.panelWaveform, 2); - this.panelWaveform.Size = new System.Drawing.Size(689, 515); + this.panelWaveform.Size = new System.Drawing.Size(689, 473); this.panelWaveform.TabIndex = 8; // // tabControlVisualization @@ -234,7 +239,7 @@ private void InitializeComponent() this.tabControlVisualization.Location = new System.Drawing.Point(0, 0); this.tabControlVisualization.Name = "tabControlVisualization"; this.tabControlVisualization.SelectedIndex = 0; - this.tabControlVisualization.Size = new System.Drawing.Size(689, 515); + this.tabControlVisualization.Size = new System.Drawing.Size(689, 473); this.tabControlVisualization.TabIndex = 6; // // tabPageWaveform @@ -244,7 +249,7 @@ private void InitializeComponent() this.tabPageWaveform.Name = "tabPageWaveform"; this.tabPageWaveform.Padding = new System.Windows.Forms.Padding(3); this.tabPageWaveform.RightToLeft = System.Windows.Forms.RightToLeft.Yes; - this.tabPageWaveform.Size = new System.Drawing.Size(681, 486); + this.tabPageWaveform.Size = new System.Drawing.Size(681, 444); this.tabPageWaveform.TabIndex = 0; this.tabPageWaveform.Text = "Stimulus Waveform"; this.tabPageWaveform.UseVisualStyleBackColor = true; @@ -262,7 +267,7 @@ private void InitializeComponent() this.zedGraphWaveform.ScrollMinX = 0D; this.zedGraphWaveform.ScrollMinY = 0D; this.zedGraphWaveform.ScrollMinY2 = 0D; - this.zedGraphWaveform.Size = new System.Drawing.Size(675, 480); + this.zedGraphWaveform.Size = new System.Drawing.Size(675, 438); this.zedGraphWaveform.TabIndex = 5; this.zedGraphWaveform.UseExtendedPrintDialog = true; // @@ -272,7 +277,7 @@ private void InitializeComponent() this.tabPageTable.Location = new System.Drawing.Point(4, 25); this.tabPageTable.Name = "tabPageTable"; this.tabPageTable.Padding = new System.Windows.Forms.Padding(3); - this.tabPageTable.Size = new System.Drawing.Size(681, 486); + this.tabPageTable.Size = new System.Drawing.Size(681, 444); this.tabPageTable.TabIndex = 1; this.tabPageTable.Text = "Table"; this.tabPageTable.UseVisualStyleBackColor = true; @@ -289,10 +294,31 @@ private void InitializeComponent() this.dataGridViewStimulusTable.ReadOnly = true; this.dataGridViewStimulusTable.RowHeadersWidth = 62; this.dataGridViewStimulusTable.RowTemplate.Height = 24; - this.dataGridViewStimulusTable.Size = new System.Drawing.Size(675, 480); + this.dataGridViewStimulusTable.Size = new System.Drawing.Size(675, 438); this.dataGridViewStimulusTable.TabIndex = 0; this.dataGridViewStimulusTable.TabStop = false; // + // flowLayoutPanel2 + // + this.flowLayoutPanel2.Controls.Add(this.button1); + this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel2.Location = new System.Drawing.Point(3, 482); + this.flowLayoutPanel2.Name = "flowLayoutPanel2"; + this.flowLayoutPanel2.Size = new System.Drawing.Size(689, 36); + this.flowLayoutPanel2.TabIndex = 9; + // + // button1 + // + this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(3, 2); + this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(144, 32); + this.button1.TabIndex = 5; + this.button1.Text = "Reset Zoom"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.ResetZoom_Click); + // // GenericStimulusSequenceDialog // this.AccessibleDescription = ""; @@ -321,6 +347,7 @@ private void InitializeComponent() this.tabPageWaveform.ResumeLayout(false); this.tabPageTable.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewStimulusTable)).EndInit(); + this.flowLayoutPanel2.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -348,5 +375,7 @@ private void InitializeComponent() private System.Windows.Forms.TabPage tabPageTable; internal System.Windows.Forms.DataGridView dataGridViewStimulusTable; internal System.Windows.Forms.ToolStripMenuItem stimulusWaveformToolStripMenuItem; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; + private System.Windows.Forms.Button button1; } } diff --git a/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.cs b/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.cs index 9b204d0..dc591ac 100644 --- a/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.cs +++ b/OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.cs @@ -10,13 +10,6 @@ namespace OpenEphys.Onix1.Design /// /// Partial class to create a channel configuration GUI for a . /// - /// - /// To use this base class, create a new Form and inherit this class. - /// Then, implement the methods in this class that are marked as virtual and throw a . - /// As an example, the method is automatically called whenever - /// is called, which is up to the inheriting class to implement correctly to pass along - /// the correct waveforms for plotting. - /// public partial class GenericStimulusSequenceDialog : Form { readonly int NumberOfChannels; @@ -24,7 +17,6 @@ public partial class GenericStimulusSequenceDialog : Form readonly bool UseTable; internal const double ZeroPeakToPeak = 1e-12; - internal double PeakToPeak = 1; internal readonly double ChannelScale = 1.1; [Obsolete("Designer only", true)] @@ -108,15 +100,6 @@ void OnZoom_Waveform(ZedGraphControl sender, ZoomState oldState, ZoomState newSt if (newState.Type == ZoomState.StateType.WheelZoom) { CenterAxesOnCursor(sender); - - if (!CheckZoomBoundaries(sender)) - { - sender.ZoomOut(sender.GraphPane); - } - } - else if (newState.Type == ZoomState.StateType.Zoom) - { - CheckZoomBoundaries(sender); } DrawScale(); @@ -126,32 +109,6 @@ bool MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e) { if (e.Button == MouseButtons.Middle) { - if (sender.GraphPane.XAxis.Scale.Max > ZoomOutBoundaryRight) - { - var diff = sender.GraphPane.XAxis.Scale.Max - ZoomOutBoundaryRight; - sender.GraphPane.XAxis.Scale.Max -= diff; - sender.GraphPane.XAxis.Scale.Min -= diff; - } - else if (sender.GraphPane.XAxis.Scale.Min < ZoomOutBoundaryLeft) - { - var diff = ZoomOutBoundaryLeft - sender.GraphPane.XAxis.Scale.Min; - sender.GraphPane.XAxis.Scale.Max += diff; - sender.GraphPane.XAxis.Scale.Min += diff; - } - - if (sender.GraphPane.YAxis.Scale.Max > ZoomOutBoundaryTop) - { - var diff = sender.GraphPane.YAxis.Scale.Max - ZoomOutBoundaryTop; - sender.GraphPane.YAxis.Scale.Max -= diff; - sender.GraphPane.YAxis.Scale.Min -= diff; - } - else if (sender.GraphPane.YAxis.Scale.Min < ZoomOutBoundaryBottom) - { - var diff = ZoomOutBoundaryBottom - sender.GraphPane.YAxis.Scale.Min; - sender.GraphPane.YAxis.Scale.Max += diff; - sender.GraphPane.YAxis.Scale.Min += diff; - } - DrawScale(); } @@ -173,28 +130,18 @@ internal CurveItem[] GetWaveformCurves() return zedGraphWaveform.GraphPane.CurveList.Where(item => item.Label.Text.Contains("Ch")).ToArray(); } - internal double YAxisMin = -1; - internal double YAxisMax = 1; - - /// - /// Calls and draws the waveforms that are returned. - /// - /// - /// - /// To modify the axis limits, ensure that the fields and - /// are properly set in the inheriting class so that all waveforms are easily visualized. - /// - /// - /// For the scale, ensure that the field is set to the maximum peak-to-peak - /// value of the waveforms, multiplied by to give a buffer between adjacent waveforms. - /// This will correctly modulate the scale to display the amplitude of the maximum waveform. - /// - /// - /// - internal void DrawStimulusWaveform() + internal void DrawStimulusWaveform(bool setZoomState = true) { zedGraphWaveform.GraphPane.CurveList.Clear(); zedGraphWaveform.GraphPane.GraphObjList.Clear(); + + var (XMin, XMax, YMin, YMax)= ( + zedGraphWaveform.GraphPane.XAxis.Scale.Min, + zedGraphWaveform.GraphPane.XAxis.Scale.Max, + zedGraphWaveform.GraphPane.YAxis.Scale.Min, + zedGraphWaveform.GraphPane.YAxis.Scale.Max + ); + zedGraphWaveform.ZoomOutAll(zedGraphWaveform.GraphPane); PointPairList[] waveforms = CreateStimulusWaveforms(); @@ -238,16 +185,24 @@ internal void DrawStimulusWaveform() return Math.Abs(val).ToString("0"); }; - DrawScale(); + dataGridViewStimulusTable.Refresh(); - SetZoomOutBoundaries(zedGraphWaveform); + if (setZoomState && XMin != 0 && XMax != 0) + { + zedGraphWaveform.GraphPane.XAxis.Scale.Min = XMin; + zedGraphWaveform.GraphPane.XAxis.Scale.Max = XMax; + zedGraphWaveform.GraphPane.YAxis.Scale.Min = YMin; + zedGraphWaveform.GraphPane.YAxis.Scale.Max = YMax; + } - ZoomInBoundaryX = (ZoomOutBoundaryRight - ZoomOutBoundaryLeft) * 0.05; + DrawScale(); zedGraphWaveform.AxisChange(); zedGraphWaveform.Refresh(); } + internal virtual double GetPeakToPeakAmplitudeInMicroAmps() => throw new NotImplementedException(); + internal string yAxisScale = "µA"; void DrawScale() @@ -261,12 +216,28 @@ void DrawScale() zedGraphWaveform.GraphPane.GraphObjList.RemoveAll(x => x is TextObj); } - var zeroOffsetX = zedGraphWaveform.GraphPane.XAxis.Scale.Min + CalculateScaleRange(zedGraphWaveform.GraphPane.XAxis.Scale) * 0.025; - var zeroOffsetY = zedGraphWaveform.GraphPane.YAxis.Scale.Min + CalculateScaleRange(zedGraphWaveform.GraphPane.YAxis.Scale) * 0.025; + var xScaleRange = CalculateScaleRange(zedGraphWaveform.GraphPane.XAxis.Scale); + var yScaleRange = CalculateScaleRange(zedGraphWaveform.GraphPane.YAxis.Scale); + + const double ScaleFactor = 0.025; + + var zeroOffsetX = zedGraphWaveform.GraphPane.XAxis.Scale.Min + xScaleRange * ScaleFactor; + var zeroOffsetY = zedGraphWaveform.GraphPane.YAxis.Scale.Min + yScaleRange * ScaleFactor; - var x = CalculateScaleRange(zedGraphWaveform.GraphPane.XAxis.Scale) * 0.05; + var x = xScaleRange * ScaleFactor * 2; var y = 1 / (ChannelScale * 2); // NB: Equal to 1/2 of the max peak-to-peak amplitude + double maxValueY = yScaleRange * 0.25; + + double yScaleValue = GetPeakToPeakAmplitudeInMicroAmps() / 2; + + if (y > maxValueY) + { + double ratio = y / maxValueY; + yScaleValue /= ratio; + y /= ratio; + } + PointPairList points = new() { { zeroOffsetX, zeroOffsetY + y }, @@ -274,18 +245,25 @@ void DrawScale() { zeroOffsetX + x, zeroOffsetY } }; - var line = zedGraphWaveform.GraphPane.AddCurve("scale", points, Color.Black, SymbolType.None); - line.Line.Width = 3; + float lineWidth = 3; + + var line = zedGraphWaveform.GraphPane.AddCurve("scale", points, Color.Black, SymbolType.Square); + line.Line.Width = lineWidth; line.Label.IsVisible = false; + line.Symbol.Size = lineWidth; + line.Symbol.Border.IsVisible = false; + line.Symbol.Fill = new Fill(Color.Black); zedGraphWaveform.GraphPane.CurveList.Move(zedGraphWaveform.GraphPane.CurveList.Count - 1, -99); - TextObj timeScale = new(GetTimeScaleString(x) + " ms", zeroOffsetX + x * 1.02, zeroOffsetY, CoordType.AxisXYScale, AlignH.Left, AlignV.Center); + const double TextObjScaleFactor = 1.02; + + TextObj timeScale = new(GetTimeScaleString(x) + " ms", zeroOffsetX + x * TextObjScaleFactor, zeroOffsetY, CoordType.AxisXYScale, AlignH.Left, AlignV.Center); timeScale.FontSpec.Border.IsVisible = false; timeScale.FontSpec.Fill.IsVisible = false; timeScale.ZOrder = ZOrder.A_InFront; zedGraphWaveform.GraphPane.GraphObjList.Add(timeScale); - TextObj amplitudeScale = new(((PeakToPeak == ZeroPeakToPeak ? 0 : PeakToPeak) / (ChannelScale * 2)).ToString("0.##") + " " + yAxisScale, zeroOffsetX, zeroOffsetY + y * 1.02, CoordType.AxisXYScale, AlignH.Left, AlignV.Bottom); + TextObj amplitudeScale = new(yScaleValue.ToString("0.##") + " µA", zeroOffsetX, zeroOffsetY + y * TextObjScaleFactor, CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom); amplitudeScale.FontSpec.Border.IsVisible = false; amplitudeScale.FontSpec.Fill.IsVisible = false; amplitudeScale.ZOrder = ZOrder.A_InFront; @@ -367,24 +345,6 @@ internal void RemoveYAxisLabels() zedGraphWaveform.GraphPane.YAxis.IsVisible = false; } - double ZoomOutBoundaryLeft = default; - double ZoomOutBoundaryRight = default; - double ZoomOutBoundaryBottom = default; - double ZoomOutBoundaryTop = default; - double? ZoomInBoundaryX = 5; - readonly double? ZoomInBoundaryY = 2; - - void SetZoomOutBoundaries(ZedGraphControl zedGraphControl) - { - var rangeX = CalculateScaleRange(zedGraphControl.GraphPane.XAxis.Scale); - var marginX = rangeX * 0.03; - - ZoomOutBoundaryLeft = zedGraphControl.GraphPane.XAxis.Scale.Min; - ZoomOutBoundaryBottom = zedGraphControl.GraphPane.YAxis.Scale.Min; - ZoomOutBoundaryRight = zedGraphControl.GraphPane.XAxis.Scale.Max + marginX; - ZoomOutBoundaryTop = zedGraphControl.GraphPane.YAxis.Scale.Max; - } - internal static double CalculateScaleRange(Scale scale) { return scale.Max - scale.Min; @@ -400,16 +360,6 @@ static PointD TransformPixelsToCoordinates(Point pixels, GraphPane graphPane) void CenterAxesOnCursor(ZedGraphControl zedGraphControl) { - if ((zedGraphControl.GraphPane.XAxis.Scale.Min == ZoomOutBoundaryLeft && - zedGraphControl.GraphPane.XAxis.Scale.Max == ZoomOutBoundaryRight && - zedGraphControl.GraphPane.YAxis.Scale.Min == ZoomOutBoundaryBottom && - zedGraphControl.GraphPane.YAxis.Scale.Max == ZoomOutBoundaryTop) || - ZoomInBoundaryX.HasValue && CalculateScaleRange(zedGraphControl.GraphPane.XAxis.Scale) == ZoomInBoundaryX.Value || - ZoomInBoundaryY.HasValue && CalculateScaleRange(zedGraphControl.GraphPane.YAxis.Scale) == ZoomInBoundaryY.Value) - { - return; - } - var mouseClientPosition = PointToClient(Cursor.Position); mouseClientPosition.X -= (zedGraphControl.Parent.Width - zedGraphControl.Width) / 2; mouseClientPosition.Y += (zedGraphControl.Parent.Height - zedGraphControl.Height) / 2; @@ -429,98 +379,6 @@ void CenterAxesOnCursor(ZedGraphControl zedGraphControl) zedGraphControl.GraphPane.YAxis.Scale.Max += diffY; } - /// - /// Checks if the is too zoomed in or out. If the graph is too zoomed in, - /// reset the boundaries to match and . If the graph is too zoomed out, - /// reset the boundaries to match the automatically generated boundaries based on the size of the waveforms. - /// - /// A object. - /// True if the zoom boundary has been correctly handled, False if the previous zoom state should be reinstated. - bool CheckZoomBoundaries(ZedGraphControl zedGraphControl) - { - var rangeX = CalculateScaleRange(zedGraphControl.GraphPane.XAxis.Scale); - var rangeY = CalculateScaleRange(zedGraphControl.GraphPane.YAxis.Scale); - - if (ZoomInBoundaryX.HasValue && rangeX < ZoomInBoundaryX) - { - if (ZoomInBoundaryX.HasValue && Math.Round(rangeX / ZoomInBoundaryX.Value, 2) == zedGraphControl.ZoomStepFraction) - { - return false; - } - else - { - if (ZoomInBoundaryX.HasValue && ZoomInBoundaryX.Value > 0) - { - var diffX = (ZoomInBoundaryX.Value - rangeX) / 2; - zedGraphControl.GraphPane.XAxis.Scale.Min -= diffX; - zedGraphControl.GraphPane.XAxis.Scale.Max += diffX; - } - } - } - - if (ZoomInBoundaryY.HasValue && rangeY < ZoomInBoundaryY) - { - if (ZoomInBoundaryY.HasValue && Math.Round(rangeY / ZoomInBoundaryY.Value, 2) == zedGraphControl.ZoomStepFraction) - return false; - else - { - if (ZoomInBoundaryY.HasValue && ZoomInBoundaryY.Value > 0) - { - var diffY = (ZoomInBoundaryY.Value - rangeY) / 2; - zedGraphControl.GraphPane.YAxis.Scale.Min -= diffY; - zedGraphControl.GraphPane.YAxis.Scale.Max += diffY; - } - } - } - - if (CalculateScaleRange(zedGraphControl.GraphPane.XAxis.Scale) >= ZoomOutBoundaryRight - ZoomOutBoundaryLeft) - { - zedGraphControl.GraphPane.XAxis.Scale.Min = ZoomOutBoundaryLeft; - zedGraphControl.GraphPane.XAxis.Scale.Max = ZoomOutBoundaryRight; - } - else - { - if (zedGraphControl.GraphPane.XAxis.Scale.Min < ZoomOutBoundaryLeft) - { - var diffX = ZoomOutBoundaryLeft - zedGraphControl.GraphPane.XAxis.Scale.Min; - zedGraphControl.GraphPane.XAxis.Scale.Min += diffX; - zedGraphControl.GraphPane.XAxis.Scale.Max += diffX; - } - - if (zedGraphControl.GraphPane.XAxis.Scale.Max > ZoomOutBoundaryRight) - { - var diffX = zedGraphControl.GraphPane.XAxis.Scale.Max - ZoomOutBoundaryRight; - zedGraphControl.GraphPane.XAxis.Scale.Min -= diffX; - zedGraphControl.GraphPane.XAxis.Scale.Max -= diffX; - } - - } - - if (CalculateScaleRange(zedGraphControl.GraphPane.YAxis.Scale) >= ZoomOutBoundaryTop - ZoomOutBoundaryBottom) - { - zedGraphControl.GraphPane.YAxis.Scale.Min = ZoomOutBoundaryBottom; - zedGraphControl.GraphPane.YAxis.Scale.Max = ZoomOutBoundaryTop; - } - else - { - if (zedGraphControl.GraphPane.YAxis.Scale.Min < ZoomOutBoundaryBottom) - { - var diffY = ZoomOutBoundaryBottom - zedGraphControl.GraphPane.YAxis.Scale.Min; - zedGraphControl.GraphPane.YAxis.Scale.Min += diffY; - zedGraphControl.GraphPane.YAxis.Scale.Max += diffY; - } - - if (zedGraphControl.GraphPane.YAxis.Scale.Max > ZoomOutBoundaryTop) - { - var diffY = zedGraphControl.GraphPane.YAxis.Scale.Max - ZoomOutBoundaryTop; - zedGraphControl.GraphPane.YAxis.Scale.Min -= diffY; - zedGraphControl.GraphPane.YAxis.Scale.Max -= diffY; - } - } - - return true; - } - internal virtual bool IsSequenceValid() { return true; @@ -627,5 +485,19 @@ internal virtual void SetTableDataSource() if (UseTable) throw new NotImplementedException(); } + + void ResetZoom_Click(object sender, EventArgs e) + { + ResetZoom(); + } + + void ResetZoom() + { + zedGraphWaveform.ZoomOutAll(zedGraphWaveform.GraphPane); + DrawStimulusWaveform(false); + zedGraphWaveform.AxisChange(); + zedGraphWaveform.Refresh(); + } + } } diff --git a/OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorSequenceDialog.cs b/OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorSequenceDialog.cs index 0be9ad7..67e5d29 100644 --- a/OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorSequenceDialog.cs +++ b/OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorSequenceDialog.cs @@ -127,9 +127,6 @@ public Headstage64ElectricalStimulatorSequenceDialog(ConfigureHeadstage64Electri toolStripStatusIsValid.BorderSides = ToolStripStatusLabelBorderSides.None; - YAxisMax = 1; - YAxisMin = -2; - SetXAxisTitle("Time [µs]"); SetYAxisTitle(""); RemoveYAxisLabels(); @@ -290,14 +287,19 @@ internal override bool CanCloseForm(out DialogResult result) } } + internal override double GetPeakToPeakAmplitudeInMicroAmps() + { + var peakToPeak = (Math.Max(Math.Max(ElectricalStimulator.PhaseOneCurrent, ElectricalStimulator.PhaseTwoCurrent), ElectricalStimulator.InterPhaseCurrent) + + Math.Abs(Math.Min(Math.Min(ElectricalStimulator.PhaseOneCurrent, ElectricalStimulator.PhaseTwoCurrent), ElectricalStimulator.InterPhaseCurrent))) * ChannelScale; + + return peakToPeak == 0 ? ZeroPeakToPeak : peakToPeak; + } + internal override PointPairList[] CreateStimulusWaveforms() { PointPairList[] waveforms = new PointPairList[NumberOfChannels]; - PeakToPeak = (Math.Max(Math.Max(ElectricalStimulator.PhaseOneCurrent, ElectricalStimulator.PhaseTwoCurrent), ElectricalStimulator.InterPhaseCurrent) - + Math.Abs(Math.Min(Math.Min(ElectricalStimulator.PhaseOneCurrent, ElectricalStimulator.PhaseTwoCurrent), ElectricalStimulator.InterPhaseCurrent))) * ChannelScale; - - PeakToPeak = PeakToPeak == 0 ? ZeroPeakToPeak : PeakToPeak; + var peakToPeak = GetPeakToPeakAmplitudeInMicroAmps(); if (ElectricalStimulator != null) { @@ -309,12 +311,12 @@ internal override PointPairList[] CreateStimulusWaveforms() { for (int j = 0; j < ElectricalStimulator.BurstPulseCount; j++) { - waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, ElectricalStimulator.PhaseOneCurrent / PeakToPeak)); - waveforms[channel].Add(new PointPair(waveforms[channel].Last().X + ElectricalStimulator.PhaseOneDuration, ElectricalStimulator.PhaseOneCurrent / PeakToPeak)); - waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, ElectricalStimulator.InterPhaseCurrent / PeakToPeak)); - waveforms[channel].Add(new PointPair(waveforms[channel].Last().X + ElectricalStimulator.InterPhaseInterval, ElectricalStimulator.InterPhaseCurrent / PeakToPeak)); - waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, ElectricalStimulator.PhaseTwoCurrent / PeakToPeak)); - waveforms[channel].Add(new PointPair(waveforms[channel].Last().X + ElectricalStimulator.PhaseTwoDuration, ElectricalStimulator.PhaseTwoCurrent / PeakToPeak)); + waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, ElectricalStimulator.PhaseOneCurrent / peakToPeak)); + waveforms[channel].Add(new PointPair(waveforms[channel].Last().X + ElectricalStimulator.PhaseOneDuration, ElectricalStimulator.PhaseOneCurrent / peakToPeak)); + waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, ElectricalStimulator.InterPhaseCurrent / peakToPeak)); + waveforms[channel].Add(new PointPair(waveforms[channel].Last().X + ElectricalStimulator.InterPhaseInterval, ElectricalStimulator.InterPhaseCurrent / peakToPeak)); + waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, ElectricalStimulator.PhaseTwoCurrent / peakToPeak)); + waveforms[channel].Add(new PointPair(waveforms[channel].Last().X + ElectricalStimulator.PhaseTwoDuration, ElectricalStimulator.PhaseTwoCurrent / peakToPeak)); waveforms[channel].Add(new PointPair(waveforms[channel].Last().X, 0)); if (j != ElectricalStimulator.BurstPulseCount - 1) diff --git a/OpenEphys.Onix1.Design/Headstage64OpticalStimulatorSequenceDialog.cs b/OpenEphys.Onix1.Design/Headstage64OpticalStimulatorSequenceDialog.cs index 222d2f0..de41c7a 100644 --- a/OpenEphys.Onix1.Design/Headstage64OpticalStimulatorSequenceDialog.cs +++ b/OpenEphys.Onix1.Design/Headstage64OpticalStimulatorSequenceDialog.cs @@ -136,9 +136,6 @@ public Headstage64OpticalStimulatorSequenceDialog(ConfigureHeadstage64OpticalSti DisableVerticalZoom(); - YAxisMax = NumberOfChannels + 1; - YAxisMin = 0; - DrawStimulusWaveform(); stimulusWaveformToolStripMenuItem.Text = "Optical Stimulus Sequence"; @@ -213,11 +210,16 @@ double GetChannelCurrentScaled(double maxCurrent, double channelPercent, double return (GetChannelCurrent(maxCurrent, channelPercent) / 100.0) / scale; } + internal override double GetPeakToPeakAmplitudeInMicroAmps() + { + return OpticalStimulator.MaxCurrent == 0 ? ZeroPeakToPeak : OpticalStimulator.MaxCurrent * ChannelScale; + } + internal override PointPairList[] CreateStimulusWaveforms() { PointPairList[] waveforms = new PointPairList[NumberOfChannels]; - PeakToPeak = OpticalStimulator.MaxCurrent == 0 ? ZeroPeakToPeak : OpticalStimulator.MaxCurrent * ChannelScale; + var peakToPeak = GetPeakToPeakAmplitudeInMicroAmps(); for (int channel = 0; channel < NumberOfChannels; channel++) { @@ -230,7 +232,7 @@ internal override PointPairList[] CreateStimulusWaveforms() var stimulusCurrent = offset + GetChannelCurrentScaled(OpticalStimulator.MaxCurrent, channel == 0 ? OpticalStimulator.ChannelOneCurrent : OpticalStimulator.ChannelTwoCurrent, - PeakToPeak); + peakToPeak); for (int i = 0; i < OpticalStimulator.BurstsPerTrain; i++) { diff --git a/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs b/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs index e83064e..c4ddd0d 100644 --- a/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs +++ b/OpenEphys.Onix1.Design/HeadstageRhs2116Dialog.Designer.cs @@ -53,7 +53,7 @@ private void InitializeComponent() this.tabControl.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(1138, 622); + this.tabControl.Size = new System.Drawing.Size(1328, 741); this.tabControl.TabIndex = 0; // // tabPageStimulusSequence @@ -62,7 +62,7 @@ private void InitializeComponent() this.tabPageStimulusSequence.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tabPageStimulusSequence.Name = "tabPageStimulusSequence"; this.tabPageStimulusSequence.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.tabPageStimulusSequence.Size = new System.Drawing.Size(1130, 593); + this.tabPageStimulusSequence.Size = new System.Drawing.Size(1320, 712); this.tabPageStimulusSequence.TabIndex = 1; this.tabPageStimulusSequence.Text = "Stimulus Sequence"; this.tabPageStimulusSequence.UseVisualStyleBackColor = true; @@ -72,7 +72,7 @@ private void InitializeComponent() this.tabPageRhs2116.Location = new System.Drawing.Point(4, 25); this.tabPageRhs2116.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tabPageRhs2116.Name = "tabPageRhs2116"; - this.tabPageRhs2116.Size = new System.Drawing.Size(1133, 429); + this.tabPageRhs2116.Size = new System.Drawing.Size(1130, 593); this.tabPageRhs2116.TabIndex = 2; this.tabPageRhs2116.Text = "Rhs2116"; this.tabPageRhs2116.UseVisualStyleBackColor = true; @@ -81,7 +81,7 @@ private void InitializeComponent() // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(991, 2); + this.buttonCancel.Location = new System.Drawing.Point(1181, 2); this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(144, 32); @@ -92,7 +92,7 @@ private void InitializeComponent() // buttonOK // this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(841, 2); + this.buttonOK.Location = new System.Drawing.Point(1031, 2); this.buttonOK.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(144, 32); @@ -109,7 +109,7 @@ private void InitializeComponent() this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); - this.menuStrip.Size = new System.Drawing.Size(1144, 24); + this.menuStrip.Size = new System.Drawing.Size(1334, 24); this.menuStrip.TabIndex = 3; this.menuStrip.Text = "menuStrip1"; // @@ -131,7 +131,7 @@ private void InitializeComponent() this.tableLayoutPanel1.RowCount = 2; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 42F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1144, 668); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1334, 787); this.tableLayoutPanel1.TabIndex = 4; // // flowLayoutPanel1 @@ -140,16 +140,16 @@ private void InitializeComponent() this.flowLayoutPanel1.Controls.Add(this.buttonOK); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 629); + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 748); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(1138, 36); + this.flowLayoutPanel1.Size = new System.Drawing.Size(1328, 36); this.flowLayoutPanel1.TabIndex = 1; // // HeadstageRhs2116Dialog // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1144, 692); + this.ClientSize = new System.Drawing.Size(1334, 811); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.menuStrip); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); diff --git a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs index 54dd3de..07f43eb 100644 --- a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs +++ b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceDialog.cs @@ -1,9 +1,9 @@ -using System.Windows.Forms; -using System; +using System; using System.Drawing; +using System.IO; using System.Linq; +using System.Windows.Forms; using ZedGraph; -using System.IO; namespace OpenEphys.Onix1.Design { @@ -83,26 +83,29 @@ public Rhs2116StimulusSequenceDialog(Rhs2116StimulusSequencePair sequence, Rhs21 StimulusSequenceOptions.checkBoxAnodicFirst.CheckedChanged += Checkbox_CheckedChanged; StimulusSequenceOptions.checkboxBiphasicSymmetrical.CheckedChanged += Checkbox_CheckedChanged; - StimulusSequenceOptions.textboxPulseWidthCathodic.KeyPress += ParameterKeyPress_Time; + StimulusSequenceOptions.textboxPulseWidthCathodic.KeyDown += ParameterKeyDown_Time; StimulusSequenceOptions.textboxPulseWidthCathodic.Leave += Samples_TextChanged; - StimulusSequenceOptions.textboxPulseWidthAnodic.KeyPress += ParameterKeyPress_Time; + StimulusSequenceOptions.textboxPulseWidthAnodic.KeyDown += ParameterKeyDown_Time; StimulusSequenceOptions.textboxPulseWidthAnodic.Leave += Samples_TextChanged; - StimulusSequenceOptions.textboxInterPulseInterval.KeyPress += ParameterKeyPress_Time; + StimulusSequenceOptions.textboxInterPulseInterval.KeyDown += ParameterKeyDown_Time; StimulusSequenceOptions.textboxInterPulseInterval.Leave += Samples_TextChanged; - StimulusSequenceOptions.textboxDelay.KeyPress += ParameterKeyPress_Time; + StimulusSequenceOptions.textboxDelay.KeyDown += ParameterKeyDown_Time; StimulusSequenceOptions.textboxDelay.Leave += Samples_TextChanged; - StimulusSequenceOptions.textboxInterStimulusInterval.KeyPress += ParameterKeyPress_Time; + StimulusSequenceOptions.textboxInterStimulusInterval.KeyDown += ParameterKeyDown_Time; StimulusSequenceOptions.textboxInterStimulusInterval.Leave += Samples_TextChanged; StimulusSequenceOptions.textboxAmplitudeAnodicRequested.Leave += Amplitude_TextChanged; - StimulusSequenceOptions.textboxAmplitudeAnodicRequested.KeyPress += ParameterKeyPress_Amplitude; + StimulusSequenceOptions.textboxAmplitudeAnodicRequested.KeyDown += ParameterKeyDown_Amplitude; StimulusSequenceOptions.textboxAmplitudeCathodicRequested.Leave += Amplitude_TextChanged; - StimulusSequenceOptions.textboxAmplitudeCathodicRequested.KeyPress += ParameterKeyPress_Amplitude; + StimulusSequenceOptions.textboxAmplitudeCathodicRequested.KeyDown += ParameterKeyDown_Amplitude; + + StimulusSequenceOptions.numericUpDownNumberOfPulses.KeyDown += NumericUpDownNumberOfPulses_KeyDown; + StimulusSequenceOptions.numericUpDownNumberOfPulses.Leave += NumericUpDownNumberOfPulses_Leave; StimulusSequenceOptions.Show(); @@ -200,11 +203,11 @@ internal override void HighlightInvalidChannels() ChannelDialog.RefreshZedGraph(); } - double GetPeakToPeakAmplitudeInMicroAmps() + internal override double GetPeakToPeakAmplitudeInMicroAmps() { return Sequence.MaximumPeakToPeakAmplitudeSteps > 0 ? Sequence.GetMaxPeakToPeakAmplitudeuA() - : Sequence.CurrentStepSizeuA * 1; // NB: Used to give a buffer when plotting the stimulus waveform + : Sequence.CurrentStepSizeuA; } PointPairList CreateStimulusWaveform(Rhs2116Stimulus stimulus, double yOffset, double peakToPeak) @@ -254,15 +257,15 @@ internal override PointPairList[] CreateStimulusWaveforms() bool plotAllContacts = ChannelDialog.SelectedContacts.All(x => x == false); - PeakToPeak = GetPeakToPeakAmplitudeInMicroAmps() * ChannelScale; + var peakToPeak = GetPeakToPeakAmplitudeInMicroAmps() * ChannelScale; for (int i = 0; i < Sequence.Stimuli.Length; i++) { - var channelOffset = -PeakToPeak * i; + var channelOffset = -peakToPeak * i; if (ChannelDialog.SelectedContacts[i] || plotAllContacts) { - waveforms[i] = CreateStimulusWaveform(Sequence.Stimuli[i], channelOffset, PeakToPeak); + waveforms[i] = CreateStimulusWaveform(Sequence.Stimuli[i], channelOffset, peakToPeak); } else { @@ -270,9 +273,6 @@ internal override PointPairList[] CreateStimulusWaveforms() } } - YAxisMin = -2; - YAxisMax = NumberOfChannels; - return waveforms; } @@ -376,12 +376,6 @@ bool GetSampleFromAmplitude(double value, Rhs2116StepSize stepSize, out byte sam void ButtonAddPulses_Click(object sender, EventArgs e) { - if (ChannelDialog.SelectedContacts.All(x => x == false)) - { - MessageBox.Show("No contacts selected. Please select contact(s) before trying to add pulses."); - return; - } - var stimuli = Sequence.Stimuli .Select((s, ind) => { return (Index: ind, Stimulus: s); }) .Where(s => s.Stimulus.Valid @@ -515,11 +509,7 @@ void ButtonAddPulses_Click(object sender, EventArgs e) Sequence.Stimuli[i].InterStimulusIntervalSamples = (uint)StimulusSequenceOptions.textboxInterStimulusInterval.Tag; } - if (uint.TryParse(StimulusSequenceOptions.textboxNumberOfStimuli.Text, out uint numberOfStimuliValue)) - { - Sequence.Stimuli[i].NumberOfStimuli = numberOfStimuliValue; - } - + Sequence.Stimuli[i].NumberOfStimuli = (uint)StimulusSequenceOptions.numericUpDownNumberOfPulses.Value; Sequence.Stimuli[i].AnodicFirst = StimulusSequenceOptions.checkBoxAnodicFirst.Checked; } } @@ -527,6 +517,7 @@ void ButtonAddPulses_Click(object sender, EventArgs e) Sequence.CurrentStepSize = StepSize; ChannelDialog.HighlightEnabledContacts(); + DrawStimulusWaveform(); } @@ -672,25 +663,48 @@ void ButtonReadPulses_Click(object sender, EventArgs e) StimulusSequenceOptions.textboxInterStimulusInterval.Text = GetTimeString(Sequence.Stimuli[index].InterStimulusIntervalSamples); StimulusSequenceOptions.textboxInterStimulusInterval.Tag = Sequence.Stimuli[index].InterStimulusIntervalSamples; - StimulusSequenceOptions.textboxNumberOfStimuli.Text = Sequence.Stimuli[index].NumberOfStimuli.ToString(); + StimulusSequenceOptions.numericUpDownNumberOfPulses.Value = Sequence.Stimuli[index].NumberOfStimuli; } - void ParameterKeyPress_Time(object sender, KeyPressEventArgs e) + void ParameterKeyDown_Time(object sender, KeyEventArgs e) { - if (e.KeyChar == '\r') + if (e.KeyCode == Keys.Enter) { Samples_TextChanged(sender, e); + ButtonAddPulses_Click(sender, e); + + e.Handled = true; + e.SuppressKeyPress = true; } } - void ParameterKeyPress_Amplitude(object sender, KeyPressEventArgs e) + void ParameterKeyDown_Amplitude(object sender, KeyEventArgs e) { - if (e.KeyChar == '\r') + if (e.KeyCode == Keys.Enter) { Amplitude_TextChanged(sender, e); + ButtonAddPulses_Click(sender, e); + + e.Handled = true; + e.SuppressKeyPress = true; } } + void NumericUpDownNumberOfPulses_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + ButtonAddPulses_Click(sender, e); + e.Handled = true; + e.SuppressKeyPress = true; + } + } + + void NumericUpDownNumberOfPulses_Leave(object sender, EventArgs e) + { + ButtonAddPulses_Click(sender, e); + } + void Samples_TextChanged(object sender, EventArgs e) { TextBox textBox = (TextBox)sender; @@ -758,6 +772,8 @@ void Samples_TextChanged(object sender, EventArgs e) StimulusSequenceOptions.textboxPulseWidthAnodic.Text = textBox.Text; StimulusSequenceOptions.textboxPulseWidthAnodic.Tag = textBox.Tag; } + + ButtonAddPulses_Click(sender, e); } bool GetSampleFromTime(double value, out uint samples) diff --git a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceOptions.Designer.cs b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceOptions.Designer.cs index 8ec07c7..b8f24ee 100644 --- a/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceOptions.Designer.cs +++ b/OpenEphys.Onix1.Design/Rhs2116StimulusSequenceOptions.Designer.cs @@ -30,6 +30,7 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Rhs2116StimulusSequenceOptions)); this.panelParameters = new System.Windows.Forms.Panel(); + this.numericUpDownNumberOfPulses = new System.Windows.Forms.NumericUpDown(); this.textBoxStepSize = new System.Windows.Forms.TextBox(); this.groupBoxCathode = new System.Windows.Forms.GroupBox(); this.textboxAmplitudeCathodic = new System.Windows.Forms.TextBox(); @@ -53,11 +54,11 @@ private void InitializeComponent() this.textboxDelay = new System.Windows.Forms.TextBox(); this.labelNumberOfPulses = new System.Windows.Forms.Label(); this.labelDelay = new System.Windows.Forms.Label(); - this.textboxNumberOfStimuli = new System.Windows.Forms.TextBox(); this.checkboxBiphasicSymmetrical = new System.Windows.Forms.CheckBox(); this.textboxInterStimulusInterval = new System.Windows.Forms.TextBox(); this.labelInterStimulusInterval = new System.Windows.Forms.Label(); this.panelParameters.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPulses)).BeginInit(); this.groupBoxCathode.SuspendLayout(); this.groupBoxAnode.SuspendLayout(); this.SuspendLayout(); @@ -65,6 +66,7 @@ private void InitializeComponent() // panelParameters // this.panelParameters.AutoScroll = true; + this.panelParameters.Controls.Add(this.numericUpDownNumberOfPulses); this.panelParameters.Controls.Add(this.textBoxStepSize); this.panelParameters.Controls.Add(this.groupBoxCathode); this.panelParameters.Controls.Add(this.groupBoxAnode); @@ -78,7 +80,6 @@ private void InitializeComponent() this.panelParameters.Controls.Add(this.textboxDelay); this.panelParameters.Controls.Add(this.labelNumberOfPulses); this.panelParameters.Controls.Add(this.labelDelay); - this.panelParameters.Controls.Add(this.textboxNumberOfStimuli); this.panelParameters.Controls.Add(this.checkboxBiphasicSymmetrical); this.panelParameters.Controls.Add(this.textboxInterStimulusInterval); this.panelParameters.Controls.Add(this.labelInterStimulusInterval); @@ -89,6 +90,23 @@ private void InitializeComponent() this.panelParameters.Size = new System.Drawing.Size(438, 289); this.panelParameters.TabIndex = 1; // + // numericUpDownNumberOfPulses + // + this.numericUpDownNumberOfPulses.Location = new System.Drawing.Point(363, 203); + this.numericUpDownNumberOfPulses.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.numericUpDownNumberOfPulses.Name = "numericUpDownNumberOfPulses"; + this.numericUpDownNumberOfPulses.Size = new System.Drawing.Size(55, 22); + this.numericUpDownNumberOfPulses.TabIndex = 13; + this.numericUpDownNumberOfPulses.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // // textBoxStepSize // this.textBoxStepSize.Enabled = false; @@ -320,14 +338,6 @@ private void InitializeComponent() this.labelDelay.TabIndex = 4; this.labelDelay.Text = "Delay [ms]"; // - // textboxNumberOfStimuli - // - this.textboxNumberOfStimuli.Location = new System.Drawing.Point(363, 202); - this.textboxNumberOfStimuli.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.textboxNumberOfStimuli.Name = "textboxNumberOfStimuli"; - this.textboxNumberOfStimuli.Size = new System.Drawing.Size(55, 22); - this.textboxNumberOfStimuli.TabIndex = 13; - // // checkboxBiphasicSymmetrical // this.checkboxBiphasicSymmetrical.AutoSize = true; @@ -371,6 +381,7 @@ private void InitializeComponent() this.Text = "Rhs2116StimulusSequenceOptions"; this.panelParameters.ResumeLayout(false); this.panelParameters.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPulses)).EndInit(); this.groupBoxCathode.ResumeLayout(false); this.groupBoxCathode.PerformLayout(); this.groupBoxAnode.ResumeLayout(false); @@ -405,9 +416,9 @@ private void InitializeComponent() internal System.Windows.Forms.TextBox textboxDelay; private System.Windows.Forms.Label labelNumberOfPulses; private System.Windows.Forms.Label labelDelay; - internal System.Windows.Forms.TextBox textboxNumberOfStimuli; internal System.Windows.Forms.CheckBox checkboxBiphasicSymmetrical; internal System.Windows.Forms.TextBox textboxInterStimulusInterval; private System.Windows.Forms.Label labelInterStimulusInterval; + internal System.Windows.Forms.NumericUpDown numericUpDownNumberOfPulses; } }