Exemplo n.º 1
0
        private async void ConvertButton_Click(object sender, RoutedEventArgs e)
        {
            if (!_currentSettings.IsValid())
            {
                _showError("All settings are required");
                return;
            }

            try
            {
                ConversionEngine.AddJobs(ConversionJob.Create(SourceTextBox.Text, OutputTextBox.Text, _currentSettings));
                ConversionEngine.CreateScriptFile();
                ProgressBar.IsIndeterminate = true;
                var startTime = DateTime.Now;
                await ConversionEngine.Run();

                var endTime = DateTime.Now;
                ProgressBar.IsIndeterminate = false;
                System.Windows.MessageBox.Show($"Conversion job started at {startTime.ToString()}{Environment.NewLine}Finished at {endTime.ToString()}", "Conversion finished", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                _showError(ex.Message + Environment.NewLine + ex.ParamName);
            }
            catch (DirectoryNotFoundException ex)
            {
                _showError(ex.Message);
            }
            catch (FileNotFoundException ex)
            {
                _showError(ex.Message + Environment.NewLine + ex.FileName);
            }
        }
 private void runButton_Click(object sender, EventArgs e)
 {
     outbox.Text = ConversionEngine.Run(
         inbox.Text,
         inputFormatSelector.DataFormat,
         outputFormatSelector.DataFormat,
         operationSelector.Operation);
 }