private string GetName(string name, string initialName, string titleText) { string groupBoxText = "Session"; if (ConfigHandler.UseTranslation) { groupBoxText = Translator.GetText("Session"); } string valueLabelText = "Name:"; if (ConfigHandler.UseTranslation) { valueLabelText = Translator.GetText("Name1"); } GetTextForm form = new GetTextForm(titleText, groupBoxText, valueLabelText, name, -1); form.ShowDialog(); string newName = form.GetText(); if (form.SaveChanges()) { bool unique = CheckForUniqueName(newName, initialName); if (!unique) { string text = "Names must be unique."; if (ConfigHandler.UseTranslation) { text = Translator.GetText("NameMustBeUnique"); } OutputHandler.Show(text, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); newName = GetName(newName, initialName, titleText); } } return(newName); }
private static string GetName(string savedSearchName, string registryName, string savedSearchesXml) { string titleText = "Search name"; if (ConfigHandler.UseTranslation) { titleText = Translator.GetText("SavedSearchName"); } string groupBoxText = "Search"; if (ConfigHandler.UseTranslation) { groupBoxText = Translator.GetText("SavedSearch"); } string valueLabelText = "Name:"; if (ConfigHandler.UseTranslation) { valueLabelText = Translator.GetText("Name1"); } GetTextForm form = new GetTextForm(titleText, groupBoxText, valueLabelText, savedSearchName, ConfigHandler.SavedSearchesMaxLength); form.ShowDialog(); string newName = form.GetText(); if (newName == null) { return(null); } if (IsSystemObject(newName, registryName)) { string text1 = "The selected search is a system object and can not be overwritten."; if (ConfigHandler.UseTranslation) { text1 = Translator.GetText("CanNotOverwriteSystemObject"); } OutputHandler.Show(text1, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); newName = GetName(form.GetText(), registryName, savedSearchesXml); } else { if (form.SaveChanges()) { bool valid = CheckForValidName(form.GetText()); if (!valid) { string text = "Name not valid."; if (ConfigHandler.UseTranslation) { text = Translator.GetText("NameNotValid"); } OutputHandler.Show(text, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); newName = GetName(form.GetText(), registryName, savedSearchesXml); } else { bool unique = CheckForUniqueName(form.GetText(), registryName); if (!unique) { string text = "Replace search \"{0}\"?"; if (ConfigHandler.UseTranslation) { text = Translator.GetText("SaveSearch"); } DialogResult result = OutputHandler.Show(string.Format(text, form.GetText()), GenericHelper.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { Save(savedSearchesXml, registryName, form.GetText()); } else { newName = GetName(form.GetText(), registryName, savedSearchesXml); } } } } } return(newName); }