Example #1
0
 private void задатьКодомToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (!hasChilds && cube != null)
     {
         hasChilds = true;
         PaintForm subform = new PaintForm(this);
         subform.Show();
     }
 }
        public ToolButtonsBuilder(IDrawingFeatures drawingFeatures, PaintForm paintForm)
        {
            _paintForm = paintForm;

            _operationsOnToolButtons = new OperationsOnToolButtons(drawingFeatures);
        }
Example #3
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;
        }