summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-02-11 20:37:33 +0000
committersr55 <[email protected]>2017-02-11 20:37:33 +0000
commit9ce3910fd193628e754abf4939c3758f1e57e100 (patch)
treebb7e367be99a36e85aa2c4beb1f45c243ae43c75 /win/CS/HandBrakeWPF/ViewModels
parenta1455ea947b0f85665228f23d2f94f66bdad2cdd (diff)
WinGui: Fix a number of stylecop warnings.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs108
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/ManagePresetViewModel.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs25
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs1
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs2
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs5
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs5
10 files changed, 82 insertions, 78 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
index 52877f61f..f8974a0c4 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs
@@ -86,7 +86,7 @@ namespace HandBrakeWPF.ViewModels
this.errorService = errorService;
this.windowManager = windowManager;
this.Title = "Add Preset";
- this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName};
+ this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName };
this.PictureSettingsModes = EnumHelper<PresetPictureSettingsMode>.GetEnumList();
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
index da65e2945..fcd1f22d9 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs
@@ -12,9 +12,7 @@ namespace HandBrakeWPF.ViewModels
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
- using System.ComponentModel.DataAnnotations;
using System.IO;
- using System.Text;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
@@ -32,7 +30,6 @@ namespace HandBrakeWPF.ViewModels
using ChapterMarker = HandBrakeWPF.Services.Encode.Model.Models.ChapterMarker;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
- using MessageBox = System.Windows.Forms.MessageBox;
/// <summary>
/// The Chapters View Model
@@ -73,6 +70,7 @@ namespace HandBrakeWPF.ViewModels
#endregion
#region Public Properties
+
/// <summary>
/// Gets or sets Task.
/// </summary>
@@ -209,9 +207,11 @@ namespace HandBrakeWPF.ViewModels
if (!this.ValidateImportedChapters(importedChapters, out validationErrorMessage))
{
if (!string.IsNullOrEmpty(validationErrorMessage))
+ {
throw new GeneralApplicationException(
Resources.ChaptersViewModel_ValidationFailedWarning,
validationErrorMessage);
+ }
// The user has cancelled the import, so exit
return;
@@ -235,55 +235,6 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Validates any imported chapter information against the currently detected chapter information in the
- /// source media. If validation fails then an error message is returned via the out parameter <see cref="validationErrorMessage"/>
- /// </summary>
- /// <param name="importedChapters">The list of imported chapter information</param>
- /// <param name="validationErrorMessage">In case of a validation error this variable will hold
- /// a detailed message that can be presented to the user</param>
- /// <returns>True if there are no errors with imported chapters, false otherwise</returns>
- private bool ValidateImportedChapters(Dictionary<int, Tuple<string, TimeSpan>> importedChapters, out string validationErrorMessage)
- {
- validationErrorMessage = null;
-
- // If the number of chapters don't match, prompt for confirmation
- if (importedChapters.Count != this.Task.ChapterNames.Count)
- {
- if (MessageBoxResult.Yes !=
- this.errorService.ShowMessageBox(
- string.Format(Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchMsg, this.Task.ChapterNames.Count, importedChapters.Count),
- Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchWarning,
- MessageBoxButton.YesNo,
- MessageBoxImage.Question))
- {
- return false;
- }
- }
-
- // If the average discrepancy in timings between chapters is either:
- // a) more than 15 sec for more than 2 chapters
- // (I chose 15sec based on empirical evidence from testing a few DVDs and comparing to chapter-marker files I downloaded)
- // => This check will not be performed for the first and last chapter as they're very likely to differ significantly due to language and region
- // differences (e.g. longer title sequences and different distributor credits)
- var diffs = importedChapters.Zip(this.Task.ChapterNames, (import, source) => source.Duration - import.Value.Item2);
- if (diffs.Count(diff => Math.Abs(diff.TotalSeconds) > 15) > 2)
- {
- if (MessageBoxResult.Yes !=
- this.errorService.ShowMessageBox(
- Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchMsg,
- Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchWarning,
- MessageBoxButton.YesNo,
- MessageBoxImage.Question))
- {
- return false;
- }
- }
-
- // All is well, we should import chapters
- return true;
- }
-
- /// <summary>
/// Setup this window for a new source
/// </summary>
/// <param name="source">
@@ -379,5 +330,58 @@ namespace HandBrakeWPF.ViewModels
}
#endregion
+
+ #region Private Methods
+
+ /// <summary>
+ /// Validates any imported chapter information against the currently detected chapter information in the
+ /// source media. If validation fails then an error message is returned via the out parameter <see cref="validationErrorMessage"/>
+ /// </summary>
+ /// <param name="importedChapters">The list of imported chapter information</param>
+ /// <param name="validationErrorMessage">In case of a validation error this variable will hold
+ /// a detailed message that can be presented to the user</param>
+ /// <returns>True if there are no errors with imported chapters, false otherwise</returns>
+ private bool ValidateImportedChapters(Dictionary<int, Tuple<string, TimeSpan>> importedChapters, out string validationErrorMessage)
+ {
+ validationErrorMessage = null;
+
+ // If the number of chapters don't match, prompt for confirmation
+ if (importedChapters.Count != this.Task.ChapterNames.Count)
+ {
+ if (this.errorService.ShowMessageBox(
+ string.Format(Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchMsg, this.Task.ChapterNames.Count, importedChapters.Count),
+ Resources.ChaptersViewModel_ValidateImportedChapters_ChapterCountMismatchWarning,
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Question) !=
+ MessageBoxResult.Yes)
+ {
+ return false;
+ }
+ }
+
+ // If the average discrepancy in timings between chapters is either:
+ // a) more than 15 sec for more than 2 chapters
+ // (I chose 15sec based on empirical evidence from testing a few DVDs and comparing to chapter-marker files I downloaded)
+ // => This check will not be performed for the first and last chapter as they're very likely to differ significantly due to language and region
+ // differences (e.g. longer title sequences and different distributor credits)
+ var diffs = importedChapters.Zip(this.Task.ChapterNames, (import, source) => source.Duration - import.Value.Item2);
+ if (diffs.Count(diff => Math.Abs(diff.TotalSeconds) > 15) > 2)
+ {
+ if (this.errorService.ShowMessageBox(
+ Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchMsg,
+ Resources.ChaptersViewModel_ValidateImportedChapters_ChapterDurationMismatchWarning,
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Question) !=
+ MessageBoxResult.Yes)
+ {
+ return false;
+ }
+ }
+
+ // All is well, we should import chapters
+ return true;
+ }
+
+ #endregion
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 5b671c23d..db7c608ff 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1857,7 +1857,7 @@ namespace HandBrakeWPF.ViewModels
Resources.DirectoryUtils_CreateFolder,
MessageBoxButton.YesNo,
MessageBoxImage.Question);
- if (MessageBoxResult.Yes == result)
+ if (result == MessageBoxResult.Yes)
{
Directory.CreateDirectory(directory);
Process.Start(directory);
@@ -2437,7 +2437,7 @@ namespace HandBrakeWPF.ViewModels
/// <param name="e">
/// The e.
/// </param>
- void QueueProcessorJobProcessingStarted(object sender, QueueProgressEventArgs e)
+ private void QueueProcessorJobProcessingStarted(object sender, QueueProgressEventArgs e)
{
Execute.OnUIThread(
() =>
@@ -2547,7 +2547,6 @@ namespace HandBrakeWPF.ViewModels
this.QueueViewModel.WhenDone(this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction), false);
break;
}
-
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/ManagePresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ManagePresetViewModel.cs
index 7f0fed5b6..42b9f4bab 100644
--- a/win/CS/HandBrakeWPF/ViewModels/ManagePresetViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/ManagePresetViewModel.cs
@@ -48,7 +48,7 @@ namespace HandBrakeWPF.ViewModels
this.errorService = errorService;
this.windowManager = windowManager;
this.Title = "Manage Preset";
- this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName};
+ this.Preset = new Preset { IsBuildIn = false, IsDefault = false, Category = PresetService.UserPresetCatgoryName };
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 7322e3060..17154f922 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -494,6 +494,7 @@ namespace HandBrakeWPF.ViewModels
#endregion
#region Preview
+
/// <summary>
/// Gets or sets VLCPath.
/// </summary>
@@ -510,6 +511,7 @@ namespace HandBrakeWPF.ViewModels
this.NotifyOfPropertyChange("VLCPath");
}
}
+
#endregion
#region System and Logging
@@ -1315,7 +1317,6 @@ namespace HandBrakeWPF.ViewModels
// Use dvdnav
this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav);
-
}
/// <summary>
@@ -1327,6 +1328,17 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// The goto tab.
+ /// </summary>
+ /// <param name="tab">
+ /// The tab.
+ /// </param>
+ public void GotoTab(OptionsTab tab)
+ {
+ this.SelectedTab = tab;
+ }
+
+ /// <summary>
/// Save the settings selected
/// </summary>
private void Save()
@@ -1452,17 +1464,6 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// The goto tab.
- /// </summary>
- /// <param name="tab">
- /// The tab.
- /// </param>
- public void GotoTab(OptionsTab tab)
- {
- this.SelectedTab = tab;
- }
-
- /// <summary>
/// Validate the Autoname Fileformat string
/// </summary>
/// <param name="input">The format string</param>
diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
index a428144c0..a28fa889b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs
@@ -788,8 +788,9 @@ namespace HandBrakeWPF.ViewModels
this.Task.Height = this.GetModulusValue(this.sourceResolution.Height - this.CropTop - this.CropBottom);
this.MaintainAspectRatio = preset.Task.KeepDisplayAspect;
}
- else // Custom
+ else
{
+ // Custom
// Set the Width, and Maintain Aspect ratio. That should calc the Height for us.
this.Task.Width = this.GetModulusValue(this.MaxWidth - this.CropLeft - this.CropRight);
@@ -1063,7 +1064,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// The changed picture field.
/// </summary>
- enum ChangedPictureField
+ public enum ChangedPictureField
{
Width,
Height,
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index 97811dec9..c5351d729 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -459,7 +459,6 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged;
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
-
}
public void Deactivate()
diff --git a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
index fdc2886c7..55045cbca 100644
--- a/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/StaticPreviewViewModel.cs
@@ -591,7 +591,7 @@ namespace HandBrakeWPF.ViewModels
// Attempt to find VLC if it doesn't exist in the default set location.
string vlcPath;
- if (IntPtr.Size == 8 || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
+ if (IntPtr.Size == 8 || (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))
vlcPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
else
vlcPath = Environment.GetEnvironmentVariable("ProgramFiles");
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
index 826805636..d38883b44 100644
--- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs
@@ -198,7 +198,7 @@ namespace HandBrakeWPF.ViewModels
/// <summary>
/// The add first for selected languages.
/// </summary>
- private void AddFirstForSelectedLanguages()
+ public void AddFirstForSelectedLanguages()
{
foreach (Subtitle sourceTrack in this.GetSelectedLanguagesTracks())
{
@@ -372,7 +372,8 @@ namespace HandBrakeWPF.ViewModels
case SubtitleBurnInBehaviourModes.FirstTrack:
foreach (var track in this.Task.SubtitleTracks)
{
- if (track.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch) // Foreign Audio Search is always first in the list.
+ // Foreign Audio Search is always first in the list.
+ if (track.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch)
{
track.Forced = true;
continue;
diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
index 32f0b8dbd..d3da0f1c0 100644
--- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs
@@ -337,7 +337,7 @@ namespace HandBrakeWPF.ViewModels
case VideoEncoder.X265_10:
case VideoEncoder.X265_12:
double cqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);
- double rfValue = 51.0 - value * cqStep;
+ double rfValue = 51.0 - (value * cqStep);
rfValue = Math.Round(rfValue, 2);
this.Task.Quality = rfValue;
break;
@@ -714,7 +714,7 @@ namespace HandBrakeWPF.ViewModels
if (encoder != null)
{
string preset = value >= 0 ? encoder.Presets[value] : null;
- this.VideoPreset = preset != null ?new VideoPreset(preset, preset) : this.VideoPresets.FirstOrDefault();
+ this.VideoPreset = preset != null ? new VideoPreset(preset, preset) : this.VideoPresets.FirstOrDefault();
}
this.NotifyOfPropertyChange(() => this.VideoPresetValue);
@@ -1062,7 +1062,6 @@ namespace HandBrakeWPF.ViewModels
}
}
-
/// <summary>
/// The get actualx 264 query.
/// </summary>