summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-03-10 16:15:42 +0000
committersr55 <[email protected]>2012-03-10 16:15:42 +0000
commita3f2fa978a733e2461d68be2bf2ce39bdf540a0b (patch)
tree188762f474905ccdd9a48dd1880f3f5184454b61 /win/CS/HandBrakeWPF
parentae344e17e55b77c982640f3a7f9ad4156681a1c7 (diff)
WinGui: (WPF) Preview pane grouping added.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4503 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs3
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs49
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml38
3 files changed, 53 insertions, 37 deletions
diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
index 589c698e2..3fb62e151 100644
--- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
@@ -52,8 +52,7 @@ namespace HandBrakeWPF.Helpers
{
// Get the Source Name and remove any invalid characters
string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty));
- sourceName = Path.GetFileNameWithoutExtension(sourceName);
-
+
// Remove Underscores
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore))
sourceName = sourceName.Replace("_", " ");
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index a0d1ee15c..67472bd81 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -12,11 +12,13 @@ namespace HandBrakeWPF.ViewModels
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+ using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
+ using System.Windows.Data;
using Caliburn.Micro;
@@ -93,11 +95,6 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private bool isMkv;
- public string sourcePath;
- private string dvdDrivePath;
- private string dvdDriveLabel;
- private List<DriveInformation> drives;
-
/// <summary>
/// The Toolbar Status Label
/// </summary>
@@ -177,6 +174,9 @@ namespace HandBrakeWPF.ViewModels
this.queueProcessor.QueuePaused += this.QueuePaused;
this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
+
+ this.Presets = this.presetService.Presets;
+
}
#region View Model Properties
@@ -259,15 +259,9 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
- /// Gets a list of presets
+ /// Gets or sets Presets.
/// </summary>
- public ObservableCollection<Preset> Presets
- {
- get
- {
- return this.presetService.Presets;
- }
- }
+ public IEnumerable<Preset> Presets { get; set; }
/// <summary>
/// Gets or sets SelectedPreset.
@@ -348,34 +342,28 @@ namespace HandBrakeWPF.ViewModels
{
get
{
- // TODO Disc Label
- //if (this.selectedSourceType == SourceType.DvdDrive)
- //{
- // return this.dvdDriveLabel;
- //}
-
+ // The title that is selected has a source name. This means it's part of a batch scan.
if (selectedTitle != null && !string.IsNullOrEmpty(selectedTitle.SourceName))
{
return Path.GetFileName(selectedTitle.SourceName);
}
- // We have a drive, selected as a folder.
- if (this.sourcePath.EndsWith("\\"))
+ // Check if we have a Folder, if so, check if it's a DVD / Bluray drive and get the label.
+ if (ScannedSource.ScanPath.EndsWith("\\"))
{
- drives = GeneralUtilities.GetDrives();
- foreach (DriveInformation item in drives)
+ foreach (DriveInformation item in GeneralUtilities.GetDrives())
{
- if (item.RootDirectory.Contains(this.sourcePath))
+ if (item.RootDirectory.Contains(this.ScannedSource.ScanPath))
{
return item.VolumeLabel;
}
}
}
- if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")
- return Path.GetFileNameWithoutExtension(this.sourcePath);
+ if (Path.GetFileNameWithoutExtension(this.ScannedSource.ScanPath) != "VIDEO_TS")
+ return Path.GetFileNameWithoutExtension(this.ScannedSource.ScanPath);
- return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.sourcePath));
+ return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.ScannedSource.ScanPath));
}
}
@@ -869,7 +857,7 @@ namespace HandBrakeWPF.ViewModels
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
- if (fileNames != null && fileNames.Count() >= 1 && File.Exists(fileNames[0]))
+ if (fileNames != null && fileNames.Any() && File.Exists(fileNames[0]))
{
this.StartScan(fileNames[0], 0);
}
@@ -1045,7 +1033,6 @@ namespace HandBrakeWPF.ViewModels
{
// TODO
// 1. Disable GUI.
- this.sourcePath = filename;
this.scanService.Scan(filename, title, this.UserSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount));
}
@@ -1171,14 +1158,14 @@ namespace HandBrakeWPF.ViewModels
/// </param>
private void ScanCompleted(object sender, HandBrake.ApplicationServices.EventArgs.ScanCompletedEventArgs e)
{
- Caliburn.Micro.Execute.OnUIThread(() =>
+ Execute.OnUIThread(() =>
{
if (e.Successful)
{
this.scanService.SouceData.CopyTo(this.ScannedSource);
this.NotifyOfPropertyChange("ScannedSource");
this.NotifyOfPropertyChange("ScannedSource.Titles");
- this.SelectedTitle = this.ScannedSource.Titles.Where(t => t.MainTitle).FirstOrDefault()
+ this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(t => t.MainTitle)
?? this.ScannedSource.Titles.FirstOrDefault();
this.JobContextService.CurrentSource = this.ScannedSource;
this.JobContextService.CurrentTask = this.CurrentTask;
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml
index e39625785..9a44920af 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml
@@ -30,6 +30,34 @@
<Setter Property="Padding" Value="5,5" />
</Style>
+
+ <CollectionViewSource x:Key="presetsCvs" Source="{Binding Presets}">
+ <CollectionViewSource.GroupDescriptions>
+ <PropertyGroupDescription PropertyName="Category"/>
+ </CollectionViewSource.GroupDescriptions>
+ </CollectionViewSource>
+
+ <DataTemplate x:Key="presetsTemplate">
+ <StackPanel>
+ <TextBlock Text="{Binding Path=Name}"/>
+ </StackPanel>
+ </DataTemplate>
+
+ <HierarchicalDataTemplate x:Key="presetsCategoryTemplate" ItemsSource="{Binding Path=Items}"
+ ItemTemplate="{StaticResource presetsTemplate}">
+ <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"/>
+ </HierarchicalDataTemplate>
+
+ <Style TargetType="TreeViewItem">
+ <Setter Property="IsExpanded" Value="True" />
+ <Setter Property="Padding" Value="0,2,0,2" />
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding IsBuildIn}" Value="True">
+ <Setter Property="Foreground" Value="DarkBlue" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+
<Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
</Window.Resources>
@@ -160,18 +188,18 @@
<ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" ItemsSource="{Binding Angles}" SelectedItem="{Binding SelectedAngle}"/>
<ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" ItemsSource="{Binding RangeMode}" SelectedItem="{Binding SelectedPointToPoint}" />
-
+
<ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" ItemsSource="{Binding StartEndRangeItems}" SelectedItem="{Binding SelectedStartPoint}"
Visibility="{Binding ShowTextEntryForPointToPointMode,Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/>
<TextBox Name="StartPointText" Margin="8,0,0,0" MinWidth="60" Text="{Binding SelectedStartPoint}"
Visibility="{Binding ShowTextEntryForPointToPointMode, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}"/>
-
+
<Label Content="through" Margin="8,0,0,0" />
<ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" ItemsSource="{Binding StartEndRangeItems}" SelectedItem="{Binding SelectedEndPoint}"
Visibility="{Binding ShowTextEntryForPointToPointMode, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}"/>
<TextBox Name="EndPointText" Margin="8,0,0,0" MinWidth="60" Text="{Binding SelectedEndPoint}"
Visibility="{Binding ShowTextEntryForPointToPointMode, Converter={StaticResource boolToVisConverter}, ConverterParameter=false}" />
-
+
<Label Content="Duration" Margin="8,0,0,0" />
<Label Content="{Binding Duration}" Margin="8,0,0,0" />
</StackPanel>
@@ -234,8 +262,10 @@
<StackPanel Margin="5,5,5,5" Orientation="Vertical">
<GroupBox Header="Presets" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<StackPanel Orientation="Vertical">
- <TreeView ItemsSource="{Binding Presets}" Width="240" Height="460">
+ <TreeView ItemsSource="{Binding Source={StaticResource presetsCvs}, Path=Groups}"
+ ItemTemplate="{StaticResource presetsCategoryTemplate}" Width="240" Height="460"
+ >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<Micro:ActionMessage MethodName="SetSelectedPreset">