diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrake10.sln.DotSettings | 1 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 13 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/PrePostActionService.cs | 71 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs | 3 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/CountdownAlertViewModel.cs | 152 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/Interfaces/ICountdownAlertViewModel.cs | 30 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml | 39 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml.cs | 27 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/Images/Advanced.png | bin | 0 -> 1133 bytes |
11 files changed, 317 insertions, 25 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index 92558f6cc..d80a485ec 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -546,6 +546,8 @@ namespace HandBrake.ApplicationServices.Services /// </param>
private void InvokeQueuePaused(EventArgs e)
{
+ this.IsProcessing = false;
+
EventHandler handler = this.QueuePaused;
if (handler != null)
{
@@ -566,6 +568,8 @@ namespace HandBrake.ApplicationServices.Services {
handler(this, e);
}
+
+ this.IsProcessing = false;
}
/// <summary>
diff --git a/win/CS/HandBrake10.sln.DotSettings b/win/CS/HandBrake10.sln.DotSettings index d55f220ff..4d549497f 100644 --- a/win/CS/HandBrake10.sln.DotSettings +++ b/win/CS/HandBrake10.sln.DotSettings @@ -3,6 +3,7 @@ <s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/IntelliSenseCompletingCharactersSettingCSharp/UpgradedFromVSSettings/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowSummary/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeEditing/Localization/CSharpLocalizationOptions/DontAnalyseVerbatimStrings/@EntryValue">False</s:Boolean> + <s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=HandBrakeWPF_002EAnnotations/@EntryIndexedValue">True</s:Boolean> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=CompareOfFloatsByEqualityOperator/@EntryIndexedValue">HINT</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=InconsistentNaming/@EntryIndexedValue">HINT</s:String> <s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=LocalizableElement/@EntryIndexedValue">DO_NOT_SHOW</s:String> diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 1422d2d5a..331bbc331 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -133,6 +133,11 @@ <Compile Include="Commands\SourceMenuCommand.cs" />
<Compile Include="Commands\AdvancedEncoderOptionsCommand.cs" />
<Compile Include="Constants.cs" />
+ <Compile Include="ViewModels\CountdownAlertViewModel.cs" />
+ <Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />
+ <Compile Include="Views\CountdownAlertView.xaml.cs">
+ <DependentUpon>CountdownAlertView.xaml</DependentUpon>
+ </Compile>
<Compile Include="Controls\DropButton\DropButton.cs" />
<Compile Include="Controls\TimeSpanBox.xaml.cs">
<DependentUpon>TimeSpanBox.xaml</DependentUpon>
@@ -335,6 +340,10 @@ <AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
+ <Page Include="Views\CountdownAlertView.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="Controls\TimeSpanBox.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -500,7 +509,9 @@ <Name>HandBrake.Server</Name>
</ProjectReference>
</ItemGroup>
- <ItemGroup />
+ <ItemGroup>
+ <Resource Include="Views\Images\Advanced.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.*\StyleCop.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
diff --git a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs index 964e453ad..7cfceace3 100644 --- a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs +++ b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs @@ -19,6 +19,7 @@ namespace HandBrakeWPF.Services using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Services.Interfaces;
+ using HandBrakeWPF.ViewModels.Interfaces;
using Application = System.Windows.Application;
@@ -38,6 +39,11 @@ namespace HandBrakeWPF.Services private readonly IUserSettingService userSettingService;
/// <summary>
+ /// The window manager.
+ /// </summary>
+ private readonly IWindowManager windowManager;
+
+ /// <summary>
/// Initializes a new instance of the <see cref="PrePostActionService"/> class.
/// </summary>
/// <param name="queueProcessor">
@@ -46,10 +52,14 @@ namespace HandBrakeWPF.Services /// <param name="userSettingService">
/// The user Setting Service.
/// </param>
- public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService)
+ /// <param name="windowManager">
+ /// The window Manager.
+ /// </param>
+ public PrePostActionService(IQueueProcessor queueProcessor, IUserSettingService userSettingService, IWindowManager windowManager)
{
this.queueProcessor = queueProcessor;
this.userSettingService = userSettingService;
+ this.windowManager = windowManager;
this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
@@ -116,27 +126,46 @@ namespace HandBrakeWPF.Services return;
}
- // Do something whent he encode ends.
- switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))
+
+ if (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction) == "Do nothing")
{
- case "Shutdown":
- Process.Start("Shutdown", "-s -t 60");
- break;
- case "Log off":
- Win32.ExitWindowsEx(0, 0);
- break;
- case "Suspend":
- System.Windows.Forms.Application.SetSuspendState(PowerState.Suspend, true, true);
- break;
- case "Hibernate":
- System.Windows.Forms.Application.SetSuspendState(PowerState.Hibernate, true, true);
- break;
- case "Lock System":
- Win32.LockWorkStation();
- break;
- case "Quit HandBrake":
- Execute.OnUIThread(() => Application.Current.Shutdown());
- break;
+ return;
+ }
+
+ // Give the user the ability to cancel the shutdown. Default 60 second timer.
+ ICountdownAlertViewModel titleSpecificView = IoC.Get<ICountdownAlertViewModel>();
+ Caliburn.Micro.Execute.OnUIThread(
+ () =>
+ {
+ titleSpecificView.SetAction(this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction));
+ this.windowManager.ShowDialog(titleSpecificView);
+ });
+
+
+ if (!titleSpecificView.IsCancelled)
+ {
+ // Do something whent he encode ends.
+ switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))
+ {
+ case "Shutdown":
+ Process.Start("Shutdown", "-s -t 60");
+ break;
+ case "Log off":
+ Win32.ExitWindowsEx(0, 0);
+ break;
+ case "Suspend":
+ System.Windows.Forms.Application.SetSuspendState(PowerState.Suspend, true, true);
+ break;
+ case "Hibernate":
+ System.Windows.Forms.Application.SetSuspendState(PowerState.Hibernate, true, true);
+ break;
+ case "Lock System":
+ Win32.LockWorkStation();
+ break;
+ case "Quit HandBrake":
+ Execute.OnUIThread(() => Application.Current.Shutdown());
+ break;
+ }
}
}
diff --git a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs index 02dcd9437..aee06213c 100644 --- a/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs +++ b/win/CS/HandBrakeWPF/Startup/CastleBootstrapper.cs @@ -78,7 +78,8 @@ namespace HandBrakeWPF.Startup this.windsorContainer.Register(Component.For<IOptionsViewModel>().ImplementedBy<OptionsViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<ITitleSpecificViewModel>().ImplementedBy<TitleSpecificViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IQueueSelectionViewModel>().ImplementedBy<QueueSelectionViewModel>().LifeStyle.Is(LifestyleType.Singleton));
-
+ this.windsorContainer.Register(Component.For<ICountdownAlertViewModel>().ImplementedBy<CountdownAlertViewModel>().LifeStyle.Is(LifestyleType.Singleton));
+
// Tab Components
this.windsorContainer.Register(Component.For<IAudioViewModel>().ImplementedBy<AudioViewModel>().LifeStyle.Is(LifestyleType.Singleton));
this.windsorContainer.Register(Component.For<IX264ViewModel>().ImplementedBy<X264ViewModel>().LifeStyle.Is(LifestyleType.Singleton));
diff --git a/win/CS/HandBrakeWPF/ViewModels/CountdownAlertViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/CountdownAlertViewModel.cs new file mode 100644 index 000000000..ca8901c7c --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/CountdownAlertViewModel.cs @@ -0,0 +1,152 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="CountdownAlertViewModel.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>
+// The Countdown Alert View Model
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels
+{
+ using System;
+ using System.Windows.Forms.VisualStyles;
+ using System.Windows.Threading;
+
+ using HandBrakeWPF.ViewModels.Interfaces;
+
+ /// <summary>
+ /// The Countdown Alert View Model
+ /// </summary>
+ public class CountdownAlertViewModel : ViewModelBase, ICountdownAlertViewModel
+ {
+ #region Private Fields
+
+ /// <summary>
+ /// The countdown time.
+ /// </summary>
+ private const int CountdownTime = 60;
+
+ /// <summary>
+ /// The action.
+ /// </summary>
+ private string action;
+
+ /// <summary>
+ /// The timer.
+ /// </summary>
+ private DispatcherTimer timer;
+
+ #endregion
+
+ #region Constructors and Destructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CountdownAlertViewModel"/> class.
+ /// </summary>
+ public CountdownAlertViewModel()
+ {
+ this.IsCancelled = false;
+
+ Caliburn.Micro.Execute.OnUIThread(
+ () =>
+ {
+ timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
+ timer.Tick += this.timer_Tick;
+
+ timer.Start();
+ });
+ }
+
+ #endregion
+
+ #region Public Properties
+
+ /// <summary>
+ /// Gets or sets a value indicating whether is cancelled.
+ /// </summary>
+ public bool IsCancelled { get; set; }
+
+ /// <summary>
+ /// Gets the notice message.
+ /// </summary>
+ public string NoticeMessage
+ {
+ get
+ {
+ return string.Format("The following action '{0}' will occur in {1} seconds.", action, CountdownTime - this.Ticks);
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the ticks.
+ /// </summary>
+ public int Ticks { get; set; }
+
+ #endregion
+
+ #region Public Methods and Operators
+
+ /// <summary>
+ /// The cancel.
+ /// </summary>
+ public void Cancel()
+ {
+ this.IsCancelled = true;
+ timer.Stop();
+ this.Ticks = 0;
+ this.TryClose();
+ }
+
+ /// <summary>
+ /// The proceed.
+ /// </summary>
+ public void Proceed()
+ {
+ this.IsCancelled = false;
+ timer.Stop();
+ this.Ticks = 0;
+ this.TryClose();
+ }
+
+ /// <summary>
+ /// The set action.
+ /// </summary>
+ /// <param name="actionMsg">
+ /// The action.
+ /// </param>
+ public void SetAction(string actionMsg)
+ {
+ this.Ticks = 0;
+ timer.Start();
+ this.action = actionMsg;
+ }
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// The timer_ tick.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void timer_Tick(object sender, EventArgs e)
+ {
+ this.Ticks = this.Ticks + 1;
+ this.NotifyOfPropertyChange(() => this.NoticeMessage);
+ if (this.Ticks > CountdownTime)
+ {
+ timer.Stop();
+ this.Ticks = 0;
+ this.TryClose();
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ICountdownAlertViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ICountdownAlertViewModel.cs new file mode 100644 index 000000000..0dac356f3 --- /dev/null +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ICountdownAlertViewModel.cs @@ -0,0 +1,30 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ICountdownAlertViewModel.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>
+// The Countdown Alert View Model Interface
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.ViewModels.Interfaces
+{
+ /// <summary>
+ /// The Countdown Alert View Model Interface
+ /// </summary>
+ public interface ICountdownAlertViewModel
+ {
+ /// <summary>
+ /// Gets a value indicating whether is cancelled.
+ /// </summary>
+ bool IsCancelled { get; }
+
+ /// <summary>
+ /// The set action.
+ /// </summary>
+ /// <param name="action">
+ /// The action.
+ /// </param>
+ void SetAction(string action);
+ }
+}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 0aae4d4b8..d673e6983 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -817,7 +817,6 @@ namespace HandBrakeWPF.ViewModels return;
}
-
this.SelectedStartPoint = 1;
this.SelectedEndPoint = selectedTitle.Chapters != null && selectedTitle.Chapters.Count > 0 ? selectedTitle.Chapters.Last().ChapterNumber : 1;
}
@@ -828,7 +827,6 @@ namespace HandBrakeWPF.ViewModels return;
}
-
this.SelectedStartPoint = 0;
int timeInSeconds;
diff --git a/win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml b/win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml new file mode 100644 index 000000000..121f43595 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml @@ -0,0 +1,39 @@ +<Window x:Class="HandBrakeWPF.Views.CountdownAlertView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:cal="http://www.caliburnproject.org"
+ Title="When Done Action" MinHeight="130" MinWidth="400" WindowStartupLocation="CenterScreen" WindowStyle="None"
+ ShowActivated="True" ShowInTaskbar="True" SizeToContent="WidthAndHeight">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+ <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="../Views/Images/Advanced.png" />
+ <StackPanel VerticalAlignment="Center" Orientation="Vertical">
+ <TextBlock FontWeight="Bold" Text="When Done Action" />
+ </StackPanel>
+ </StackPanel>
+
+ <TextBlock Text="{Binding NoticeMessage}" Grid.Row="1" Margin="40,0,10,0"/>
+
+ <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,10,10,5" HorizontalAlignment="Right">
+ <Button Content="Proceed" HorizontalAlignment="Right"
+ cal:Message.Attach="[Event Click] = [Action Proceed]" Padding="8,2" Margin="0,10,10,5"/>
+
+ <Button Content="Cancel Action" HorizontalAlignment="Right" Margin="0,10,10,5"
+ cal:Message.Attach="[Event Click] = [Action Cancel]" Padding="8,2" IsDefault="True" />
+ </StackPanel>
+
+ </Grid>
+</Window>
diff --git a/win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml.cs b/win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml.cs new file mode 100644 index 000000000..b53ca2ba1 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/CountdownAlertView.xaml.cs @@ -0,0 +1,27 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="CountdownAlertView.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 CountdownAlertView.xaml
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Views
+{
+ using System.Windows;
+
+ /// <summary>
+ /// Interaction logic for CountdownAlertView.xaml
+ /// </summary>
+ public partial class CountdownAlertView : Window
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CountdownAlertView"/> class.
+ /// </summary>
+ public CountdownAlertView()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Views/Images/Advanced.png b/win/CS/HandBrakeWPF/Views/Images/Advanced.png Binary files differnew file mode 100644 index 000000000..25b648003 --- /dev/null +++ b/win/CS/HandBrakeWPF/Views/Images/Advanced.png |