From cd3e951792f05944fb9ba4f1bc17e581318bfe8f Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 30 Dec 2011 18:57:30 +0000 Subject: WinGui: (WPF) Move all the main UI tab UserControls into an MVVM format. Mostly code shuffling. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4393 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 60 +++++-- win/CS/HandBrakeWPF/README BEFORE WRITING CODE.txt | 7 + win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs | 9 + win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs | 13 +- .../HandBrakeWPF/ViewModels/AddPresetViewModel.cs | 18 +- .../HandBrakeWPF/ViewModels/AdvancedViewModel.cs | 44 +++++ win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs | 62 +++++++ .../HandBrakeWPF/ViewModels/ChaptersViewModel.cs | 177 ++++++++++++++++++ win/CS/HandBrakeWPF/ViewModels/ErrorViewModel.cs | 1 - win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs | 39 ++++ .../ViewModels/Interfaces/IAdvancedViewModel.cs | 18 ++ .../ViewModels/Interfaces/IAudioViewModel.cs | 18 ++ .../ViewModels/Interfaces/IChaptersViewModel.cs | 18 ++ .../ViewModels/Interfaces/IErrorViewModel.cs | 6 +- .../ViewModels/Interfaces/IFiltersViewModel.cs | 18 ++ .../Interfaces/IPictureSettingsViewModel.cs | 18 ++ .../ViewModels/Interfaces/ISubtitlesViewModel.cs | 18 ++ .../ViewModels/Interfaces/IVideoViewModel.cs | 18 ++ win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs | 1 - win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 49 ++++- win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 3 +- .../ViewModels/PictureSettingsViewModel.cs | 39 ++++ win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs | 2 +- win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 1 - .../HandBrakeWPF/ViewModels/SubtitlesViewModel.cs | 72 ++++++++ win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs | 39 ++++ win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs | 17 +- win/CS/HandBrakeWPF/Views/AdvancedView.xaml | 22 +++ win/CS/HandBrakeWPF/Views/AdvancedView.xaml.cs | 27 +++ win/CS/HandBrakeWPF/Views/AudioView.xaml | 110 ++++++++++++ win/CS/HandBrakeWPF/Views/AudioView.xaml.cs | 27 +++ win/CS/HandBrakeWPF/Views/ChaptersView.xaml | 40 +++++ win/CS/HandBrakeWPF/Views/ChaptersView.xaml.cs | 27 +++ .../HandBrakeWPF/Views/Controls/AdvancedView.xaml | 22 --- .../Views/Controls/AdvancedView.xaml.cs | 49 ----- win/CS/HandBrakeWPF/Views/Controls/AudioView.xaml | 110 ------------ .../HandBrakeWPF/Views/Controls/AudioView.xaml.cs | 75 -------- .../HandBrakeWPF/Views/Controls/ChaptersView.xaml | 40 ----- .../Views/Controls/ChaptersView.xaml.cs | 197 --------------------- .../Views/Controls/PictureSettingsView.xaml | 96 ---------- .../Views/Controls/PictureSettingsView.xaml.cs | 15 -- .../HandBrakeWPF/Views/Controls/SubtitlesView.xaml | 112 ------------ .../Views/Controls/SubtitlesView.xaml.cs | 88 --------- win/CS/HandBrakeWPF/Views/FiltersView.xaml | 58 ++++++ win/CS/HandBrakeWPF/Views/FiltersView.xaml.cs | 27 +++ win/CS/HandBrakeWPF/Views/MainView.xaml | 133 ++------------ win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml | 96 ++++++++++ .../HandBrakeWPF/Views/PictureSettingsView.xaml.cs | 27 +++ win/CS/HandBrakeWPF/Views/SubtitlesView.xaml | 112 ++++++++++++ win/CS/HandBrakeWPF/Views/SubtitlesView.xaml.cs | 27 +++ win/CS/HandBrakeWPF/Views/VideoView.xaml | 68 +++++++ win/CS/HandBrakeWPF/Views/VideoView.xaml.cs | 27 +++ 52 files changed, 1432 insertions(+), 985 deletions(-) create mode 100644 win/CS/HandBrakeWPF/README BEFORE WRITING CODE.txt create mode 100644 win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs create mode 100644 win/CS/HandBrakeWPF/Views/AdvancedView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/AdvancedView.xaml.cs create mode 100644 win/CS/HandBrakeWPF/Views/AudioView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/AudioView.xaml.cs create mode 100644 win/CS/HandBrakeWPF/Views/ChaptersView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/ChaptersView.xaml.cs delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/AdvancedView.xaml delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/AdvancedView.xaml.cs delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/AudioView.xaml delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/AudioView.xaml.cs delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/ChaptersView.xaml delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/ChaptersView.xaml.cs delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/PictureSettingsView.xaml delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/PictureSettingsView.xaml.cs delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/SubtitlesView.xaml delete mode 100644 win/CS/HandBrakeWPF/Views/Controls/SubtitlesView.xaml.cs create mode 100644 win/CS/HandBrakeWPF/Views/FiltersView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/FiltersView.xaml.cs create mode 100644 win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/PictureSettingsView.xaml.cs create mode 100644 win/CS/HandBrakeWPF/Views/SubtitlesView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/SubtitlesView.xaml.cs create mode 100644 win/CS/HandBrakeWPF/Views/VideoView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/VideoView.xaml.cs (limited to 'win') diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index d91abdb9f..055ee5372 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -93,8 +93,22 @@ + + + + + + + + + + + + + + @@ -116,18 +130,24 @@ Code - + AdvancedView.xaml - + AudioView.xaml - - ChaptersView.xaml - AddPresetView.xaml + + ChaptersView.xaml + + + FiltersView.xaml + + + SubtitlesView.xaml + ErrorView.xaml @@ -143,15 +163,15 @@ MainView.xaml - + PictureSettingsView.xaml - - SubtitlesView.xaml - OptionsView.xaml + + VideoView.xaml + @@ -183,19 +203,27 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + + MSBuild:Compile Designer + + MSBuild:Compile + Designer - + + Designer + MSBuild:Compile + + MSBuild:Compile Designer @@ -219,15 +247,15 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/win/CS/HandBrakeWPF/README BEFORE WRITING CODE.txt b/win/CS/HandBrakeWPF/README BEFORE WRITING CODE.txt new file mode 100644 index 000000000..252bae71b --- /dev/null +++ b/win/CS/HandBrakeWPF/README BEFORE WRITING CODE.txt @@ -0,0 +1,7 @@ +This is the port of the current WinForms GUI over to WPF. +It is an incomplete work-in-progress and not currently in a usable state! + +Goals: + +- Move as much of the busness logic into the ApplicaitonServices library so it's reusable. +- Rebuild the UI in WPF using MVVM approach using Caliburn Micro 1.2 as the base and Castle Windsor for IoC/DI \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index 8c2e05d93..2fe913baa 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -62,6 +62,15 @@ namespace HandBrakeWPF.Startup this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + + // Tab Components + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs index c300487e3..e506fb987 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AboutViewModel.cs @@ -24,11 +24,6 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IAboutViewModel))] public class AboutViewModel : ViewModelBase, IAboutViewModel { - /// - /// Backing Field for the User setting service. - /// - private readonly IUserSettingService userSettingService; - /// /// Initializes a new instance of the class. /// @@ -39,9 +34,7 @@ namespace HandBrakeWPF.ViewModels /// The user Setting Service. /// public AboutViewModel(IWindowManager windowManager, IUserSettingService userSettingService) - : base(windowManager) { - this.userSettingService = userSettingService; this.Title = "About HandBrake"; } @@ -52,11 +45,11 @@ namespace HandBrakeWPF.ViewModels { get { - string nightly = userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty; + string nightly = UserSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty; return string.Format( "{0} ({1}) {2}", - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion), - userSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeBuild), + UserSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeVersion), + UserSettingService.GetUserSetting(ASUserSettingConstants.HandBrakeBuild), nightly); } } diff --git a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs index d4a6f077c..c46792c7c 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AddPresetViewModel.cs @@ -7,18 +7,20 @@ // // -------------------------------------------------------------------------------------------------------------------- -using System.Windows; -using HandBrake.ApplicationServices.Model; -using HandBrake.ApplicationServices.Services.Interfaces; -using HandBrake.ApplicationServices.Utilities; -using HandBrakeWPF.Services.Interfaces; - namespace HandBrakeWPF.ViewModels { using System.ComponentModel.Composition; - using Interfaces; + using System.Windows; + using Caliburn.Micro; + using HandBrake.ApplicationServices.Model; + using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrake.ApplicationServices.Utilities; + + using HandBrakeWPF.Services.Interfaces; + using HandBrakeWPF.ViewModels.Interfaces; + /// /// The Add Preset View Model /// @@ -47,7 +49,7 @@ namespace HandBrakeWPF.ViewModels /// /// The Error Service /// - public AddPresetViewModel(IWindowManager windowManager, IPresetService presetService, IErrorService errorService) : base(windowManager) + public AddPresetViewModel(IWindowManager windowManager, IPresetService presetService, IErrorService errorService) { this.presetService = presetService; this.errorService = errorService; diff --git a/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs new file mode 100644 index 000000000..9b50acc5c --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs @@ -0,0 +1,44 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Advanced View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.ComponentModel.Composition; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Advanced View Model + /// + [Export(typeof(IAdvancedViewModel))] + public class AdvancedViewModel : ViewModelBase, IAdvancedViewModel + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + } + + /// + /// Gets or sets State. + /// + public string Query { get; set; } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs new file mode 100644 index 000000000..d8e4c194d --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -0,0 +1,62 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Audio View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.Collections.ObjectModel; + using System.ComponentModel.Composition; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Model.Encoding; + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Audio View Model + /// + [Export(typeof(IAudioViewModel))] + public class AudioViewModel : ViewModelBase, IAudioViewModel + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public AudioViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + this.AudioTracks = new ObservableCollection(); + } + + /// + /// Gets or sets AudioTracks. + /// + public ObservableCollection AudioTracks { get; set; } + + /// + /// Add an Audio Track + /// + public void Add() + { + this.AudioTracks.Add(new AudioTrack()); + } + + /// + /// Remove the Selected Track + /// + public void Remove() + { + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs new file mode 100644 index 000000000..672082b51 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/ChaptersViewModel.cs @@ -0,0 +1,177 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Chapters View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.ComponentModel.Composition; + using System.IO; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Exceptions; + using HandBrake.ApplicationServices.Model.Encoding; + using HandBrake.ApplicationServices.Parsing; + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + using Ookii.Dialogs.Wpf; + + /// + /// The Chapters View Model + /// + [Export(typeof(IChaptersViewModel))] + public class ChaptersViewModel : ViewModelBase, IChaptersViewModel + { + /// + /// Gets or sets SourceChapterList. + /// + private ObservableCollection SourceChapterList { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public ChaptersViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + this.Chapters = new ObservableCollection(); + } + + /// + /// Gets or sets State. + /// + public ObservableCollection Chapters { get; set; } + + /// + /// Gets or sets a value indicating whether chapter markers are enabled. + /// + public bool IncludeChapterMarkers { get; set; } + + /// + /// Set the Source Chapters List + /// + /// + /// The source chapters. + /// + public void SetSourceChapters(IEnumerable sourceChapters) + { + // Cache the chapters in this screen + this.SourceChapterList = new ObservableCollection(sourceChapters); + this.Chapters.Clear(); + + // Then Add new Chapter Markers. + foreach (Chapter chapter in SourceChapterList) + { + ChapterMarker marker = new ChapterMarker(chapter.ChapterNumber, chapter.ChapterName); + this.Chapters.Add(marker); + } + } + + /// + /// Export the Chapter Markers to a CSV file + /// + /// + /// The filename. + /// + /// + /// Thrown when exporting fails. + /// + public void ExportChaptersToCSV(string filename) + { + try + { + string csv = string.Empty; + + foreach (ChapterMarker row in this.Chapters) + { + csv += row.ChapterNumber.ToString(); + csv += ","; + csv += row.ChapterName.Replace(",", "\\,"); + csv += Environment.NewLine; + } + StreamWriter file = new StreamWriter(filename); + file.Write(csv); + file.Close(); + file.Dispose(); + } + catch (Exception exc) + { + throw new GeneralApplicationException("Unable to save Chapter Makrers file! ", "Chapter marker names will NOT be saved in your encode.", exc); + } + } + + /// + /// Import a CSV file + /// + private void Import() + { + VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "CSV files (*.csv)|*.csv", CheckFileExists = true }; + dialog.ShowDialog(); + string filename = dialog.FileName; + + if (string.IsNullOrEmpty(filename)) + { + return; + } + + IDictionary chapterMap = new Dictionary(); + try + { + StreamReader sr = new StreamReader(filename); + string csv = sr.ReadLine(); + while (csv != null) + { + if (csv.Trim() != string.Empty) + { + csv = csv.Replace("\\,", ""); + string[] contents = csv.Split(','); + int chapter; + int.TryParse(contents[0], out chapter); + chapterMap.Add(chapter, contents[1].Replace("", ",")); + } + csv = sr.ReadLine(); + } + } + catch (Exception) + { + // Do Nothing + } + + // Now iterate over each chatper we have, and set it's name + foreach (ChapterMarker item in Chapters) + { + string chapterName; + chapterMap.TryGetValue(item.ChapterNumber, out chapterName); + item.ChapterName = chapterName; + // TODO force a fresh of this property + } + } + + /// + /// Export a CSV file. + /// + private void Export() + { + VistaSaveFileDialog saveFileDialog = new VistaSaveFileDialog { Filter = "Csv File|*.csv", DefaultExt = "csv", CheckPathExists = true }; + saveFileDialog.ShowDialog(); + if (!string.IsNullOrEmpty(saveFileDialog.FileName)) + { + this.ExportChaptersToCSV(saveFileDialog.FileName); + } + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/ErrorViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ErrorViewModel.cs index b93671970..bed8806a4 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ErrorViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ErrorViewModel.cs @@ -46,7 +46,6 @@ namespace HandBrakeWPF.ViewModels /// Initializes a new instance of the class. /// public ErrorViewModel() - : base(null) { this.Title = "Error"; this.ErrorMessage = "An Unknown Error has occured."; diff --git a/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs new file mode 100644 index 000000000..571606e1d --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/FiltersViewModel.cs @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Filters View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.ComponentModel.Composition; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Filters View Model + /// + [Export(typeof(IFiltersViewModel))] + public class FiltersViewModel : ViewModelBase, IFiltersViewModel + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public FiltersViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs new file mode 100644 index 000000000..1ffb86c96 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAdvancedViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the IAdvancedViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Advanced View Model Interface + /// + public interface IAdvancedViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs new file mode 100644 index 000000000..bd13345db --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IAudioViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the IAudioViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Audio View Model Interface + /// + public interface IAudioViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs new file mode 100644 index 000000000..8e9710d74 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IChaptersViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the IChaptersViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Chapters View Model Interface + /// + public interface IChaptersViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IErrorViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IErrorViewModel.cs index a0fa8e36d..6094157b0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IErrorViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IErrorViewModel.cs @@ -15,17 +15,17 @@ namespace HandBrakeWPF.ViewModels.Interfaces public interface IErrorViewModel { /// - /// The Error Details + /// Sets Details. /// string Details { set; } /// - /// The Error Message + /// Sets ErrorMessage. /// string ErrorMessage { set; } /// - /// The Error Solution + /// Sets Solution. /// string Solution { set; } } diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs new file mode 100644 index 000000000..24662f946 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IFiltersViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the IFiltersViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Filters View Model Interface + /// + public interface IFiltersViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs new file mode 100644 index 000000000..35a8e4eaf --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IPictureSettingsViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the IPictureSettingsViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Picture Settings View Model Interface + /// + public interface IPictureSettingsViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs new file mode 100644 index 000000000..2a490c274 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ISubtitlesViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the ISubtitlesViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Subtiles View Model Interface + /// + public interface ISubtitlesViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs new file mode 100644 index 000000000..7690b87a9 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IVideoViewModel.cs @@ -0,0 +1,18 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the IVideoViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Video View Model Interface + /// + public interface IVideoViewModel + { + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs index aeba8e32e..8733445fd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs @@ -69,7 +69,6 @@ namespace HandBrakeWPF.ViewModels /// The scan service. /// public LogViewModel(IWindowManager windowManager, IEncode encodeService, IScan scanService) - : base(windowManager) { this.encodeService = encodeService; this.scanService = scanService; diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index d742eea5c..daf8bcce0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -41,11 +41,6 @@ namespace HandBrakeWPF.ViewModels { #region Private Variables and Services - /// - /// The Backing field for the user setting service. - /// - private readonly IUserSettingService userSettingService; - /// /// The Source Scan Service. /// @@ -153,9 +148,7 @@ namespace HandBrakeWPF.ViewModels [ImportingConstructor] public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService, IErrorService errorService) - : base(windowManager) { - this.userSettingService = userSettingService; this.scanService = scanService; this.encodeService = encodeService; this.presetService = presetService; @@ -178,6 +171,44 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged; } + #region View Model Properties + /// + /// Gets or sets PictureSettingsViewModel. + /// + public IPictureSettingsViewModel PictureSettingsViewModel { get; set; } + + /// + /// Gets or sets AudioViewModel. + /// + public IAudioViewModel AudioViewModel { get; set; } + + /// + /// Gets or sets SubtitleViewModel. + /// + public ISubtitlesViewModel SubtitleViewModel { get; set; } + + /// + /// Gets or sets ChaptersViewModel. + /// + public IChaptersViewModel ChaptersViewModel { get; set; } + + /// + /// Gets or sets AdvancedViewModel. + /// + public IAdvancedViewModel AdvancedViewModel { get; set; } + + /// + /// Gets or sets VideoViewModel. + /// + public IVideoViewModel VideoViewModel { get; set; } + + /// + /// Gets or sets FiltersViewModel. + /// + public IFiltersViewModel FiltersViewModel { get; set; } + + #endregion + #region Properties /// /// Gets or sets TestProperty. @@ -934,7 +965,7 @@ namespace HandBrakeWPF.ViewModels // TODO // 1. Disable GUI. this.sourcePath = filename; - this.scanService.Scan(filename, title, this.userSettingService.GetUserSetting(ASUserSettingConstants.PreviewScanCount)); + this.scanService.Scan(filename, title, this.UserSettingService.GetUserSetting(ASUserSettingConstants.PreviewScanCount)); } /// @@ -948,7 +979,7 @@ namespace HandBrakeWPF.ViewModels // Make sure the output extension is set correctly based on the users preferences and selection. if (newExtension == ".mp4" || newExtension == ".m4v") { - switch (this.userSettingService.GetUserSetting(UserSettingConstants.UseM4v)) + switch (this.UserSettingService.GetUserSetting(UserSettingConstants.UseM4v)) { case 0: // Auto newExtension = this.CurrentTask.RequiresM4v ? ".m4v" : ".mp4"; diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 4d11f6786..1f5802503 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -318,10 +318,9 @@ namespace HandBrakeWPF.ViewModels /// The user Setting Service. /// public OptionsViewModel(IWindowManager windowManager, IUserSettingService userSettingService) - : base(windowManager) { this.Title = "Options"; - this.userSettingService = userSettingService; + this.userSettingService = this.UserSettingService; this.Load(); } diff --git a/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs new file mode 100644 index 000000000..60c6feb09 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/PictureSettingsViewModel.cs @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Picture Settings View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.ComponentModel.Composition; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Picture Settings View Model + /// + [Export(typeof(IPictureSettingsViewModel))] + public class PictureSettingsViewModel : ViewModelBase, IPictureSettingsViewModel + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public PictureSettingsViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs index e7fd8f098..0f9c7a213 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs @@ -23,7 +23,7 @@ namespace HandBrakeWPF.ViewModels /// /// The window manager. /// - public PreviewViewModel(IWindowManager windowManager) : base(windowManager) + public PreviewViewModel(IWindowManager windowManager) { this.Title = "Preview"; } diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index e651d9830..060d9ec38 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -65,7 +65,6 @@ namespace HandBrakeWPF.ViewModels /// The Error Service /// public QueueViewModel(IWindowManager windowManager, IQueueProcessor queueProcessor, IErrorService errorService) - : base(windowManager) { this.queueProcessor = queueProcessor; this.errorService = errorService; diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs new file mode 100644 index 000000000..d57f19fb9 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -0,0 +1,72 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Subtitles View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System; + using System.Collections.ObjectModel; + using System.ComponentModel.Composition; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Model.Encoding; + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Subtitles View Model + /// + [Export(typeof(ISubtitlesViewModel))] + public class SubtitlesViewModel : ViewModelBase, ISubtitlesViewModel + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + this.SubtitleTracks = new ObservableCollection(); + } + + /// + /// Gets or sets State. + /// + public ObservableCollection SubtitleTracks { get; set; } + + /// + /// Add a new Track + /// + public void Add() + { + this.SubtitleTracks.Add(new SubtitleTrack()); + } + + /// + /// Remove a Track + /// + public void Remove() + { + throw new NotImplementedException(); + } + + /// + /// Import an SRT File. + /// + public void Import() + { + throw new NotImplementedException(); + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs new file mode 100644 index 000000000..59b6a98f5 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Video View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.ComponentModel.Composition; + + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Services.Interfaces; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Video View Model + /// + [Export(typeof(IVideoViewModel))] + public class VideoViewModel : ViewModelBase, IVideoViewModel + { + /// + /// Initializes a new instance of the class. + /// + /// + /// The window manager. + /// + /// + /// The user Setting Service. + /// + public VideoViewModel(IWindowManager windowManager, IUserSettingService userSettingService) + { + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs index e226fc549..f1766741e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ViewModelBase.cs @@ -11,6 +11,8 @@ namespace HandBrakeWPF.ViewModels { using Caliburn.Micro; + using HandBrake.ApplicationServices.Services.Interfaces; + using HandBrakeWPF.ViewModels.Interfaces; /// @@ -37,12 +39,8 @@ namespace HandBrakeWPF.ViewModels /// /// Initializes a new instance of the class. /// - /// - /// The window manager. - /// - public ViewModelBase(IWindowManager windowManager) + public ViewModelBase() { - this.WindowManager = windowManager; } #endregion @@ -67,9 +65,14 @@ namespace HandBrakeWPF.ViewModels } /// - /// Gets WindowManager. + /// Gets or sets WindowManager. + /// + public IWindowManager WindowManager { get; set; } + + /// + /// Gets or sets UserSettingService. /// - public IWindowManager WindowManager { get; private set; } + public IUserSettingService UserSettingService { get; set; } #endregion diff --git a/win/CS/HandBrakeWPF/Views/AdvancedView.xaml b/win/CS/HandBrakeWPF/Views/AdvancedView.xaml new file mode 100644 index 000000000..ce91077ba --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/AdvancedView.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/win/CS/HandBrakeWPF/Views/AdvancedView.xaml.cs b/win/CS/HandBrakeWPF/Views/AdvancedView.xaml.cs new file mode 100644 index 000000000..a47bf3efd --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/AdvancedView.xaml.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Interaction logic for AdvancedView.xaml +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Views +{ + using System.Windows.Controls; + + /// + /// Interaction logic for AdvancedView.xaml + /// + public partial class AdvancedView : UserControl + { + /// + /// Initializes a new instance of the class. + /// + public AdvancedView() + { + InitializeComponent(); + } + } +} diff --git a/win/CS/HandBrakeWPF/Views/AudioView.xaml b/win/CS/HandBrakeWPF/Views/AudioView.xaml new file mode 100644 index 000000000..84616338b --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/AudioView.xaml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + - +