diff options
author | sr55 <sr55.hb@outlook.com> | 2014-11-27 21:01:15 +0000 |
---|---|---|
committer | sr55 <sr55.hb@outlook.com> | 2014-11-27 21:01:15 +0000 |
commit | 69d30f36f080a863e73f152691569e3f2322600e (patch) | |
tree | 7c3535f44d9e2437dfd2efe9f6b87df6b6aa8332 /win | |
parent | b8238f76de25707da2d9e480d265c94d3d7d1ada (diff) |
WinGui: Don't allow previews less than 32x32 as it'll crash. Handle SEH exceptions for this method.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6561 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs | 54 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml | 9 | ||||
-rw-r--r-- | win/CS/Settings.StyleCop | 1 |
3 files changed, 62 insertions, 2 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs index 622319f61..2424008bb 100644 --- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -10,11 +10,13 @@ namespace HandBrakeWPF.ViewModels
{
using System;
+ using System.Runtime.ExceptionServices;
using System.Windows;
using System.Windows.Media.Imaging;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.Interop.Model.Encoding;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -25,7 +27,6 @@ namespace HandBrakeWPF.ViewModels {
/*
* TODO
- * - Screen needs to be made DPI Aware
* - Integrate Video Preview panel.
*/
@@ -56,6 +57,11 @@ namespace HandBrakeWPF.ViewModels /// </summary>
private int width;
+ /// <summary>
+ /// The preview not available.
+ /// </summary>
+ private bool previewNotAvailable;
+
#endregion
#region Constructors and Destructors
@@ -71,6 +77,7 @@ namespace HandBrakeWPF.ViewModels this.scanService = scanService;
this.selectedPreviewImage = 1;
this.Title = Properties.Resources.Preview;
+ this.PreviewNotAvailable = true;
}
#endregion
@@ -176,6 +183,26 @@ namespace HandBrakeWPF.ViewModels }
}
+ /// <summary>
+ /// Gets or sets a value indicating whether preview not available.
+ /// </summary>
+ public bool PreviewNotAvailable
+ {
+ get
+ {
+ return this.previewNotAvailable;
+ }
+ set
+ {
+ if (value.Equals(this.previewNotAvailable))
+ {
+ return;
+ }
+ this.previewNotAvailable = value;
+ this.NotifyOfPropertyChange(() => this.PreviewNotAvailable);
+ }
+ }
+
#endregion
#region Public Methods and Operators
@@ -202,12 +229,35 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// The update preview frame.
/// </summary>
+ [HandleProcessCorruptedStateExceptions]
public void UpdatePreviewFrame()
{
- BitmapImage image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage);
+ // Don't preview for small images.
+ if (this.Task.Anamorphic == Anamorphic.Loose && this.Task.Width < 32)
+ {
+ PreviewNotAvailable = true;
+ return;
+ }
+
+ if ((this.Task.Anamorphic == Anamorphic.None || this.Task.Anamorphic == Anamorphic.Custom) && (this.Task.Width < 32 || this.Task.Height < 32))
+ {
+ PreviewNotAvailable = true;
+ return;
+ }
+
+ BitmapImage image = null;
+ try
+ {
+ image = this.scanService.GetPreview(this.Task, this.SelectedPreviewImage);
+ }
+ catch (Exception exc)
+ {
+ PreviewNotAvailable = true;
+ }
if (image != null)
{
+ PreviewNotAvailable = false;
this.Width = (int)Math.Ceiling(image.Width);
this.Height = (int)Math.Ceiling(image.Height);
this.PreviewImage = image;
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml index ae044945c..df437bd77 100644 --- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml @@ -4,13 +4,22 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cal="http://www.caliburnproject.org"
+ xmlns:converters="clr-namespace:HandBrakeWPF.Converters"
mc:Ignorable="d" SizeToContent="WidthAndHeight"
TextOptions.TextFormattingMode="Display"
WindowStartupLocation="CenterScreen"
cal:Message.Attach="[Event SizeChanged] = [Action PreviewSizeChanged($eventArgs)]"
Title="{Binding Title}">
+
+ <Window.Resources>
+ <converters:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
+ </Window.Resources>
<Grid>
+ <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="LightGray" Visibility="{Binding PreviewNotAvailable, Converter={StaticResource booleanToVisibilityConverter}}">
+ <TextBlock Text="No Preview Available" VerticalAlignment="Center" Padding="60,60,60,60" FontWeight="Bold" FontSize="25" Foreground="DarkGray" />
+ </StackPanel>
+
<Image Source="{Binding PreviewImage}" MaxWidth="{Binding Width}" MaxHeight="{Binding Height}" />
<Slider Maximum="{Binding TotalPreviews}" Minimum="0"
Value="{Binding SelectedPreviewImage}"
diff --git a/win/CS/Settings.StyleCop b/win/CS/Settings.StyleCop index 7b02bc0d5..0dc5564f9 100644 --- a/win/CS/Settings.StyleCop +++ b/win/CS/Settings.StyleCop @@ -63,6 +63,7 @@ <AnalyzerSettings>
<StringProperty Name="CompanyName">HandBrake Project (http://handbrake.fr)</StringProperty>
<StringProperty Name="Copyright">This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.</StringProperty>
+ <BooleanProperty Name="IncludeFields">False</BooleanProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.MaintainabilityRules">
|