/// <summary> /// Try to get option values checking for errors /// </summary> /// <returns></returns> bool GetValues( out SmallWorldPredefinedParameters swp) { int maxHits = 0; swp = new SmallWorldPredefinedParameters(); if (Lex.IsUndefined(DatabaseComboBox.Text)) { MessageBoxMx.ShowError("Database to search must be defined"); return(false); } swp.Database = DatabaseComboBox.Text; // one or more database names swp.Distance = new RangeParm(DistanceRange.Value.Minimum, DistanceRange.Value.Maximum); if (!TryParseMaxHits(out maxHits)) { return(false); } swp.MaxHits = maxHits; swp.TerminalUp = TerminalRangeUp.GetRange(); swp.TerminalDown = TerminalRangeDown.GetRange(); swp.RingUp = RingRangeUp.GetRange(); swp.RingDown = RingRangeDown.GetRange(); swp.LinkerUp = LinkerRangeUp.GetRange(); swp.LinkerDown = LinkerRangeDown.GetRange(); swp.MatchAtomTypes = MatchAtomTypes.Checked; swp.MutationMinor = MutationRangeMinor.GetRange(); swp.MutationMajor = MutationRangeMajor.GetRange(); swp.SubstitutionRange = SubstitutionRange.GetRange(); swp.HybridisationChange = HybridizationRange.GetRange(); swp.PresetName = PresetsComboBox.Text; swp.Highlight = ShowColors.Checked; swp.Align = AlignStructs.Checked; return(true); }
/// <summary> /// Setup the options from psc /// </summary> /// <param name="psc"></param> public void Setup( SmallWorldPredefinedParameters swpArg) { try { InSetup = true; bool t = true, f = false; Swp = swpArg; // save reference to parameters if (SwDbDict == null) { SwDbDict = DictionaryMx.Get("SmallWorldDatabases"); if (SwDbDict != null) { UIMisc.SetListControlItemsFromDictionary(DatabaseComboBox.Properties.Items, SwDbDict.Name, true); } GetDefaultSmallWorldOptions(); // also get any default options for user } if (Swp == null) // get initial option values { SmallWorldPredefinedParameters swp = FindStandardPresetMatchingCustomSettings(); if (swp == null) // if no match then use my preferred { swp = CustomSettings; } if (swp.MaxHits <= 0) // be sure maxhits is defined { swp.MaxHits = SmallWorldPredefinedParameters.DefaultMaxHits; } Swp = swp.Clone(); // make copy } List <string> dbList = GetDbSetList(); string dbs = ""; foreach (string dbName in dbList) { if (SwDbDict.LookupDefinition(dbName) == null) { continue; } if (dbs != "") { dbs += ", "; } dbs += dbName; } Swp.Database = dbs; if (Lex.IsUndefined(Swp.Database)) // default to first entry in dict { Swp.Database = SwDbDict.Words[0]; // assign first database as default if not defined } DatabaseComboBox.Text = Swp.Database; PresetsComboBox.Text = Swp.PresetName; CriteriaStructureRangeCtl.SetRange(DistanceRange, "", DistanceRangeLabel, null, Swp.Distance); if (Swp.MaxHits < 0) { MaxHits.Text = ""; } else { MaxHits.Text = Swp.MaxHits.ToString(); } // Set the Defined and Enabled attributes for each range based on search type Swp.TerminalUp.Enabled = Swp.TerminalDown.Enabled = true; Swp.RingUp.Enabled = Swp.RingDown.Enabled = true; Swp.LinkerUp.Enabled = Swp.LinkerDown.Enabled = true; Swp.MutationMinor.Enabled = Swp.MutationMajor.Enabled = true; Swp.SubstitutionRange.Enabled = Swp.HybridisationChange.Enabled = true; if (Lex.Eq(Swp.PresetName, SmallWorld.PresetName) || Lex.Eq(Swp.PresetName, CustomSettings.PresetName)) { ; } else if (Lex.Eq(Swp.PresetName, Substructure.PresetName)) { Swp.TerminalDown.Enabled = false; Swp.RingDown.Enabled = false; Swp.LinkerDown.Enabled = false; Swp.MutationMinor.Enabled = Swp.MutationMajor.Enabled = false; } else if (Lex.Eq(Swp.PresetName, SuperStructure.PresetName)) { Swp.TerminalUp.Enabled = false; Swp.RingUp.Enabled = false; Swp.LinkerUp.Enabled = false; Swp.MutationMinor.Enabled = Swp.MutationMajor.Enabled = false; } else if (Lex.Eq(Swp.PresetName, BemisMurckoFramework.PresetName)) { Swp.RingUp.Enabled = Swp.RingDown.Enabled = false; Swp.LinkerUp.Enabled = Swp.LinkerDown.Enabled = false; } else if (Lex.Eq(Swp.PresetName, NqMCS.PresetName)) { Swp.LinkerUp.Enabled = Swp.LinkerDown.Enabled = false; Swp.MutationMinor.Enabled = Swp.MutationMajor.Enabled = false; } else if (Lex.Eq(Swp.PresetName, ElementGraph.PresetName)) { Swp.TerminalUp.Enabled = Swp.TerminalDown.Enabled = false; Swp.RingUp.Enabled = Swp.RingDown.Enabled = false; Swp.LinkerUp.Enabled = Swp.LinkerDown.Enabled = false; Swp.MutationMinor.Enabled = Swp.MutationMajor.Enabled = false; } MatchAtomTypes.Checked = Swp.MatchAtomTypes; bool e = Swp.MatchAtomTypes; Swp.LinkerUp.Active = Swp.LinkerDown.Active = !e; Swp.MutationMinor.Active = Swp.MutationMajor.Active = e; Swp.SubstitutionRange.Active = Swp.HybridisationChange.Active = e; // Set the range controls TerminalRangeUp.Set(Swp.TerminalUp); TerminalRangeDown.Set(Swp.TerminalDown); RingRangeUp.Set(Swp.RingUp); RingRangeDown.Set(Swp.RingDown); LinkerRangeUp.Set(Swp.LinkerUp); LinkerRangeDown.Set(Swp.LinkerDown); MutationRangeMinor.Set(Swp.MutationMinor); MutationRangeMajor.Set(Swp.MutationMajor); SubstitutionRange.Set(Swp.SubstitutionRange); HybridizationRange.Set(Swp.HybridisationChange); ShowColors.Checked = Swp.Highlight; SetControlBackgroundColors(ShowColors.Checked); AlignStructs.Checked = Swp.Align; } finally { InSetup = false; } return; }