private ModulesConfiguration GenerateConfigFromControls() { ModulesConfiguration mc = new ModulesConfiguration(); if (acquisitionComboBox.SelectedIndex >= 0) { mc.AcquisitionModule = new ModuleMetaData(); mc.AcquisitionModule.ModuleID = engine.AcquisitionModules.ElementAt(acquisitionComboBox.SelectedIndex).ModuleID; mc.AcquisitionModule.ModuleName = engine.AcquisitionModules.ElementAt(acquisitionComboBox.SelectedIndex).ModuleName; } if (pointerComboBox.SelectedIndex >= 0) { mc.PointerModule = new ModuleMetaData(); mc.PointerModule.ModuleID = engine.PointerModules.ElementAt(pointerComboBox.SelectedIndex).ModuleID; mc.PointerModule.ModuleName = engine.PointerModules.ElementAt(pointerComboBox.SelectedIndex).ModuleName; } if (transformationComboBox.SelectedIndex >= 0) { mc.TransformationModule = new ModuleMetaData(); mc.TransformationModule.ModuleID = engine.TransformationModules.ElementAt(transformationComboBox.SelectedIndex).ModuleID; mc.TransformationModule.ModuleName = engine.TransformationModules.ElementAt(transformationComboBox.SelectedIndex).ModuleName; } if (outputComboBox.SelectedIndex >= 0) { mc.OutputModule = new ModuleMetaData(); mc.OutputModule.ModuleID = engine.OutputModules.ElementAt(outputComboBox.SelectedIndex).ModuleID; mc.OutputModule.ModuleName = engine.OutputModules.ElementAt(outputComboBox.SelectedIndex).ModuleName; } return mc; }
public bool Equals(ModulesConfiguration mc) { // If parameter is null, return false. if (Object.ReferenceEquals(mc, null)) return false; // Optimization for a common success case. if (Object.ReferenceEquals(this, mc)) return true; // If types are different, instances can't be equal if (this.GetType() != mc.GetType()) return false; // finally let equality be determined by IDs. return ( (mc.AcquisitionModule.ModuleID == this.AcquisitionModule.ModuleID) && (mc.PointerModule.ModuleID == this.PointerModule.ModuleID) && (mc.TransformationModule.ModuleID == this.TransformationModule.ModuleID) && (mc.OutputModule.ModuleID == this.OutputModule.ModuleID) ); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.Filter = filefilter; if (this.filename.Length > 0) save.FileName = this.filename; save.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); if (save.ShowDialog() == DialogResult.OK) { ModulesConfiguration mc = GenerateConfigFromControls(); if (mc.SaveConfiguration(save.FileName)) { ModuleSelectionGroup.Text = Path.GetFileName(save.FileName); this.config = mc; } } }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { this.suspectChecks = true; try { OpenFileDialog open = new OpenFileDialog(); open.Filter = filefilter; open.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); if (open.ShowDialog() == DialogResult.OK) { ModuleSelectionGroup.Text = Path.GetFileName(open.FileName); this.filename = open.FileName; try { this.config = ModulesConfiguration.LoadConfiguration(open.FileName); bool loaded = false; for (int i = 0; i < engine.AcquisitionModules.Count(); i++) { if (config.AcquisitionModule.ModuleID == engine.AcquisitionModules.ElementAt(i).ModuleID) { loaded = true; acquisitionComboBox.SelectedIndex = i; break; } } for (int i = 0; i < engine.PointerModules.Count(); i++) { if (config.PointerModule.ModuleID == engine.PointerModules.ElementAt(i).ModuleID) { loaded = true; pointerComboBox.SelectedIndex = i; break; } } for (int i = 0; i < engine.TransformationModules.Count(); i++) { if (config.TransformationModule.ModuleID == engine.TransformationModules.ElementAt(i).ModuleID) { loaded = true; transformationComboBox.SelectedIndex = i; break; } } for (int i = 0; i < engine.OutputModules.Count(); i++) { if (config.OutputModule.ModuleID == engine.OutputModules.ElementAt(i).ModuleID) { loaded = true; outputComboBox.SelectedIndex = i; break; } } } catch (Exception ex) { } finally { this.suspectChecks = false; this.RecheckStuff(); } } } catch (Exception) { throw new ApplicationException("Failed loading config file"); } }