Skip to content

Commit e5c2a11

Browse files
committed
Add PropertyGrid to stimulus sequence dialogs
- Remove constructor arguments from base class - Rhs2116 is not refactored, as the controls are not 1:1 tied to an underlying object, but are dynamic controls depending on what is selected
1 parent e6e3137 commit e5c2a11

19 files changed

+463
-509
lines changed

OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.Designer.cs

Lines changed: 89 additions & 125 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.cs

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ namespace OpenEphys.Onix1.Design
1212
/// </summary>
1313
public partial class GenericStimulusSequenceDialog : Form
1414
{
15+
internal object Device
16+
{
17+
get => propertyGrid.SelectedObject;
18+
set => propertyGrid.SelectedObject = value;
19+
}
20+
1521
readonly int NumberOfChannels;
16-
readonly bool UseProbeGroup;
17-
readonly bool UseTable;
1822

1923
internal const double ZeroPeakToPeak = 1e-12;
2024
internal readonly double ChannelScale = 1.1;
@@ -25,37 +29,23 @@ public partial class GenericStimulusSequenceDialog : Form
2529
InitializeComponent();
2630

2731
NumberOfChannels = 0;
28-
UseProbeGroup = true;
2932
}
3033

3134
/// <summary>
32-
/// Opens a dialog allowing for easy changing of stimulus sequence parameters, with visual feedback on what the resulting stimulus sequence looks like.
35+
/// Opens a dialog allowing for easy changing of stimulus sequence parameters,
36+
/// with visual feedback on what the resulting stimulus sequence looks like.
3337
/// </summary>
34-
public GenericStimulusSequenceDialog(int numberOfChannels, bool useProbeGroup, bool useTable = false)
38+
public GenericStimulusSequenceDialog(object device, int numberOfChannels)
3539
{
3640
InitializeComponent();
3741
Shown += FormShown;
3842

39-
NumberOfChannels = numberOfChannels;
40-
UseProbeGroup = useProbeGroup;
41-
UseTable = useTable;
43+
Device = device;
44+
bindingSource.DataSource = Device;
4245

43-
if (!UseProbeGroup)
44-
{
45-
tableLayoutPanel1.Controls.Remove(panelProbe);
46-
GroupBox gb = tableLayoutPanel1.Controls[nameof(groupBoxDefineStimuli)] as GroupBox;
47-
tableLayoutPanel1.SetRow(gb, 0);
48-
tableLayoutPanel1.SetRowSpan(gb, 2);
49-
}
50-
51-
if (!UseTable)
52-
{
53-
panelWaveform.Controls.Remove(tabControlVisualization);
54-
panelWaveform.Controls.Add(zedGraphWaveform);
55-
}
46+
NumberOfChannels = numberOfChannels;
5647

5748
InitializeZedGraphWaveform();
58-
SetTableDataSource();
5949

6050
zedGraphWaveform.ZoomEvent += OnZoom_Waveform;
6151
zedGraphWaveform.MouseMoveEvent += MouseMoveEvent;
@@ -210,8 +200,6 @@ internal void DrawStimulusWaveform(bool setZoomState = true)
210200
return Math.Abs(val).ToString("0");
211201
};
212202

213-
dataGridViewStimulusTable.Refresh();
214-
215203
if (setZoomState && XMin != 0 && XMax != 0)
216204
{
217205
zedGraphWaveform.GraphPane.XAxis.Scale.Min = XMin;
@@ -505,12 +493,6 @@ internal void HideMenuStrip()
505493
menuStrip.Enabled = false;
506494
}
507495

508-
internal virtual void SetTableDataSource()
509-
{
510-
if (UseTable)
511-
throw new NotImplementedException();
512-
}
513-
514496
void ResetZoom_Click(object sender, EventArgs e)
515497
{
516498
ResetZoom();
@@ -524,5 +506,9 @@ void ResetZoom()
524506
zedGraphWaveform.Refresh();
525507
}
526508

509+
void PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
510+
{
511+
DrawStimulusWaveform();
512+
}
527513
}
528514
}

OpenEphys.Onix1.Design/GenericStimulusSequenceDialog.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127127
<value>626, 12</value>
128128
</metadata>
129+
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130+
<value>724, 12</value>
131+
</metadata>
129132
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
130133
<value>25</value>
131134
</metadata>

OpenEphys.Onix1.Design/Headstage64Dialog.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenEphys.Onix1.Design/Headstage64Dialog.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public Headstage64Dialog(ConfigureHeadstage64 configureNode)
2222
{
2323
InitializeComponent();
2424

25-
Rhd2164Dialog = new(new ConfigureRhd2164(configureNode.Rhd2164));
25+
Rhd2164Dialog = new(configureNode.Rhd2164);
2626
Rhd2164Dialog.SetChildFormProperties(this).AddDialogToTab(tabPageRhd2164);
2727

28-
Bno055Dialog = new(new ConfigureBno055(configureNode.Bno055));
28+
Bno055Dialog = new(configureNode.Bno055);
2929
Bno055Dialog.SetChildFormProperties(this).AddDialogToTab(tabPageBno055);
3030

31-
TS4231V1Dialog = new(new ConfigureTS4231V1(configureNode.TS4231));
31+
TS4231V1Dialog = new(configureNode.TS4231);
3232
TS4231V1Dialog.SetChildFormProperties(this).AddDialogToTab(tabPageTS4231);
3333

3434
ElectricalStimulatorSequenceDialog = new(configureNode.ElectricalStimulator);

OpenEphys.Onix1.Design/Headstage64Editor.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon
1818
var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState));
1919
if (editorState != null && !editorState.WorkflowRunning && component is ConfigureHeadstage64 configureNode)
2020
{
21-
using var editorDialog = new Headstage64Dialog(configureNode);
21+
var configuration = new ConfigureHeadstage64(configureNode);
22+
23+
using var editorDialog = new Headstage64Dialog(configuration);
2224

2325
if (editorDialog.ShowDialog() == DialogResult.OK)
2426
{
@@ -27,10 +29,10 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon
2729
DesignHelper.CopyProperties((ConfigureTS4231V1)editorDialog.TS4231V1Dialog.Device, configureNode.TS4231, DesignHelper.PropertiesToIgnore);
2830

2931
if (editorDialog.ElectricalStimulatorSequenceDialog.DialogResult == DialogResult.OK)
30-
configureNode.ElectricalStimulator = editorDialog.ElectricalStimulatorSequenceDialog.ElectricalStimulator;
32+
DesignHelper.CopyProperties((ConfigureHeadstage64ElectricalStimulator)editorDialog.ElectricalStimulatorSequenceDialog.Device, configureNode.ElectricalStimulator, DesignHelper.PropertiesToIgnore);
3133

3234
if (editorDialog.OpticalStimulatorSequenceDialog.DialogResult == DialogResult.OK)
33-
configureNode.OpticalStimulator = editorDialog.OpticalStimulatorSequenceDialog.OpticalStimulator;
35+
DesignHelper.CopyProperties((ConfigureHeadstage64OpticalStimulator)editorDialog.OpticalStimulatorSequenceDialog.Device, configureNode.OpticalStimulator, DesignHelper.PropertiesToIgnore);
3436

3537
return true;
3638
}

OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorComponentEditor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public override bool EditComponent(ITypeDescriptorContext context, object compon
1515
var editorState = (IWorkflowEditorState)provider.GetService(typeof(IWorkflowEditorState));
1616
if (editorState != null && !editorState.WorkflowRunning && component is ConfigureHeadstage64ElectricalStimulator configureNode)
1717
{
18-
using var editorDialog = new Headstage64ElectricalStimulatorSequenceDialog(configureNode);
18+
var configuration = new ConfigureHeadstage64ElectricalStimulator(configureNode);
19+
20+
using var editorDialog = new Headstage64ElectricalStimulatorSequenceDialog(configuration);
1921

2022
if (editorDialog.ShowDialog() == DialogResult.OK)
2123
{

OpenEphys.Onix1.Design/Headstage64ElectricalStimulatorOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public Headstage64ElectricalStimulatorOptions()
2121
/// <param name="electricalStimulator"></param>
2222
public Headstage64ElectricalStimulatorOptions(ConfigureHeadstage64ElectricalStimulator electricalStimulator)
2323
: this()
24+
{
25+
UpdateControls(electricalStimulator);
26+
}
27+
28+
internal void UpdateControls(ConfigureHeadstage64ElectricalStimulator electricalStimulator)
2429
{
2530
textBoxPhaseOneCurrent.Text = electricalStimulator.PhaseOneCurrent.ToString();
2631
textBoxPhaseOneDuration.Text = electricalStimulator.PhaseOneDuration.ToString();

0 commit comments

Comments
 (0)