summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/App.xaml.cs26
-rw-r--r--win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs28
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs35
-rw-r--r--win/CS/HandBrakeWPF/Views/MainView.xaml56
-rw-r--r--win/CS/HandBrakeWPF/Views/OptionsView.xaml2
-rw-r--r--win/CS/HandBrakeWPF/Views/Styles/Styles.xaml2
6 files changed, 132 insertions, 17 deletions
diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs
index 13efba30b..ff32ba5c9 100644
--- a/win/CS/HandBrakeWPF/App.xaml.cs
+++ b/win/CS/HandBrakeWPF/App.xaml.cs
@@ -59,7 +59,19 @@ namespace HandBrakeWPF
private void Dispatcher_UnhandledException(
object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
- this.ShowError(e.Exception);
+ if (e.Exception.GetType() == typeof(GeneralApplicationException))
+ {
+ this.ShowError(e.Exception);
+ }
+ else if (e.Exception.InnerException.GetType() == typeof(GeneralApplicationException))
+ {
+ this.ShowError(e.Exception.InnerException);
+ }
+ else
+ {
+ this.ShowError(e.Exception);
+ }
+
e.Handled = true;
}
@@ -83,9 +95,19 @@ namespace HandBrakeWPF
GeneralApplicationException applicationException = exception as GeneralApplicationException;
if (applicationException != null)
{
+ string details = string.Format(
+ "{0}{1}{2}{3}{4}",
+ applicationException.Error,
+ Environment.NewLine,
+ applicationException.Solution,
+ Environment.NewLine,
+ applicationException.ActualException != null
+ ? applicationException.ActualException.ToString()
+ : "No additional exception information available.");
+
errorView.ErrorMessage = applicationException.Error;
errorView.Solution = applicationException.Solution;
- errorView.Details = applicationException.ActualException.ToString();
+ errorView.Details = details;
}
}
else
diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
index 3fb62e151..bf39d859a 100644
--- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
+++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs
@@ -52,7 +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));
-
+
// Remove Underscores
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore))
sourceName = sourceName.Replace("_", " ");
@@ -161,5 +161,31 @@ namespace HandBrakeWPF.Helpers
return autoNamePath;
}
+
+ /// <summary>
+ /// Check if there is a valid autoname path.
+ /// </summary>
+ /// <returns>
+ /// True if there is a valid path
+ /// </returns>
+ public static bool IsAutonamingEnabled()
+ {
+ IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
+ // If there is an auto name path, use it...
+ if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}"))
+ {
+ return true;
+ }
+ else if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}"))
+ {
+ return true;
+ }
+ else
+ {
+ return
+ Directory.Exists(
+ userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNamePath).Trim());
+ }
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 6c5576442..80b56edea 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -24,6 +24,7 @@ namespace HandBrakeWPF.ViewModels
using Caliburn.Micro;
using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
@@ -290,7 +291,7 @@ namespace HandBrakeWPF.ViewModels
// 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 titleSpecific = new MenuItem { Header = new TextBlock { Text = "Title Specific Scan", Margin = new Thickness(8, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center } };
MenuItem titleSpecificFolder = new MenuItem
{
@@ -599,7 +600,10 @@ namespace HandBrakeWPF.ViewModels
this.SelectedPointToPoint = PointToPointMode.Chapters;
this.SelectedAngle = 1;
- this.CurrentTask.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName);
+ if (this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNaming))
+ {
+ this.CurrentTask.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName);
+ }
this.NotifyOfPropertyChange(() => this.CurrentTask);
this.Duration = selectedTitle.Duration.ToString();
@@ -813,7 +817,7 @@ namespace HandBrakeWPF.ViewModels
QueueTask task = new QueueTask
{
- Task = this.CurrentTask,
+ Task = new EncodeTask(this.CurrentTask),
Query = QueryGeneratorUtility.GenerateQuery(this.CurrentTask)
};
this.queueProcessor.QueueManager.Add(task);
@@ -825,6 +829,30 @@ namespace HandBrakeWPF.ViewModels
}
/// <summary>
+ /// Add all Items to the queue
+ /// </summary>
+ public void AddAllToQueue()
+ {
+ 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;
+ }
+
+ foreach (Title title in this.ScannedSource.Titles)
+ {
+ this.SelectedTitle = title;
+ this.AddToQueue();
+ }
+ }
+
+ /// <summary>
/// Folder Scan
/// </summary>
public void FolderScan()
@@ -888,7 +916,6 @@ namespace HandBrakeWPF.ViewModels
}
}
-
/// <summary>
/// Cancel a Scan
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml
index 6d8e57b98..425ff041b 100644
--- a/win/CS/HandBrakeWPF/Views/MainView.xaml
+++ b/win/CS/HandBrakeWPF/Views/MainView.xaml
@@ -3,9 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Data="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
- xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" Title="{Data:Binding Path=WindowTitle}" Width="1015" FontSize="11" Background="#FFF0F0F0"
+ xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" Title="{Data:Binding Path=WindowTitle}" Width="1015"
+ FontSize="11" Background="#FFF0F0F0"
Micro:Message.Attach="[Event Loaded] = [Action Load]"
UseLayoutRounding="True" SizeToContent="Height"
+ SnapsToDevicePixels="True"
AllowDrop="True">
<i:Interaction.Triggers>
@@ -140,13 +142,49 @@
<Label Content="Stop" Margin="8,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</Button>
-
- <Button Name="AddToQueue" Micro:Message.Attach="[Event Click] = [Action AddToQueue]">
- <StackPanel Orientation="Horizontal">
- <Image Source="Images/AddToQueue.png" Height="32" Width="32" SnapsToDevicePixels="True" />
- <Label Content="Add To Queue" Margin="8,0,0,0" VerticalAlignment="Center" />
- </StackPanel>
- </Button>
+
+ <Menu Background="Transparent">
+ <MenuItem >
+ <MenuItem.Header>
+ <StackPanel Orientation="Horizontal">
+ <Button Name="QueueDrop" Micro:Message.Attach="[Event Click] = [Action AddToQueue]"
+ VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
+ HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
+ Background="Transparent">
+ <StackPanel Orientation="Horizontal">
+ <Image Source="Images/AddToQueue.png" Height="32" Width="32" SnapsToDevicePixels="True" />
+ <Label Content="Add To Queue" Margin="8,0,0,0" VerticalAlignment="Center" />
+ </StackPanel>
+ <Button.Style>
+ <Style TargetType="{x:Type Button}">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type Button}">
+ <Border x:Name="border" SnapsToDevicePixels="True" Background="{TemplateBinding Background}">
+ <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
+ Content="{TemplateBinding Content}"
+ ContentTemplate="{TemplateBinding ContentTemplate}"/>
+ </Border>
+ <ControlTemplate.Triggers>
+ <Trigger Property="IsPressed" Value="True">
+ <Setter Property="Background" TargetName="border" Value="#FF98B5E2"/>
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </Button.Style>
+ </Button>
+
+ <Path Fill="{DynamicResource GlyphBrush}" Data="M 0 0 L 4 4 L 8 0 Z" Height="5" Margin="2,2,2,0"/>
+ </StackPanel>
+ </MenuItem.Header>
+ <MenuItem Header="Add All" Micro:Message.Attach="[Event Click] = [Action AddAllToQueue]"/>
+ </MenuItem>
+ </Menu>
<Button Name="ShowQueue" Micro:Message.Attach="[Event Click] = [Action OpenQueueWindow]">
<StackPanel Orientation="Horizontal">
@@ -335,7 +373,7 @@
<Button Content="BETA WPF UI RELEASE NOTES" Micro:Message.Attach="[Event Click] = [Action ShowReleaseNotes]"
FontWeight="Bold" Foreground="Blue" Padding="0,0,0,5" FontSize="11"
/>
-
+
</StatusBar>
diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
index b4e14a088..e79fd91a7 100644
--- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml
+++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml
@@ -100,7 +100,7 @@
<CheckBox Content="Automatically name output files" IsChecked="{Binding AutomaticallyNameFiles}" />
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
- <TextBlock VerticalAlignment="Center" Text="Arguments: " />
+ <TextBlock VerticalAlignment="Center" Text="Default Path: " />
<TextBox Name="autoNameOutputPath" Text="{Binding AutoNameDefaultPath}" Width="180" />
<Button Content="Browse" Margin="5,0,0,0" cal:Message.Attach="[Event Click] = [Action BrowseAutoNamePath]" Width="55"/>
</StackPanel>
diff --git a/win/CS/HandBrakeWPF/Views/Styles/Styles.xaml b/win/CS/HandBrakeWPF/Views/Styles/Styles.xaml
index ada586ec4..1bdb2e727 100644
--- a/win/CS/HandBrakeWPF/Views/Styles/Styles.xaml
+++ b/win/CS/HandBrakeWPF/Views/Styles/Styles.xaml
@@ -15,4 +15,6 @@
</Setter>
</Style>
+ <SolidColorBrush x:Key="GlyphBrush" Color="#444"/>
+
</ResourceDictionary> \ No newline at end of file