示例#1
0
 private void SetupKeyDownEvents(ConfirmDialogForm confirmForm)
 {
     foreach (Control control in confirmForm.Controls)
     {
         control.KeyDown += ConfirmDialogForm_KeyDown;
     }
 }
示例#2
0
        private void AddCollectionButton_Click(object sender, EventArgs e)
        {
            bool needReset            = false;
            ConfirmDialogForm confirm = null;

            if (ruler.IsGameStarted)
            {
                confirm   = GetConfirmStatus("Сбросить игру?");
                needReset = confirm.Yes;
            }
            else
            {
                needReset = true;
            }

            if (needReset)
            {
                ResetGame();

                if (newCollectionDialogForm == null)
                {
                    newCollectionDialogForm = new NewCollectionDialogForm();
                }

                SoundPlayer.PlaySettingsSound();
                newCollectionDialogForm.StartPosition         = FormStartPosition.Manual;
                newCollectionDialogForm.Location              = this.Location;
                newCollectionDialogForm.StartPosition         = FormStartPosition.CenterParent;
                newCollectionDialogForm.BackgroundImageLayout = ImageLayout.Stretch;
                this.Enabled = false;
                newCollectionDialogForm.NewCollectionTextBox.Focus();
                newCollectionDialogForm.ShowDialog(this);
                var newCollectionName = newCollectionDialogForm.CollectionName;
                this.Enabled = true;

                if (!string.IsNullOrEmpty(newCollectionName) && newCollectionName?.Length > 2)
                {
                    this.Invoke((Action)(() => this.Enabled = false));

                    new Thread(() => {
                        Thread.CurrentThread.IsBackground = true;
                        this.Invoke((Action)(() => baseForm.ShowStatusMessage($"ПОИСК ИЗОБРАЖЕНИЙ ПО КАТЕГОРИИ '{newCollectionName.ToUpper()}' ...")));
                        this.Invoke((Action)(() => customImageCollectionConfigurator.GenerateImageCollectionByCategory(baseForm, newCollectionName, 180, 190)));
                        this.Invoke((Action)(() => buttonManager.AssignImages(newCollectionName)));
                        this.Invoke((Action)(() => buttonManager.HideButtonImages()));
                        this.Invoke((Action)(() => CategoryComboBox.DataSource = libManager.GetCategories().ToList()));
                        this.Invoke((Action)(() => CategoryComboBox.SelectedIndex = CategoryComboBox.FindStringExact(newCollectionName)));
                        this.Invoke((Action)(() => newCollectionDialogForm.ResetCollectionName()));
                        this.Invoke((Action)(() => this.Enabled = true));
                        this.Invoke((Action)(() => baseForm.HideStatusMessage()));
                        SoundPlayer.PlayShuffleSound();
                    }).Start();
                }
            }

            confirm?.Dispose();
            this.Enabled = true;
        }
示例#3
0
        private ConfirmDialogForm GetConfirmStatus(string confirmMessage)
        {
            var confirm = new ConfirmDialogForm(confirmMessage);

            SoundPlayer.PlaySettingsSound();
            confirm.StartPosition         = FormStartPosition.Manual;
            confirm.Location              = this.Location;
            confirm.StartPosition         = FormStartPosition.CenterParent;
            confirm.BackgroundImageLayout = ImageLayout.Stretch;
            this.Enabled = false;
            confirm.ShowDialog(this);
            return(confirm);
        }
示例#4
0
        private void CustomPaintButton_Click(object sender, EventArgs e)
        {
            SoundPlayer.PlaySettingsSound();

            bool needReset            = false;
            ConfirmDialogForm confirm = null;

            if (ruler.IsGameStarted)
            {
                confirm   = GetConfirmStatus("Сбросить игру?");
                needReset = confirm.Yes;
            }
            else
            {
                needReset = true;
            }

            if (needReset)
            {
                ResetGame();

                var collectionNameDialog = new CustomCollectionNameDialogForm();
                collectionNameDialog.StartPosition         = FormStartPosition.Manual;
                collectionNameDialog.Location              = this.Location;
                collectionNameDialog.StartPosition         = FormStartPosition.CenterParent;
                collectionNameDialog.BackgroundImageLayout = ImageLayout.Stretch;
                this.Enabled = false;
                collectionNameDialog.ShowDialog(this);
                this.Enabled = true;

                var newCollectionName = collectionNameDialog.GetCollectionName();

                if (libManager.GetCategories().Contains(newCollectionName))
                {
                    baseForm.ShowStatusMessage($"Коллекция {newCollectionName} уже существует", error: true, true);
                    return;
                }

                if (!string.IsNullOrEmpty(newCollectionName))
                {
                    var collectionPath = Path.Combine(libManager.LibraryPath, newCollectionName);
                    if (fileManager.IsDirectoryExist(collectionPath))
                    {
                        var popUpMessage = new TimedPopUp();
                        popUpMessage.Set($"Коллекция {newCollectionName} уже существует");
                        popUpMessage.ShowError(3000);
                        this.Invoke((Action)(() => this.Enabled = true));
                        return;
                    }

                    collectionNameDialog.Dispose();
                    collectionNameDialog = null;
                    paintForm            = new PaintForm(this, baseForm, newCollectionName);

                    new Thread(() =>
                    {
                        this.Invoke((Action)(() => paintForm.StartPosition = FormStartPosition.Manual));
                        this.Invoke((Action)(() => paintForm.Location = this.Location));
                        this.Invoke((Action)(() => paintForm.StartPosition = FormStartPosition.CenterParent));
                        this.Invoke((Action)(() => paintForm.BackgroundImageLayout = ImageLayout.Stretch));
                        this.Invoke((Action)(() => this.Enabled = false));
                        this.Invoke((Action)(() => paintForm.ShowDialog(this)));
                        List <CustomImage> newCollection = paintForm.GetCollection();
                        SaveCustomImageCollection(newCollectionName, newCollection);
                        this.Invoke((Action)(() => CategoryComboBox.DataSource = libManager.GetCategories().ToList()));
                        this.Invoke((Action)(() => CategoryComboBox.SelectedIndex = CategoryComboBox.FindStringExact(newCollectionName)));
                        paintForm.Dispose();
                        paintForm = null;
                        this.Invoke((Action)(() => this.Enabled = true));
                    }).Start();
                }
            }

            confirm?.Dispose();
            this.Enabled = true;
        }