summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-11-22 22:25:59 +0000
committersr55 <[email protected]>2013-11-22 22:25:59 +0000
commit6d1a0aaf440872cde4661d9ae50816a97331d55f (patch)
tree531f5be5317cc6a7cddcf60069ea989033c4d822 /win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
parentacc52477100589c854cd3410a09949dd86fac754 (diff)
WinGui: Some additional work on Static Previews. Added slider to select the preview and set Max size on the image to prevent upscaling. Note, this feature is still not enabled in the UI.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5902 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs159
1 files changed, 154 insertions, 5 deletions
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