Пример #1
0
        void buttonAddPalette_Click(object sender, EventArgs e)
        {
            using (var inputDialog = new InputDialog(Resources.QueryEnterNewPaletteName))
            {
                if (inputDialog.ShowDialog(this) == DialogResult.OK)
                {
                    var newName = inputDialog.Answer.Trim();

                    if (string.IsNullOrEmpty(newName))
                    {
                        return;
                    }

                    if (AllPalettes.Any(p => p.PaletteName.Equals(newName, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        MessageBox.Show(Resources.ErrorSelectedPaletteNameAlreadyUsed);
                        return;
                    }

                    var palette = new CodedPalette {
                        Name = newName, IsSystem = false, FileName = Path.Combine(Settings.Default.UserPalettesLocationSafe, newName + SAEResources.ThreadFileExtension)
                    };
                    AddNewPalette(palette);
                }
            }
        }
Пример #2
0
        void buttonCopyPalette_Click(object sender, EventArgs e)
        {
            var paletteData     = gridViewPalettes.CurrentRow?.DataBoundItem as PaletteData;
            var selectedPalette = paletteData?.Palette;

            if (selectedPalette == null)
            {
                return;
            }

            using (var inputDialog = new InputDialog(Resources.QueryEnterNewPaletteName))
            {
                if (inputDialog.ShowDialog(this) == DialogResult.OK)
                {
                    var newName = inputDialog.Answer.Trim();

                    if (string.IsNullOrEmpty(newName))
                    {
                        return;
                    }

                    if (AllPalettes.Any(p => p.PaletteName.Equals(newName, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        MessageBox.Show(Resources.ErrorSelectedPaletteNameAlreadyUsed);
                        return;
                    }

                    var newPalette = selectedPalette.Clone();
                    newPalette.Name     = newName;
                    newPalette.IsSystem = false;
                    newPalette.FileName = Path.Combine(Settings.Default.UserPalettesLocationSafe, newName + SAEResources.ThreadFileExtension);

                    AddNewPalette(newPalette);
                }
            }
        }