From 98749c2316335055e1742b205cb627255ca3d71a Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 20 Jan 2013 14:21:58 +0000 Subject: [PATCH] WinGui: Just some prototype code for safe keeping. Not currently used. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5185 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Parsing/Title.cs | 3 - .../HandBrakeInterop/SourceData/Title.cs | 17 +- win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 10 + win/CS/HandBrakeWPF/Model/SelectionTitle.cs | 88 ++++++++ .../Startup/CastleBootstrapper.cs | 2 + .../Interfaces/IQueueSelectionViewModel.cs | 40 ++++ .../HandBrakeWPF/ViewModels/MainViewModel.cs | 32 +++ .../ViewModels/QueueSelectionViewModel.cs | 198 ++++++++++++++++++ .../HandBrakeWPF/Views/AddPresetView.xaml.cs | 4 +- win/CS/HandBrakeWPF/Views/MainView.xaml | 1 + .../Views/QueueSelectionView.xaml | 140 +++++++++++++ .../Views/QueueSelectionView.xaml.cs | 27 +++ 12 files changed, 554 insertions(+), 8 deletions(-) create mode 100644 win/CS/HandBrakeWPF/Model/SelectionTitle.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs create mode 100644 win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs create mode 100644 win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml create mode 100644 win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml.cs diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index 04d00c1f2..f834c4fa9 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -16,9 +16,6 @@ namespace HandBrake.ApplicationServices.Parsing using System.Linq; using System.Text.RegularExpressions; - using Caliburn.Micro; - - using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.Interop.Model; using Size = System.Drawing.Size; diff --git a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs index 344759c1d..fbe8e8532 100644 --- a/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs +++ b/win/CS/HandBrake.Interop/HandBrakeInterop/SourceData/Title.cs @@ -19,9 +19,20 @@ namespace HandBrake.Interop.SourceData /// public class Title { - private readonly List audioTracks; - private readonly List chapters; - private readonly List subtitles; + /// + /// The audio tracks. + /// + private readonly List audioTracks; + + /// + /// The chapters. + /// + private readonly List chapters; + + /// + /// The subtitles. + /// + private readonly List subtitles; /// /// Initializes a new instance of the Title class. diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index a7076bf6e..e0d2e7696 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -151,6 +151,7 @@ + @@ -163,6 +164,11 @@ + + + + QueueSelectionView.xaml + ShellView.xaml @@ -317,6 +323,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/win/CS/HandBrakeWPF/Model/SelectionTitle.cs b/win/CS/HandBrakeWPF/Model/SelectionTitle.cs new file mode 100644 index 000000000..63ad47793 --- /dev/null +++ b/win/CS/HandBrakeWPF/Model/SelectionTitle.cs @@ -0,0 +1,88 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// TODO: Update summary. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Model +{ + using Caliburn.Micro; + + using HandBrake.ApplicationServices.Parsing; + + /// + /// A model for the multiple selection window for adding to the queue. + /// + public class SelectionTitle : PropertyChangedBase + { + /// + /// The source name. + /// + private readonly string sourceName; + + /// + /// The is selected. + /// + private bool isSelected; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The title. + /// + /// + /// The source Name. + /// + public SelectionTitle(Title title, string sourceName) + { + this.sourceName = sourceName; + this.Title = title; + } + + /// + /// Gets the source name. + /// + public string SourceName + { + get + { + return !string.IsNullOrEmpty(Title.SourceName) ? Title.SourceName : sourceName; + } + } + + /// + /// Gets or sets the end point. + /// + public int EndPoint { get; set; } + + /// + /// Gets or sets a value indicating whether is selected. + /// + public bool IsSelected + { + get + { + return this.isSelected; + } + set + { + this.isSelected = value; + this.NotifyOfPropertyChange(() => this.IsSelected); + } + } + + /// + /// Gets or sets the start point. + /// + public int StartPoint { get; set; } + + /// + /// Gets or sets the title. + /// + public Title Title { get; set; } + } +} \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index 5b06c97ba..97930ba4d 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -78,6 +78,8 @@ 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/IQueueSelectionViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs new file mode 100644 index 000000000..36a64846a --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs @@ -0,0 +1,40 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Queue Selection View Model Interface +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels.Interfaces +{ + using System.Collections.Generic; + using System.ComponentModel; + + using HandBrake.ApplicationServices.Parsing; + + using HandBrakeWPF.Model; + + /// + /// The Add Preset View Model + /// + public interface IQueueSelectionViewModel + { + /// + /// Gets the selected titles. + /// + BindingList TitleList { get; } + + /// + /// The setup. + /// + /// + /// The scanned source. + /// + /// + /// The source Name. + /// + void Setup(Source scannedSource, string sourceName); + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 2db2c66c7..1d4d0e7ed 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1033,6 +1033,38 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// The add selection to queue. + /// + public void AddSelectionToQueue() + { + if (this.ScannedSource == null || this.ScannedSource.Titles == null || this.ScannedSource.Titles.Count == 0) + { + this.errorService.ShowMessageBox("You must first scan a source and setup your job before adding to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (!AutoNameHelper.IsAutonamingEnabled()) + { + this.errorService.ShowMessageBox("You must turn on automatic file naming in preferences before you can add to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + Window window = Application.Current.Windows.Cast().FirstOrDefault(x => x.GetType() == typeof(QueueSelectionViewModel)); + IQueueSelectionViewModel viewModel = IoC.Get(); + + viewModel.Setup(this.ScannedSource, this.SourceName); + + if (window != null) + { + window.Activate(); + } + else + { + this.WindowManager.ShowWindow(viewModel); + } + } + /// /// Folder Scan /// diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs new file mode 100644 index 000000000..c5b6072cc --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs @@ -0,0 +1,198 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// The Queue Selection View Model +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.ViewModels +{ + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Linq; + + using HandBrake.ApplicationServices.Parsing; + + using HandBrakeWPF.Model; + using HandBrakeWPF.Services.Interfaces; + using HandBrakeWPF.ViewModels.Interfaces; + + /// + /// The Queue Selection View Model + /// + public class QueueSelectionViewModel : ViewModelBase, IQueueSelectionViewModel + { + /// + /// The error service. + /// + private readonly IErrorService errorService; + + /// + /// The ordered by duration. + /// + private bool orderedByDuration; + + /// + /// The ordered by title. + /// + private bool orderedByTitle; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The Error Service + /// + public QueueSelectionViewModel(IErrorService errorService) + { + this.errorService = errorService; + this.Title = "Add to Queue"; + this.TitleList = new BindingList(); + this.OrderedByTitle = true; + } + + /// + /// Gets or sets the source. + /// + public string Source { get; set; } + + /// + /// Gets or sets the selected titles. + /// + public BindingList TitleList { get; set; } + + /// + /// Gets or sets a value indicating whether ordered by title. + /// + public bool OrderedByTitle + { + get + { + return this.orderedByTitle; + } + + set + { + this.orderedByTitle = value; + this.NotifyOfPropertyChange(() => OrderedByTitle); + } + } + + /// + /// Gets or sets a value indicating whether ordered by duration. + /// + public bool OrderedByDuration + { + get + { + return this.orderedByDuration; + } + + set + { + this.orderedByDuration = value; + this.NotifyOfPropertyChange(() => OrderedByDuration); + } + } + + /// + /// The order by title. + /// + public void OrderByTitle() + { + TitleList = new BindingList(TitleList.OrderBy(o => o.Title.TitleNumber).ToList()); + this.NotifyOfPropertyChange(() => TitleList); + this.OrderedByTitle = true; + this.OrderedByDuration = false; + } + + /// + /// The order by duration. + /// + public void OrderByDuration() + { + TitleList = new BindingList(TitleList.OrderByDescending(o => o.Title.Duration).ToList()); + this.NotifyOfPropertyChange(() => TitleList); + this.OrderedByTitle = false; + this.OrderedByDuration = true; + } + + /// + /// The select all. + /// + public void SelectAll() + { + foreach (var item in TitleList) + { + item.IsSelected = true; + } + } + + /// + /// The select all. + /// + public void UnSelectAll() + { + foreach (var item in TitleList) + { + item.IsSelected = false; + } + } + + /// + /// Add a Preset + /// + public void Add() + { + this.Close(); + } + + /// + /// Cancel adding a preset + /// + public void Cancel() + { + this.TitleList.Clear(); + this.Close(); + } + + /// + /// Close this window. + /// + public void Close() + { + this.TryClose(); + } + + /// + /// The setup. + /// + /// + /// The scanned source. + /// + /// + /// The src Name. + /// + public void Setup(Source scannedSource, string srcName) + { + this.TitleList.Clear(); + + if (scannedSource != null) + { + + IEnumerable titles = orderedByTitle + ? scannedSource.Titles + : scannedSource.Titles.OrderByDescending(o => o.Duration).ToList(); + + foreach (Title item in titles) + { + SelectionTitle title = new SelectionTitle(item, srcName); + TitleList.Add(title); + } + } + } + } +} diff --git a/win/CS/HandBrakeWPF/Views/AddPresetView.xaml.cs b/win/CS/HandBrakeWPF/Views/AddPresetView.xaml.cs index 91968fdc0..d3485d2c0 100644 --- a/win/CS/HandBrakeWPF/Views/AddPresetView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/AddPresetView.xaml.cs @@ -3,7 +3,7 @@ // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // </copyright> // <summary> -// Interaction logic for VideoView.xaml +// Interaction logic for AddPresetView.xaml // </summary> // -------------------------------------------------------------------------------------------------------------------- @@ -12,7 +12,7 @@ namespace HandBrakeWPF.Views using System.Windows; /// <summary> - /// Interaction logic for VideoView.xaml + /// Interaction logic for AddPresetView.xaml /// </summary> public partial class AddPresetView : Window { diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 76dbf7872..1131e5bdd 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -269,6 +269,7 @@ </StackPanel> </MenuItem.Header> <MenuItem Header="Add All" Micro:Message.Attach="[Event Click] = [Action AddAllToQueue]" /> + <!--<MenuItem Header="Add Selection" Micro:Message.Attach="[Event Click] = [Action AddSelectionToQueue]" />--> </MenuItem> </Menu> diff --git a/win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml b/win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml new file mode 100644 index 000000000..b46b07ff5 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml @@ -0,0 +1,140 @@ +<Window x:Class="HandBrakeWPF.Views.QueueSelectionView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:cal="http://www.caliburnproject.org" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + Title="{Binding Title}" + Width="450" + MaxHeight="450" + SizeToContent="Height" + WindowStartupLocation="CenterScreen" + TextOptions.TextFormattingMode="Display" + mc:Ignorable="d"> + + <Window.Resources> + + <Style x:Key="LongToolTipHolder" TargetType="FrameworkElement"> + <Setter Property="ToolTipService.ShowDuration" Value="20000" /> + <Setter Property="Margin" Value="0,2,0,2" /> + </Style> + </Window.Resources> + + <Grid HorizontalAlignment="Stretch" + VerticalAlignment="Stretch" + Background="#FFF1F0EF"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + + <!-- Header --> + <StackPanel Grid.Row="0" + Height="30" + Margin="0,0,0,10" + Background="White" + Orientation="Horizontal"> + <Image Width="24" + Height="24" + Margin="10,0,5,0" + VerticalAlignment="Center" + Source="Images/AddToQueue_small.png" /> + <StackPanel VerticalAlignment="Center" Orientation="Vertical"> + <TextBlock FontWeight="Bold" Text="Queue Multiple Items" /> + </StackPanel> + </StackPanel> + + <!-- Text --> + <StackPanel Orientation="Vertical" Grid.Row="1" Margin="10,10,10,0"> + <TextBlock Text="Select multiple titles to add: " /> + </StackPanel> + + <!-- Selection --> + <ListBox Grid.Row="2" + Margin="10,10,10,10" + VerticalAlignment="Stretch" + Background="LightGray" + ItemsSource="{Binding TitleList}" + SelectionMode="Single"> + <ListBox.ItemContainerStyle> + <Style TargetType="ListBoxItem"> + <Setter Property="HorizontalContentAlignment" Value="Stretch" /> + <Setter Property="Background" Value="WhiteSmoke" /> + <Setter Property="Margin" Value="0,0,0,1" /> + </Style> + </ListBox.ItemContainerStyle> + + <ListBox.ContextMenu> + <ContextMenu> + <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action SelectAll]" /> + <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action UnSelectAll]" /> + <Separator /> + <MenuItem Header="Order by Title" IsChecked="{Binding OrderedByTitle}" cal:Message.Attach="[Event Click] = [Action OrderByTitle]" /> + <MenuItem Header="Order by Duration" IsChecked="{Binding OrderedByDuration}" cal:Message.Attach="[Event Click] = [Action OrderByDuration]" /> + </ContextMenu> + </ListBox.ContextMenu> + + <ListBox.ItemTemplate> + <DataTemplate> + <Grid HorizontalAlignment="Stretch" MinHeight="28"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="Auto" /> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="Auto" /> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="Auto" /> + </Grid.ColumnDefinitions> + + <CheckBox IsChecked="{Binding IsSelected}" Grid.RowSpan="2" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" /> + + <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" > + <TextBlock Text="Title:" Margin="0,0,5,0" FontWeight="Bold" /> + <TextBlock Text="{Binding Title}" Margin="5,0,5,0" /> + </StackPanel> + + <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" > + <TextBlock Text="Source:" Margin="0,0,5,0" FontWeight="Bold" /> + <TextBlock Text="{Binding SourceName}" Margin="5,0,5,0" /> + </StackPanel> + </Grid> + + </DataTemplate> + </ListBox.ItemTemplate> + </ListBox> + + <!-- Checlist --> + <StackPanel Orientation="Vertical" Grid.Row="3" Margin="10,10,10,0"> + <TextBlock Text="Checklist " /> + </StackPanel> + + <!-- Controls --> + <Grid Grid.Row="4" + Margin="0,20,0,0" + Background="LightGray"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*" /> + <ColumnDefinition Width="Auto" /> + <ColumnDefinition Width="Auto" /> + </Grid.ColumnDefinitions> + + <Button Grid.Column="1" + Margin="0,5,10,5" + cal:Message.Attach="[Event Click] = [Action Cancel]" + Content="Cancel" + IsCancel="True" + Padding="8,2" /> + <Button Grid.Column="2" + Margin="0,5,10,5" + cal:Message.Attach="[Event Click] = [Action Add]" + Content="Add" + IsDefault="True" + Padding="8,2" /> + </Grid> + + </Grid> +</Window> diff --git a/win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml.cs b/win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml.cs new file mode 100644 index 000000000..553c7201f --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/QueueSelectionView.xaml.cs @@ -0,0 +1,27 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <copyright file="QueueSelectionView.xaml.cs" company="HandBrake Project (http://handbrake.fr)"> +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// </copyright> +// <summary> +// Interaction logic for QueueSelectionView.xaml +// </summary> +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Views +{ + using System.Windows; + + /// <summary> + /// Interaction logic for QueueSelectionView.xaml + /// </summary> + public partial class QueueSelectionView : Window + { + /// <summary> + /// Initializes a new instance of the <see cref="QueueSelectionView"/> class. + /// </summary> + public QueueSelectionView() + { + InitializeComponent(); + } + } +} -- 2.40.0