diff options
6 files changed, 125 insertions, 18 deletions
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 5765de23f..802eae0b4 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -2421,6 +2421,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Preview {0} of {1}.
+ /// </summary>
+ public static string SummaryView_PreviewInfo {
+ get {
+ return ResourceManager.GetString("SummaryView_PreviewInfo", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Rotation.
/// </summary>
public static string SummaryView_Rotation {
diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index a9c6d3881..27a3a055e 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -968,4 +968,7 @@ This will not affect your current settings in the Subtitle tab.</value> <data name="QueueView_OpenSourceDir" xml:space="preserve">
<value>Open Source Directory</value>
</data>
+ <data name="SummaryView_PreviewInfo" xml:space="preserve">
+ <value>Preview {0} of {1}</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISummaryViewModel.cs index 8ed5deb78..e7440b7a8 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISummaryViewModel.cs @@ -19,5 +19,6 @@ namespace HandBrakeWPF.ViewModels.Interfaces event EventHandler<OutputFormatChangedEventArgs> OutputFormatChanged; void SetContainer(OutputFormat container); void UpdateDisplayedInfo(); + void SetPreviewControlVisibility(bool isPreviousVisible, bool isNextVisible); } }
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs index cac78160b..10f53517f 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SummaryViewModel.cs @@ -42,6 +42,7 @@ namespace HandBrakeWPF.ViewModels private Source source; private Title currentTitle; private bool isMkv; + private int selectedPreview = 2; public SummaryViewModel(IScan scanService, IUserSettingService userSettingService) { @@ -137,6 +138,8 @@ namespace HandBrakeWPF.ViewModels public bool IsPreviousPreviewControlVisible { get; set; } = false; public bool IsNextPreviewControlVisible { get; set; } = false; + public bool IsPreviewInfoVisible { get; set; } = false; + public string PreviewInfo { get; set; } #endregion @@ -289,6 +292,62 @@ namespace HandBrakeWPF.ViewModels this.SelectedOutputFormat = container; } + public void NextPreview() + { + int maxPreview = this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount); + this.selectedPreview = this.selectedPreview + 1; + this.UpdatePreviewFrame(); + this.PreviewInfo = string.Format(ResourcesUI.SummaryView_PreviewInfo, this.selectedPreview, maxPreview); + this.NotifyOfPropertyChange(() => this.PreviewInfo); + + if (this.selectedPreview == maxPreview) + { + this.IsNextPreviewControlVisible = false; + this.NotifyOfPropertyChange(() => this.IsNextPreviewControlVisible); + } + } + + public void PreviousPreview() + { + int maxPreview = this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount); + this.selectedPreview = this.selectedPreview - 1; + this.UpdatePreviewFrame(); + this.PreviewInfo = string.Format(ResourcesUI.SummaryView_PreviewInfo, this.selectedPreview, maxPreview); + this.NotifyOfPropertyChange(() => this.PreviewInfo); + + if (this.selectedPreview == 1) + { + this.IsPreviousPreviewControlVisible = false; + this.NotifyOfPropertyChange(() => this.IsPreviousPreviewControlVisible); + } + } + + public void SetPreviewControlVisibility(bool isPreviousVisible, bool isNextVisible) + { + if (this.selectedPreview > 1) + { + this.IsPreviousPreviewControlVisible = isPreviousVisible; + } + else + { + this.IsPreviousPreviewControlVisible = false; + } + + if (this.selectedPreview < this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount)) + { + this.IsNextPreviewControlVisible = isNextVisible; + } + else + { + this.IsNextPreviewControlVisible = false; + } + + this.NotifyOfPropertyChange(() => this.IsPreviousPreviewControlVisible); + this.NotifyOfPropertyChange(() => this.IsNextPreviewControlVisible); + } + + #region Private Methods + private void UpdateSettings(Preset selectedPreset) { // Main Window Settings @@ -368,6 +427,10 @@ namespace HandBrakeWPF.ViewModels this.AspectInfo = string.Empty; this.NotifyOfPropertyChange(() => this.AspectInfo); + + // Preview + this.PreviewInfo = string.Format(ResourcesUI.SummaryView_PreviewInfo, this.selectedPreview, this.userSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount)); + this.NotifyOfPropertyChange(() => this.PreviewInfo); } private string GetFilterDescription() @@ -506,6 +569,8 @@ namespace HandBrakeWPF.ViewModels if (this.Task.Anamorphic == Anamorphic.Loose && this.Task.Width < 32) { this.PreviewNotAvailable = true; + this.IsPreviewInfoVisible = false; + this.NotifyOfPropertyChange(() => this.IsPreviewInfoVisible); return; } @@ -518,7 +583,7 @@ namespace HandBrakeWPF.ViewModels BitmapImage image = null; try { - image = this.scanService.GetPreview(this.Task, 2, HBConfigurationFactory.Create()); // TODO make preview image configurable? + image = this.scanService.GetPreview(this.Task, this.selectedPreview - 1, HBConfigurationFactory.Create()); } catch (Exception exc) { @@ -530,6 +595,8 @@ namespace HandBrakeWPF.ViewModels { this.PreviewNotAvailable = false; this.PreviewImage = image; + this.IsPreviewInfoVisible = true; + this.NotifyOfPropertyChange(() => this.IsPreviewInfoVisible); this.NotifyOfPropertyChange(() => this.PreviewImage); } } @@ -538,5 +605,7 @@ namespace HandBrakeWPF.ViewModels { this.OutputFormatChanged?.Invoke(this, e); } + + #endregion } } diff --git a/win/CS/HandBrakeWPF/Views/SummaryView.xaml b/win/CS/HandBrakeWPF/Views/SummaryView.xaml index 8dd6b46e9..59a0ce04b 100644 --- a/win/CS/HandBrakeWPF/Views/SummaryView.xaml +++ b/win/CS/HandBrakeWPF/Views/SummaryView.xaml @@ -5,6 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Properties="clr-namespace:HandBrakeWPF.Properties" xmlns:converters="clr-namespace:HandBrakeWPF.Converters" + xmlns:cal="http://www.caliburnproject.org" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="600"> @@ -100,23 +101,25 @@ <RowDefinition Height="*" /> </Grid.RowDefinitions> - - <Image Source="{Binding PreviewImage}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,5,10,0" /> - - <Border BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" VerticalAlignment="Center" HorizontalAlignment="Left" - Background="Black" Opacity="0.55" Margin="10,5,20,0" Visibility="{Binding IsPreviousPreviewControlVisible, Converter={StaticResource boolToVisConverter}}"> - <TextBlock Text="<" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="8,3" Margin="0" /> - </Border> - - <Border BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" VerticalAlignment="Center" HorizontalAlignment="Right" - Background="Black" Opacity="0.55" Margin="10,5,20,0" Visibility="{Binding IsNextPreviewControlVisible, Converter={StaticResource boolToVisConverter}}"> - <TextBlock Text=">" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="8,3" Margin="0" /> - </Border> - - <Border BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" VerticalAlignment="Bottom" HorizontalAlignment="Center" - Background="Black" Opacity="0.66" Margin="10,5,20,5"> - <TextBlock Text="Preview 2 of 10" FontSize="14" Foreground="White" Padding="8,3" Visibility="Collapsed" /> - </Border> + <Grid> + <Image Source="{Binding PreviewImage}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10,5,10,0" x:Name="previewImage" MouseMove="PreviewImage_OnMouseMove" Panel.ZIndex="0" /> + + <Border BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" VerticalAlignment="Center" HorizontalAlignment="Left" Panel.ZIndex="1" cal:Message.Attach="[Event MouseDown] = [Action PreviousPreview]" + Background="Black" Opacity="0.75" Margin="20,0,0,0" Visibility="{Binding IsPreviousPreviewControlVisible, Converter={StaticResource boolToVisConverter}}" > + <TextBlock Text="<" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="8,3" Margin="0" /> + </Border> + + <Border BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" VerticalAlignment="Center" HorizontalAlignment="Right" Panel.ZIndex="1" cal:Message.Attach="[Event MouseDown] = [Action NextPreview]" + Background="Black" Opacity="0.75" Margin="0,0,20,0" Visibility="{Binding IsNextPreviewControlVisible, Converter={StaticResource boolToVisConverter}}"> + <TextBlock Text=">" FontSize="30" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="8,3" Margin="0" /> + </Border> + + <Border BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" VerticalAlignment="Bottom" HorizontalAlignment="Center" + Background="Black" Opacity="0.75" Margin="0,5,0,10"> + <TextBlock Text="{Binding PreviewInfo}" FontSize="14" Foreground="White" Padding="8,3" Visibility="{Binding IsPreviewInfoVisible, Converter={StaticResource boolToVisConverter}}" /> + </Border> + </Grid> + <Grid Margin="10,5,0,0" Grid.Row="1"> <Grid.ColumnDefinitions> diff --git a/win/CS/HandBrakeWPF/Views/SummaryView.xaml.cs b/win/CS/HandBrakeWPF/Views/SummaryView.xaml.cs index e3c35b48e..744003698 100644 --- a/win/CS/HandBrakeWPF/Views/SummaryView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/SummaryView.xaml.cs @@ -10,6 +10,12 @@ namespace HandBrakeWPF.Views { using System.Windows.Controls; + using System.Windows.Input; + + using HandBrakeWPF.ViewModels.Interfaces; + + using Image = System.Windows.Controls.Image; + using Point = System.Windows.Point; /// <summary> /// Interaction logic for SummaryView.xaml @@ -20,5 +26,21 @@ namespace HandBrakeWPF.Views { this.InitializeComponent(); } + + private void PreviewImage_OnMouseMove(object sender, MouseEventArgs e) + { + Image image = sender as Image; + + if (image != null && image.ActualWidth > 0) + { + Point p = Mouse.GetPosition(image); + double width = image.ActualWidth / 2; + + bool leftHalf = p.X <= width; + bool rightHalf = p.X > width; + + ((ISummaryViewModel)this.DataContext).SetPreviewControlVisibility(leftHalf, rightHalf); + } + } } } |