using System.Collections.Generic;\r
using System.Globalization;\r
\r
+ using HandBrake.ApplicationServices.Interop;\r
using HandBrake.ApplicationServices.Interop.Model;\r
using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
\r
/// <summary>\r
/// Gets or sets DisplayWidth.\r
/// </summary>\r
- public int DisplayWidth\r
+ public long DisplayWidth\r
{\r
get\r
{\r
/// <returns>\r
/// The <see cref="PictureSize.PictureSettingsJob"/>.\r
/// </returns>\r
- private PictureSize.PictureSettingsJob GetPictureSettings()\r
+ private PictureSize.PictureSettingsJob GetPictureSettings(ChangedPictureField changedField)\r
{\r
PictureSize.PictureSettingsJob job = new PictureSize.PictureSettingsJob\r
{\r
Crop = new Cropping(this.CropTop, this.CropBottom, this.CropLeft, this.CropRight),\r
};\r
\r
- if (this.SelectedAnamorphicMode == Anamorphic.Loose)\r
+ if (this.SelectedAnamorphicMode == Anamorphic.Custom)\r
{\r
- job.ParW = sourceParValues.Width;\r
- job.ParH = sourceParValues.Height;\r
+ if (changedField == ChangedPictureField.DisplayWidth)\r
+ {\r
+ var displayWidth = this.DisplayWidth;\r
+ job.ParW = (int)displayWidth; // num\r
+ job.ParH = job.Width; // den\r
+ }\r
}\r
\r
- if (SelectedAnamorphicMode == Anamorphic.Custom)\r
+ // Reduce the Par W/H if we can. Don't do it while the user is altering the PAR controls through as it will mess with the result.\r
+ if (changedField != ChangedPictureField.ParH && changedField != ChangedPictureField.ParW)\r
{\r
- job.ParW = this.DisplayWidth; // num\r
- job.ParH = this.Width; // den\r
+ long x, y;\r
+ HandBrakeUtils.Reduce(job.ParW, job.ParH, out x, out y);\r
+ job.ParW = (int)y;\r
+ job.ParH = (int)x;\r
}\r
\r
return job;\r
}\r
\r
// Step 2, For the changed field, call hb_set_anamorphic_size and process the results.\r
- PictureSize.AnamorphicResult result = PictureSize.hb_set_anamorphic_size2(this.GetPictureSettings(), this.GetPictureTitleInfo(), setting);\r
+ PictureSize.AnamorphicResult result = PictureSize.hb_set_anamorphic_size2(this.GetPictureSettings(changedField), this.GetPictureTitleInfo(), setting);\r
+ double dispWidth = Math.Round((result.OutputWidth * result.OutputParWidth / result.OutputParHeight), 0);\r
+\r
this.Task.Width = result.OutputWidth;\r
this.Task.Height = result.OutputHeight;\r
+ long x, y;\r
+ HandBrakeUtils.Reduce((int)Math.Round(result.OutputParWidth, 0), (int)Math.Round(result.OutputParHeight, 0), out x, out y);\r
this.Task.PixelAspectX = (int)Math.Round(result.OutputParWidth, 0);\r
this.Task.PixelAspectY = (int)Math.Round(result.OutputParHeight, 0);\r
+ this.Task.DisplayWidth = dispWidth;\r
\r
// Step 3, Set the display width label to indicate the output.\r
- double dispWidth = Math.Round((result.OutputWidth * result.OutputParWidth / result.OutputParHeight), 0);\r
this.DisplaySize = this.sourceResolution == null || this.sourceResolution.IsEmpty\r
? string.Empty\r
: string.Format(Resources.PictureSettingsViewModel_StorageDisplayLabel, dispWidth, result.OutputHeight, this.ParWidth, this.ParHeight);\r
\r
- if (changedField != ChangedPictureField.DisplayWidth)\r
- {\r
- this.Task.DisplayWidth = (int)dispWidth;\r
- }\r
-\r
// Step 4, Force an update on all the UI elements.\r
this.NotifyOfPropertyChange(() => this.Width);\r
this.NotifyOfPropertyChange(() => this.Height);\r
<Label Content="{x:Static Properties:ResourcesUI.PictureSettingsView_PAR}" Grid.Row="1" Grid.Column="0" />\r
\r
<controls:NumberBox Width="60" Number="{Binding DisplayWidth, Mode=TwoWay}" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,0,5" \r
- AllowEmpty="False" />\r
+ AllowEmpty="False" IsEnabled="{Binding MaintainAspectRatio, Converter={StaticResource boolConverter}, ConverterParameter=true}" />\r
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">\r
<controls:NumberBox Width="60" Number="{Binding ParWidth, Mode=TwoWay}" HorizontalAlignment="Left" AllowEmpty="False"\r
IsEnabled="{Binding MaintainAspectRatio, Converter={StaticResource boolConverter}, ConverterParameter=true}" Margin="0,0,0,5"\r