diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 20 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 197 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 43 |
3 files changed, 141 insertions, 119 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs index cca7b2334..e270e3c15 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs @@ -38,7 +38,7 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// The source chapters backing field
/// </summary>
- private List<Chapter> sourceChaptersList;
+ private List<Chapter> sourceChaptersList;
#region Constructors and Destructors
@@ -99,13 +99,13 @@ namespace HandBrakeWPF.ViewModels public void Export()
{
var saveFileDialog = new OpenFileDialog
- {
- Filter = "Csv File|*.csv",
- DefaultExt = "csv",
- CheckPathExists = true
- };
- saveFileDialog.ShowDialog();
- if (!string.IsNullOrEmpty(saveFileDialog.FileName))
+ {
+ Filter = "Csv File|*.csv",
+ DefaultExt = "csv",
+ CheckPathExists = true
+ };
+ bool? dialogResult = saveFileDialog.ShowDialog();
+ if (dialogResult.HasValue && dialogResult.Value && !string.IsNullOrEmpty(saveFileDialog.FileName))
{
this.ExportChaptersToCSV(saveFileDialog.FileName);
}
@@ -153,10 +153,10 @@ namespace HandBrakeWPF.ViewModels public void Import()
{
var dialog = new OpenFileDialog { Filter = "CSV files (*.csv)|*.csv", CheckFileExists = true };
- dialog.ShowDialog();
+ bool? dialogResult = dialog.ShowDialog();
string filename = dialog.FileName;
- if (string.IsNullOrEmpty(filename))
+ if (!dialogResult.HasValue || !dialogResult.Value || string.IsNullOrEmpty(filename))
{
return;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 320ffbf23..c614dde2d 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -264,8 +264,8 @@ namespace HandBrakeWPF.ViewModels /// The static Preview View Model.
/// </param>
public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
- IErrorService errorService, IUpdateService updateService, INotificationService notificationService,
- IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel,
+ IErrorService errorService, IUpdateService updateService, INotificationService notificationService,
+ IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel,
IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel,
IAdvancedViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel)
{
@@ -569,7 +569,7 @@ namespace HandBrakeWPF.ViewModels {
return new List<PointToPointMode>
{
- PointToPointMode.Chapters, PointToPointMode.Seconds, PointToPointMode.Frames
+ PointToPointMode.Chapters, PointToPointMode.Seconds, PointToPointMode.Frames
};
}
}
@@ -1228,7 +1228,7 @@ namespace HandBrakeWPF.ViewModels // Queue Recovery
QueueRecoveryHelper.RecoverQueue(this.queueProcessor, this.errorService);
-
+
this.SelectedPreset = this.presetService.DefaultPreset;
// Log Cleaning
@@ -1467,13 +1467,13 @@ namespace HandBrakeWPF.ViewModels IQueueSelectionViewModel viewModel = IoC.Get<IQueueSelectionViewModel>();
viewModel.Setup(this.ScannedSource, this.SourceName, (tasks) =>
+ {
+ foreach (SelectionTitle title in tasks)
{
- foreach (SelectionTitle title in tasks)
- {
- this.SelectedTitle = title.Title;
- this.AddToQueue();
- }
- });
+ this.SelectedTitle = title.Title;
+ this.AddToQueue();
+ }
+ });
if (window != null)
{
@@ -1491,11 +1491,14 @@ namespace HandBrakeWPF.ViewModels public void FolderScan()
{
VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = Resources.Main_PleaseSelectFolder, UseDescriptionForTitle = true };
- dialog.ShowDialog();
+ bool? dialogResult = dialog.ShowDialog();
- ShowSourceSelection = false;
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ ShowSourceSelection = false;
- this.StartScan(dialog.SelectedPath, this.TitleSpecificScan);
+ this.StartScan(dialog.SelectedPath, this.TitleSpecificScan);
+ }
}
/// <summary>
@@ -1504,11 +1507,14 @@ namespace HandBrakeWPF.ViewModels public void FileScan()
{
OpenFileDialog dialog = new OpenFileDialog { Filter = "All files (*.*)|*.*" };
- dialog.ShowDialog();
+ bool? dialogResult = dialog.ShowDialog();
- ShowSourceSelection = false;
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ ShowSourceSelection = false;
- this.StartScan(dialog.FileName, this.TitleSpecificScan);
+ this.StartScan(dialog.FileName, this.TitleSpecificScan);
+ }
}
/// <summary>
@@ -1674,13 +1680,13 @@ namespace HandBrakeWPF.ViewModels public void BrowseDestination()
{
SaveFileDialog saveFileDialog = new SaveFileDialog
- {
- Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv",
- CheckPathExists = true,
- AddExtension = true,
- DefaultExt = ".mp4",
- OverwritePrompt = true,
- };
+ {
+ Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv",
+ CheckPathExists = true,
+ AddExtension = true,
+ DefaultExt = ".mp4",
+ OverwritePrompt = true,
+ };
string extension = Path.GetExtension(this.CurrentTask.Destination);
@@ -1849,9 +1855,12 @@ namespace HandBrakeWPF.ViewModels public void PresetImport()
{
OpenFileDialog dialog = new OpenFileDialog { Filter = "Preset Files|*.json;*.plist", CheckFileExists = true };
- dialog.ShowDialog();
- this.presetService.Import(dialog.FileName);
- this.NotifyOfPropertyChange(() => this.Presets);
+ bool? dialogResult = dialog.ShowDialog();
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ this.presetService.Import(dialog.FileName);
+ this.NotifyOfPropertyChange(() => this.Presets);
+ }
}
/// <summary>
@@ -1860,14 +1869,14 @@ namespace HandBrakeWPF.ViewModels public void PresetExport()
{
SaveFileDialog savefiledialog = new SaveFileDialog
- {
- Filter = "json|*.json",
- CheckPathExists = true,
- AddExtension = true,
- DefaultExt = ".json",
- OverwritePrompt = true,
- FilterIndex = 0
- };
+ {
+ Filter = "json|*.json",
+ CheckPathExists = true,
+ AddExtension = true,
+ DefaultExt = ".json",
+ OverwritePrompt = true,
+ FilterIndex = 0
+ };
if (this.selectedPreset != null)
{
savefiledialog.ShowDialog();
@@ -1944,41 +1953,41 @@ namespace HandBrakeWPF.ViewModels {
/* TODO Fix this. */
Execute.OnUIThread(() =>
- {
- // Copy all the Scan data into the UI
- scannedSource.CopyTo(this.ScannedSource);
- this.NotifyOfPropertyChange(() => this.ScannedSource);
- this.NotifyOfPropertyChange(() => this.ScannedSource.Titles);
+ {
+ // Copy all the Scan data into the UI
+ scannedSource.CopyTo(this.ScannedSource);
+ this.NotifyOfPropertyChange(() => this.ScannedSource);
+ this.NotifyOfPropertyChange(() => this.ScannedSource.Titles);
- // Select the Users Title
- this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault();
- this.CurrentTask = new EncodeTask(queueEditTask);
- this.NotifyOfPropertyChange(() => this.CurrentTask);
- this.HasSource = true;
+ // Select the Users Title
+ this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault();
+ this.CurrentTask = new EncodeTask(queueEditTask);
+ this.NotifyOfPropertyChange(() => this.CurrentTask);
+ this.HasSource = true;
- // Update the Main Window
- this.NotifyOfPropertyChange(() => this.Destination);
- this.NotifyOfPropertyChange(() => this.SelectedStartPoint);
- this.NotifyOfPropertyChange(() => this.SelectedEndPoint);
- this.NotifyOfPropertyChange(() => this.SelectedAngle);
- this.NotifyOfPropertyChange(() => this.SelectedPointToPoint);
- this.NotifyOfPropertyChange(() => this.SelectedOutputFormat);
- this.NotifyOfPropertyChange(() => IsMkv);
+ // Update the Main Window
+ this.NotifyOfPropertyChange(() => this.Destination);
+ this.NotifyOfPropertyChange(() => this.SelectedStartPoint);
+ this.NotifyOfPropertyChange(() => this.SelectedEndPoint);
+ this.NotifyOfPropertyChange(() => this.SelectedAngle);
+ this.NotifyOfPropertyChange(() => this.SelectedPointToPoint);
+ this.NotifyOfPropertyChange(() => this.SelectedOutputFormat);
+ this.NotifyOfPropertyChange(() => IsMkv);
- // Update the Tab Controls
- this.PictureSettingsViewModel.UpdateTask(this.CurrentTask);
- this.VideoViewModel.UpdateTask(this.CurrentTask);
- this.FiltersViewModel.UpdateTask(this.CurrentTask);
- this.AudioViewModel.UpdateTask(this.CurrentTask);
- this.SubtitleViewModel.UpdateTask(this.CurrentTask);
- this.ChaptersViewModel.UpdateTask(this.CurrentTask);
- this.AdvancedViewModel.UpdateTask(this.CurrentTask);
-
- // Cleanup
- this.ShowStatusWindow = false;
- this.SourceLabel = this.SourceName;
- this.StatusLabel = Resources.Main_ScanCompleted;
- });
+ // Update the Tab Controls
+ this.PictureSettingsViewModel.UpdateTask(this.CurrentTask);
+ this.VideoViewModel.UpdateTask(this.CurrentTask);
+ this.FiltersViewModel.UpdateTask(this.CurrentTask);
+ this.AudioViewModel.UpdateTask(this.CurrentTask);
+ this.SubtitleViewModel.UpdateTask(this.CurrentTask);
+ this.ChaptersViewModel.UpdateTask(this.CurrentTask);
+ this.AdvancedViewModel.UpdateTask(this.CurrentTask);
+
+ // Cleanup
+ this.ShowStatusWindow = false;
+ this.SourceLabel = this.SourceName;
+ this.StatusLabel = Resources.Main_ScanCompleted;
+ });
}
/// <summary>
@@ -2146,36 +2155,36 @@ namespace HandBrakeWPF.ViewModels }
Execute.OnUIThread(() =>
+ {
+ if (e.Successful)
{
- if (e.Successful)
- {
- this.NotifyOfPropertyChange(() => this.ScannedSource);
- this.NotifyOfPropertyChange(() => this.ScannedSource.Titles);
- this.HasSource = true;
- this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(t => t.MainTitle) ?? this.ScannedSource.Titles.FirstOrDefault();
- }
- else
- {
- this.OpenAlertWindow(Resources.Main_ScanNoTitlesFound, Resources.Main_ScanNoTitlesFoundMessage);
- }
+ this.NotifyOfPropertyChange(() => this.ScannedSource);
+ this.NotifyOfPropertyChange(() => this.ScannedSource.Titles);
+ this.HasSource = true;
+ this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(t => t.MainTitle) ?? this.ScannedSource.Titles.FirstOrDefault();
+ }
+ else
+ {
+ this.OpenAlertWindow(Resources.Main_ScanNoTitlesFound, Resources.Main_ScanNoTitlesFoundMessage);
+ }
- this.ShowStatusWindow = false;
- if (e.Successful)
- {
- this.SourceLabel = this.SourceName;
- this.StatusLabel = Resources.Main_ScanCompleted;
- }
- else if (e.Cancelled)
- {
- this.SourceLabel = Resources.Main_ScanCancelled;
- this.StatusLabel = Resources.Main_ScanCancelled;
- }
- else
- {
- this.SourceLabel = Resources.Main_ScanFailled_CheckLog;
- this.StatusLabel = Resources.Main_ScanFailled_CheckLog;
- }
- });
+ this.ShowStatusWindow = false;
+ if (e.Successful)
+ {
+ this.SourceLabel = this.SourceName;
+ this.StatusLabel = Resources.Main_ScanCompleted;
+ }
+ else if (e.Cancelled)
+ {
+ this.SourceLabel = Resources.Main_ScanCancelled;
+ this.StatusLabel = Resources.Main_ScanCancelled;
+ }
+ else
+ {
+ this.SourceLabel = Resources.Main_ScanFailled_CheckLog;
+ this.StatusLabel = Resources.Main_ScanFailled_CheckLog;
+ }
+ });
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 41dc93291..331c9bf5c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -552,6 +552,7 @@ namespace HandBrakeWPF.ViewModels }
}
+
#endregion
#region Output Files
@@ -1217,10 +1218,13 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void BrowseSendFileTo()
{
- VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "All files (*.*)|*.*" };
- dialog.ShowDialog();
- this.SendFileTo = Path.GetFileNameWithoutExtension(dialog.FileName);
- this.sendFileToPath = dialog.FileName;
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "All files (*.*)|*.*", FileName = this.sendFileToPath };
+ bool? dialogResult = dialog.ShowDialog();
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ this.SendFileTo = Path.GetFileNameWithoutExtension(dialog.FileName);
+ this.sendFileToPath = dialog.FileName;
+ }
}
/// <summary>
@@ -1228,9 +1232,12 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void BrowseAutoNamePath()
{
- VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = "Please select a folder.", UseDescriptionForTitle = true };
- dialog.ShowDialog();
- this.AutoNameDefaultPath = dialog.SelectedPath;
+ VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = "Please select a folder.", UseDescriptionForTitle = true, SelectedPath = this.AutoNameDefaultPath };
+ bool? dialogResult = dialog.ShowDialog();
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ this.AutoNameDefaultPath = dialog.SelectedPath;
+ }
}
/// <summary>
@@ -1238,9 +1245,12 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void BrowseVlcPath()
{
- VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "All files (*.exe)|*.exe" };
- dialog.ShowDialog();
- this.VLCPath = dialog.FileName;
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "All files (*.exe)|*.exe", FileName = this.VLCPath };
+ bool? dialogResult = dialog.ShowDialog();
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ this.VLCPath = dialog.FileName;
+ }
}
/// <summary>
@@ -1248,9 +1258,12 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void BrowseLogPath()
{
- VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = "Please select a folder.", UseDescriptionForTitle = true };
- dialog.ShowDialog();
- this.LogDirectory = dialog.SelectedPath;
+ VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = "Please select a folder.", UseDescriptionForTitle = true, SelectedPath = this.LogDirectory };
+ bool? dialogResult = dialog.ShowDialog();
+ if (dialogResult.HasValue && dialogResult.Value)
+ {
+ this.LogDirectory = dialog.SelectedPath;
+ }
}
/// <summary>
@@ -1453,7 +1466,7 @@ namespace HandBrakeWPF.ViewModels this.MinLength = this.userSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration);
// Use dvdnav
- this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav);
+ this.DisableLibdvdNav = userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav);
}
/// <summary>
@@ -1483,7 +1496,7 @@ namespace HandBrakeWPF.ViewModels /* Previews */
this.userSettingService.SetUserSetting(UserSettingConstants.VLCPath, this.VLCPath);
-
+
/* Video */
this.userSettingService.SetUserSetting(UserSettingConstants.DisableQuickSyncDecoding, this.DisableQuickSyncDecoding);
this.userSettingService.SetUserSetting(UserSettingConstants.EnableDxva, this.EnableDxvaDecoding);
|