diff options
Diffstat (limited to 'win/CS')
4 files changed, 174 insertions, 10 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs index 91c75fe45..a0374b5f1 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs @@ -11,6 +11,8 @@ namespace HandBrakeWPF.ViewModels.Interfaces {
using System.Windows.Media.Imaging;
+ using HandBrake.ApplicationServices.Model;
+
/// <summary>
/// The Static Preview View Model Interface
/// </summary>
@@ -22,6 +24,9 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <param name="image">
/// The image.
/// </param>
- void PreviewFrame(BitmapImage image);
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ void PreviewFrame(BitmapImage image, EncodeTask task);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index 2cde191f5..e3cb8afa1 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -807,11 +807,11 @@ namespace HandBrakeWPF.ViewModels public void PreviewImage()
{
IScan scanService = IoC.Get<IScan>();
- BitmapImage image = scanService.GetPreview(this.Task, 5);
+ BitmapImage image = scanService.GetPreview(this.Task, 1);
if (image != null)
{
- this.StaticPreviewViewModel.PreviewFrame(image);
+ this.StaticPreviewViewModel.PreviewFrame(image, this.Task);
this.WindowManager.ShowDialog(this.StaticPreviewViewModel);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs index dc851864a..d836f6d49 100644 --- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -9,22 +9,88 @@ namespace HandBrakeWPF.ViewModels
{
+ using System;
using System.Windows.Media.Imaging;
+ using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
- /// The Static Preview View Model
+ /// The Static Preview View Model
/// </summary>
public class StaticPreviewViewModel : ViewModelBase, IStaticPreviewViewModel
{
+ #region Fields
+
+ /// <summary>
+ /// The scan service.
+ /// </summary>
+ private readonly IScan scanService;
+
+ /// <summary>
+ /// The height.
+ /// </summary>
+ private int height;
+
/// <summary>
- /// The preview image.
+ /// The preview image.
/// </summary>
private BitmapImage previewImage;
/// <summary>
- /// Gets or sets the preview image.
+ /// The selected preview image.
+ /// </summary>
+ private int selectedPreviewImage;
+
+ /// <summary>
+ /// The width.
+ /// </summary>
+ private int width;
+
+ #endregion
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class.
+ /// </summary>
+ /// <param name="scanService">
+ /// The scan service.
+ /// </param>
+ public StaticPreviewViewModel(IScan scanService)
+ {
+ this.scanService = scanService;
+ this.selectedPreviewImage = 1;
+ }
+
+ #endregion
+
+ #region Public Properties
+
+ /// <summary>
+ /// Gets or sets the height.
+ /// </summary>
+ public int Height
+ {
+ get
+ {
+ return this.height;
+ }
+ set
+ {
+ if (value == this.height)
+ {
+ return;
+ }
+ this.height = value;
+ this.NotifyOfPropertyChange(() => this.Height);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the preview image.
/// </summary>
public BitmapImage PreviewImage
{
@@ -45,14 +111,97 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets the selected preview image.
+ /// </summary>
+ public int SelectedPreviewImage
+ {
+ get
+ {
+ return this.selectedPreviewImage;
+ }
+ set
+ {
+ if (value == this.selectedPreviewImage)
+ {
+ return;
+ }
+ this.selectedPreviewImage = value;
+ this.NotifyOfPropertyChange(() => this.SelectedPreviewImage);
+
+ this.UpdatePreviewFrame();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the task.
+ /// </summary>
+ public EncodeTask Task { get; set; }
+
+ /// <summary>
+ /// Gets the total previews.
+ /// </summary>
+ public int TotalPreviews
+ {
+ get
+ {
+ return this.UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount) - 1;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the width.
+ /// </summary>
+ public int Width
+ {
+ get
+ {
+ return this.width;
+ }
+ set
+ {
+ if (value == this.width)
+ {
+ return;
+ }
+ this.width = value;
+ this.NotifyOfPropertyChange(() => this.Width);
+ }
+ }
+
+ #endregion
+
+ #region Public Methods and Operators
+
+ /// <summary>
/// The preview frame.
/// </summary>
/// <param name="image">
/// The image.
/// </param>
- public void PreviewFrame(BitmapImage image)
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ public void PreviewFrame(BitmapImage image, EncodeTask task)
{
+ this.Task = task;
+ this.Width = (int)Math.Ceiling(image.Width);
+ this.Height = (int)Math.Ceiling(image.Height);
this.PreviewImage = image;
}
+
+ /// <summary>
+ /// The update preview frame.
+ /// </summary>
+ public void UpdatePreviewFrame()
+ {
+ BitmapImage image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage);
+
+ if (image != null)
+ {
+ this.PreviewFrame(image, this.Task);
+ }
+ }
+
+ #endregion
}
-}
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml index 133ce551e..080d10ea8 100644 --- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml @@ -3,8 +3,18 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- mc:Ignorable="d">
+ mc:Ignorable="d" SizeToContent="WidthAndHeight"
+ TextOptions.TextFormattingMode="Display"
+ Title="Still Preview">
<Grid>
- <Image Source="{Binding PreviewImage}" />
+
+ <Image Source="{Binding PreviewImage}" MaxWidth="{Binding Width}" MaxHeight="{Binding Height}" />
+ <Slider Maximum="{Binding TotalPreviews}" Minimum="0"
+ Value="{Binding SelectedPreviewImage}"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Center"
+ Margin="0,0,0,20" Width="150"
+ Background="Transparent"
+ />
</Grid>
</Window>
|