diff options
author | sr55 <[email protected]> | 2012-09-11 19:27:40 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-09-11 19:27:40 +0000 |
commit | 3c3ac7ad93a7b644a327ac8027a4593395b0ba24 (patch) | |
tree | 331d3102c1b4c4af107c583dd2b01cb343045835 | |
parent | c89447522c74531483eb3c4b80749c2819845bee (diff) |
WinGui: Couple fixes to Pictures settings and add presets.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4959 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs | 6 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 6 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs | 89 |
3 files changed, 48 insertions, 53 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs index 00d6652b6..aa447e2e2 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -155,13 +155,13 @@ namespace HandBrakeWPF.ViewModels this.Preset.PictureSettingsMode = this.SelectedPictureSettingMode;
// Setting W, H, MW and MH
- if (SelectedPictureSettingMode == PresetPictureSettingsMode.None)
+ if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.None)
{
this.Preset.Task.MaxHeight = null;
this.Preset.Task.MaxWidth = null;
}
- if (SelectedPictureSettingMode == PresetPictureSettingsMode.Custom)
+ if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.Custom)
{
this.Preset.Task.MaxWidth = this.CustomWidth;
this.Preset.Task.MaxHeight = this.CustomHeight;
@@ -169,7 +169,7 @@ namespace HandBrakeWPF.ViewModels this.Preset.Task.Height = null;
}
- if (SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum)
+ if (this.SelectedPictureSettingMode == PresetPictureSettingsMode.SourceMaximum)
{
this.Preset.Task.MaxWidth = this.Preset.Task.Width;
this.Preset.Task.MaxHeight = this.Preset.Task.Height;
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index e62abf174..86c8d3a14 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels using System;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows;
@@ -1412,7 +1413,8 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void PresetExport()
{
- VistaSaveFileDialog savefiledialog = new VistaSaveFileDialog { Filter = "plist|*.plist", CheckPathExists = true };
+ VistaSaveFileDialog savefiledialog = new VistaSaveFileDialog
+ { Filter = "plist|*.plist", CheckPathExists = true, AddExtension = true };
if (this.selectedPreset != null)
{
savefiledialog.ShowDialog();
@@ -1420,7 +1422,7 @@ namespace HandBrakeWPF.ViewModels if (filename != null)
{
- PlistUtility.Export(savefiledialog.FileName, this.selectedPreset, userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild).ToString());
+ PlistUtility.Export(savefiledialog.FileName, this.selectedPreset, userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild).ToString(CultureInfo.InvariantCulture));
}
}
else
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs index 7bca93ced..dbca8aa0a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -12,6 +12,7 @@ namespace HandBrakeWPF.ViewModels using System;
using System.Collections.Generic;
using System.Drawing;
+ using System.Globalization;
using Caliburn.Micro;
@@ -232,7 +233,7 @@ namespace HandBrakeWPF.ViewModels get
{
return this.Task.DisplayWidth.HasValue
- ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString())
+ ? int.Parse(Math.Round(this.Task.DisplayWidth.Value, 0).ToString(CultureInfo.InvariantCulture))
: 0;
}
@@ -572,8 +573,8 @@ namespace HandBrakeWPF.ViewModels this.SelectedAnamorphicMode = preset.Task.Anamorphic;
// Set the limits on the UI Controls.
- this.MaxWidth = preset.Task.MaxWidth ?? sourceResolution.Width;
- this.MaxHeight = preset.Task.MaxHeight ?? sourceResolution.Height;
+ this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;
+ this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;
this.Task.MaxWidth = preset.Task.MaxWidth;
this.Task.MaxHeight = preset.Task.MaxHeight;
@@ -588,15 +589,14 @@ namespace HandBrakeWPF.ViewModels else
{
// Figure out the best width based on the preset and source
- this.Width = preset.Task.Width ?? this.getRes((sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth.Value);
+ this.Width = preset.Task.Width ?? this.GetModulusValue(this.getRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth.Value));
}
}
else
{
- this.Width = preset.Task.Width ?? (sourceResolution.Width - this.CropLeft - this.CropRight);
+ this.Width = preset.Task.Width ?? this.GetModulusValue((this.sourceResolution.Width - this.CropLeft - this.CropRight));
}
-
// Set the Maintain Aspect ratio. This will calculate Height for us now.
this.MaintainAspectRatio = preset.Task.Anamorphic == Anamorphic.None || preset.Task.KeepDisplayAspect;
@@ -615,7 +615,7 @@ namespace HandBrakeWPF.ViewModels {
this.Height = preset.Task.Height ??
this.getRes(
- (sourceResolution.Height - this.CropTop - this.CropBottom),
+ (this.sourceResolution.Height - this.CropTop - this.CropBottom),
preset.Task.MaxHeight.Value);
}
}
@@ -694,22 +694,22 @@ namespace HandBrakeWPF.ViewModels this.sourceResolution = title.Resolution;
// Set the Max Width / Height available to the user controls
- if (sourceResolution.Width < this.MaxWidth)
+ if (this.sourceResolution.Width < this.MaxWidth)
{
- this.MaxWidth = sourceResolution.Width;
+ this.MaxWidth = this.sourceResolution.Width;
}
- else if (sourceResolution.Width > this.MaxWidth)
+ else if (this.sourceResolution.Width > this.MaxWidth)
{
- this.MaxWidth = preset.Task.MaxWidth ?? sourceResolution.Width;
+ this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;
}
- if (sourceResolution.Height < this.MaxHeight)
+ if (this.sourceResolution.Height < this.MaxHeight)
{
- this.MaxHeight = sourceResolution.Height;
+ this.MaxHeight = this.sourceResolution.Height;
}
- else if (sourceResolution.Height > this.MaxHeight)
+ else if (this.sourceResolution.Height > this.MaxHeight)
{
- this.MaxHeight = preset.Task.MaxHeight ?? sourceResolution.Height;
+ this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;
}
// Set Screen Controls
@@ -748,7 +748,7 @@ namespace HandBrakeWPF.ViewModels if (this.SelectedAnamorphicMode == Anamorphic.Custom)
{
- AnamorphicAdjust(); // Refresh the values
+ this.AnamorphicAdjust(); // Refresh the values
}
}
@@ -863,7 +863,7 @@ namespace HandBrakeWPF.ViewModels - 2: Loose anamorphic, round to mod16 and preserve storage aspect ratio
- 3: Power user anamorphic, specify everything
*/
- double calcWidth, calcHeight;
+ double calcHeight;
switch (this.SelectedAnamorphicMode)
{
default:
@@ -881,7 +881,7 @@ namespace HandBrakeWPF.ViewModels - Uses mod16-compliant dimensions,
- Allows users to set the width
*/
- calcWidth = this.GetModulusValue(this.Width); /* Time to get picture width that divide cleanly.*/
+ double calcWidth = this.GetModulusValue(this.Width);
calcHeight = (calcWidth / storageAspect) + 0.5;
calcHeight = this.GetModulusValue(calcHeight); /* Time to get picture height that divide cleanly.*/
@@ -902,18 +902,18 @@ namespace HandBrakeWPF.ViewModels case Anamorphic.Custom:
// Get the User Interface Values
- double UIdisplayWidth;
- double.TryParse(this.DisplayWidth.ToString(), out UIdisplayWidth);
+ double uIdisplayWidth;
+ double.TryParse(this.DisplayWidth.ToString(CultureInfo.InvariantCulture), out uIdisplayWidth);
/* Anamorphic 3: Power User Jamboree - Set everything based on specified values */
calcHeight = this.GetModulusValue(this.Height);
if (this.MaintainAspectRatio)
{
- return new Size((int)Math.Truncate(UIdisplayWidth), (int)calcHeight);
+ return new Size((int)Math.Truncate(uIdisplayWidth), (int)calcHeight);
}
- return new Size((int)Math.Truncate(UIdisplayWidth), (int)calcHeight);
+ return new Size((int)Math.Truncate(uIdisplayWidth), (int)calcHeight);
}
}
@@ -957,7 +957,7 @@ namespace HandBrakeWPF.ViewModels /// <returns>
/// Value corrected so that value % selected modulus == 0
/// </returns>
- private double GetModulusValue(double value)
+ private int GetModulusValue(double value)
{
if (this.SelectedModulus == null)
{
@@ -966,14 +966,16 @@ namespace HandBrakeWPF.ViewModels double remainder = value % this.SelectedModulus.Value;
- if (remainder == 0)
+ if (remainder.Equals(0.0d))
{
- return value;
+ return (int)Math.Abs(value);
}
- return remainder >= ((double)this.SelectedModulus.Value / 2)
+ double result = remainder >= ((double)this.SelectedModulus.Value / 2)
? value + (this.SelectedModulus.Value - remainder)
: value - remainder;
+
+ return (int)Math.Abs(result);
}
/// <summary>
@@ -981,7 +983,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
private void HeightAdjust()
{
- if (this.sourceResolution == new Size(0,0))
+ if (this.sourceResolution == new Size(0, 0))
{
return;
}
@@ -997,14 +999,14 @@ namespace HandBrakeWPF.ViewModels case Anamorphic.None:
if (this.MaintainAspectRatio)
{
- double crop_width = this.sourceResolution.Width - this.CropLeft - this.CropRight;
- double crop_height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
+ double cropWidth = this.sourceResolution.Width - this.CropLeft - this.CropRight;
+ double cropHeight = this.sourceResolution.Height - this.CropTop - this.CropBottom;
- double new_width = ((double)this.Height * this.sourceResolution.Height * this.SourceAspect.Width *
- crop_width) /
- ((double)this.sourceResolution.Width * this.SourceAspect.Height * crop_height);
+ double newWidth = ((double)this.Height * this.sourceResolution.Height * this.SourceAspect.Width *
+ cropWidth) /
+ ((double)this.sourceResolution.Width * this.SourceAspect.Height * cropHeight);
- this.Task.Width = (int)Math.Round(this.GetModulusValue(new_width), 0);
+ this.Task.Width = this.GetModulusValue(newWidth);
this.NotifyOfPropertyChange(() => this.Task.Width);
}
@@ -1052,8 +1054,8 @@ namespace HandBrakeWPF.ViewModels case Anamorphic.None:
if (this.MaintainAspectRatio)
{
- double crop_width = this.sourceResolution.Width - this.CropLeft - this.CropRight;
- double crop_height = this.sourceResolution.Height - this.CropTop - this.CropBottom;
+ double cropWidth = this.sourceResolution.Width - this.CropLeft - this.CropRight;
+ double cropHeight = this.sourceResolution.Height - this.CropTop - this.CropBottom;
if (this.SourceAspect.Width == 0 && this.SourceAspect.Height == 0)
{
@@ -1061,10 +1063,10 @@ namespace HandBrakeWPF.ViewModels }
double newHeight = ((double)this.Width * this.sourceResolution.Width * this.SourceAspect.Height *
- crop_height) /
- ((double)this.sourceResolution.Height * this.SourceAspect.Width * crop_width);
+ cropHeight) /
+ ((double)this.sourceResolution.Height * this.SourceAspect.Width * cropWidth);
- this.Task.Height = (int)Math.Round(this.GetModulusValue(newHeight), 0);
+ this.Task.Height = this.GetModulusValue(newHeight);
this.NotifyOfPropertyChange(() => this.Height);
}
this.SetDisplaySize();
@@ -1103,16 +1105,7 @@ namespace HandBrakeWPF.ViewModels /// </returns>
private int getRes(int value, int max)
{
- if (value > max)
- {
- return max;
- }
- else
- {
- return value;
- }
-
- return 0;
+ return value > max ? max : value;
}
#endregion
|