Skip to content

Commit

Permalink
v1.8 - Countdown Date/Time, Format, Prefix
Browse files Browse the repository at this point in the history
- 🆕 `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
  • Loading branch information
BarRaider committed Mar 31, 2022
1 parent b9d1a13 commit 8fbe235
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 45 deletions.
55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
15 changes: 12 additions & 3 deletions streamdeck-streamtimer/Actions/DateTimeCountdownAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion streamdeck-streamtimer/Actions/FocusTimerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static PluginSettings CreateDefaultSettings()
PlaySoundOnEndFile = String.Empty,
HourglassTime = true,
WorkImageFile = null,
BreakImageFile = null
BreakImageFile = null,
};

return instance;
Expand Down
15 changes: 13 additions & 2 deletions streamdeck-streamtimer/Actions/StreamTimerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions streamdeck-streamtimer/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
4 changes: 2 additions & 2 deletions streamdeck-streamtimer/Backend/TimerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions streamdeck-streamtimer/CountdownTimer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
<Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.Registry, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\Microsoft.Win32.Registry.4.7.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>
<Reference Include="Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\NLog.4.7.6\lib\net45\NLog.dll</HintPath>
<HintPath>..\..\..\DotNet\StreamDeck\packages\NLog.4.7.15\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="PickersUtil">
<HintPath>..\..\PickersUtil\PickersUtil\bin\Release\PickersUtil.dll</HintPath>
Expand All @@ -61,16 +61,16 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Drawing.Common.5.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security.AccessControl, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Security.AccessControl.4.7.0\lib\net461\System.Security.AccessControl.dll</HintPath>
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
</Reference>
<Reference Include="System.Security.Principal.Windows, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\DotNet\StreamDeck\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
</Reference>
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
Expand Down
11 changes: 11 additions & 0 deletions streamdeck-streamtimer/PropertyInspector/DateTimeCountdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@
</div>
</div>
</div>
<div type="checkbox" class="sdpi-item" id="dvCountUpOnEnd">
<div class="sdpi-item-label">Count Up</div>
<div class="sdpi-item-value">
<input id="countUpOnEnd" type="checkbox" value="" class="sdProperty sdCheckbox" oninput="setSettings()">
<label for="countUpOnEnd" class="sdpi-item-label"><span></span>Start counting up when timer ends</label>
</div>
</div>
<hr />
<details class="message">
<summary>Display Modes:</summary>
</details>
<div type="checkbox" class="sdpi-item" id="dvHourglassMode">
<div class="sdpi-item-label">Hourglass mode</div>
<div class="sdpi-item-value">
Expand Down
4 changes: 4 additions & 0 deletions streamdeck-streamtimer/PropertyInspector/Focus.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
<label for="resumeOnClick" class="sdpi-item-label"><span></span>Unpausing does not reset</label>
</div>
</div>
<hr />
<details class="message">
<summary>Display Modes:</summary>
</details>
<div type="checkbox" class="sdpi-item" id="dvHourglassShowTime">
<div class="sdpi-item-label">Show Time</div>
<div class="sdpi-item-value">
Expand Down
11 changes: 11 additions & 0 deletions streamdeck-streamtimer/PropertyInspector/StreamTimer.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@
</div>
</div>
</div>
<div type="checkbox" class="sdpi-item" id="dvCountUpOnEnd">
<div class="sdpi-item-label">Count Up</div>
<div class="sdpi-item-value">
<input id="countUpOnEnd" type="checkbox" value="" class="sdProperty sdCheckbox" oninput="setSettings()">
<label for="countUpOnEnd" class="sdpi-item-label"><span></span>Start counting up when timer ends</label>
</div>
</div>
<div type="checkbox" class="sdpi-item" id="dvClearFileOnReset">
<div class="sdpi-item-label">Clear on Reset</div>
<div class="sdpi-item-value">
Expand All @@ -107,6 +114,10 @@
<label for="resumeOnClick" class="sdpi-item-label"><span></span>Unpausing does not reset</label>
</div>
</div>
<hr />
<details class="message">
<summary>Display Modes:</summary>
</details>
<div type="checkbox" class="sdpi-item" id="dvHourglassMode">
<div class="sdpi-item-label">Hourglass mode</div>
<div class="sdpi-item-value">
Expand Down
2 changes: 1 addition & 1 deletion streamdeck-streamtimer/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions streamdeck-streamtimer/packages.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="2.8.0" targetFramework="net472" />
<package id="Microsoft.Win32.Registry" version="4.7.0" targetFramework="net472" />
<package id="Microsoft.Win32.Registry" version="5.0.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="NLog" version="4.7.6" targetFramework="net472" />
<package id="NLog" version="4.7.15" targetFramework="net48" />
<package id="streamdeck-client-csharp" version="4.3.0" targetFramework="net472" />
<package id="StreamDeck-Tools" version="3.2.0" targetFramework="net472" />
<package id="System.Drawing.Common" version="5.0.0" targetFramework="net472" />
<package id="System.Security.AccessControl" version="4.7.0" targetFramework="net472" />
<package id="System.Security.Principal.Windows" version="4.7.0" targetFramework="net472" />
<package id="System.Drawing.Common" version="6.0.0" targetFramework="net48" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net48" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net48" />
</packages>

0 comments on commit 8fbe235

Please sign in to comment.