private void buttonDecompress_Click(object sender, EventArgs e) { try { Clear(); Coder coder = new Coder(); Bitmap[] decompressedImages = coder.Decompress(fileName, numberOfPictures, checkBoxRandomImage.Checked); for (int i = 0; i < numberOfPictures; i++) { pictures[i].Image = decompressedImages[i]; } pictureBoxRestored.Image = decompressedImages[numberOfPictures - 1]; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void buttonCompress_Click(object sender, EventArgs e) { Data.RankBlockSize = Convert.ToInt32(comboBoxRankBlockSize.SelectedItem); Data.DomainBlockSize = Convert.ToInt32(comboBoxDomainBlockSize.SelectedItem); if (!Data.Validate()) { MessageBox.Show("Размер рангового блока должен быть меньше доменного"); return; } Lock(true); Coder coder = new Coder(); tokenSource = new CancellationTokenSource(); var progress = new Progress <int>(s => progressBarStatus.Value = s); await Task.Factory.StartNew(() => coder.Compress(image, progress, tokenSource.Token), tokenSource.Token); Lock(false); }