private void PhotoBTN_Click(object sender, EventArgs e) { openFileDialog.ShowDialog(); try { Bitmap imageToProcess = new Bitmap(Image.FromFile(openFileDialog.FileName)); TimeCounterHelper time = new TimeCounterHelper(); time.Start(); imageService.ImageDivider(imageToProcess); time.Stop(); time_divide_label.Text = time.Time; loger.Debug(String.Format("Obraz podzielony w czasie {0} ms.", time.Time)); pictureBox_original.Image = imageToProcess; BitmapParts_label.Text = imageService.Length.ToString(); StartBTN.Enabled = true; } catch (System.IO.FileNotFoundException exception) { loger.Error(exception.Message); MessageBox.Show(String.Format("Nie znaleziono pliku:\n\r{0}", exception.Message)); } catch (NotDivisibleBy16Exception exception) { loger.Error(exception.Message); MessageBox.Show(String.Format("Jestem leniwym programista i zamiast obrobic zdjęcie wymagam zeby jego wysokosc byla podzielna przez 16. \n\r\n\r {0}", exception.Message)); } catch (Exception exception) { loger.Error(exception.Message); if (exception is ArgumentException) { MessageBox.Show(exception.GetType().ToString()); } else if (exception is OutOfMemoryException) { MessageBox.Show(exception.GetType().ToString()); } else { MessageBox.Show(String.Format("Błąd łądowania zdjęcia.{0}{0}{1}", Environment.NewLine, exception.Message)); } } }
private void UpdateModifiedPhoto() { if (label_time.InvokeRequired) { label_time.Invoke(new EndOfThreads(UpdateModifiedPhoto)); } else { label_time.Text = threadsService.Time; loger.Debug(String.Format("Obraz przetworzony w czasie {0} ms.", threadsService.Time)); TimeCounterHelper time = new TimeCounterHelper(); time.Start(); pictureBox_modified.Image = imageService.JoinIntoBigOne(); time.Stop(); time_join_label.Text = time.Time; loger.Debug(String.Format("Obraz polaczony w czasie {0} ms.", time.Time)); StartBTN.Enabled = true; } }