using System.Linq;\r
using System.Text.RegularExpressions;\r
\r
- using Caliburn.Micro;\r
-\r
- using HandBrake.ApplicationServices.Services.Interfaces;\r
using HandBrake.Interop.Model;\r
\r
using Size = System.Drawing.Size;\r
/// </summary>\r
public class Title\r
{\r
- private readonly List<AudioTrack> audioTracks;\r
- private readonly List<Chapter> chapters;\r
- private readonly List<Subtitle> subtitles;\r
+ /// <summary>\r
+ /// The audio tracks.\r
+ /// </summary>\r
+ private readonly List<AudioTrack> audioTracks;\r
+\r
+ /// <summary>\r
+ /// The chapters.\r
+ /// </summary>\r
+ private readonly List<Chapter> chapters;\r
+\r
+ /// <summary>\r
+ /// The subtitles.\r
+ /// </summary>\r
+ private readonly List<Subtitle> subtitles;\r
\r
/// <summary>\r
/// Initializes a new instance of the Title class.\r
<Compile Include="Helpers\GrayscaleImage.cs" />\r
<Compile Include="Helpers\GrowlCommunicator.cs" />\r
<Compile Include="Model\OptionsTab.cs" />\r
+ <Compile Include="Model\SelectionTitle.cs" />\r
<Compile Include="Services\DriveDetectService.cs" />\r
<Compile Include="Services\EncodeServiceWrapper.cs" />\r
<Compile Include="Services\Interfaces\IDriveDetectService.cs" />\r
<Compile Include="Services\NotificationService.cs" />\r
<Compile Include="Services\ScanServiceWrapper.cs" />\r
<Compile Include="Services\UpdateService.cs" />\r
+ <Compile Include="ViewModels\Interfaces\IQueueSelectionViewModel.cs" />\r
+ <Compile Include="ViewModels\QueueSelectionViewModel.cs" />\r
+ <Compile Include="Views\QueueSelectionView.xaml.cs">\r
+ <DependentUpon>QueueSelectionView.xaml</DependentUpon>\r
+ </Compile>\r
<Compile Include="Views\ShellView.xaml.cs">\r
<DependentUpon>ShellView.xaml</DependentUpon>\r
</Compile>\r
<SubType>Designer</SubType>\r
<Generator>MSBuild:Compile</Generator>\r
</Page>\r
+ <Page Include="Views\QueueSelectionView.xaml">\r
+ <Generator>MSBuild:Compile</Generator>\r
+ <SubType>Designer</SubType>\r
+ </Page>\r
<Page Include="Views\ShellView.xaml">\r
<SubType>Designer</SubType>\r
<Generator>MSBuild:Compile</Generator>\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="SelectionTitle.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// TODO: Update summary.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Model\r
+{\r
+ using Caliburn.Micro;\r
+\r
+ using HandBrake.ApplicationServices.Parsing;\r
+\r
+ /// <summary>\r
+ /// A model for the multiple selection window for adding to the queue.\r
+ /// </summary>\r
+ public class SelectionTitle : PropertyChangedBase\r
+ {\r
+ /// <summary>\r
+ /// The source name.\r
+ /// </summary>\r
+ private readonly string sourceName;\r
+\r
+ /// <summary>\r
+ /// The is selected.\r
+ /// </summary>\r
+ private bool isSelected;\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="SelectionTitle"/> class.\r
+ /// </summary>\r
+ /// <param name="title">\r
+ /// The title.\r
+ /// </param>\r
+ /// <param name="sourceName">\r
+ /// The source Name.\r
+ /// </param>\r
+ public SelectionTitle(Title title, string sourceName)\r
+ {\r
+ this.sourceName = sourceName;\r
+ this.Title = title;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the source name.\r
+ /// </summary>\r
+ public string SourceName\r
+ {\r
+ get\r
+ {\r
+ return !string.IsNullOrEmpty(Title.SourceName) ? Title.SourceName : sourceName;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the end point.\r
+ /// </summary>\r
+ public int EndPoint { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether is selected.\r
+ /// </summary>\r
+ public bool IsSelected\r
+ {\r
+ get\r
+ {\r
+ return this.isSelected;\r
+ }\r
+ set\r
+ {\r
+ this.isSelected = value;\r
+ this.NotifyOfPropertyChange(() => this.IsSelected);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the start point.\r
+ /// </summary>\r
+ public int StartPoint { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the title.\r
+ /// </summary>\r
+ public Title Title { get; set; }\r
+ }\r
+}
\ No newline at end of file
this.windsorContainer.Register(Component.For<IOptionsViewModel>().ImplementedBy<OptionsViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
this.windsorContainer.Register(Component.For<IUpdateVersionService>().ImplementedBy<UpdateVersionService>().LifeStyle.Is(LifestyleType.Singleton));\r
this.windsorContainer.Register(Component.For<ITitleSpecificViewModel>().ImplementedBy<TitleSpecificViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
+ this.windsorContainer.Register(Component.For<IQueueSelectionViewModel>().ImplementedBy<QueueSelectionViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
+ \r
\r
// Tab Components\r
this.windsorContainer.Register(Component.For<IAudioViewModel>().ImplementedBy<AudioViewModel>().LifeStyle.Is(LifestyleType.Singleton));\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="IQueueSelectionViewModel.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The Queue Selection View Model Interface\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.ViewModels.Interfaces\r
+{\r
+ using System.Collections.Generic;\r
+ using System.ComponentModel;\r
+\r
+ using HandBrake.ApplicationServices.Parsing;\r
+\r
+ using HandBrakeWPF.Model;\r
+\r
+ /// <summary>\r
+ /// The Add Preset View Model\r
+ /// </summary>\r
+ public interface IQueueSelectionViewModel\r
+ {\r
+ /// <summary>\r
+ /// Gets the selected titles.\r
+ /// </summary>\r
+ BindingList<SelectionTitle> TitleList { get; }\r
+\r
+ /// <summary>\r
+ /// The setup.\r
+ /// </summary>\r
+ /// <param name="scannedSource">\r
+ /// The scanned source.\r
+ /// </param>\r
+ /// <param name="sourceName">\r
+ /// The source Name.\r
+ /// </param>\r
+ void Setup(Source scannedSource, string sourceName);\r
+ }\r
+}\r
}\r
}\r
\r
+ /// <summary>\r
+ /// The add selection to queue.\r
+ /// </summary>\r
+ public void AddSelectionToQueue()\r
+ {\r
+ if (this.ScannedSource == null || this.ScannedSource.Titles == null || this.ScannedSource.Titles.Count == 0)\r
+ {\r
+ this.errorService.ShowMessageBox("You must first scan a source and setup your job before adding to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);\r
+ return;\r
+ }\r
+\r
+ if (!AutoNameHelper.IsAutonamingEnabled())\r
+ {\r
+ this.errorService.ShowMessageBox("You must turn on automatic file naming in preferences before you can add to the queue.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);\r
+ return;\r
+ }\r
+\r
+ Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(QueueSelectionViewModel));\r
+ IQueueSelectionViewModel viewModel = IoC.Get<IQueueSelectionViewModel>();\r
+\r
+ viewModel.Setup(this.ScannedSource, this.SourceName);\r
+\r
+ if (window != null)\r
+ {\r
+ window.Activate();\r
+ }\r
+ else\r
+ {\r
+ this.WindowManager.ShowWindow(viewModel);\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Folder Scan\r
/// </summary>\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="QueueSelectionViewModel.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The Queue Selection View Model\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.ViewModels\r
+{\r
+ using System;\r
+ using System.Collections.Generic;\r
+ using System.ComponentModel;\r
+ using System.Linq;\r
+\r
+ using HandBrake.ApplicationServices.Parsing;\r
+\r
+ using HandBrakeWPF.Model;\r
+ using HandBrakeWPF.Services.Interfaces;\r
+ using HandBrakeWPF.ViewModels.Interfaces;\r
+\r
+ /// <summary>\r
+ /// The Queue Selection View Model\r
+ /// </summary>\r
+ public class QueueSelectionViewModel : ViewModelBase, IQueueSelectionViewModel\r
+ {\r
+ /// <summary>\r
+ /// The error service.\r
+ /// </summary>\r
+ private readonly IErrorService errorService;\r
+\r
+ /// <summary>\r
+ /// The ordered by duration.\r
+ /// </summary>\r
+ private bool orderedByDuration;\r
+\r
+ /// <summary>\r
+ /// The ordered by title.\r
+ /// </summary>\r
+ private bool orderedByTitle;\r
+\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="QueueSelectionViewModel"/> class. \r
+ /// </summary>\r
+ /// <param name="errorService">\r
+ /// The Error Service\r
+ /// </param>\r
+ public QueueSelectionViewModel(IErrorService errorService)\r
+ {\r
+ this.errorService = errorService;\r
+ this.Title = "Add to Queue";\r
+ this.TitleList = new BindingList<SelectionTitle>();\r
+ this.OrderedByTitle = true;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the source.\r
+ /// </summary>\r
+ public string Source { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets the selected titles.\r
+ /// </summary>\r
+ public BindingList<SelectionTitle> TitleList { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether ordered by title.\r
+ /// </summary>\r
+ public bool OrderedByTitle\r
+ {\r
+ get\r
+ {\r
+ return this.orderedByTitle;\r
+ }\r
+\r
+ set\r
+ {\r
+ this.orderedByTitle = value;\r
+ this.NotifyOfPropertyChange(() => OrderedByTitle);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets a value indicating whether ordered by duration.\r
+ /// </summary>\r
+ public bool OrderedByDuration\r
+ {\r
+ get\r
+ {\r
+ return this.orderedByDuration;\r
+ }\r
+\r
+ set\r
+ {\r
+ this.orderedByDuration = value;\r
+ this.NotifyOfPropertyChange(() => OrderedByDuration);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The order by title.\r
+ /// </summary>\r
+ public void OrderByTitle()\r
+ {\r
+ TitleList = new BindingList<SelectionTitle>(TitleList.OrderBy(o => o.Title.TitleNumber).ToList());\r
+ this.NotifyOfPropertyChange(() => TitleList);\r
+ this.OrderedByTitle = true;\r
+ this.OrderedByDuration = false;\r
+ }\r
+\r
+ /// <summary>\r
+ /// The order by duration.\r
+ /// </summary>\r
+ public void OrderByDuration()\r
+ {\r
+ TitleList = new BindingList<SelectionTitle>(TitleList.OrderByDescending(o => o.Title.Duration).ToList());\r
+ this.NotifyOfPropertyChange(() => TitleList);\r
+ this.OrderedByTitle = false;\r
+ this.OrderedByDuration = true;\r
+ }\r
+\r
+ /// <summary>\r
+ /// The select all.\r
+ /// </summary>\r
+ public void SelectAll()\r
+ {\r
+ foreach (var item in TitleList)\r
+ {\r
+ item.IsSelected = true;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The select all.\r
+ /// </summary>\r
+ public void UnSelectAll()\r
+ {\r
+ foreach (var item in TitleList)\r
+ {\r
+ item.IsSelected = false;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Add a Preset\r
+ /// </summary>\r
+ public void Add()\r
+ {\r
+ this.Close();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Cancel adding a preset\r
+ /// </summary>\r
+ public void Cancel()\r
+ {\r
+ this.TitleList.Clear();\r
+ this.Close();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Close this window.\r
+ /// </summary>\r
+ public void Close()\r
+ {\r
+ this.TryClose();\r
+ }\r
+\r
+ /// <summary>\r
+ /// The setup.\r
+ /// </summary>\r
+ /// <param name="scannedSource">\r
+ /// The scanned source.\r
+ /// </param>\r
+ /// <param name="srcName">\r
+ /// The src Name.\r
+ /// </param>\r
+ public void Setup(Source scannedSource, string srcName)\r
+ {\r
+ this.TitleList.Clear();\r
+\r
+ if (scannedSource != null)\r
+ {\r
+\r
+ IEnumerable<Title> titles = orderedByTitle\r
+ ? scannedSource.Titles\r
+ : scannedSource.Titles.OrderByDescending(o => o.Duration).ToList();\r
+\r
+ foreach (Title item in titles)\r
+ {\r
+ SelectionTitle title = new SelectionTitle(item, srcName);\r
+ TitleList.Add(title);\r
+ }\r
+ }\r
+ }\r
+ }\r
+}\r
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
// </copyright>\r
// <summary>\r
-// Interaction logic for VideoView.xaml\r
+// Interaction logic for AddPresetView.xaml\r
// </summary>\r
// --------------------------------------------------------------------------------------------------------------------\r
\r
using System.Windows;\r
\r
/// <summary>\r
- /// Interaction logic for VideoView.xaml\r
+ /// Interaction logic for AddPresetView.xaml\r
/// </summary>\r
public partial class AddPresetView : Window\r
{\r
</StackPanel>\r
</MenuItem.Header>\r
<MenuItem Header="Add All" Micro:Message.Attach="[Event Click] = [Action AddAllToQueue]" />\r
+ <!--<MenuItem Header="Add Selection" Micro:Message.Attach="[Event Click] = [Action AddSelectionToQueue]" />-->\r
</MenuItem>\r
</Menu>\r
\r
--- /dev/null
+<Window x:Class="HandBrakeWPF.Views.QueueSelectionView"\r
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"\r
+ xmlns:cal="http://www.caliburnproject.org"\r
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"\r
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"\r
+ Title="{Binding Title}"\r
+ Width="450"\r
+ MaxHeight="450"\r
+ SizeToContent="Height"\r
+ WindowStartupLocation="CenterScreen"\r
+ TextOptions.TextFormattingMode="Display"\r
+ mc:Ignorable="d">\r
+\r
+ <Window.Resources>\r
+\r
+ <Style x:Key="LongToolTipHolder" TargetType="FrameworkElement">\r
+ <Setter Property="ToolTipService.ShowDuration" Value="20000" />\r
+ <Setter Property="Margin" Value="0,2,0,2" />\r
+ </Style>\r
+ </Window.Resources>\r
+\r
+ <Grid HorizontalAlignment="Stretch"\r
+ VerticalAlignment="Stretch"\r
+ Background="#FFF1F0EF">\r
+ <Grid.RowDefinitions>\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="*" />\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ </Grid.RowDefinitions>\r
+\r
+ <!-- Header -->\r
+ <StackPanel Grid.Row="0"\r
+ Height="30"\r
+ Margin="0,0,0,10"\r
+ Background="White"\r
+ Orientation="Horizontal">\r
+ <Image Width="24"\r
+ Height="24"\r
+ Margin="10,0,5,0"\r
+ VerticalAlignment="Center"\r
+ Source="Images/AddToQueue_small.png" />\r
+ <StackPanel VerticalAlignment="Center" Orientation="Vertical">\r
+ <TextBlock FontWeight="Bold" Text="Queue Multiple Items" />\r
+ </StackPanel>\r
+ </StackPanel>\r
+\r
+ <!-- Text -->\r
+ <StackPanel Orientation="Vertical" Grid.Row="1" Margin="10,10,10,0">\r
+ <TextBlock Text="Select multiple titles to add: " />\r
+ </StackPanel>\r
+\r
+ <!-- Selection -->\r
+ <ListBox Grid.Row="2"\r
+ Margin="10,10,10,10"\r
+ VerticalAlignment="Stretch"\r
+ Background="LightGray"\r
+ ItemsSource="{Binding TitleList}"\r
+ SelectionMode="Single">\r
+ <ListBox.ItemContainerStyle>\r
+ <Style TargetType="ListBoxItem">\r
+ <Setter Property="HorizontalContentAlignment" Value="Stretch" />\r
+ <Setter Property="Background" Value="WhiteSmoke" />\r
+ <Setter Property="Margin" Value="0,0,0,1" />\r
+ </Style>\r
+ </ListBox.ItemContainerStyle>\r
+\r
+ <ListBox.ContextMenu>\r
+ <ContextMenu>\r
+ <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action SelectAll]" />\r
+ <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action UnSelectAll]" />\r
+ <Separator />\r
+ <MenuItem Header="Order by Title" IsChecked="{Binding OrderedByTitle}" cal:Message.Attach="[Event Click] = [Action OrderByTitle]" />\r
+ <MenuItem Header="Order by Duration" IsChecked="{Binding OrderedByDuration}" cal:Message.Attach="[Event Click] = [Action OrderByDuration]" />\r
+ </ContextMenu>\r
+ </ListBox.ContextMenu>\r
+\r
+ <ListBox.ItemTemplate>\r
+ <DataTemplate>\r
+ <Grid HorizontalAlignment="Stretch" MinHeight="28">\r
+ <Grid.RowDefinitions>\r
+ <RowDefinition Height="Auto" />\r
+ <RowDefinition Height="Auto" />\r
+ </Grid.RowDefinitions>\r
+ <Grid.ColumnDefinitions>\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="*" />\r
+ <ColumnDefinition Width="Auto" />\r
+ </Grid.ColumnDefinitions>\r
+ \r
+ <CheckBox IsChecked="{Binding IsSelected}" Grid.RowSpan="2" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />\r
+\r
+ <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" > \r
+ <TextBlock Text="Title:" Margin="0,0,5,0" FontWeight="Bold" />\r
+ <TextBlock Text="{Binding Title}" Margin="5,0,5,0" />\r
+ </StackPanel>\r
+\r
+ <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" >\r
+ <TextBlock Text="Source:" Margin="0,0,5,0" FontWeight="Bold" />\r
+ <TextBlock Text="{Binding SourceName}" Margin="5,0,5,0" />\r
+ </StackPanel>\r
+ </Grid>\r
+\r
+ </DataTemplate>\r
+ </ListBox.ItemTemplate>\r
+ </ListBox>\r
+\r
+ <!-- Checlist -->\r
+ <StackPanel Orientation="Vertical" Grid.Row="3" Margin="10,10,10,0">\r
+ <TextBlock Text="Checklist " />\r
+ </StackPanel>\r
+\r
+ <!-- Controls -->\r
+ <Grid Grid.Row="4"\r
+ Margin="0,20,0,0"\r
+ Background="LightGray">\r
+ <Grid.ColumnDefinitions>\r
+ <ColumnDefinition Width="*" />\r
+ <ColumnDefinition Width="Auto" />\r
+ <ColumnDefinition Width="Auto" />\r
+ </Grid.ColumnDefinitions>\r
+\r
+ <Button Grid.Column="1"\r
+ Margin="0,5,10,5"\r
+ cal:Message.Attach="[Event Click] = [Action Cancel]"\r
+ Content="Cancel"\r
+ IsCancel="True"\r
+ Padding="8,2" />\r
+ <Button Grid.Column="2"\r
+ Margin="0,5,10,5"\r
+ cal:Message.Attach="[Event Click] = [Action Add]"\r
+ Content="Add"\r
+ IsDefault="True"\r
+ Padding="8,2" />\r
+ </Grid>\r
+\r
+ </Grid>\r
+</Window>\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="QueueSelectionView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// Interaction logic for QueueSelectionView.xaml\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Views\r
+{\r
+ using System.Windows;\r
+\r
+ /// <summary>\r
+ /// Interaction logic for QueueSelectionView.xaml\r
+ /// </summary>\r
+ public partial class QueueSelectionView : Window\r
+ {\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="QueueSelectionView"/> class.\r
+ /// </summary>\r
+ public QueueSelectionView()\r
+ {\r
+ InitializeComponent();\r
+ }\r
+ }\r
+}\r