Skip to content

Commit 9eb4650

Browse files
committed
Minor modifications to neuropixels config GUIs
- Starting folder when browsing for calibration files is set to the previous location if it exists - File IO and access exceptions presented as MessageBoxs with error styling
1 parent 0b03555 commit 9eb4650

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

OpenEphys.Onix1.Design/NeuropixelsV1eDialog.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,12 @@ private void CheckStatus()
243243
}
244244
catch (IOException ex)
245245
{
246-
MessageBox.Show($"An I/O error occurred while parsing {ConfigureNode.AdcCalibrationFile}. Check the error log below." +
247-
$"\n\n" + ex.Message);
246+
MessageBox.Show(ex.Message, "I/O error", MessageBoxButtons.OK, MessageBoxIcon.Error);
248247
return;
249248
}
250249
catch (UnauthorizedAccessException ex)
251250
{
252-
MessageBox.Show($"An unauthorized access error occurred while parsing {ConfigureNode.AdcCalibrationFile}. Check the error log below." +
253-
$"\n\n" + ex.Message);
251+
MessageBox.Show(ex.Message, "Unauthorized access error", MessageBoxButtons.OK, MessageBoxIcon.Error);
254252
return;
255253
}
256254

@@ -275,14 +273,12 @@ private void CheckStatus()
275273
}
276274
catch (IOException ex)
277275
{
278-
MessageBox.Show($"An I/O error occurred while parsing {ConfigureNode.GainCalibrationFile}. Check the error log below." +
279-
$"\n\n" + ex.Message);
276+
MessageBox.Show(ex.Message, "I/O error", MessageBoxButtons.OK, MessageBoxIcon.Error);
280277
return;
281278
}
282279
catch (UnauthorizedAccessException ex)
283280
{
284-
MessageBox.Show($"An unauthorized access error occurred while parsing {ConfigureNode.GainCalibrationFile}. Check the error log below." +
285-
$"\n\n" + ex.Message);
281+
MessageBox.Show(ex.Message, "Unauthorized access error", MessageBoxButtons.OK, MessageBoxIcon.Error);
286282
return;
287283
}
288284

@@ -330,7 +326,11 @@ private void ChooseGainCalibrationFile_Click(object sender, EventArgs e)
330326
{
331327
CheckFileExists = true,
332328
Filter = "Gain calibration files (*_gainCalValues.csv)|*_gainCalValues.csv|All Files|*.*",
333-
FilterIndex = 0
329+
FilterIndex = 0,
330+
InitialDirectory = File.Exists(textBoxGainCalibrationFile.Text) ?
331+
Path.GetDirectoryName(textBoxGainCalibrationFile.Text) :
332+
""
333+
334334
};
335335

336336
if (ofd.ShowDialog() == DialogResult.OK)
@@ -347,7 +347,10 @@ private void ChooseAdcCalibrationFile_Click(object sender, EventArgs e)
347347
{
348348
CheckFileExists = true,
349349
Filter = "ADC calibration files (*_ADCCalibration.csv)|*_ADCCalibration.csv|All Files|*.*",
350-
FilterIndex = 0
350+
FilterIndex = 0,
351+
InitialDirectory = File.Exists(textBoxAdcCalibrationFile.Text) ?
352+
Path.GetDirectoryName(textBoxAdcCalibrationFile.Text) :
353+
""
351354
};
352355

353356
if (ofd.ShowDialog() == DialogResult.OK)

OpenEphys.Onix1.Design/NeuropixelsV2eProbeConfigurationDialog.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,12 @@ private void CheckStatus()
522522
}
523523
catch (IOException ex)
524524
{
525-
MessageBox.Show($"An I/O error occurred while parsing {textBoxProbeCalibrationFile.Text}. Check the error log below." +
526-
$"\n\n" + ex.Message);
525+
MessageBox.Show(ex.Message, "I/O error", MessageBoxButtons.OK, MessageBoxIcon.Error);
527526
return;
528527
}
529528
catch (UnauthorizedAccessException ex)
530529
{
531-
MessageBox.Show($"An unauthorized access error occurred while parsing {textBoxProbeCalibrationFile.Text}. Check the error log below." +
532-
$"\n\n" + ex.Message);
530+
MessageBox.Show(ex.Message, "Unauthorized access error", MessageBoxButtons.OK, MessageBoxIcon.Error);
533531
return;
534532
}
535533

@@ -550,7 +548,10 @@ internal void ChooseCalibrationFile_Click(object sender, EventArgs e)
550548
{
551549
CheckFileExists = true,
552550
Filter = "Gain calibration files (*_gainCalValues.csv)|*_gainCalValues.csv|All Files|*.*",
553-
FilterIndex = 0
551+
FilterIndex = 0,
552+
InitialDirectory = File.Exists(textBoxProbeCalibrationFile.Text) ?
553+
Path.GetDirectoryName(textBoxProbeCalibrationFile.Text) :
554+
""
554555
};
555556

556557
if (ofd.ShowDialog() == DialogResult.OK)

0 commit comments

Comments
 (0)