]> granicus.if.org Git - handbrake/commitdiff
WinGui: Putting in place the framework for a static preview window. Initial window...
authorsr55 <sr55.hb@outlook.com>
Tue, 19 Nov 2013 23:18:43 +0000 (23:18 +0000)
committersr55 <sr55.hb@outlook.com>
Tue, 19 Nov 2013 23:18:43 +0000 (23:18 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5901 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Services/Interfaces/IScan.cs
win/CS/HandBrake.ApplicationServices/Services/LibScan.cs
win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs
win/CS/HandBrakeWPF/HandBrakeWPF.csproj
win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs
win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs [new file with mode: 0644]
win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml [new file with mode: 0644]
win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs [new file with mode: 0644]

index f102d0d36030af6b4b6c10fae405ed87fefadef4..05bc52499673404d488f6bbc645529b592ea0dee 100644 (file)
@@ -10,6 +10,7 @@
 namespace HandBrake.ApplicationServices.Services.Interfaces\r
 {\r
     using System;\r
+    using System.Windows.Media.Imaging;\r
 \r
     using HandBrake.ApplicationServices.EventArgs;\r
     using HandBrake.ApplicationServices.Model;\r
@@ -90,6 +91,20 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
         /// </param>\r
         void Scan(string sourcePath, int title, Action<bool> postAction, HBConfiguration configuration);\r
 \r
+        /// <summary>\r
+        /// Get a Preview image for the current job and preview number.\r
+        /// </summary>\r
+        /// <param name="task">\r
+        /// The task.\r
+        /// </param>\r
+        /// <param name="preview">\r
+        /// The preview.\r
+        /// </param>\r
+        /// <returns>\r
+        /// The <see cref="BitmapImage"/>.\r
+        /// </returns>\r
+        BitmapImage GetPreview(EncodeTask task, int preview);\r
+\r
         /// <summary>\r
         /// Kill the scan\r
         /// </summary>\r
index 167394764997d8e63e60051a0ded2bf8646581d4..24c364024ce74a89dbafce68421a15c539eabe0d 100644 (file)
@@ -13,6 +13,7 @@ namespace HandBrake.ApplicationServices.Services
     using System.Collections.Generic;\r
     using System.IO;\r
     using System.Text;\r
+    using System.Windows.Media.Imaging;\r
 \r
     using HandBrake.ApplicationServices.EventArgs;\r
     using HandBrake.ApplicationServices.Model;\r
@@ -23,6 +24,7 @@ namespace HandBrake.ApplicationServices.Services
     using HandBrake.Interop;\r
     using HandBrake.Interop.EventArgs;\r
     using HandBrake.Interop.Interfaces;\r
+    using HandBrake.Interop.Model;\r
 \r
     using AudioTrack = HandBrake.ApplicationServices.Parsing.Audio;\r
     using ScanProgressEventArgs = HandBrake.Interop.EventArgs.ScanProgressEventArgs;\r
@@ -239,6 +241,30 @@ namespace HandBrake.ApplicationServices.Services
             }\r
         }\r
 \r
+        /// <summary>\r
+        /// Get a Preview image for the current job and preview number.\r
+        /// </summary>\r
+        /// <param name="job">\r
+        /// The job.\r
+        /// </param>\r
+        /// <param name="preview">\r
+        /// The preview.\r
+        /// </param>\r
+        /// <returns>\r
+        /// The <see cref="BitmapImage"/>.\r
+        /// </returns>\r
+        public BitmapImage GetPreview(EncodeTask job, int preview)\r
+        {\r
+            if (this.instance == null)\r
+            {\r
+                return null;\r
+            }\r
+\r
+            EncodeJob encodeJob = InteropModelCreator.GetEncodeJob(job);\r
+            BitmapImage bitmapImage = this.instance.GetPreview(encodeJob, preview);\r
+            return bitmapImage;\r
+        }\r
+\r
         #endregion\r
 \r
         #region Private Methods\r
index 81b4a63c1863d7009f47643843c3b4c62b453522..c8095f9c14449ef0dba3689712ef589cf574467b 100644 (file)
@@ -25,13 +25,13 @@ namespace HandBrake.ApplicationServices.Utilities
     public class InteropModelCreator\r
     {\r
         /// <summary>\r
-        /// Get an EncodeJob model for a LibHB Encode.\r
+        /// The get encode job.\r
         /// </summary>\r
         /// <param name="task">\r
         /// The task.\r
         /// </param>\r
         /// <returns>\r
-        /// An Interop.EncodeJob model.\r
+        /// The <see cref="EncodeJob"/>.\r
         /// </returns>\r
         public static EncodeJob GetEncodeJob(QueueTask task)\r
         {\r
@@ -41,8 +41,22 @@ namespace HandBrake.ApplicationServices.Utilities
                 return null;\r
             }\r
 \r
+            return GetEncodeJob(task.Task);\r
+        }\r
+\r
+        /// <summary>\r
+        /// Get an EncodeJob model for a LibHB Encode.\r
+        /// </summary>\r
+        /// <param name="task">\r
+        /// The task.\r
+        /// </param>\r
+        /// <returns>\r
+        /// An Interop.EncodeJob model.\r
+        /// </returns>\r
+        public static EncodeJob GetEncodeJob(EncodeTask task)\r
+        {\r
             // The current Job Configuration\r
-            EncodeTask work = task.Task;\r
+            EncodeTask work = task;\r
 \r
             // Which will be converted to this EncodeJob Model.\r
             EncodeJob job = new EncodeJob();\r
index 5e8ab59c2c170bc950060ba4b7256164263bb770..f7b44df16d8490d2cd856704cd1995426926f693 100644 (file)
     <Compile Include="Services\UserSettingService.cs" />\r
     <Compile Include="ViewModels\CountdownAlertViewModel.cs" />\r
     <Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />\r
+    <Compile Include="ViewModels\Interfaces\IStaticPreviewViewModel.cs" />\r
+    <Compile Include="ViewModels\StaticPreviewViewModel.cs" />\r
     <Compile Include="Views\CountdownAlertView.xaml.cs">\r
       <DependentUpon>CountdownAlertView.xaml</DependentUpon>\r
     </Compile>\r
     <Compile Include="ViewModels\Interfaces\ITitleSpecificViewModel.cs" />\r
     <Compile Include="ViewModels\ShellViewModel.cs" />\r
     <Compile Include="ViewModels\TitleSpecificViewModel.cs" />\r
+    <Compile Include="Views\StaticPreviewView.xaml.cs">\r
+      <DependentUpon>StaticPreviewView.xaml</DependentUpon>\r
+    </Compile>\r
     <Compile Include="Views\TitleSpecificView.xaml.cs">\r
       <DependentUpon>TitleSpecificView.xaml</DependentUpon>\r
     </Compile>\r
       <SubType>Designer</SubType>\r
       <Generator>MSBuild:Compile</Generator>\r
     </Page>\r
+    <Page Include="Views\StaticPreviewView.xaml">\r
+      <SubType>Designer</SubType>\r
+      <Generator>MSBuild:Compile</Generator>\r
+    </Page>\r
     <Page Include="Views\TitleSpecificView.xaml">\r
       <SubType>Designer</SubType>\r
       <Generator>MSBuild:Compile</Generator>\r
index 45dbde20d29935c7532bd970f22db351c37ee01c..387a950ec5fb64aa6c1d793ebde5eec179bee238 100644 (file)
@@ -81,9 +81,11 @@ namespace HandBrakeWPF.Startup
             this.windsorContainer.Register(Component.For<ITitleSpecificViewModel>().ImplementedBy<TitleSpecificViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
             this.windsorContainer.Register(Component.For<IQueueSelectionViewModel>().ImplementedBy<QueueSelectionViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
             this.windsorContainer.Register(Component.For<ICountdownAlertViewModel>().ImplementedBy<CountdownAlertViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
-                   \r
+                 \r
+            // Experimental Services and Windows.\r
             this.windsorContainer.Register(Component.For<IInstantViewModel>().ImplementedBy<InstantViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
-\r
+            this.windsorContainer.Register(Component.For<IStaticPreviewViewModel>().ImplementedBy<StaticPreviewViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
+                \r
             // Tab Components\r
             this.windsorContainer.Register(Component.For<IAudioViewModel>().ImplementedBy<AudioViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
             this.windsorContainer.Register(Component.For<IX264ViewModel>().ImplementedBy<X264ViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs
new file mode 100644 (file)
index 0000000..91c75fe
--- /dev/null
@@ -0,0 +1,27 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="IStaticPreviewViewModel.cs" company="HandBrake Project (http://handbrake.fr)">\r
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+//   The Static Preview View Model Interface\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.ViewModels.Interfaces\r
+{\r
+    using System.Windows.Media.Imaging;\r
+\r
+    /// <summary>\r
+    /// The Static Preview View Model Interface\r
+    /// </summary>\r
+    public interface IStaticPreviewViewModel\r
+    {\r
+        /// <summary>\r
+        /// The preview frame.\r
+        /// </summary>\r
+        /// <param name="image">\r
+        /// The image.\r
+        /// </param>\r
+        void PreviewFrame(BitmapImage image);\r
+    }\r
+}\r
index 59ce2094253baff89e219924c8bd176f53cd8a74..2cde191f572b57e522561e10aaa304df125619ae 100644 (file)
@@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels
     using System;\r
     using System.Collections.Generic;\r
     using System.Globalization;\r
+    using System.Windows.Media.Imaging;\r
 \r
     using Caliburn.Micro;\r
 \r
@@ -109,13 +110,7 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.PictureSettingsViewModel"/> class.\r
         /// </summary>\r
-        /// <param name="windowManager">\r
-        /// The window manager.\r
-        /// </param>\r
-        /// <param name="userSettingService">\r
-        /// The user Setting Service.\r
-        /// </param>\r
-        public PictureSettingsViewModel(IWindowManager windowManager, IUserSettingService userSettingService)\r
+        public PictureSettingsViewModel()\r
         {\r
             this.Task = new EncodeTask();\r
             this.SelectedModulus = 16;\r
@@ -130,6 +125,11 @@ namespace HandBrakeWPF.ViewModels
 \r
         #region Properties\r
 \r
+        /// <summary>\r
+        /// Gets or sets the static preview view model.\r
+        /// </summary>\r
+        public IStaticPreviewViewModel StaticPreviewViewModel { get; set; }\r
+\r
         /// <summary>\r
         /// Gets AnamorphicModes.\r
         /// </summary>\r
@@ -595,9 +595,7 @@ namespace HandBrakeWPF.ViewModels
 \r
         #endregion\r
 \r
-        #region Implemented Interfaces\r
-\r
-        #region ITabInterface\r
+        #region Public Methods\r
 \r
         /// <summary>\r
         /// Setup this tab for the specified preset.\r
@@ -802,7 +800,21 @@ namespace HandBrakeWPF.ViewModels
             this.NotifyOfPropertyChange(() => this.Task);\r
         }\r
 \r
-        #endregion\r
+        /// <summary>\r
+        /// The preview image.\r
+        /// Experimental Feature => In-Progress\r
+        /// </summary>\r
+        public void PreviewImage()\r
+        {\r
+            IScan scanService = IoC.Get<IScan>();\r
+            BitmapImage image = scanService.GetPreview(this.Task, 5);\r
+\r
+            if (image != null)\r
+            {\r
+                this.StaticPreviewViewModel.PreviewFrame(image);\r
+                this.WindowManager.ShowDialog(this.StaticPreviewViewModel);\r
+            }\r
+        }\r
 \r
         #endregion\r
 \r
@@ -1164,6 +1176,6 @@ namespace HandBrakeWPF.ViewModels
             return job;\r
         }\r
 \r
-        #endregion\r
+       #endregion\r
     }\r
 }
\ 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 (file)
index 0000000..dc85186
--- /dev/null
@@ -0,0 +1,58 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="StaticPreviewViewModel.cs" company="HandBrake Project (http://handbrake.fr)">\r
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+//   The Static Preview View Model\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.ViewModels\r
+{\r
+    using System.Windows.Media.Imaging;\r
+\r
+    using HandBrakeWPF.ViewModels.Interfaces;\r
+\r
+    /// <summary>\r
+    /// The Static Preview View Model\r
+    /// </summary>\r
+    public class StaticPreviewViewModel : ViewModelBase, IStaticPreviewViewModel\r
+    {\r
+        /// <summary>\r
+        /// The preview image.\r
+        /// </summary>\r
+        private BitmapImage previewImage;\r
+\r
+        /// <summary>\r
+        /// Gets or sets the preview image.\r
+        /// </summary>\r
+        public BitmapImage PreviewImage\r
+        {\r
+            get\r
+            {\r
+                return this.previewImage;\r
+            }\r
+            set\r
+            {\r
+                if (Equals(value, this.previewImage))\r
+                {\r
+                    return;\r
+                }\r
+\r
+                this.previewImage = value;\r
+                this.NotifyOfPropertyChange(() => this.PreviewImage);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// The preview frame.\r
+        /// </summary>\r
+        /// <param name="image">\r
+        /// The image.\r
+        /// </param>\r
+        public void PreviewFrame(BitmapImage image)\r
+        {\r
+            this.PreviewImage = image;\r
+        }\r
+    }\r
+}\r
index a808c76b4ecf582e05dfeed6b3aad618d666dff7..12d75bf44abda2136f93ac3c38d4f6eb41eae29b 100644 (file)
@@ -2,7 +2,8 @@
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
              xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"\r
-             xmlns:controls="clr-namespace:HandBrakeWPF.Controls">\r
+             xmlns:controls="clr-namespace:HandBrakeWPF.Controls"\r
+             xmlns:cal="http://www.caliburnproject.org">\r
 \r
     <UserControl.Resources>\r
         <Converters:BooleanConverter x:Key="boolConverter" />\r
@@ -59,7 +60,7 @@
                           Visibility="{Binding ShowModulus, Converter={StaticResource boolToVisConverter}}"\r
                           Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" />\r
             </Grid>\r
-            \r
+\r
             <!-- Custom Anamoprhic -->\r
             <Grid Margin="5,15,5,0" Visibility="{Binding ShowCustomAnamorphicControls, Converter={StaticResource boolToVisConverter}}">\r
                 <Grid.RowDefinitions>\r
@@ -84,7 +85,7 @@
                 <controls:NumberBox Width="60" Number="{Binding ParHeight, Mode=TwoWay}" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" AllowEmpty="False"\r
                                              IsEnabled="{Binding MaintainAspectRatio, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,0,5" />\r
             </Grid>\r
-            \r
+\r
             <!-- Row 5-->\r
             <Grid Margin="5,15,5,0">\r
                 <Grid.RowDefinitions>\r
 \r
             </Grid>\r
 \r
+\r
+            <Label Content="Preview" FontWeight="Bold" Margin="15,0,0,0" Visibility="Collapsed" />\r
+            <Button Content="Show Preview" cal:Message.Attach="[Event Click] = [Action PreviewImage]" Visibility="Collapsed" />\r
+\r
         </StackPanel>\r
     </StackPanel>\r
 </UserControl>\r
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml
new file mode 100644 (file)
index 0000000..133ce55
--- /dev/null
@@ -0,0 +1,10 @@
+<Window x:Class="HandBrakeWPF.Views.StaticPreviewView"\r
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" \r
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" \r
+             mc:Ignorable="d">\r
+    <Grid>\r
+            <Image Source="{Binding PreviewImage}" />\r
+    </Grid>\r
+</Window>\r
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs
new file mode 100644 (file)
index 0000000..8c2c559
--- /dev/null
@@ -0,0 +1,27 @@
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="StaticPreviewView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">\r
+//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+//   Interaction logic for StaticPreviewView.xaml\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Views\r
+{\r
+    using System.Windows;\r
+\r
+    /// <summary>\r
+    /// Interaction logic for StaticPreviewView.xaml\r
+    /// </summary>\r
+    public partial class StaticPreviewView : Window\r
+    {\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="StaticPreviewView"/> class.\r
+        /// </summary>\r
+        public StaticPreviewView()\r
+        {\r
+            InitializeComponent();\r
+        }\r
+    }\r
+}\r