diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 9 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs | 5 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/LibScan.cs | 25 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/AudioView.xaml | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/VideoView.xaml | 5 |
8 files changed, 46 insertions, 9 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 70ff7170c..752fd547e 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1515,6 +1515,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to An error occured when trying to stop the scan. Please restart HandBrake..
+ /// </summary>
+ public static string ScanService_ScanStopFailed {
+ get {
+ return ResourceManager.GetString("ScanService_ScanStopFailed", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to An Encode is currently running. Exiting HandBrake will stop this encode.
///Are you sure you wish to exit HandBrake?.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 09f221101..765b9636b 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -786,4 +786,7 @@ Are you sure you want to import the chapter names?</value> <data name="ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchWarning" xml:space="preserve">
<value>Chapter duration doesn't match between source and input file</value>
</data>
+ <data name="ScanService_ScanStopFailed" xml:space="preserve">
+ <value>An error occured when trying to stop the scan. Please restart HandBrake.</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs index 8d7440f06..5f022f6b5 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/EncodeTask.cs @@ -144,7 +144,7 @@ namespace HandBrakeWPF.Services.Encode.Model this.VideoLevel = task.VideoLevel; this.VideoProfile = task.VideoProfile; this.VideoPreset = task.VideoPreset; - this.VideoTunes = task.VideoTunes; + this.VideoTunes = new List<VideoTune>(task.VideoTunes); this.ExtraAdvancedArguments = task.ExtraAdvancedArguments; this.ShowAdvancedTab = task.ShowAdvancedTab; diff --git a/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs b/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs index 1c0d3a851..0af5f30ec 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Interfaces/IScan.cs @@ -89,6 +89,11 @@ namespace HandBrakeWPF.Services.Scan.Interfaces void Scan(string sourcePath, int title, Action<bool, Source> postAction, HBConfiguration configuration); /// <summary> + /// Cancel the current scan. + /// </summary> + void Cancel(); + + /// <summary> /// Get a Preview image for the current job and preview number. /// </summary> /// <param name="task"> diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs index b43ec3ce3..3d9d475a1 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs @@ -26,6 +26,7 @@ namespace HandBrakeWPF.Services.Scan using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Utilities; + using HandBrakeWPF.Properties; using HandBrakeWPF.Services.Encode.Model; using HandBrakeWPF.Services.Encode.Model.Models; using HandBrakeWPF.Services.Scan.EventArgs; @@ -90,6 +91,11 @@ namespace HandBrakeWPF.Services.Scan /// </summary> private Action<bool, Source> postScanOperation; + /// <summary> + /// Global to handle cancelled scans. + /// </summary> + private bool isCancelled = false; + #endregion /// <summary> @@ -243,13 +249,24 @@ namespace HandBrakeWPF.Services.Scan } } } - catch (Exception) + catch (Exception exc) { + this.isCancelled = false; + this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(false, exc, Resources.ScanService_ScanStopFailed, null)); // Do Nothing. } } /// <summary> + /// Cancel the current scan. + /// </summary> + public void Cancel() + { + this.isCancelled = true; + this.Stop(); + } + + /// <summary> /// Get a Preview image for the current job and preview number. /// </summary> /// <param name="job"> @@ -365,6 +382,8 @@ namespace HandBrakeWPF.Services.Scan private void InstanceScanCompleted(object sender, System.EventArgs e) { this.ServiceLogMessage("Scan Finished ..."); + bool cancelled = this.isCancelled; + this.isCancelled = false; // Write the log file out before we start processing incase we crash. try @@ -391,7 +410,7 @@ namespace HandBrakeWPF.Services.Scan // Process into internal structures. Source sourceData = null; - if (this.instance != null && this.instance.Titles != null) + if (this.instance?.Titles != null) { sourceData = new Source { Titles = ConvertTitles(this.instance.Titles), ScanPath = path }; } @@ -413,7 +432,7 @@ namespace HandBrakeWPF.Services.Scan } else { - if (this.ScanCompleted != null) this.ScanCompleted(this, new ScanCompletedEventArgs(false, null, string.Empty, sourceData)); + this.ScanCompleted?.Invoke(this, new ScanCompletedEventArgs(cancelled, null, string.Empty, sourceData)); } } diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 20a779e43..b9e8da0e4 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1464,7 +1464,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void CancelScan()
{
- this.scanService.Stop();
+ this.scanService.Cancel();
}
/// <summary>
@@ -2130,7 +2130,7 @@ namespace HandBrakeWPF.ViewModels this.HasSource = true;
this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(t => t.MainTitle) ?? this.ScannedSource.Titles.FirstOrDefault();
}
- else
+ else if (!e.Cancelled)
{
this.OpenAlertWindow(Resources.Main_ScanNoTitlesFound, Resources.Main_ScanNoTitlesFoundMessage);
}
diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml index 1a7048b60..1fddda1be 100644 --- a/win/CS/HandBrakeWPF/Views/AudioView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -170,7 +170,7 @@ </Grid.RowDefinitions>
<!-- Row 1 -->
- <ComboBox Grid.Column="1" Height="22" Width="135" Margin="5,0,5,0" HorizontalAlignment="Stretch"
+ <ComboBox Grid.Column="1" Height="22" Width="130" Margin="5,0,5,0" HorizontalAlignment="Stretch"
ItemsSource="{Binding DataContext.SourceTracks, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
SelectedItem="{Binding ScannedTrack}" />
diff --git a/win/CS/HandBrakeWPF/Views/VideoView.xaml b/win/CS/HandBrakeWPF/Views/VideoView.xaml index 76cd39c98..2f2004481 100644 --- a/win/CS/HandBrakeWPF/Views/VideoView.xaml +++ b/win/CS/HandBrakeWPF/Views/VideoView.xaml @@ -152,6 +152,7 @@ <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
@@ -188,8 +189,8 @@ <!-- Row 3 -->
<TextBlock Text="{x:Static Properties:ResourcesUI.VideoView_ExtraOptions}" Grid.Row="4" Grid.Column="0" Margin="0,5,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" />
- <TextBox Text="{Binding ExtraArguments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="200"
- Height="30" MaxLines="2" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Margin="5,10,0,0" VerticalAlignment="Center"
+ <TextBox Text="{Binding ExtraArguments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="200" Width="365" HorizontalAlignment="Left" TextWrapping="WrapWithOverflow"
+ Height="30" MaxLines="3" Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="4" Margin="5,10,0,0" VerticalAlignment="Center"
ToolTip="{Binding FullOptionsTooltip}" Style="{StaticResource LongToolTipHolder}" >
<TextBox.ContextMenu>
<ContextMenu>
|