private void CheckBoxEnableSelection_Checked(object sender, RoutedEventArgs e) { TimeSpan StartTime = TimeSpan.FromMilliseconds((int.Parse(TextBoxStartHour.Text) * 3600 * 1000) + (int.Parse(TextBoxStartMinute.Text) * 60 * 1000) + (int.Parse(TextBoxStartSecond.Text) * 1000) + int.Parse(TextBoxStartMilisecond.Text)); TimeSpan EndTime = TimeSpan.FromMilliseconds((int.Parse(TextBoxEndHour.Text) * 3600 * 1000) + (int.Parse(TextBoxEndMinute.Text) * 60 * 1000) + (int.Parse(TextBoxEndSecond.Text) * 1000) + int.Parse(TextBoxEndMilisecond.Text)); TimeSpan SelectedDuration = EndTime - StartTime; if (InputFiles != null && InputFiles.Length != 0) { foreach (MediaFile MediaFile in InputFiles) { if (EndTime < StartTime) { CheckBoxEnableSelection.IsChecked = false; System.Windows.MessageBox.Show("The selection cannot be applied because Start Time is greater than End Time.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); TabItemInput.Focus(); break; } if (EndTime > MediaFile.Duration || StartTime > MediaFile.Duration) { CheckBoxEnableSelection.IsChecked = false; System.Windows.MessageBox.Show("The selection cannot be applied because the file \"" + MediaFile.Filename + "\" duration is outside the selection range.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); TabItemInput.Focus(); break; } } } }
private void ButtonConvert_Click(object sender, RoutedEventArgs e) { if (!ValidateParameters()) { return; } TimeSpan StartTime = TimeSpan.FromMilliseconds((int.Parse(TextBoxStartHour.Text) * 3600 * 1000) + (int.Parse(TextBoxStartMinute.Text) * 60 * 1000) + (int.Parse(TextBoxStartSecond.Text) * 1000) + int.Parse(TextBoxStartMilisecond.Text)); TimeSpan EndTime = TimeSpan.FromMilliseconds((int.Parse(TextBoxEndHour.Text) * 3600 * 1000) + (int.Parse(TextBoxEndMinute.Text) * 60 * 1000) + (int.Parse(TextBoxEndSecond.Text) * 1000) + int.Parse(TextBoxEndMilisecond.Text)); TimeSpan SelectedDuration = EndTime - StartTime; if (InputFiles != null && InputFiles.Length != 0) { foreach (MediaFile MediaFile in InputFiles) { if (EndTime < StartTime) { CheckBoxEnableSelection.IsChecked = false; System.Windows.MessageBox.Show("The selection cannot be applied because Start Time is greater than End Time.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); TabItemInput.Focus(); break; } if (EndTime > MediaFile.Duration || StartTime > MediaFile.Duration) { CheckBoxEnableSelection.IsChecked = false; System.Windows.MessageBox.Show("The selection cannot be applied because the file \"" + MediaFile.Filename + "\" duration is outside the selection range.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); TabItemInput.Focus(); break; } } } ButtonConvert.IsEnabled = false; ButtonBrowse.IsEnabled = false; ButtonBrowsePath.IsEnabled = false; CheckBoxVideo.IsEnabled = false; CheckBoxAudio.IsEnabled = false; new Thread(new ThreadStart(StartBatch)).Start(); }