diff options
author | sr55 <[email protected]> | 2013-11-19 23:18:43 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-11-19 23:18:43 +0000 |
commit | acc52477100589c854cd3410a09949dd86fac754 (patch) | |
tree | bf4658ab3770f0541a5be78498a5cecc7687484f /win | |
parent | c32a46c925608e51be9edcd6b5647c50124dd16a (diff) |
WinGui: Putting in place the framework for a static preview window. Initial window created and now displays a static preview. This feature is not enabled in the UI yet.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5901 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
11 files changed, 225 insertions, 20 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs index f102d0d36..05bc52499 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs @@ -10,6 +10,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
{
using System;
+ using System.Windows.Media.Imaging;
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
@@ -91,6 +92,20 @@ namespace HandBrake.ApplicationServices.Services.Interfaces void Scan(string sourcePath, int title, Action<bool> postAction, HBConfiguration configuration);
/// <summary>
+ /// Get a Preview image for the current job and preview number.
+ /// </summary>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <param name="preview">
+ /// The preview.
+ /// </param>
+ /// <returns>
+ /// The <see cref="BitmapImage"/>.
+ /// </returns>
+ BitmapImage GetPreview(EncodeTask task, int preview);
+
+ /// <summary>
/// Kill the scan
/// </summary>
void Stop();
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs index 167394764..24c364024 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibScan.cs @@ -13,6 +13,7 @@ namespace HandBrake.ApplicationServices.Services using System.Collections.Generic;
using System.IO;
using System.Text;
+ using System.Windows.Media.Imaging;
using HandBrake.ApplicationServices.EventArgs;
using HandBrake.ApplicationServices.Model;
@@ -23,6 +24,7 @@ namespace HandBrake.ApplicationServices.Services using HandBrake.Interop;
using HandBrake.Interop.EventArgs;
using HandBrake.Interop.Interfaces;
+ using HandBrake.Interop.Model;
using AudioTrack = HandBrake.ApplicationServices.Parsing.Audio;
using ScanProgressEventArgs = HandBrake.Interop.EventArgs.ScanProgressEventArgs;
@@ -239,6 +241,30 @@ namespace HandBrake.ApplicationServices.Services }
}
+ /// <summary>
+ /// Get a Preview image for the current job and preview number.
+ /// </summary>
+ /// <param name="job">
+ /// The job.
+ /// </param>
+ /// <param name="preview">
+ /// The preview.
+ /// </param>
+ /// <returns>
+ /// The <see cref="BitmapImage"/>.
+ /// </returns>
+ public BitmapImage GetPreview(EncodeTask job, int preview)
+ {
+ if (this.instance == null)
+ {
+ return null;
+ }
+
+ EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);
+ BitmapImage bitmapImage = this.instance.GetPreview(encodeJob, preview);
+ return bitmapImage;
+ }
+
#endregion
#region Private Methods
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index 81b4a63c1..c8095f9c1 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -25,13 +25,13 @@ namespace HandBrake.ApplicationServices.Utilities public class InteropModelCreator
{
/// <summary>
- /// Get an EncodeJob model for a LibHB Encode.
+ /// The get encode job.
/// </summary>
/// <param name="task">
/// The task.
/// </param>
/// <returns>
- /// An Interop.EncodeJob model.
+ /// The <see cref="EncodeJob"/>.
/// </returns>
public static EncodeJob GetEncodeJob(QueueTask task)
{
@@ -41,8 +41,22 @@ namespace HandBrake.ApplicationServices.Utilities return null;
}
+ return GetEncodeJob(task.Task);
+ }
+
+ /// <summary>
+ /// Get an EncodeJob model for a LibHB Encode.
+ /// </summary>
+ /// <param name="task">
+ /// The task.
+ /// </param>
+ /// <returns>
+ /// An Interop.EncodeJob model.
+ /// </returns>
+ public static EncodeJob GetEncodeJob(EncodeTask task)
+ {
// The current Job Configuration
- EncodeTask work = task.Task;
+ EncodeTask work = task;
// Which will be converted to this EncodeJob Model.
EncodeJob job = new EncodeJob();
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 5e8ab59c2..f7b44df16 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -145,6 +145,8 @@ <Compile Include="Services\UserSettingService.cs" />
<Compile Include="ViewModels\CountdownAlertViewModel.cs" />
<Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />
+ <Compile Include="ViewModels\Interfaces\IStaticPreviewViewModel.cs" />
+ <Compile Include="ViewModels\StaticPreviewViewModel.cs" />
<Compile Include="Views\CountdownAlertView.xaml.cs">
<DependentUpon>CountdownAlertView.xaml</DependentUpon>
</Compile>
@@ -216,6 +218,9 @@ <Compile Include="ViewModels\Interfaces\ITitleSpecificViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="ViewModels\TitleSpecificViewModel.cs" />
+ <Compile Include="Views\StaticPreviewView.xaml.cs">
+ <DependentUpon>StaticPreviewView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Views\TitleSpecificView.xaml.cs">
<DependentUpon>TitleSpecificView.xaml</DependentUpon>
</Compile>
@@ -395,6 +400,10 @@ <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
+ <Page Include="Views\StaticPreviewView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Views\TitleSpecificView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index 45dbde20d..387a950ec 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -81,9 +81,11 @@ namespace HandBrakeWPF.Startup this.windsorContainer.Register(Component.For<ITitleSpecificViewModel>().ImplementedBy<TitleSpecificViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IQueueSelectionViewModel>().ImplementedBy<QueueSelectionViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<ICountdownAlertViewModel>().ImplementedBy<CountdownAlertViewModel>().LifeStyle.Is(LifestyleType.Singleton));
-
+
+ // Experimental Services and Windows.
this.windsorContainer.Register(Component.For<IInstantViewModel>().ImplementedBy<InstantViewModel>().LifeStyle.Is(LifestyleType.Singleton));
-
+ this.windsorContainer.Register(Component.For<IStaticPreviewViewModel>().ImplementedBy<StaticPreviewViewModel>().LifeStyle.Is(LifestyleType.Singleton));
+
// Tab Components
this.windsorContainer.Register(Component.For<IAudioViewModel>().ImplementedBy<AudioViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IX264ViewModel>().ImplementedBy<X264ViewModel>().LifeStyle.Is(LifestyleType.Singleton));
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs new file mode 100644 index 000000000..91c75fe45 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs @@ -0,0 +1,27 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="IStaticPreviewViewModel.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The Static Preview View Model Interface
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ using System.Windows.Media.Imaging;
+
+ /// <summary>
+ /// The Static Preview View Model Interface
+ /// </summary>
+ public interface IStaticPreviewViewModel
+ {
+ /// <summary>
+ /// The preview frame.
+ /// </summary>
+ /// <param name="image">
+ /// The image.
+ /// </param>
+ void PreviewFrame(BitmapImage image);
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index 59ce20942..2cde191f5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels using System;
using System.Collections.Generic;
using System.Globalization;
+ using System.Windows.Media.Imaging;
using Caliburn.Micro;
@@ -109,13 +110,7 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.PictureSettingsViewModel"/> class.
/// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public PictureSettingsViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ public PictureSettingsViewModel()
{
this.Task = new EncodeTask();
this.SelectedModulus = 16;
@@ -131,6 +126,11 @@ namespace HandBrakeWPF.ViewModels #region Properties
/// <summary>
+ /// Gets or sets the static preview view model.
+ /// </summary>
+ public IStaticPreviewViewModel StaticPreviewViewModel { get; set; }
+
+ /// <summary>
/// Gets AnamorphicModes.
/// </summary>
public IEnumerable<Anamorphic> AnamorphicModes
@@ -595,9 +595,7 @@ namespace HandBrakeWPF.ViewModels #endregion
- #region Implemented Interfaces
-
- #region ITabInterface
+ #region Public Methods
/// <summary>
/// Setup this tab for the specified preset.
@@ -802,7 +800,21 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Task);
}
- #endregion
+ /// <summary>
+ /// The preview image.
+ /// Experimental Feature => In-Progress
+ /// </summary>
+ public void PreviewImage()
+ {
+ IScan scanService = IoC.Get<IScan>();
+ BitmapImage image = scanService.GetPreview(this.Task, 5);
+
+ if (image != null)
+ {
+ this.StaticPreviewViewModel.PreviewFrame(image);
+ this.WindowManager.ShowDialog(this.StaticPreviewViewModel);
+ }
+ }
#endregion
@@ -1164,6 +1176,6 @@ namespace HandBrakeWPF.ViewModels return job;
}
- #endregion
+ #endregion
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs new file mode 100644 index 000000000..dc851864a --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -0,0 +1,58 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="StaticPreviewViewModel.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The Static Preview View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System.Windows.Media.Imaging;
+
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Static Preview View Model
+ /// </summary>
+ public class StaticPreviewViewModel : ViewModelBase, IStaticPreviewViewModel
+ {
+ /// <summary>
+ /// The preview image.
+ /// </summary>
+ private BitmapImage previewImage;
+
+ /// <summary>
+ /// Gets or sets the preview image.
+ /// </summary>
+ public BitmapImage PreviewImage
+ {
+ get
+ {
+ return this.previewImage;
+ }
+ set
+ {
+ if (Equals(value, this.previewImage))
+ {
+ return;
+ }
+
+ this.previewImage = value;
+ this.NotifyOfPropertyChange(() => this.PreviewImage);
+ }
+ }
+
+ /// <summary>
+ /// The preview frame.
+ /// </summary>
+ /// <param name="image">
+ /// The image.
+ /// </param>
+ public void PreviewFrame(BitmapImage image)
+ {
+ this.PreviewImage = image;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml b/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml index a808c76b4..12d75bf44 100644 --- a/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml +++ b/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
- xmlns:controls="clr-namespace:HandBrakeWPF.Controls">
+ xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
+ xmlns:cal="http://www.caliburnproject.org">
<UserControl.Resources>
<Converters:BooleanConverter x:Key="boolConverter" />
@@ -59,7 +60,7 @@ Visibility="{Binding ShowModulus, Converter={StaticResource boolToVisConverter}}"
Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />
</Grid>
-
+
<!-- Custom Anamoprhic -->
<Grid Margin="5,15,5,0" Visibility="{Binding ShowCustomAnamorphicControls, Converter={StaticResource boolToVisConverter}}">
<Grid.RowDefinitions>
@@ -84,7 +85,7 @@ <controls:NumberBox Width="60" Number="{Binding ParHeight, Mode=TwoWay}" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" AllowEmpty="False"
IsEnabled="{Binding MaintainAspectRatio, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,0,5" />
</Grid>
-
+
<!-- Row 5-->
<Grid Margin="5,15,5,0">
<Grid.RowDefinitions>
@@ -143,6 +144,10 @@ </Grid>
+
+ <Label Content="Preview" FontWeight="Bold" Margin="15,0,0,0" Visibility="Collapsed" />
+ <Button Content="Show Preview" cal:Message.Attach="[Event Click] = [Action PreviewImage]" Visibility="Collapsed" />
+
</StackPanel>
</StackPanel>
</UserControl>
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml new file mode 100644 index 000000000..133ce551e --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml @@ -0,0 +1,10 @@ +<Window x:Class="HandBrakeWPF.Views.StaticPreviewView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ 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">
+ <Grid>
+ <Image Source="{Binding PreviewImage}" />
+ </Grid>
+</Window>
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs new file mode 100644 index 000000000..8c2c55991 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs @@ -0,0 +1,27 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="StaticPreviewView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Interaction logic for StaticPreviewView.xaml
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Views
+{
+ using System.Windows;
+
+ /// <summary>
+ /// Interaction logic for StaticPreviewView.xaml
+ /// </summary>
+ public partial class StaticPreviewView : Window
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="StaticPreviewView"/> class.
+ /// </summary>
+ public StaticPreviewView()
+ {
+ InitializeComponent();
+ }
+ }
+}
|