Esempio n. 1
0
        private string PromptForThemeName(string defaultName)
        {
            var etnd = new EnterThemeNameDialog
            {
                ThemeName = Path.GetFileNameWithoutExtension(defaultName)
            };

            while (true)
            {
                if (etnd.ShowDialog(this) != DialogResult.OK)
                {
                    return(null);
                }

                if (AvailableThemesList.Items.Cast <Theme>().Any(x => x.Name == etnd.ThemeName))
                {
                    MessageBox.Show(this,
                                    "A theme with this name already exists. Please choose a different name.",
                                    "Name already in use",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
                else if (etnd.ThemeName.Intersect(invalidFileNameChars).Any())
                {
                    MessageBox.Show(this,
                                    "The specified name is not a valid file name. Please choose a different name.",
                                    "Invalid name",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                }
                else
                {
                    return(etnd.ThemeName);
                }
            }
        }
Esempio n. 2
0
        private string PromptForThemeName(string defaultName)
        {
            var etnd = new EnterThemeNameDialog
                           {
                               ThemeName = Path.GetFileNameWithoutExtension(defaultName)
                           };

            while (true)
            {
                if (etnd.ShowDialog(this) != DialogResult.OK) return null;

                if (AvailableThemesList.Items.Cast<Theme>().Any(x => x.Name == etnd.ThemeName))
                    MessageBox.Show(this,
                                    "A theme with this name already exists. Please choose a different name.",
                                    "Name already in use",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                else if (etnd.ThemeName.Intersect(invalidFileNameChars).Any())
                    MessageBox.Show(this,
                                    "The specified name is not a valid file name. Please choose a different name.",
                                    "Invalid name",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                else
                    return etnd.ThemeName;
            }
        }