/// <summary> /// Convert images /// </summary> /// <param name="sender">Triggering source</param> /// <param name="e">Event Arguments</param> private void ButtonConvert_Click(object sender, RoutedEventArgs e) { this.buttonConvert.IsEnabled = false; this.buttonCancel.IsEnabled = true; ImgConverter.Helper.ConversionInformation conversionInformation = new ImgConverter.Helper.ConversionInformation(); conversionInformation.DestinationPath = this.DestinationFolderPath.Content.ToString(); conversionInformation.FileNames = this.openFileDialog.FileNames; conversionInformation.ImageType = this.comboBoxImageFormat.Text; conversionInformation.PixelFormat = this.comboBoxPixelFormat.Text; this.backgroundWorker.RunWorkerAsync(conversionInformation); }
/// <summary> /// Function where the looping conversion is done /// </summary> /// <param name="sender">Sender of the task</param> /// <param name="e">DoWork arguments</param> private void BackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { ImgConverter.Helper.ConversionInformation conversionInformation = (ImgConverter.Helper.ConversionInformation)e.Argument; for (int i = 0; i < conversionInformation.FileNames.Length; i++) { string fileName = conversionInformation.FileNames.GetValue(i).ToString(); bool conversionSuccess = Helper.Convert(fileName, conversionInformation.DestinationPath, conversionInformation.PixelFormat, conversionInformation.ImageType); this.listBoxFiles.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, this.update, i, conversionSuccess); if (this.backgroundWorker.CancellationPending) { e.Cancel = true; return; } } }