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; }
//Overrided method accepting a category parameter obtained from menu selection private void ShowConverter(String category) { //Shows the converter menu's controls and labels CategoryLabel.Show(); CategoryComboBox.Show(); InstructionLabel.Show(); ValueOfLabel.Show(); UserInputTextBox.Show(); FromLabel.Show(); InitialUnitsComboBox.Show(); ToLabel.Show(); ResultingUnitsComboBox.Show(); ConvertSubmissionButton.Show(); BackButtonLabel.Show(); BackButton.Show(); DividerLabel.Show(); //Selects the category field in the converter CategoryComboBox.SelectedIndex = CategoryComboBox.FindStringExact(category); //Shows the default units of measurement ShowDefaultUnits(category); UserInputTextBox.Focus(); }
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; }