@@ -9,12 +9,33 @@ namespace OpenEphys.Onix1.Design
99 /// </summary>
1010 public partial class NeuropixelsV2eDialog : Form
1111 {
12- readonly IReadOnlyList < NeuropixelsV2eProbeConfigurationDialog > ProbeConfigurations ;
12+ internal readonly Dictionary < NeuropixelsV2Probe , NeuropixelsV2eProbeConfigurationDialog > ProbeConfigurations ;
13+
14+ internal NeuropixelsV2ProbeConfiguration ProbeConfigurationA
15+ {
16+ get
17+ {
18+ return ProbeConfigurations . TryGetValue ( NeuropixelsV2Probe . ProbeA , out var probeConfigurationDialog )
19+ ? probeConfigurationDialog . ProbeConfiguration
20+ : throw new NullReferenceException ( "Unable to find the probe configuration dialog for Probe A." ) ;
21+ }
22+ }
23+
24+ internal NeuropixelsV2ProbeConfiguration ProbeConfigurationB
25+ {
26+ get
27+ {
28+ return ProbeConfigurations . TryGetValue ( NeuropixelsV2Probe . ProbeB , out var probeConfigurationDialog )
29+ ? probeConfigurationDialog . ProbeConfiguration
30+ : throw new NullReferenceException ( "Unable to find the probe configuration dialog for Probe B." ) ;
31+ }
32+ }
1333
1434 /// <summary>
1535 /// Public <see cref="IConfigureNeuropixelsV2"/> interface that is manipulated by
1636 /// <see cref="NeuropixelsV2eDialog"/>.
1737 /// </summary>
38+ [ Obsolete ]
1839 public IConfigureNeuropixelsV2 ConfigureNode { get ; set ; }
1940
2041 /// <summary>
@@ -26,75 +47,27 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)
2647 InitializeComponent ( ) ;
2748 Shown += FormShown ;
2849
29- if ( configureNode is ConfigureNeuropixelsV2eBeta configureV2eBeta )
50+ if ( configureNode is ConfigureNeuropixelsV2eBeta )
3051 {
31- ConfigureNode = new ConfigureNeuropixelsV2eBeta ( configureV2eBeta ) ;
3252 Text = Text . Replace ( "NeuropixelsV2e " , "NeuropixelsV2eBeta " ) ;
3353 }
34- else if ( configureNode is ConfigureNeuropixelsV2e configureV2e )
35- {
36- ConfigureNode = new ConfigureNeuropixelsV2e ( configureV2e ) ;
37- }
3854
39- ProbeConfigurations = new List < NeuropixelsV2eProbeConfigurationDialog >
55+ ProbeConfigurations = new ( )
4056 {
41- new ( ConfigureNode . ProbeConfigurationA , ConfigureNode . GainCalibrationFileA , ConfigureNode . InvertPolarity )
42- {
43- TopLevel = false ,
44- FormBorderStyle = FormBorderStyle . None ,
45- Dock = DockStyle . Fill ,
46- Parent = this ,
47- Tag = NeuropixelsV2Probe . ProbeA
48- } ,
49- new ( ConfigureNode . ProbeConfigurationB , ConfigureNode . GainCalibrationFileB , ConfigureNode . InvertPolarity )
50- {
51- TopLevel = false ,
52- FormBorderStyle = FormBorderStyle . None ,
53- Dock = DockStyle . Fill ,
54- Parent = this ,
55- Tag = NeuropixelsV2Probe . ProbeB
56- }
57+ { NeuropixelsV2Probe . ProbeA , new ( configureNode . ProbeConfigurationA ) } ,
58+ { NeuropixelsV2Probe . ProbeB , new ( configureNode . ProbeConfigurationB ) }
5759 } ;
5860
5961 foreach ( var channelConfiguration in ProbeConfigurations )
6062 {
61- channelConfiguration . InvertPolarityChanged += InvertPolarityChanged ;
62-
63- string probeName = GetProbeName ( ( NeuropixelsV2Probe ) channelConfiguration . Tag ) ;
63+ string probeName = channelConfiguration . Key . ToString ( ) ;
6464
6565 tabControlProbe . TabPages . Add ( probeName , probeName ) ;
66- tabControlProbe . TabPages [ probeName ] . Controls . Add ( channelConfiguration ) ;
67- this . AddMenuItemsFromDialogToFileOption ( channelConfiguration , probeName ) ;
66+ channelConfiguration . Value . SetChildFormProperties ( this ) . AddDialogToTab ( tabControlProbe . TabPages [ probeName ] ) ;
67+ this . AddMenuItemsFromDialogToFileOption ( channelConfiguration . Value , probeName ) ;
6868 }
6969 }
7070
71- private void InvertPolarityChanged ( object sender , EventArgs e )
72- {
73- NeuropixelsV2eProbeConfigurationDialog sendingDialog = ( NeuropixelsV2eProbeConfigurationDialog ) sender ;
74- foreach ( var channelConfiguration in ProbeConfigurations )
75- {
76- if ( channelConfiguration . Tag != sendingDialog . Tag )
77- {
78- channelConfiguration . SetInvertPolarity ( sendingDialog . InvertPolarity ) ;
79- }
80- }
81- }
82-
83- private string GetProbeName ( NeuropixelsV2Probe probe )
84- {
85- return probe switch
86- {
87- NeuropixelsV2Probe . ProbeA => "Probe A" ,
88- NeuropixelsV2Probe . ProbeB => "Probe B" ,
89- _ => "Invalid probe was specified."
90- } ;
91- }
92-
93- private int GetProbeIndex ( NeuropixelsV2Probe probe )
94- {
95- return probe == NeuropixelsV2Probe . ProbeA ? 0 : 1 ;
96- }
97-
9871 private void FormShown ( object sender , EventArgs e )
9972 {
10073 if ( ! TopLevel )
@@ -107,26 +80,13 @@ private void FormShown(object sender, EventArgs e)
10780
10881 foreach ( var channelConfiguration in ProbeConfigurations )
10982 {
110- channelConfiguration . Show ( ) ;
83+ channelConfiguration . Value . Show ( ) ;
11184 }
11285 }
11386
11487 internal void Okay_Click ( object sender , EventArgs e )
11588 {
116- SaveVariables ( ) ;
117-
11889 DialogResult = DialogResult . OK ;
11990 }
120-
121- internal void SaveVariables ( )
122- {
123- ConfigureNode . ProbeConfigurationA = ProbeConfigurations [ GetProbeIndex ( NeuropixelsV2Probe . ProbeA ) ] . ProbeConfiguration ;
124- ConfigureNode . ProbeConfigurationB = ProbeConfigurations [ GetProbeIndex ( NeuropixelsV2Probe . ProbeB ) ] . ProbeConfiguration ;
125-
126- ConfigureNode . GainCalibrationFileA = ProbeConfigurations [ GetProbeIndex ( NeuropixelsV2Probe . ProbeA ) ] . textBoxProbeCalibrationFile . Text ;
127- ConfigureNode . GainCalibrationFileB = ProbeConfigurations [ GetProbeIndex ( NeuropixelsV2Probe . ProbeB ) ] . textBoxProbeCalibrationFile . Text ;
128-
129- ConfigureNode . InvertPolarity = ProbeConfigurations [ GetProbeIndex ( NeuropixelsV2Probe . ProbeA ) ] . InvertPolarity ;
130- }
13191 }
13292}
0 commit comments