From 1908ceb760de50f2be2ea874926d9c7a0c28c9f5 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 6 Apr 2012 22:47:52 +0000 Subject: WinGui: (WPF) Initial Implementation of title specific scanning. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4582 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 9 ++ win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs | 1 + .../Interfaces/ITitleSpecificViewModel.cs | 22 +++++ win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 108 +++++++++++++++++++-- .../ViewModels/TitleSpecificViewModel.cs | 85 ++++++++++++++++ win/CS/HandBrakeWPF/Views/MainView.xaml | 1 + win/CS/HandBrakeWPF/Views/MainView.xaml.cs | 1 - win/CS/HandBrakeWPF/Views/TitleSpecificView.xaml | 27 ++++++ .../HandBrakeWPF/Views/TitleSpecificView.xaml.cs | 27 ++++++ 9 files changed, 272 insertions(+), 9 deletions(-) create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/ITitleSpecificViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/TitleSpecificViewModel.cs create mode 100644 win/CS/HandBrakeWPF/Views/TitleSpecificView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/TitleSpecificView.xaml.cs (limited to 'win/CS') diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 94723903e..a27c42d96 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -110,6 +110,11 @@ MSBuild:Compile Designer + + + + TitleSpecificView.xaml + @@ -246,6 +251,10 @@ + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index e43358e79..47bb3b356 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -63,6 +63,7 @@ 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)); + this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); // Tab Components this.windsorContainer.Register(Component.For().ImplementedBy().LifeStyle.Is(LifestyleType.Singleton)); diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITitleSpecificViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITitleSpecificViewModel.cs new file mode 100644 index 000000000..dd7007230 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ITitleSpecificViewModel.cs @@ -0,0 +1,22 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the ITitleSpecificViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + /// + /// The Title Specific View Model Interface + /// + public interface ITitleSpecificViewModel + { + /// + /// Gets SelectedTitle. + /// + int? SelectedTitle { get; } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 68f20cf85..ad60af389 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -266,12 +266,14 @@ namespace HandBrakeWPF.ViewModels { get { + // TODO - Find a cleaner way of implementing this + BindingList menuItems = new BindingList(); // Folder Menu Item MenuItem folderMenuItem = new MenuItem { - Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrakeWPF;component/Views/Images/folder.png")), Width = 16, Height = 16 }, + Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/folder.png")), Width = 16, Height = 16 }, Header = new TextBlock { Text = "Open Folder", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center } }; folderMenuItem.Click += this.folderMenuItem_Click; @@ -280,19 +282,40 @@ namespace HandBrakeWPF.ViewModels // File Menu Item MenuItem fileMenuItem = new MenuItem { - Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrakeWPF;component/Views/Images/Movies.png")), Width = 16, Height = 16 }, + Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/Movies.png")), Width = 16, Height = 16 }, Header = new TextBlock { Text = "Open File", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center } }; fileMenuItem.Click += this.fileMenuItem_Click; menuItems.Add(fileMenuItem); + // File Menu Item + MenuItem titleSpecific = new MenuItem {Header = new TextBlock { Text = "Title Specific Scan", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center }}; + + MenuItem titleSpecificFolder = new MenuItem + { + Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/folder.png")), Width = 16, Height = 16 }, + Header = new TextBlock { Text = "Open Folder", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center } + }; + MenuItem titleSpecificFile = new MenuItem + { + Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/Movies.png")), Width = 16, Height = 16 }, + Header = new TextBlock { Text = "Open File", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center } + }; + titleSpecificFolder.Click += this.titleSpecificFolder_Click; + titleSpecificFile.Click += this.titleSpecificFile_Click; + + titleSpecific.Items.Add(titleSpecificFolder); + titleSpecific.Items.Add(titleSpecificFile); + + menuItems.Add(titleSpecific); + // Drives foreach (DriveInformation item in GeneralUtilities.GetDrives()) { MenuItem driveMenuItem = new MenuItem { - Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrakeWPF;component/Views/Images/disc_small.png")), Width = 16, Height = 16 }, + Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/HandBrake;component/Views/Images/disc_small.png")), Width = 16, Height = 16 }, Header = new TextBlock { Text = string.Format("{0} ({1})", item.RootDirectory, item.VolumeLabel), Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center }, Tag = item }; @@ -816,6 +839,51 @@ namespace HandBrakeWPF.ViewModels this.StartScan(dialog.FileName, 0); } + /// + /// Folder Scan + /// + public void FolderScanTitleSpecific() + { + VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog { Description = "Please select a folder.", UseDescriptionForTitle = true }; + dialog.ShowDialog(); + + if (string.IsNullOrEmpty(dialog.SelectedPath)) + { + return; + } + + ITitleSpecificViewModel titleSpecificView = IoC.Get(); + this.WindowManager.ShowDialog(titleSpecificView); + + if (titleSpecificView.SelectedTitle.HasValue) + { + this.StartScan(dialog.SelectedPath, titleSpecificView.SelectedTitle.Value); + } + } + + /// + /// File Scan + /// + public void FileScanTitleSpecific() + { + VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "All files (*.*)|*.*" }; + dialog.ShowDialog(); + + if (string.IsNullOrEmpty(dialog.FileName)) + { + return; + } + + ITitleSpecificViewModel titleSpecificView = IoC.Get(); + this.WindowManager.ShowDialog(titleSpecificView); + + if (titleSpecificView.SelectedTitle.HasValue) + { + this.StartScan(dialog.FileName, titleSpecificView.SelectedTitle.Value); + } + } + + /// /// Cancel a Scan /// @@ -912,11 +980,6 @@ namespace HandBrakeWPF.ViewModels MessageBoxImage.Information); } - public void SourceContextMenuOpening(MenuItem item) - { - Console.WriteLine(item); - } - #endregion #region Main Window Public Methods @@ -1400,6 +1463,35 @@ namespace HandBrakeWPF.ViewModels { this.FolderScan(); } + + /// + /// Title Specific Scan for File + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void titleSpecificFile_Click(object sender, RoutedEventArgs e) + { + this.FileScanTitleSpecific(); + } + + /// + /// Title Specific Scan for folder + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void titleSpecificFolder_Click(object sender, RoutedEventArgs e) + { + this.FolderScanTitleSpecific(); + } + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/TitleSpecificViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/TitleSpecificViewModel.cs new file mode 100644 index 000000000..06055dff1 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/TitleSpecificViewModel.cs @@ -0,0 +1,85 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the TitleSpecificViewModel type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System.ComponentModel.Composition; + + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Title Specific View Model + /// + [Export(typeof(ITitleSpecificViewModel))] + public class TitleSpecificViewModel : ViewModelBase, ITitleSpecificViewModel + { + #region Constants and Fields + + /// + /// The selected title. + /// + private int? selectedTitle; + + #endregion + + #region Constructors and Destructors + + /// + /// Initializes a new instance of the class. + /// + public TitleSpecificViewModel() + { + this.SelectedTitle = 0; + } + + #endregion + + #region Properties + + /// + /// Gets or sets SelectedTitle. + /// + public int? SelectedTitle + { + get + { + return this.selectedTitle; + } + + set + { + this.selectedTitle = value; + this.NotifyOfPropertyChange(() => this.SelectedTitle); + } + } + + #endregion + + #region Public Methods + + /// + /// Cancel the request to scan. + /// + public void Cancel() + { + this.selectedTitle = null; + this.TryClose(); + } + + /// + /// Open the selected title. + /// + public void Open() + { + this.TryClose(); + } + + #endregion + } +} \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 79cc340eb..15e01502a 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -121,6 +121,7 @@ diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs index 057a35a5e..165e74923 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml.cs @@ -9,7 +9,6 @@ namespace HandBrakeWPF.Views { - using System; using System.Windows; /// diff --git a/win/CS/HandBrakeWPF/Views/TitleSpecificView.xaml b/win/CS/HandBrakeWPF/Views/TitleSpecificView.xaml new file mode 100644 index 000000000..4cb13468b --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/TitleSpecificView.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + +