private void ResetToNewOrder() { try { _foundImages.Clear(); _foundImagesEnumerator = null; DestinationBox.ReadOnly = false; DestinationBox.Clear(); DestinationBox.BackColor = SystemColors.Control; InputBarcodeBox.Visible = false; if (PictureBox.Image != null) { PictureBox.Image.Dispose(); PictureBox.Image = null; } NextBtnPanel.Visible = false; SearchModePanel.Visible = false; ProductImagesList.Items.Clear(); BarcodeCountLabel.Text = "0"; ProductCountLabel.Text = "0"; _copiedImages.Clear(); _copyFileService.SetDestinationDirectory(null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void DestinationBtn_Click(object sender, EventArgs e) { folderBrowserDialog1.RootFolder = Environment.SpecialFolder.DesktopDirectory; try { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { DestinationBox.Text = folderBrowserDialog1.SelectedPath; await new TaskFactory().StartNew(() => _copyFileService.SetDestinationDirectory(DestinationBox.Text)); DestinationBox.BackColor = Color.LimeGreen; InputBarcodeBox.Visible = _copyFileService.IsSourceDirectorySet(); DestinationBox.ReadOnly = true; ProductImagesList.Items.Clear(); _copiedImages = await new TaskFactory().StartNew(() => _copyFileService.LoadFromDestinationDirectory()); _copiedImages.CollectionChanged += CopiedImages_Change; if (_copiedImages.Any()) { ProductImagesList.Items.AddRange(ConvertCopiedToList(_copiedImages)); FixProductListCount(); RecalculateCopiedImagesCollection(); } } } catch (FileLoadException fl) { MessageBox.Show("Загрузка списка изображений из сохраненного файла со списком не удалась\n" + fl.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); DestinationBox.ReadOnly = false; DestinationBox.Clear(); DestinationBox.BackColor = SystemColors.Control; } }
private async void DestinationBox_KeyDown(object sender, KeyEventArgs e) { try { switch (e.KeyCode) { case Keys.Enter: if (!string.IsNullOrWhiteSpace(DestinationBox.Text) && !DestinationBox.ReadOnly) { await new TaskFactory().StartNew(() => _copyFileService.SetDestinationDirectory(DestinationBox.Text)); DestinationBox.BackColor = Color.LimeGreen; InputBarcodeBox.Visible = _copyFileService.IsSourceDirectorySet(); DestinationBox.ReadOnly = true; ProductImagesList.Items.Clear(); _copiedImages = await new TaskFactory().StartNew(() => _copyFileService.LoadFromDestinationDirectory()); _copiedImages.CollectionChanged += CopiedImages_Change; if (_copiedImages.Any()) { ProductImagesList.Items.AddRange(ConvertCopiedToList(_copiedImages)); FixProductListCount(); RecalculateCopiedImagesCollection(); } } break; case Keys.Delete: DestinationBox.Clear(); DestinationBox.ReadOnly = false; DestinationBox.BackColor = SystemColors.Control; break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }