diff options
author | sr55 <[email protected]> | 2012-06-26 20:46:19 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-06-26 20:46:19 +0000 |
commit | a47da7b31e9150888bcd8a495841be00f97b1114 (patch) | |
tree | fdb3ef05132ce0c34891641a2ce498d70ed9da4f /win | |
parent | be14d23c567b88a857df6f91f5c8a95c8c8e17fa (diff) |
WinGui: Another set of assorted fixes and UI tweaks.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4781 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/App.xaml | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs | 8 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 43 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs | 49 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/QueueView.xaml | 11 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/ShellView.xaml.cs | 19 |
6 files changed, 95 insertions, 38 deletions
diff --git a/win/CS/HandBrakeWPF/App.xaml b/win/CS/HandBrakeWPF/App.xaml index 5ac1f993e..24ea02909 100644 --- a/win/CS/HandBrakeWPF/App.xaml +++ b/win/CS/HandBrakeWPF/App.xaml @@ -1,6 +1,7 @@ <Application x:Class="HandBrakeWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HandBrakeWPF.Startup">
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HandBrakeWPF.Startup"
+ ShutdownMode="OnMainWindowClose">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs index 4964e8b40..6c537ef66 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs @@ -23,5 +23,13 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// The window.
/// </param>
void DisplayWindow(ShellWindow window);
+
+ /// <summary>
+ /// Checks with the use if this window can be closed.
+ /// </summary>
+ /// <returns>
+ /// Returns true if the window can be closed.
+ /// </returns>
+ bool CanClose();
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index fe1e333eb..54c0d8e1e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -192,7 +192,6 @@ namespace HandBrakeWPF.ViewModels this.scanService.ScanStatusChanged += this.ScanStatusChanged;
this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
this.queueProcessor.QueueCompleted += this.QueueCompleted;
- this.queueProcessor.QueuePaused += this.QueuePaused;
this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
this.Presets = this.presetService.Presets;
@@ -834,7 +833,6 @@ namespace HandBrakeWPF.ViewModels this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
this.queueProcessor.QueueCompleted -= this.QueueCompleted;
- this.queueProcessor.QueuePaused -= this.QueuePaused;
this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;
this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;
}
@@ -935,7 +933,15 @@ namespace HandBrakeWPF.ViewModels }
QueueTask task = new QueueTask { Task = new EncodeTask(this.CurrentTask) };
- this.queueProcessor.QueueManager.Add(task);
+ if (!this.queueProcessor.QueueManager.CheckForDestinationPathDuplicates(task.Task.Destination))
+ {
+ this.queueProcessor.QueueManager.Add(task);
+ }
+ else
+ {
+ this.errorService.ShowMessageBox("There are jobs on the queue with the same destination path. Please choose a different path for this job.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+
if (!this.IsEncoding)
{
@@ -1044,6 +1050,12 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void StartEncode()
{
+ if (this.queueProcessor.IsProcessing)
+ {
+ this.errorService.ShowMessageBox("HandBrake is already encoding.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
// Check if we already have jobs, and if we do, just start the queue.
if (this.queueProcessor.QueueManager.Count != 0)
{
@@ -1064,11 +1076,6 @@ namespace HandBrakeWPF.ViewModels return;
}
- if (this.queueProcessor.IsProcessing)
- {
- this.errorService.ShowMessageBox("HandBrake is already encoding.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
if (File.Exists(this.Destination))
{
@@ -1103,6 +1110,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void StopEncode()
{
+ this.queueProcessor.Pause();
this.encodeService.Stop();
}
@@ -1534,23 +1542,6 @@ namespace HandBrakeWPF.ViewModels this.ProgramStatusLabel = "Preparing to encode ...";
this.IsEncoding = true;
});
-
- // TODO Handle Updating the UI
- }
-
- /// <summary>
- /// The Queue has been paused handler
- /// </summary>
- /// <param name="sender">
- /// The Sender
- /// </param>
- /// <param name="e">
- /// The EventArgs
- /// </param>
- private void QueuePaused(object sender, EventArgs e)
- {
- this.IsEncoding = false;
- // TODO Handle Updating the UI
}
/// <summary>
@@ -1572,8 +1563,6 @@ namespace HandBrakeWPF.ViewModels this.ProgramStatusLabel = "Queue Finished";
this.IsEncoding = false;
});
-
- // TODO Handle Updating the UI
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs index 349dc1200..ef3f1a53a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs @@ -10,8 +10,14 @@ namespace HandBrakeWPF.ViewModels
{
using System.ComponentModel.Composition;
+ using System.Windows;
+
+ using Caliburn.Micro;
+
+ using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrakeWPF.Model;
+ using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
@@ -20,6 +26,11 @@ namespace HandBrakeWPF.ViewModels [Export(typeof(IShellViewModel))]
public class ShellViewModel : ViewModelBase, IShellViewModel
{
+ /// <summary>
+ /// Backing field for the error service.
+ /// </summary>
+ private readonly IErrorService errorService;
+
#region Constants and Fields
/// <summary>
@@ -37,8 +48,12 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Initializes a new instance of the <see cref="ShellViewModel"/> class.
/// </summary>
- public ShellViewModel()
+ /// <param name="errorService">
+ /// The error Service.
+ /// </param>
+ public ShellViewModel(IErrorService errorService)
{
+ this.errorService = errorService;
this.showMainWindow = true;
this.showOptions = false;
}
@@ -60,7 +75,7 @@ namespace HandBrakeWPF.ViewModels {
this.ShowOptions = true;
this.ShowMainWindow = false;
- }
+ }
else
{
this.ShowMainWindow = true;
@@ -124,5 +139,35 @@ namespace HandBrakeWPF.ViewModels }
#endregion
+
+ /// <summary>
+ /// Checks with the use if this window can be closed.
+ /// </summary>
+ /// <returns>
+ /// Returns true if the window can be closed.
+ /// </returns>
+ public bool CanClose()
+ {
+ IQueueProcessor processor = IoC.Get<IQueueProcessor>();
+ if (processor.EncodeService.IsEncoding)
+ {
+ MessageBoxResult result =
+ errorService.ShowMessageBox(
+ "An Encode is currently running. Exiting HandBrake will stop this encode.\nAre you sure you wish to continue?",
+ "Warning",
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Warning);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ processor.Pause();
+ processor.EncodeService.Stop();
+ return true;
+ }
+ return false;
+ }
+
+ return true;
+ }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml index e505800fc..7ef652b29 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml @@ -146,11 +146,11 @@ <ListBox.ContextMenu>
<ContextMenu>
- <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />
- <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />
- <Separator />
<MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="Clear" />
<MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="Clear Completed" />
+ <Separator />
+ <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />
+ <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />
</ContextMenu>
</ListBox.ContextMenu>
@@ -245,11 +245,6 @@ <TextBlock FontWeight="Bold" Text="Destination: " />
<TextBlock Text="{Binding Task.Destination, Converter={StaticResource filePathToFilenameConverter}}" />
</StackPanel>
-
- <StackPanel Orientation="Horizontal">
- <TextBlock FontWeight="Bold" Text="Status: " />
- <TextBlock Text="{Binding Status, Converter={StaticResource enumComboConverter}}" />
- </StackPanel>
</StackPanel>
<!-- Delete -->
diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs index cc6b381de..6b291702d 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs @@ -11,6 +11,8 @@ namespace HandBrakeWPF.Views {
using System.Windows;
+ using HandBrakeWPF.ViewModels.Interfaces;
+
/// <summary>
/// Interaction logic for ShellView.xaml
/// </summary>
@@ -23,5 +25,22 @@ namespace HandBrakeWPF.Views {
this.InitializeComponent();
}
+
+ /// <summary>
+ /// Check with the user before closing.
+ /// </summary>
+ /// <param name="e">
+ /// The CancelEventArgs.
+ /// </param>
+ protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
+ {
+ bool canClose = ((IShellViewModel)this.DataContext).CanClose();
+ if (!canClose)
+ {
+ e.Cancel = true;
+ }
+
+ base.OnClosing(e);
+ }
}
}
|