<Compile Include="Model\Subtitles\SubtitleBurnInBehaviourModes.cs" />\r
<Compile Include="Model\Subtitles\SubtitleBehaviourModes.cs" />\r
<Compile Include="Model\Subtitles\SubtitleBehaviours.cs" />\r
+ <Compile Include="Properties\Resources.Designer.cs">\r
+ <AutoGen>True</AutoGen>\r
+ <DesignTime>True</DesignTime>\r
+ <DependentUpon>Resources.resx</DependentUpon>\r
+ </Compile>\r
<Compile Include="Properties\ResourcesTooltips.Designer.cs">\r
<DependentUpon>ResourcesTooltips.resx</DependentUpon>\r
<AutoGen>True</AutoGen>\r
<Compile Include="Properties\AssemblyInfo.cs">\r
<SubType>Code</SubType>\r
</Compile>\r
- <Compile Include="Properties\Resources.Designer.cs">\r
- <AutoGen>True</AutoGen>\r
- <DesignTime>True</DesignTime>\r
- <DependentUpon>Resources.resx</DependentUpon>\r
- </Compile>\r
<EmbeddedResource Include="Properties\ResourcesTooltips.resx">\r
<Generator>PublicResXFileCodeGenerator</Generator>\r
<LastGenOutput>ResourcesTooltips.Designer.cs</LastGenOutput>\r
</EmbeddedResource>\r
<EmbeddedResource Include="Properties\Resources.resx">\r
<Generator>PublicResXFileCodeGenerator</Generator>\r
- <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r
<SubType>Designer</SubType>\r
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>\r
</EmbeddedResource>\r
<AdditionalFiles Include="..\stylecop.json">\r
<Link>stylecop.json</Link>\r
}\r
\r
/// <summary>\r
- /// Looks up a localized string similar to Preview.\r
+ /// Looks up a localized string similar to Preview {0}.\r
/// </summary>\r
public static string Preview {\r
get {\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Looks up a localized string similar to Preview ({0}% actual size).\r
+ /// </summary>\r
+ public static string StaticPreviewView_Title {\r
+ get {\r
+ return ResourceManager.GetString("StaticPreviewView_Title", resourceCulture);\r
+ }\r
+ }\r
+ \r
/// <summary>\r
/// Looks up a localized string similar to Handbrake is already encoding a video! Only one file can be encoded at any one time..\r
/// </summary>\r
<value>The entered destination path contained illegal characters and will not be updated.</value>\r
</data>\r
<data name="Preview" xml:space="preserve">\r
- <value>Preview</value>\r
+ <value>Preview {0}</value>\r
</data>\r
<data name="Preview_Scaled" xml:space="preserve">\r
<value>Preview (Scaled)</value>\r
FPS: {3:000.0}, Avg FPS: {4:000.0}\r
Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss}</value>\r
</data>\r
+ <data name="StaticPreviewView_Title" xml:space="preserve">\r
+ <value>Preview ({0}% actual size)</value>\r
+ </data>\r
</root>
\ No newline at end of file
\r
namespace HandBrakeWPF.ViewModels.Interfaces\r
{\r
+ using System.Windows.Media.Imaging;\r
+\r
using HandBrakeWPF.Services.Scan.Model;\r
\r
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
/// </summary>\r
bool IsOpen { get; set; }\r
\r
+ BitmapImage PreviewImage { get; }\r
+\r
void PreviousPreview();\r
void NextPreview();\r
}\r
{\r
return;\r
}\r
- this.height = value;\r
+ this.height = this.FixHeight(value);\r
this.NotifyOfPropertyChange(() => this.Height);\r
}\r
}\r
{\r
return;\r
}\r
- this.width = value;\r
+ this.width = this.FixWidth(value);\r
this.NotifyOfPropertyChange(() => this.Width);\r
}\r
}\r
/// <summary>\r
/// The update preview frame.\r
/// </summary>\r
- [HandleProcessCorruptedStateExceptions] \r
+ [HandleProcessCorruptedStateExceptions]\r
public void UpdatePreviewFrame()\r
{\r
// Don't preview for small images.\r
/// <param name="ea">\r
/// The ea.\r
/// </param>\r
- public void PreviewSizeChanged(SizeChangedEventArgs ea)\r
+ public int FixWidth(int width)\r
{\r
- // TODO implement window size scaling here.\r
Rect workArea = SystemParameters.WorkArea;\r
- if (ea.NewSize.Width > workArea.Width)\r
+ if (width > workArea.Width)\r
{\r
- this.Width = (int)Math.Round(workArea.Width, 0) - 50;\r
- this.Title = Resources.Preview_Scaled;\r
+ return (int)Math.Round(workArea.Width, 0) - 50;\r
}\r
\r
- if (ea.NewSize.Height > workArea.Height)\r
+ return 100;\r
+ }\r
+\r
+ public int FixHeight(int height)\r
+ {\r
+ Rect workArea = SystemParameters.WorkArea;\r
+ if (height > workArea.Height)\r
{\r
- this.Height = (int)Math.Round(workArea.Height, 0) - 50;\r
- this.Title = Resources.Preview_Scaled;\r
+ return (int)Math.Round(workArea.Height, 0) - 50;\r
}\r
+\r
+ return 100;\r
}\r
+\r
#endregion\r
\r
#region Public Method - Live Preview \r
- \r
+\r
#region Public Methods\r
\r
/// <summary>\r
mc:Ignorable="d" SizeToContent="WidthAndHeight"\r
TextOptions.TextFormattingMode="Display"\r
WindowStartupLocation="CenterScreen"\r
- cal:Message.Attach="[Event SizeChanged] = [Action PreviewSizeChanged($eventArgs)]" \r
Title="{Binding Title}">\r
\r
<Window.Resources>\r
<TextBlock Text="No Preview Available" VerticalAlignment="Center" Padding="60,60,60,60" FontWeight="Bold" FontSize="25" Foreground="DarkGray" />\r
</StackPanel>\r
\r
- <Image Source="{Binding PreviewImage}" MaxWidth="{Binding Width}" MaxHeight="{Binding Height}" MouseWheel="PreviewImage_OnMouseWheel" />\r
+ <Image x:Name="previewImage" Source="{Binding PreviewImage}" MaxWidth="{Binding Width}" MaxHeight="{Binding Height}" MouseWheel="PreviewImage_OnMouseWheel" />\r
\r
\r
<Border BorderBrush="WhiteSmoke" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8" Padding="8"\r
\r
namespace HandBrakeWPF.Views\r
{\r
+ using System;\r
using System.Windows;\r
using System.Windows.Input;\r
+ using System.Windows.Media.Imaging;\r
\r
using HandBrakeWPF.ViewModels.Interfaces;\r
\r
/// </summary>\r
public StaticPreviewView()\r
{\r
- InitializeComponent();\r
+ this.InitializeComponent();\r
+\r
+ this.SizeChanged += this.StaticPreviewView_SizeChanged;\r
+ this.Title = Properties.Resources.Preview;\r
+ }\r
+\r
+ private void StaticPreviewView_SizeChanged(object sender, SizeChangedEventArgs e)\r
+ {\r
+ // Prevent the Window Growing Past Screen Bounds\r
+ Rect workArea = SystemParameters.WorkArea;\r
+ if (e.NewSize.Width > workArea.Width)\r
+ {\r
+ this.Width = (int)Math.Round(workArea.Width, 0) - 50;\r
+ }\r
+\r
+ if (e.NewSize.Height > workArea.Height)\r
+ {\r
+ this.Height = (int)Math.Round(workArea.Height, 0) - 50;\r
+ }\r
+\r
+ // Update Window title scale factor.\r
+ this.UpdateWindowTitle();\r
}\r
\r
private void PreviewImage_OnMouseWheel(object sender, MouseWheelEventArgs e)\r
((IStaticPreviewViewModel)this.DataContext).PreviousPreview();\r
}\r
}\r
+\r
+ private void UpdateWindowTitle()\r
+ {\r
+ BitmapImage image = ((IStaticPreviewViewModel)this.DataContext).PreviewImage;\r
+ if (image != null && this.previewImage != null && this.previewImage.ActualWidth > 0)\r
+ {\r
+ double origWidth = Math.Round(image.Width, 0);\r
+ double origHeight = Math.Round(image.Height, 0);\r
+\r
+ double actualWidth = Math.Round(this.previewImage.ActualWidth, 0);\r
+ double actualHeight = Math.Round(this.previewImage.ActualHeight, 0);\r
+\r
+ double scaleW = actualWidth / origWidth;\r
+ double scaleH = actualHeight / origHeight;\r
+\r
+ double scaleFactor = Math.Min(scaleW, scaleH);\r
+\r
+ double scalePercentage = Math.Round(100 * scaleFactor, 0);\r
+\r
+ this.Title = string.Format(Properties.Resources.StaticPreviewView_Title, scalePercentage);\r
+ }\r
+ else\r
+ {\r
+ this.Title = Properties.Resources.Preview;\r
+ }\r
+ }\r
}\r
}\r