-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- This is almost exactly identical to the NeuropixelsV2e GUI, due to the many similarities - Adds dialogs at all levels (probe / device / headstage)
- Loading branch information
Showing
13 changed files
with
4,290 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
OpenEphys.Onix1.Design/NeuropixelsV2eBetaDialog.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Windows.Forms; | ||
|
||
namespace OpenEphys.Onix1.Design | ||
{ | ||
/// <summary> | ||
/// Partial class to create a GUI for <see cref="ConfigureNeuropixelsV2e"/>. | ||
/// </summary> | ||
public partial class NeuropixelsV2eBetaDialog : Form | ||
{ | ||
readonly IReadOnlyList<NeuropixelsV2eProbeConfigurationDialog> ProbeConfigurations; | ||
|
||
/// <summary> | ||
/// Public <see cref="ConfigureNeuropixelsV2eBeta"/> object that is manipulated by | ||
/// <see cref="NeuropixelsV2eBetaDialog"/>. | ||
/// </summary> | ||
public ConfigureNeuropixelsV2eBeta ConfigureNode { get; set; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of <see cref="NeuropixelsV2eBetaDialog"/>. | ||
/// </summary> | ||
/// <param name="configureNode">A <see cref="ConfigureNeuropixelsV2eBeta"/> object holding the current configuration settings.</param> | ||
public NeuropixelsV2eBetaDialog(ConfigureNeuropixelsV2eBeta configureNode) | ||
{ | ||
InitializeComponent(); | ||
Shown += FormShown; | ||
|
||
ConfigureNode = new(configureNode); | ||
|
||
ProbeConfigurations = new List<NeuropixelsV2eProbeConfigurationDialog> | ||
{ | ||
new(ConfigureNode.ProbeConfigurationA, ConfigureNode.GainCalibrationFileA) | ||
{ | ||
TopLevel = false, | ||
FormBorderStyle = FormBorderStyle.None, | ||
Dock = DockStyle.Fill, | ||
Parent = this, | ||
Tag = NeuropixelsV2Probe.ProbeA | ||
}, | ||
new(ConfigureNode.ProbeConfigurationB, ConfigureNode.GainCalibrationFileB) | ||
{ | ||
TopLevel = false, | ||
FormBorderStyle = FormBorderStyle.None, | ||
Dock = DockStyle.Fill, | ||
Parent = this, | ||
Tag = NeuropixelsV2Probe.ProbeB | ||
} | ||
}; | ||
|
||
foreach (var channelConfiguration in ProbeConfigurations) | ||
{ | ||
string probeName = GetProbeName((NeuropixelsV2Probe)channelConfiguration.Tag); | ||
|
||
tabControlProbe.TabPages.Add(probeName, probeName); | ||
tabControlProbe.TabPages[probeName].Controls.Add(channelConfiguration); | ||
this.AddMenuItemsFromDialogToFileOption(channelConfiguration, probeName); | ||
} | ||
} | ||
|
||
private string GetProbeName(NeuropixelsV2Probe probe) | ||
{ | ||
return probe switch | ||
{ | ||
NeuropixelsV2Probe.ProbeA => "Probe A", | ||
NeuropixelsV2Probe.ProbeB => "Probe B", | ||
_ => throw new ArgumentException("Invalid probe was specified.") | ||
}; | ||
} | ||
|
||
private int GetProbeIndex(NeuropixelsV2Probe probe) | ||
{ | ||
return probe == NeuropixelsV2Probe.ProbeA ? 0 : 1; | ||
} | ||
|
||
private void FormShown(object sender, EventArgs e) | ||
{ | ||
if (!TopLevel) | ||
{ | ||
tableLayoutPanel1.Controls.Remove(flowLayoutPanel1); | ||
tableLayoutPanel1.RowCount = 1; | ||
|
||
menuStrip.Visible = false; | ||
} | ||
|
||
foreach (var channelConfiguration in ProbeConfigurations) | ||
{ | ||
channelConfiguration.Show(); | ||
} | ||
} | ||
|
||
internal void ButtonClick(object sender, EventArgs e) | ||
{ | ||
if (sender is Button button && button != null) | ||
{ | ||
if (button.Name == nameof(buttonOkay)) | ||
{ | ||
SaveVariables(); | ||
|
||
DialogResult = DialogResult.OK; | ||
} | ||
else if (button.Name == nameof(buttonCancel)) | ||
{ | ||
DialogResult = DialogResult.Cancel; | ||
} | ||
} | ||
} | ||
|
||
internal void SaveVariables() | ||
{ | ||
ConfigureNode.ProbeConfigurationA = ProbeConfigurations[GetProbeIndex(NeuropixelsV2Probe.ProbeA)].ProbeConfiguration; | ||
ConfigureNode.ProbeConfigurationB = ProbeConfigurations[GetProbeIndex(NeuropixelsV2Probe.ProbeB)].ProbeConfiguration; | ||
|
||
ConfigureNode.GainCalibrationFileA = ProbeConfigurations[GetProbeIndex(NeuropixelsV2Probe.ProbeA)].textBoxProbeCalibrationFile.Text; | ||
ConfigureNode.GainCalibrationFileB = ProbeConfigurations[GetProbeIndex(NeuropixelsV2Probe.ProbeB)].textBoxProbeCalibrationFile.Text; | ||
} | ||
} | ||
} |
Oops, something went wrong.