Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shells-dw committed Jan 23, 2023
1 parent 2e06aae commit 2aea143
Show file tree
Hide file tree
Showing 21 changed files with 603 additions and 128 deletions.
14 changes: 11 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,22 @@ If you'd like to drop me a coffee for the hours I've spent on this:
or use Ko-Fi [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y8Y4CE9LH)

# Changelog
## [1.3.0] - 2023-01-23
### Added
- Display calendar week (based on local time)
- Numeric day of the year (0-365, based on local time)
- Numeric days remaining in the year (0-365, based on local time)
- count down days until custom date (enter in YYYY-MM-DD format, based on local time)
### Fixed
- Weekday displays wouldn't work on Sunday _(I get that, but still fixed it_ :wink: _)_.

<details><summary>Changelog History</summary><p>

## [1.2.0] - 2023-01-14
### Added
- Digital watch faces with additional day of the week display
### Improved
- Removed the need for Newtonsoft.Json and went with JSON functions that come with the SDK to avoid potential mismatch issues between the bundled and the NuGet Newtonsoft.Json version in the future

<details><summary>Changelog History</summary><p>

## [1.1.0] - 2023-01-10
### Added
- UI Translation for German and French
Expand Down
97 changes: 97 additions & 0 deletions WorldClockPlugin/Actions/DaysLeft.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
namespace Loupedeck.WorldClockPlugin
{
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

using Loupedeck.WorldClockPlugin.Helpers;
using Loupedeck.WorldClockPlugin.l10n;

using NodaTime;
using NodaTime.Extensions;

public class DaysLeft : PluginDynamicCommand
{
private WorldClockPlugin _plugin;
private L10n _l10n;
private Dictionary<String, String> l7dValues;
public DaysLeft()
: base(displayName: "Days until date", description: "Display how many days are left until given date", groupName: "Day") => this.MakeProfileAction("text;YYYY-MM-DD");
protected override Boolean OnLoad()
{
this._plugin = base.Plugin as WorldClockPlugin;
if (this._plugin is null)
{
return false;
}
this._l10n = new L10n(this._plugin);
this.l7dValues = this._l10n.GetL7dNames("daysleft");
if (this.l7dValues != null)
{
this.DisplayName = this.l7dValues["displayName"];
this.Description = this.l7dValues["description"];
this.GroupName = this.l7dValues["groupName"];
}
else
{
this.DisplayName = "Days left until date";
this.GroupName = "Digital";
this._plugin.Log.Info($"12S : l7dValues was empty or null: DisplayName: {this.l7dValues["displayName"]}, groupName: {this.l7dValues["groupName"]}.");
}
this._plugin.Tick += (sender, e) => this.ActionImageChanged("");
return base.OnLoad();
}

protected override void RunCommand(String actionParameter) => this.ActionImageChanged(actionParameter);

// update command image (nothing to update here per se, but that's called to draw whatever is shown on the Loupedeck)
protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
if (actionParameter != null && Regex.IsMatch(actionParameter, @"^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])$"))
{
var split = actionParameter.Split("-");
DateTimeZone zone = DateTimeZoneProviders.Tzdb.GetSystemDefault();
ZonedClock clock = SystemClock.Instance.InZone(zone);
ZonedDateTime today = clock.GetCurrentZonedDateTime();
LocalDateTime countdownDate = new LocalDateTime(Int32.Parse(split[0]), Int32.Parse(split[1]), Int32.Parse(split[2])+1, 0, 0, 0);

Period timeLeft = Period.Between(today.LocalDateTime, countdownDate, PeriodUnits.Days);

Int32 idx = actionParameter.LastIndexOf("/");
using (var bitmapBuilder = new BitmapBuilder(imageSize))
{
bitmapBuilder.Clear(BitmapColor.Black);
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.58;
var y2 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(timeLeft.Days.ToString(), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 40 : 9, imageSize == PluginImageSize.Width90 ? 12 : 5);
bitmapBuilder.DrawText($"{this.l7dValues["additionalText"]} {actionParameter}", (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 7 : 5, 6);
}
return bitmapBuilder.ToImage();
}
}
else
{
using (var bitmapBuilder = new BitmapBuilder(imageSize))
{
bitmapBuilder.Clear(BitmapColor.Black);
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.58;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText("enter date in format YYYY-MM-DD", (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 12 : 5);
}
return bitmapBuilder.ToImage();
}
}
}
}
}
11 changes: 2 additions & 9 deletions WorldClockPlugin/Actions/WorldClock12DL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,17 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
{
bitmapBuilder.Clear(BitmapColor.Black);
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
}
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.01;
var x2 = bitmapBuilder.Width * 0.43;
var x3 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.35;
var y2 = bitmapBuilder.Height * 0.62;
var y3 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x3, (Int32)y3, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
bitmapBuilder.DrawText(today.ToString("hh:mm", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 23 : 9, imageSize == PluginImageSize.Width90 ? 11 : 8);
bitmapBuilder.DrawText(today.ToString("tt", CultureInfo.InvariantCulture), (Int32)x2, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 12 : 9, imageSize == PluginImageSize.Width90 ? 11 : 8);
bitmapBuilder.DrawText(today.LocalDateTime.ToString(currentCulture.DateTimeFormat.ShortDatePattern, currentCulture), (Int32)x3, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 16 : 8, 1);
Expand Down
5 changes: 2 additions & 3 deletions WorldClockPlugin/Actions/WorldClock12DWN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace Loupedeck.WorldClockPlugin

using NodaTime;
using NodaTime.Extensions;


using NodaTime.Utility;

public class WorldClock12DWN : PluginDynamicCommand
{
Expand Down Expand Up @@ -88,7 +87,7 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma

bitmapBuilder.DrawText(today.ToString("hh:mm", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 33 : 9, imageSize == PluginImageSize.Width90 ? 11 : 8);
bitmapBuilder.DrawText(today.ToString("tt", CultureInfo.InvariantCulture), (Int32)x2, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 12 : 9, imageSize == PluginImageSize.Width90 ? 11 : 8);
bitmapBuilder.DrawText(currentCulture.DateTimeFormat.GetDayName((DayOfWeek)today.DayOfWeek), (Int32)x1, (Int32)y3, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 15 : 9, imageSize == PluginImageSize.Width90 ? 7 : 5, 10);
bitmapBuilder.DrawText(currentCulture.DateTimeFormat.GetDayName(BclConversions.ToDayOfWeek(today.DayOfWeek)), (Int32)x1, (Int32)y3, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 15 : 9, imageSize == PluginImageSize.Width90 ? 7 : 5, 10);
bitmapBuilder.DrawText(today.LocalDateTime.ToString(currentCulture.DateTimeFormat.ShortDatePattern, currentCulture), (Int32)x3, (Int32)y4, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 16 : 8, 1);
}
return bitmapBuilder.ToImage();
Expand Down
11 changes: 2 additions & 9 deletions WorldClockPlugin/Actions/WorldClock12L.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,15 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
{
bitmapBuilder.Clear(BitmapColor.Black);
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
}
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.45;
var y2 = bitmapBuilder.Height * 0.65;
var y3 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y3, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
bitmapBuilder.DrawText(today.ToString("hh:mm", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 33 : 9, imageSize == PluginImageSize.Width90 ? 11 : 8);
bitmapBuilder.DrawText(today.ToString("tt", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 12 : 9, imageSize == PluginImageSize.Width90 ? 10 : 8, 6);
}
Expand Down
11 changes: 2 additions & 9 deletions WorldClockPlugin/Actions/WorldClock12SL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,15 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
{
bitmapBuilder.Clear(BitmapColor.Black);
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.1;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 8 : 6, 6);
}
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.45;
var y2 = bitmapBuilder.Height * 0.65;
var y3 = bitmapBuilder.Height * 0.1;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y3, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 8 : 6, 6);
bitmapBuilder.DrawText(today.ToString("hh:mm:ss", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 17 : 9, imageSize == PluginImageSize.Width90 ? 11 : 8);
bitmapBuilder.DrawText(today.ToString("tt", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 12 : 9, imageSize == PluginImageSize.Width90 ? 10 : 8, 6);
}
Expand Down
11 changes: 2 additions & 9 deletions WorldClockPlugin/Actions/WorldClock24DL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,15 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
{
bitmapBuilder.Clear(BitmapColor.Black);
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
}
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.42;
var y2 = bitmapBuilder.Height * 0.62;
var y3 = bitmapBuilder.Height * 0.05;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y3, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
bitmapBuilder.DrawText(today.ToString("HH:mm", currentCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 33 : 9, imageSize == PluginImageSize.Width90 ? 12 : 5);
bitmapBuilder.DrawText(today.LocalDateTime.ToString(currentCulture.DateTimeFormat.ShortDatePattern, currentCulture), (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 16 : 8, 1);
}
Expand Down
5 changes: 2 additions & 3 deletions WorldClockPlugin/Actions/WorldClock24DWN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ namespace Loupedeck.WorldClockPlugin

using NodaTime;
using NodaTime.Extensions;


using NodaTime.Utility;

public class WorldClock24DWN : PluginDynamicCommand
{
Expand Down Expand Up @@ -85,7 +84,7 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(today.ToString("HH:mm", currentCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 33 : 9, imageSize == PluginImageSize.Width90 ? 12 : 5);
bitmapBuilder.DrawText(currentCulture.DateTimeFormat.GetDayName((DayOfWeek)today.DayOfWeek), (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 7 : 5, 10);
bitmapBuilder.DrawText(currentCulture.DateTimeFormat.GetDayName(BclConversions.ToDayOfWeek(today.DayOfWeek)), (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 7 : 5, 10);
bitmapBuilder.DrawText(today.LocalDateTime.ToString(currentCulture.DateTimeFormat.ShortDatePattern, currentCulture), (Int32)x1, (Int32)y3, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 16 : 8, 1);
}
return bitmapBuilder.ToImage();
Expand Down
11 changes: 2 additions & 9 deletions WorldClockPlugin/Actions/WorldClock24L.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,11 @@ protected override BitmapImage GetCommandImage(String actionParameter, PluginIma
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.05;
var y2 = bitmapBuilder.Height * 0.5;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(actionParameter.Substring(idx + 1).Replace("_", " "), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, new BitmapColor(255, 255, 255, 200), imageSize == PluginImageSize.Width90 ? 13 : 9, imageSize == PluginImageSize.Width90 ? 2 : 0, 10);
}
if (!String.IsNullOrEmpty(actionParameter))
{
var x1 = bitmapBuilder.Width * 0.1;
var w = bitmapBuilder.Width * 0.8;
var y1 = bitmapBuilder.Height * 0.5;
var h = bitmapBuilder.Height * 0.3;

bitmapBuilder.DrawText(today.ToString("HH:mm", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y1, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 35 : 9, imageSize == PluginImageSize.Width90 ? 12 : 8, 1);
bitmapBuilder.DrawText(today.ToString("HH:mm", CultureInfo.InvariantCulture), (Int32)x1, (Int32)y2, (Int32)w, (Int32)h, BitmapColor.White, imageSize == PluginImageSize.Width90 ? 33 : 9, imageSize == PluginImageSize.Width90 ? 12 : 8, 1);
}
return bitmapBuilder.ToImage();
}
Expand Down
Loading

0 comments on commit 2aea143

Please sign in to comment.