From 8fbe235bdcf69877a7c2fc3315435accf07b5a10 Mon Sep 17 00:00:00 2001 From: BarRaider <46548278+BarRaider@users.noreply.github.com> Date: Thu, 31 Mar 2022 16:11:00 +0300 Subject: [PATCH] v1.8 - Countdown Date/Time, Format, Prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - :new: `Date/Time Countdown` action - Let's you countdown to a specific date or time. 🔥 - Added a new `Format` setting which allows you to customize the timer displayed on key (and file). 🔥 - Added support for timer Prefix on keys - Both File Prefix and Key Prefix support newlines \n - Now customizable if timer starts counting up or not when timer ends - Minor bug fixes --- README.md | 55 +++++++++++-------- .../Actions/DateTimeCountdownAction.cs | 15 ++++- .../Actions/FocusTimerAction.cs | 2 +- .../Actions/StreamTimerAction.cs | 15 ++++- streamdeck-streamtimer/App.config | 8 +++ .../Backend/TimerManager.cs | 4 +- streamdeck-streamtimer/CountdownTimer.csproj | 18 +++--- .../PropertyInspector/DateTimeCountdown.html | 11 ++++ .../PropertyInspector/Focus.html | 4 ++ .../PropertyInspector/StreamTimer.html | 11 ++++ streamdeck-streamtimer/manifest.json | 2 +- streamdeck-streamtimer/packages.config | 10 ++-- 12 files changed, 110 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index b1c506c..a4be275 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,38 @@ Set a timer on your Stream Deck, and have it shown on your Stream too. Will star **Author's website and contact information:** [https://barraider.com](https://barraider.com) +## New in v1.8 +- :new: `Date/Time Countdown` action - Let's you countdown to a specific date or time. 🔥 +- Added a new `Format` setting which allows you to customize the timer displayed on key (and file). 🔥 +- Added support for timer Prefix on keys +- Both File Prefix and Key Prefix support newlines \n +- Now customizable if timer starts counting up or not when timer ends +- Minor bug fixes + +## Features +- Countdown is written to file so you can display the remaining time on your stream +- Supports adding a title prefix in the file (such as `Time left: `) +- Timer starts flashing when time is up, you can choose the color of the alert +- Hourglass mode creates a visual representation instead of a numeric timer +- Countdown continues writing to the file even if you move to a different Stream Deck profile + +### Download + +* [Download plugin](https://github.com/BarRaider/streamdeck-streamtimer/releases/) + +## I found a bug, who do I contact? +For support please contact the developer. Contact information is available at https://barraider.com + +## I have a feature request, who do I contact? +Please contact the developer. Contact information is available at https://barraider.com + +## Dependencies +* Uses StreamDeck-Tools by BarRaider: [![NuGet](https://img.shields.io/nuget/v/streamdeck-tools.svg?style=flat)](https://www.nuget.org/packages/streamdeck-tools) +* Uses [Easy-PI](https://github.com/BarRaider/streamdeck-easypi) by BarRaider - Provides seamless integration with the Stream Deck PI (Property Inspector) + +## Change Log + + ## New in v1.6 - :new: `Focus Timer` action alternates between work and break intervals to improve your focus and get work done. - `Auto Reset` feature allows you to reset the timer automatically after a customizable number of seconds @@ -28,25 +60,4 @@ Set a timer on your Stream Deck, and have it shown on your Stream too. Will star - :new2: `Streamathon Mode` - Increase the time left by a customizable interval on every key press. (Long click to reset). - Hourglass Mode now shows an indication on whether the timer is running or paused on every keypress - Customizable text to show on stream when the timer ends -- Option to clear the text file (and thus remove from stream) when the timer ends - -## Features -- Countdown is written to file so you can display the remaining time on your stream -- Supports adding a title prefix in the file (such as `Time left: `) -- Timer starts flashing when time is up, you can choose the color of the alert -- Hourglass mode creates a visual representation instead of a numeric timer -- Countdown continues writing to the file even if you move to a different Stream Deck profile - -### Download - -* [Download plugin](https://github.com/BarRaider/streamdeck-streamtimer/releases/) - -## I found a bug, who do I contact? -For support please contact the developer. Contact information is available at https://barraider.com - -## I have a feature request, who do I contact? -Please contact the developer. Contact information is available at https://barraider.com - -## Dependencies -* Uses StreamDeck-Tools by BarRaider: [![NuGet](https://img.shields.io/nuget/v/streamdeck-tools.svg?style=flat)](https://www.nuget.org/packages/streamdeck-tools) -* Uses [Easy-PI](https://github.com/BarRaider/streamdeck-easypi) by BarRaider - Provides seamless integration with the Stream Deck PI (Property Inspector) +- Option to clear the text file (and thus remove from stream) when the timer ends \ No newline at end of file diff --git a/streamdeck-streamtimer/Actions/DateTimeCountdownAction.cs b/streamdeck-streamtimer/Actions/DateTimeCountdownAction.cs index 68028ee..4ce1f0e 100644 --- a/streamdeck-streamtimer/Actions/DateTimeCountdownAction.cs +++ b/streamdeck-streamtimer/Actions/DateTimeCountdownAction.cs @@ -51,7 +51,8 @@ public static PluginSettings CreateDefaultSettings() CountdownTime = DEFAULT_COUNTDOWN_TIME_INTERVAL, CountdownDateTime = DEFAULT_COUNTDOWN_DATETIME_INTERVAL, TimeFormat = HelperUtils.DEFAULT_TIME_FORMAT, - KeyPrefix = String.Empty + KeyPrefix = String.Empty, + CountUpOnEnd = false }; return instance; @@ -115,6 +116,9 @@ public static PluginSettings CreateDefaultSettings() [JsonProperty(PropertyName = "keyPrefix")] public string KeyPrefix { get; set; } + + [JsonProperty(PropertyName = "countUpOnEnd")] + public bool CountUpOnEnd { get; set; } } #region Private members @@ -285,13 +289,18 @@ private async void HandleTimeDisplay() private async Task ShowElapsedTimeOnKey() { + if (!settings.CountUpOnEnd) + { + await Connection.SetTitleAsync(null); + return; + } string output = HelperUtils.FormatTime((long)(DateTime.Now - endDateTime).TotalSeconds, "h:mm:ss", settings.Multiline); await Connection.SetTitleAsync(output); string fileOutput = "00:00"; if (!String.IsNullOrEmpty(settings.CountdownEndText)) { - fileOutput = settings.CountdownEndText; + fileOutput = settings.CountdownEndText.Replace(@"\n", "\n"); } HelperUtils.WriteToFile(settings.TimerFileName, fileOutput); } @@ -304,7 +313,7 @@ private async Task ShowTimeOnKey() await SaveSettings(); } await Connection.SetTitleAsync($"{settings.KeyPrefix?.Replace(@"\n", "\n")}{output}"); - HelperUtils.WriteToFile(settings.TimerFileName, $"{settings.FilePrefix}{output.Replace("\n",":")}"); + HelperUtils.WriteToFile(settings.TimerFileName, $"{settings.FilePrefix.Replace(@"\n", "\n")}{output.Replace("\n", ":")}"); } private void SetRemainingInterval() diff --git a/streamdeck-streamtimer/Actions/FocusTimerAction.cs b/streamdeck-streamtimer/Actions/FocusTimerAction.cs index c72e2cf..458d4a8 100644 --- a/streamdeck-streamtimer/Actions/FocusTimerAction.cs +++ b/streamdeck-streamtimer/Actions/FocusTimerAction.cs @@ -45,7 +45,7 @@ public static PluginSettings CreateDefaultSettings() PlaySoundOnEndFile = String.Empty, HourglassTime = true, WorkImageFile = null, - BreakImageFile = null + BreakImageFile = null, }; return instance; diff --git a/streamdeck-streamtimer/Actions/StreamTimerAction.cs b/streamdeck-streamtimer/Actions/StreamTimerAction.cs index 5a896ce..1fba46b 100644 --- a/streamdeck-streamtimer/Actions/StreamTimerAction.cs +++ b/streamdeck-streamtimer/Actions/StreamTimerAction.cs @@ -53,7 +53,8 @@ public static PluginSettings CreateDefaultSettings() HourglassImageMode = false, AutoResetSeconds = DEFAULT_AUTO_RESET_SECONDS.ToString(), TimeFormat = HelperUtils.DEFAULT_TIME_FORMAT, - KeyPrefix = String.Empty + KeyPrefix = String.Empty, + CountUpOnEnd = false }; return instance; @@ -127,6 +128,9 @@ public static PluginSettings CreateDefaultSettings() [JsonProperty(PropertyName = "keyPrefix")] public string KeyPrefix { get; set; } + + [JsonProperty(PropertyName = "countUpOnEnd")] + public bool CountUpOnEnd { get; set; } } #region Private members @@ -284,7 +288,14 @@ public async override void OnTick() if (endTime > DateTime.MinValue) { long secondsElapsed = (long)(DateTime.Now - endTime).TotalSeconds; - await ShowElapsedTimeOnKey(secondsElapsed); + if (settings.CountUpOnEnd) + { + await ShowElapsedTimeOnKey(secondsElapsed); + } + else + { + await Connection.SetTitleAsync(null); + } if (autoResetSeconds > 0 && secondsElapsed > autoResetSeconds) { diff --git a/streamdeck-streamtimer/App.config b/streamdeck-streamtimer/App.config index dcc85ee..ef6dbf5 100644 --- a/streamdeck-streamtimer/App.config +++ b/streamdeck-streamtimer/App.config @@ -9,6 +9,14 @@ + + + + + + + + diff --git a/streamdeck-streamtimer/Backend/TimerManager.cs b/streamdeck-streamtimer/Backend/TimerManager.cs index eac2c3e..061eee9 100644 --- a/streamdeck-streamtimer/Backend/TimerManager.cs +++ b/streamdeck-streamtimer/Backend/TimerManager.cs @@ -218,7 +218,7 @@ private void WriteCounterToFile(string timerKey) total = SecondsLeft(timerKey); if (total <= 0 && !String.IsNullOrEmpty(counterData.FileCountdownEndText)) { - HelperUtils.WriteToFile(counterData.Filename, counterData.FileCountdownEndText); + HelperUtils.WriteToFile(counterData.Filename, counterData.FileCountdownEndText.Replace(@"\n", "\n")); return; } else if (total <= 0 && counterData.ClearFileOnReset) @@ -232,7 +232,7 @@ private void WriteCounterToFile(string timerKey) } string output = HelperUtils.FormatTime(total, counterData.TimeFormat, false); - HelperUtils.WriteToFile(counterData.Filename, $"{counterData.FileTitlePrefix}{output}"); + HelperUtils.WriteToFile(counterData.Filename, $"{counterData.FileTitlePrefix?.Replace(@"\n", "\n")}{output}"); } private long SecondsLeft(string counterKey) diff --git a/streamdeck-streamtimer/CountdownTimer.csproj b/streamdeck-streamtimer/CountdownTimer.csproj index be0f639..0e69acc 100644 --- a/streamdeck-streamtimer/CountdownTimer.csproj +++ b/streamdeck-streamtimer/CountdownTimer.csproj @@ -39,14 +39,14 @@ ..\..\..\DotNet\StreamDeck\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll - - ..\..\..\DotNet\StreamDeck\packages\Microsoft.Win32.Registry.4.7.0\lib\net461\Microsoft.Win32.Registry.dll + + ..\..\..\DotNet\StreamDeck\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll ..\..\..\DotNet\StreamDeck\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - ..\..\..\DotNet\StreamDeck\packages\NLog.4.7.6\lib\net45\NLog.dll + ..\..\..\DotNet\StreamDeck\packages\NLog.4.7.15\lib\net45\NLog.dll ..\..\PickersUtil\PickersUtil\bin\Release\PickersUtil.dll @@ -61,16 +61,16 @@ - - ..\..\..\DotNet\StreamDeck\packages\System.Drawing.Common.5.0.0\lib\net461\System.Drawing.Common.dll + + ..\..\..\DotNet\StreamDeck\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll - - ..\..\..\DotNet\StreamDeck\packages\System.Security.AccessControl.4.7.0\lib\net461\System.Security.AccessControl.dll + + ..\..\..\DotNet\StreamDeck\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll - - ..\..\..\DotNet\StreamDeck\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll + + ..\..\..\DotNet\StreamDeck\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll diff --git a/streamdeck-streamtimer/PropertyInspector/DateTimeCountdown.html b/streamdeck-streamtimer/PropertyInspector/DateTimeCountdown.html index fcb30ed..68195fe 100644 --- a/streamdeck-streamtimer/PropertyInspector/DateTimeCountdown.html +++ b/streamdeck-streamtimer/PropertyInspector/DateTimeCountdown.html @@ -95,6 +95,17 @@ +
+
Count Up
+
+ + +
+
+
+
+ Display Modes: +
Hourglass mode
diff --git a/streamdeck-streamtimer/PropertyInspector/Focus.html b/streamdeck-streamtimer/PropertyInspector/Focus.html index 2c813ad..d2d817b 100644 --- a/streamdeck-streamtimer/PropertyInspector/Focus.html +++ b/streamdeck-streamtimer/PropertyInspector/Focus.html @@ -105,6 +105,10 @@
+
+
+ Display Modes: +
Show Time
diff --git a/streamdeck-streamtimer/PropertyInspector/StreamTimer.html b/streamdeck-streamtimer/PropertyInspector/StreamTimer.html index aeebcd5..62cfa75 100644 --- a/streamdeck-streamtimer/PropertyInspector/StreamTimer.html +++ b/streamdeck-streamtimer/PropertyInspector/StreamTimer.html @@ -93,6 +93,13 @@
+
+
Count Up
+
+ + +
+
Clear on Reset
@@ -107,6 +114,10 @@
+
+
+ Display Modes: +
Hourglass mode
diff --git a/streamdeck-streamtimer/manifest.json b/streamdeck-streamtimer/manifest.json index 5fab115..6ccc08b 100644 --- a/streamdeck-streamtimer/manifest.json +++ b/streamdeck-streamtimer/manifest.json @@ -51,7 +51,7 @@ "Name": "Stream Countdown Timer", "Icon": "Images/pluginIcon", "URL": "https://BarRaider.com/", - "Version": "1.7.2", + "Version": "1.8", "CodePath": "com.barraider.streamcountdowntimer", "Category": "Timer [BarRaider]", "CategoryIcon": "Images/categoryIcon", diff --git a/streamdeck-streamtimer/packages.config b/streamdeck-streamtimer/packages.config index e3cf9da..9a2f359 100644 --- a/streamdeck-streamtimer/packages.config +++ b/streamdeck-streamtimer/packages.config @@ -1,12 +1,12 @@  - + - + - - - + + + \ No newline at end of file