summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj1
-rw-r--r--win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs73
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs47
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs6
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml3
-rw-r--r--win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml10
6 files changed, 131 insertions, 9 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index 106921783..b3c73822b 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -144,6 +144,7 @@
<Compile Include="Factories\HBConfigurationFactory.cs" />
<Compile Include="Services\Interfaces\IUserSettingService.cs" />
<Compile Include="Services\UserSettingService.cs" />
+ <Compile Include="Utilities\DelayedActionProcessor.cs" />
<Compile Include="ViewModels\CountdownAlertViewModel.cs" />
<Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />
<Compile Include="Controls\SourceSelection.xaml.cs">
diff --git a/win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs b/win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs
new file mode 100644
index 000000000..14d70c691
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs
@@ -0,0 +1,73 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DelayedActionProcessor.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>
+// An Action processor that supports queueing/delayed action processing.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System;
+ using System.Timers;
+
+ /// <summary>
+ /// An Action processor that supports queueing/delayed action processing.
+ /// </summary>
+ public class DelayedActionProcessor
+ {
+ /// <summary>
+ /// The task.
+ /// </summary>
+ private Action task;
+
+ /// <summary>
+ /// The timer.
+ /// </summary>
+ private Timer timer;
+
+ /// <summary>
+ /// The set task.
+ /// </summary>
+ /// <param name="taskReset">
+ /// The task reset.
+ /// </param>
+ /// <param name="timems">
+ /// The timems.
+ /// </param>
+ public void PerformTask(Action taskReset, int timems)
+ {
+ if (timer != null)
+ {
+ timer.Stop();
+ timer.Close();
+ }
+
+
+ timer = new Timer(timems) { AutoReset = true };
+ timer.Elapsed += this.timer_Elapsed;
+ task = taskReset;
+ timer.Stop();
+ timer.Start();
+ }
+
+ /// <summary>
+ /// The timer_ elapsed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void timer_Elapsed(object sender, ElapsedEventArgs e)
+ {
+ if (task != null)
+ {
+ timer.Stop();
+ task();
+ }
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
index e3cb8afa1..c45299e8e 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
@@ -23,7 +23,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.Interop.Model.Encoding;
using HandBrakeWPF.Helpers;
- using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
using Size = System.Drawing.Size;
@@ -103,6 +103,11 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private bool showKeepAr = true;
+ /// <summary>
+ /// The delayed previewprocessor.
+ /// </summary>
+ private DelayedActionProcessor delayedPreviewprocessor = new DelayedActionProcessor();
+
#endregion
#region Constructors and Destructors
@@ -157,6 +162,7 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange(() => this.CropBottom);
this.CropAdjust();
this.SetDisplaySize();
+ this.UpdatePreviewImage();
}
}
@@ -176,6 +182,7 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange(() => this.CropLeft);
this.CropAdjust();
this.SetDisplaySize();
+ this.UpdatePreviewImage();
}
}
@@ -195,6 +202,7 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange(() => this.CropRight);
this.CropAdjust();
this.SetDisplaySize();
+ this.UpdatePreviewImage();
}
}
@@ -214,6 +222,7 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange(() => this.CropTop);
this.CropAdjust();
this.SetDisplaySize();
+ this.UpdatePreviewImage();
}
}
@@ -253,6 +262,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.DisplayWidth = value;
this.CustomAnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.DisplayWidth);
+ this.UpdatePreviewImage();
}
}
}
@@ -274,6 +284,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.Height = value;
this.HeightAdjust();
this.NotifyOfPropertyChange(() => this.Height);
+ this.UpdatePreviewImage();
}
}
}
@@ -327,6 +338,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.KeepDisplayAspect = value;
this.WidthAdjust();
this.NotifyOfPropertyChange(() => this.MaintainAspectRatio);
+ this.UpdatePreviewImage();
}
}
@@ -358,6 +370,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.PixelAspectY = value;
this.CustomAnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.ParHeight);
+ this.UpdatePreviewImage();
}
}
}
@@ -379,6 +392,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.PixelAspectX = value;
this.CustomAnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.ParWidth);
+ this.UpdatePreviewImage();
}
}
}
@@ -400,6 +414,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.Anamorphic = value;
this.AnamorphicAdjust();
this.NotifyOfPropertyChange(() => this.SelectedAnamorphicMode);
+ this.UpdatePreviewImage();
}
}
}
@@ -419,6 +434,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.Modulus = value;
this.ModulusAdjust();
this.NotifyOfPropertyChange(() => this.SelectedModulus);
+ this.UpdatePreviewImage();
}
}
@@ -510,6 +526,7 @@ namespace HandBrakeWPF.ViewModels
this.Task.Width = value;
this.WidthAdjust();
this.NotifyOfPropertyChange(() => this.Width);
+ this.UpdatePreviewImage();
}
}
}
@@ -768,7 +785,7 @@ namespace HandBrakeWPF.ViewModels
if (this.SelectedAnamorphicMode == Anamorphic.None)
{
this.Width = preset.Task.Width ?? (this.MaxWidth - this.CropLeft - this.CropRight);
- // Note: This will be auto-corrected in the property if it's too large.
+ // Note: This will be auto-corrected in the property if it's too large.
}
else
{
@@ -812,7 +829,7 @@ namespace HandBrakeWPF.ViewModels
if (image != null)
{
this.StaticPreviewViewModel.PreviewFrame(image, this.Task);
- this.WindowManager.ShowDialog(this.StaticPreviewViewModel);
+ this.WindowManager.ShowWindow(this.StaticPreviewViewModel);
}
}
@@ -1176,6 +1193,28 @@ namespace HandBrakeWPF.ViewModels
return job;
}
- #endregion
+ /// <summary>
+ /// Updates the preview after a period of time.
+ /// This gives the user the opertunity to make changes in quick sucession without the image refreshing instantly
+ /// and causing performance lag.
+ /// </summary>
+ private void UpdatePreviewImage()
+ {
+ if (delayedPreviewprocessor != null)
+ {
+ delayedPreviewprocessor.PerformTask(() =>
+ {
+ IScan scanService = IoC.Get<IScan>();
+ BitmapImage image = scanService.GetPreview(this.Task, 1);
+
+ if (image != null)
+ {
+ this.StaticPreviewViewModel.PreviewFrame(image, this.Task);
+ }
+ }, 800);
+ }
+ }
+
+ #endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index d836f6d49..c4a26e033 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -189,6 +189,12 @@ namespace HandBrakeWPF.ViewModels
this.PreviewImage = image;
}
+ protected override void OnActivate()
+ {
+ Console.Write("test");
+ base.OnActivate();
+ }
+
/// <summary>
/// The update preview frame.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml
index 46fc614f0..9c5a21f00 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml
@@ -686,7 +686,8 @@
<!-- Source Selection-->
<Controls:SourceSelection Grid.Row="1" Width="400" VerticalAlignment="Stretch" BorderThickness="1" BorderBrush="DarkGray"
- Visibility="{Binding ShowSourceSelection, Converter={StaticResource boolToVisConverter}}" />
+ Visibility="{Binding ShowSourceSelection, Converter={StaticResource boolToVisConverter}}"
+ Margin="0,10,0,10" />
<!-- StatusPanel -->
<Controls:StatusPanel x:Name="loadingPanel"
diff --git a/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml b/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
index 629fa85a1..2a5d136bc 100644
--- a/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml
@@ -16,6 +16,12 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
+ <StackPanel.ContextMenu>
+ <ContextMenu>
+ <MenuItem Header="Show Still Preview (Experimental)" cal:Message.Attach="[Event Click] = [Action PreviewImage]" Visibility="Visible" />
+ </ContextMenu>
+ </StackPanel.ContextMenu>
+
<!-- Size Panel-->
<StackPanel Name="SizePanel" Orientation="Vertical" >
<Label Content="Size" FontWeight="Bold" />
@@ -144,10 +150,6 @@
</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>