diff --git a/PomoTime/App.xaml.cs b/PomoTime/App.xaml.cs
index 1605087..9507fb2 100644
--- a/PomoTime/App.xaml.cs
+++ b/PomoTime/App.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.QueryStringDotNET;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -84,6 +85,8 @@ namespace PomoTime
}
if (e is ToastNotificationActivatedEventArgs)
{
+ var toastActivationArgs = e as ToastNotificationActivatedEventArgs;
+
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values["MinutesLeft"] != null)
{
@@ -94,6 +97,22 @@ namespace PomoTime
RunningState.CurrentPeriod = (Period)localSettings.Values["CurrentPeriod"];
}
+ QueryString args = QueryString.Parse(toastActivationArgs.Argument);
+ if (args.Contains("action"))
+ {
+ localSettings.Values["SuspendTime"] = (DateTime.Now + new TimeSpan(1, 0, 0)).Ticks;
+ switch (args["action"])
+ {
+ case "continue":
+ RunningState.IsRunning = true;
+ break;
+ case "5minutes":
+ RunningState.MinutesLeft += 5;
+ RunningState.IsRunning = true;
+ break;
+ }
+ }
+
rootFrame.Navigate(typeof(MainPage), RunningState);
Window.Current.Activate();
}
diff --git a/PomoTime/MainPage.xaml.cs b/PomoTime/MainPage.xaml.cs
index 60cd7b8..93c821d 100644
--- a/PomoTime/MainPage.xaml.cs
+++ b/PomoTime/MainPage.xaml.cs
@@ -109,7 +109,7 @@ namespace PomoTime
}
}
- void timer_Tick()
+ void TimerTick()
{
if (!MainViewRunningState.IsRunning)
{
@@ -167,25 +167,12 @@ namespace PomoTime
{
MainViewRunningState.SecondsLeft--;
}
+ SaveLocalState();
}
void SchedulePeriodOverNotification()
{
- string header;
- switch (MainViewRunningState.CurrentPeriod)
- {
- case Period.LongBreak:
- header = "Long break time over!";
- break;
- case Period.ShortBreak:
- header = "Short break time over!";
- break;
- case Period.Work:
- header = "Work time over!";
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
+ string header = $"{MainViewRunningState.CurrentPeriod.Name()} is over!";
ToastVisual visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
@@ -206,9 +193,27 @@ namespace PomoTime
}
};
+ ToastActionsCustom actions = new ToastActionsCustom()
+ {
+ Buttons =
+ {
+ new ToastButton("Continue", "action=continue")
+ {
+ ActivationType = ToastActivationType.Foreground
+ },
+
+ new ToastButton("Add 5 minutes", "action=5minutes")
+ {
+ ActivationType = ToastActivationType.Foreground
+ }
+ }
+ };
+
ToastContent toastContent = new ToastContent()
{
Visual = visual,
+ Actions = actions,
+ Scenario = ToastScenario.Alarm,
};
TimeSpan WaitTime = new TimeSpan(0, MainViewRunningState.MinutesLeft, MainViewRunningState.SecondsLeft);
@@ -231,6 +236,8 @@ namespace PomoTime
{
AppBarButton b = sender as AppBarButton;
MainViewRunningState.IsRunning = true;
+ MainViewRunningState.StartTime = DateTime.Now;
+ SaveLocalState();
if (MainViewRunningState.MinutesLeft != 0 || MainViewRunningState.SecondsLeft != 0)
{
@@ -291,21 +298,31 @@ namespace PomoTime
minutes["LongBreakMinutes"] = LongBreakMinutes;
roamingSettings.Values["Minutes"] = minutes;
+ SaveLocalState();
+
+ deferral.Complete();
+ }
+
+ private void SaveLocalState()
+ {
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
SuspendTime = DateTime.Now;
localSettings.Values["SuspendTime"] = SuspendTime.Ticks;
+ localSettings.Values["StartTime"] = MainViewRunningState.StartTime.Ticks;
localSettings.Values["MinutesLeft"] = MainViewRunningState.MinutesLeft;
localSettings.Values["SecondsLeft"] = MainViewRunningState.SecondsLeft;
localSettings.Values["IsRunning"] = MainViewRunningState.IsRunning;
localSettings.Values["PreviousShortBreaks"] = MainViewRunningState.PreviousShortBreaks;
localSettings.Values["CurrentPeriod"] = (int)MainViewRunningState.CurrentPeriod;
-
- deferral.Complete();
}
private void FastForwardTime(DateTime since)
{
TimeSpan TimeFromSuspend = DateTime.Now - since;
+ if(TimeFromSuspend.TotalMilliseconds < 0)
+ {
+ return;
+ }
if (!MainViewRunningState.IsRunning)
{
return;
@@ -349,7 +366,7 @@ namespace PomoTime
await Dispatcher.RunAsync(CoreDispatcherPriority.High,
() =>
{
- timer_Tick();
+ TimerTick();
});
}, TimeSpan.FromSeconds(1));
}
@@ -375,6 +392,7 @@ namespace PomoTime
else
{
Reset();
+ SaveLocalState();
}
}
diff --git a/PomoTime/Package.appxmanifest b/PomoTime/Package.appxmanifest
index aaf5653..b7cfb20 100644
--- a/PomoTime/Package.appxmanifest
+++ b/PomoTime/Package.appxmanifest
@@ -9,7 +9,7 @@
+ Version="1.0.6.0" />
diff --git a/PomoTime/PeriodToStringConverter.cs b/PomoTime/PeriodToStringConverter.cs
index 15753df..1f45e83 100644
--- a/PomoTime/PeriodToStringConverter.cs
+++ b/PomoTime/PeriodToStringConverter.cs
@@ -19,24 +19,7 @@ namespace PomoTime
{
// The value parameter is the data from the source object.
Period period = (Period)value;
- string output;
- switch (period)
- {
- case Period.LongBreak:
- output = "Long break";
- break;
- case Period.ShortBreak:
- output = "Short break";
- break;
- case Period.Work:
- output = "Work";
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
-
- // Return the month value to pass to the target.
- return output;
+ return period.Name();
}
// ConvertBack is not implemented for a OneWay binding.
diff --git a/PomoTime/PomoTime.csproj b/PomoTime/PomoTime.csproj
index 2876541..17034b6 100644
--- a/PomoTime/PomoTime.csproj
+++ b/PomoTime/PomoTime.csproj
@@ -222,6 +222,9 @@
2.3.200213001
+
+ 1.0.0
+
14.0
diff --git a/PomoTime/RunningState.cs b/PomoTime/RunningState.cs
index 3008363..0e6f95c 100644
--- a/PomoTime/RunningState.cs
+++ b/PomoTime/RunningState.cs
@@ -8,6 +8,29 @@ using System.Threading.Tasks;
namespace PomoTime
{
+ public static class PeriodExtensions
+ {
+ public static string Name(this Period period)
+ {
+ string output;
+ switch (period)
+ {
+ case Period.LongBreak:
+ output = "Long break";
+ break;
+ case Period.ShortBreak:
+ output = "Short break";
+ break;
+ case Period.Work:
+ output = "Work";
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+
+ return output;
+ }
+ }
public enum Period
{
Work, ShortBreak, LongBreak
@@ -69,6 +92,18 @@ namespace PomoTime
}
+ public DateTime _start_time;
+
+ public DateTime StartTime
+ {
+ get { return _start_time; }
+ set
+ {
+ _start_time = value;
+ NotifyPropertyChanged("StartTime");
+ }
+ }
+
public int _previous_short_breaks;
public int PreviousShortBreaks
@@ -80,6 +115,11 @@ namespace PomoTime
NotifyPropertyChanged("PreviousShortBreaks");
}
}
+
+ public string CurrentPeriodName()
+ {
+ return CurrentPeriod.Name();
+ }
}