/// <summary> /// Get 5 Searches /// </summary> /// <returns></returns> private EaAddinButtons[] GetButtonsSearch() { int pos = 0; string text = ""; string type = ""; string par1 = ""; string par2 = ""; EaAddinButtons[] l = new EaAddinButtons[10]; foreach (KeyValueConfigurationElement configEntry in CurrentConfig.AppSettings.Settings) { var sKey = configEntry.Key; string regex = @"key([0-9]+)([a-zA-Z_0-9]+)"; Match match = Regex.Match(sKey, regex); if (match.Success) { int posValue = Convert.ToInt16(match.Groups[1].Value); switch (match.Groups[2].Value) { case "Type": type = configEntry.Value; break; case "Text": text = configEntry.Value; break; case "Par1": par1 = configEntry.Value; break; case "Par2": par2 = configEntry.Value; break; case "Tooltip": switch (type) { case "Search": l[pos] = new EaAddinShortcutSearch(posValue, text, par1, par2, configEntry.Value); pos = pos + 1; break; } break; } } } return l; }
private void SetButtonsSearch(EaAddinButtons[] l) { foreach (EaAddinButtons button in l) { if (button == null) continue; { var el = (EaAddinShortcutSearch)button; string basicKey = "Key" + el.KeyPos; CurrentConfig.AppSettings.Settings[basicKey + "Text"].Value = el.KeyText; CurrentConfig.AppSettings.Settings[basicKey + "Type"].Value = "Search"; CurrentConfig.AppSettings.Settings[basicKey + "Par1"].Value = el.KeySearchName; CurrentConfig.AppSettings.Settings[basicKey + "Par2"].Value = el.KeySearchTerm; CurrentConfig.AppSettings.Settings[basicKey + "Tooltip"].Value = el.KeySearchTooltip; } } }