diff options
author | sr55 <[email protected]> | 2013-08-21 16:07:48 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-08-21 16:07:48 +0000 |
commit | edc9bf98907f9f794443facc7ce9072ee27af08c (patch) | |
tree | c2e44b43d14e8f70b87e826afa535b537f65beaf /win/CS/HandBrakeWPF/ViewModels | |
parent | 58a7211154567065ce0a2845c573177334b6b8e2 (diff) |
WinGui: Initial work around around a when done countdown.
When a queue finishes it will now popup a window giving the user 60 seconds to cancel the when done operation.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5728 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
3 files changed, 182 insertions, 2 deletions
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;
|