diff options
author | sr55 <[email protected]> | 2017-12-15 22:40:06 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2017-12-15 22:40:06 +0000 |
commit | 7244ea454654b4b6d8f97f33174303445edb08ff (patch) | |
tree | a056e203998eeb00c01f41f1bf4feb9fcecb2689 /win/CS | |
parent | add6e2ac430652a96ff6fd1a72824796064e259f (diff) |
WinGui: Add % Actual Size to the static preview window title.
Diffstat (limited to 'win/CS')
7 files changed, 93 insertions, 23 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 7f2a7cbbd..226a6eeb2 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -189,6 +189,11 @@ <Compile Include="Model\Subtitles\SubtitleBurnInBehaviourModes.cs" />
<Compile Include="Model\Subtitles\SubtitleBehaviourModes.cs" />
<Compile Include="Model\Subtitles\SubtitleBehaviours.cs" />
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
<Compile Include="Properties\ResourcesTooltips.Designer.cs">
<DependentUpon>ResourcesTooltips.resx</DependentUpon>
<AutoGen>True</AutoGen>
@@ -472,11 +477,6 @@ <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Properties\Resources.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>Resources.resx</DependentUpon>
- </Compile>
<EmbeddedResource Include="Properties\ResourcesTooltips.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>ResourcesTooltips.Designer.cs</LastGenOutput>
@@ -489,8 +489,8 @@ </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
- <LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<AdditionalFiles Include="..\stylecop.json">
<Link>stylecop.json</Link>
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index c30ec5f3a..947ea86da 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -1423,7 +1423,7 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
- /// Looks up a localized string similar to Preview.
+ /// Looks up a localized string similar to Preview {0}.
/// </summary>
public static string Preview {
get {
@@ -1730,6 +1730,15 @@ namespace HandBrakeWPF.Properties { }
/// <summary>
+ /// Looks up a localized string similar to Preview ({0}% actual size).
+ /// </summary>
+ public static string StaticPreviewView_Title {
+ get {
+ return ResourceManager.GetString("StaticPreviewView_Title", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to Handbrake is already encoding a video! Only one file can be encoded at any one time..
/// </summary>
public static string StaticPreviewViewModel_AlreadyEncoding {
diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index c841deee1..f0c3f0316 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -467,7 +467,7 @@ Do you wish to proceed?</value> <value>The entered destination path contained illegal characters and will not be updated.</value>
</data>
<data name="Preview" xml:space="preserve">
- <value>Preview</value>
+ <value>Preview {0}</value>
</data>
<data name="Preview_Scaled" xml:space="preserve">
<value>Preview (Scaled)</value>
@@ -869,4 +869,7 @@ Remaining Time: {4}</value> FPS: {3:000.0}, Avg FPS: {4:000.0}
Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss}</value>
</data>
+ <data name="StaticPreviewView_Title" xml:space="preserve">
+ <value>Preview ({0}% actual size)</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs index 06a22ae01..0c1884bb1 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IStaticPreviewViewModel.cs @@ -9,6 +9,8 @@ namespace HandBrakeWPF.ViewModels.Interfaces
{
+ using System.Windows.Media.Imaging;
+
using HandBrakeWPF.Services.Scan.Model;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
@@ -34,6 +36,8 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// </summary>
bool IsOpen { get; set; }
+ BitmapImage PreviewImage { get; }
+
void PreviousPreview();
void NextPreview();
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs index 6f5fc6e5d..4a2d3e2b2 100644 --- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs @@ -173,7 +173,7 @@ namespace HandBrakeWPF.ViewModels {
return;
}
- this.height = value;
+ this.height = this.FixHeight(value);
this.NotifyOfPropertyChange(() => this.Height);
}
}
@@ -257,7 +257,7 @@ namespace HandBrakeWPF.ViewModels {
return;
}
- this.width = value;
+ this.width = this.FixWidth(value);
this.NotifyOfPropertyChange(() => this.Width);
}
}
@@ -450,7 +450,7 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// The update preview frame.
/// </summary>
- [HandleProcessCorruptedStateExceptions]
+ [HandleProcessCorruptedStateExceptions]
public void UpdatePreviewFrame()
{
// Don't preview for small images.
@@ -492,26 +492,32 @@ namespace HandBrakeWPF.ViewModels /// <param name="ea">
/// The ea.
/// </param>
- public void PreviewSizeChanged(SizeChangedEventArgs ea)
+ public int FixWidth(int width)
{
- // TODO implement window size scaling here.
Rect workArea = SystemParameters.WorkArea;
- if (ea.NewSize.Width > workArea.Width)
+ if (width > workArea.Width)
{
- this.Width = (int)Math.Round(workArea.Width, 0) - 50;
- this.Title = Resources.Preview_Scaled;
+ return (int)Math.Round(workArea.Width, 0) - 50;
}
- if (ea.NewSize.Height > workArea.Height)
+ return 100;
+ }
+
+ public int FixHeight(int height)
+ {
+ Rect workArea = SystemParameters.WorkArea;
+ if (height > workArea.Height)
{
- this.Height = (int)Math.Round(workArea.Height, 0) - 50;
- this.Title = Resources.Preview_Scaled;
+ return (int)Math.Round(workArea.Height, 0) - 50;
}
+
+ return 100;
}
+
#endregion
#region Public Method - Live Preview
-
+
#region Public Methods
/// <summary>
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml index c7eb5fb09..2ec3dcaa3 100644 --- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml @@ -9,7 +9,6 @@ mc:Ignorable="d" SizeToContent="WidthAndHeight"
TextOptions.TextFormattingMode="Display"
WindowStartupLocation="CenterScreen"
- cal:Message.Attach="[Event SizeChanged] = [Action PreviewSizeChanged($eventArgs)]"
Title="{Binding Title}">
<Window.Resources>
@@ -21,7 +20,7 @@ <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}" MouseWheel="PreviewImage_OnMouseWheel" />
+ <Image x:Name="previewImage" Source="{Binding PreviewImage}" MaxWidth="{Binding Width}" MaxHeight="{Binding Height}" MouseWheel="PreviewImage_OnMouseWheel" />
<Border BorderBrush="WhiteSmoke" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" Padding="8"
diff --git a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs index 17ef64928..2289cfe45 100644 --- a/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/StaticPreviewView.xaml.cs @@ -9,8 +9,10 @@ namespace HandBrakeWPF.Views
{
+ using System;
using System.Windows;
using System.Windows.Input;
+ using System.Windows.Media.Imaging;
using HandBrakeWPF.ViewModels.Interfaces;
@@ -24,7 +26,28 @@ namespace HandBrakeWPF.Views /// </summary>
public StaticPreviewView()
{
- InitializeComponent();
+ this.InitializeComponent();
+
+ this.SizeChanged += this.StaticPreviewView_SizeChanged;
+ this.Title = Properties.Resources.Preview;
+ }
+
+ private void StaticPreviewView_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ // Prevent the Window Growing Past Screen Bounds
+ Rect workArea = SystemParameters.WorkArea;
+ if (e.NewSize.Width > workArea.Width)
+ {
+ this.Width = (int)Math.Round(workArea.Width, 0) - 50;
+ }
+
+ if (e.NewSize.Height > workArea.Height)
+ {
+ this.Height = (int)Math.Round(workArea.Height, 0) - 50;
+ }
+
+ // Update Window title scale factor.
+ this.UpdateWindowTitle();
}
private void PreviewImage_OnMouseWheel(object sender, MouseWheelEventArgs e)
@@ -38,5 +61,31 @@ namespace HandBrakeWPF.Views ((IStaticPreviewViewModel)this.DataContext).PreviousPreview();
}
}
+
+ private void UpdateWindowTitle()
+ {
+ BitmapImage image = ((IStaticPreviewViewModel)this.DataContext).PreviewImage;
+ if (image != null && this.previewImage != null && this.previewImage.ActualWidth > 0)
+ {
+ double origWidth = Math.Round(image.Width, 0);
+ double origHeight = Math.Round(image.Height, 0);
+
+ double actualWidth = Math.Round(this.previewImage.ActualWidth, 0);
+ double actualHeight = Math.Round(this.previewImage.ActualHeight, 0);
+
+ double scaleW = actualWidth / origWidth;
+ double scaleH = actualHeight / origHeight;
+
+ double scaleFactor = Math.Min(scaleW, scaleH);
+
+ double scalePercentage = Math.Round(100 * scaleFactor, 0);
+
+ this.Title = string.Format(Properties.Resources.StaticPreviewView_Title, scalePercentage);
+ }
+ else
+ {
+ this.Title = Properties.Resources.Preview;
+ }
+ }
}
}
|