public NeuropixelsEditorDialog(Bonsai.ONIX.NeuropixelsConfiguration config) { InitializeComponent(); this.ControlBox = false; // Create a deep copy of the configuration to work with internally that won't // commit changes to config until user clicks "OK" Config = ObjectExtensions.Copy(config); label_ProbeSN.Text = "Probe SN: " + Config.ProbeSN.ToString(); comboBox_CalibrationMode.DataSource = Enum.GetValues(typeof(NeuropixelsConfiguration.OperationMode)); comboBox_CalibrationMode.SelectedItem = Config.Mode; DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn(); col.HeaderText = "Bank"; col.DataPropertyName = "Bank"; col.ValueType = typeof(NeuropixelsChannel.ElectrodeBank); col.DataSource = Enum.GetValues(typeof(NeuropixelsChannel.ElectrodeBank)); dataGridView_Channels.Columns.Add(col); col = new DataGridViewComboBoxColumn(); col.HeaderText = "AP Gain"; col.DataPropertyName = "APGain"; col.ValueType = typeof(NeuropixelsChannel.Gain); col.DataSource = Enum.GetValues(typeof(NeuropixelsChannel.Gain)); dataGridView_Channels.Columns.Add(col); col = new DataGridViewComboBoxColumn(); col.HeaderText = "LFP Gain"; col.DataPropertyName = "LFPGain"; col.ValueType = typeof(NeuropixelsChannel.Gain); col.DataSource = Enum.GetValues(typeof(NeuropixelsChannel.Gain)); dataGridView_Channels.Columns.Add(col); col = new DataGridViewComboBoxColumn(); col.HeaderText = "Reference"; col.DataPropertyName = "Reference"; col.ValueType = typeof(NeuropixelsChannel.Ref); col.DataSource = Enum.GetValues(typeof(NeuropixelsChannel.Ref)); dataGridView_Channels.Columns.Add(col); // Bind the data grids dataGridView_Channels.DataSource = Config.Channels; // ch_source; dataGridView_ADCs.DataSource = Config.ADCs; dataGridView_Electrodes.DataSource = Config.Electrodes; // TODO: This does not work foreach (var i in Config.InternalReferenceChannels) { dataGridView_Channels.Rows[i].ReadOnly = true; dataGridView_Channels.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen; } }
private void importToolStripMenuItem_Click(object sender, EventArgs e) { var fd = new OpenFileDialog(); fd.Filter = "JSON file|*.json|XML file|*.xml"; fd.Title = "Import neuropixels configuration"; var result = fd.ShowDialog(); if (result == DialogResult.OK && fd.FileName != "") { var config_tmp = new NeuropixelsConfiguration(); switch (fd.FilterIndex) { case 1: var json = File.ReadAllText(fd.FileName); config_tmp = JsonSerializer.Deserialize <NeuropixelsConfiguration>(json); break; case 2: var xml = new XmlSerializer(typeof(NeuropixelsConfiguration)); var xml_file = new FileStream(fd.FileName, FileMode.Open); config_tmp = (NeuropixelsConfiguration)xml.Deserialize(xml_file); break; } if (config_tmp.ProbeSN != Config.ProbeSN) { var txt = String.Format("Warning, probe serial numbers do not match. " + "Do you wish to import the channel configuration from probe {0}?. " + "The current ADC calibration data will be preserved", config_tmp.ProbeSN); result = MessageBox.Show(txt, "Serial number mismatch", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Config.Channels = config_tmp.Channels; dataGridView_Channels.DataSource = Config.Channels; } } else { Config = config_tmp; // Bind the data grids dataGridView_Channels.DataSource = Config.Channels; dataGridView_ADCs.DataSource = Config.ADCs; dataGridView_Electrodes.DataSource = Config.Electrodes; } } }