From 11997b8b4cec72e476c58c21460f4b2bb890382c Mon Sep 17 00:00:00 2001
From: thisismy-github <48284263+thisismy-github@users.noreply.github.com>
Date: Fri, 16 Feb 2024 21:18:45 -0500
Subject: [PATCH] Add clock format overriding & `Clock` settings tab
Also, moved the "Notification area" `ContentControl` and its `Border`
into the resource dictionary as a `ControlTemplate` (using the key
`"NotificationAreaPreview"`) so it can be reused.
---
RetroBar/Controls/Clock.xaml.cs | 48 ++++++++--
RetroBar/Languages/English.xaml | 9 ++
RetroBar/PropertiesWindow.xaml | 159 ++++++++++++++++++++++----------
RetroBar/Utilities/Settings.cs | 85 +++++++++++++++++
4 files changed, 244 insertions(+), 57 deletions(-)
diff --git a/RetroBar/Controls/Clock.xaml.cs b/RetroBar/Controls/Clock.xaml.cs
index bddeda9e..ec8e2bbe 100644
--- a/RetroBar/Controls/Clock.xaml.cs
+++ b/RetroBar/Controls/Clock.xaml.cs
@@ -78,16 +78,26 @@ private void StopClock()
private void Settings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
- if (e.PropertyName == "ShowClock")
- {
- if (Settings.Instance.ShowClock)
- {
- StartClock();
- }
- else
- {
- StopClock();
- }
+ switch (e.PropertyName) {
+ case "ShowClock":
+ if (Settings.Instance.ShowClock)
+ {
+ StartClock();
+ }
+ else
+ {
+ StopClock();
+ }
+ break;
+
+ case "Theme":
+ case "OverrideClockFormat":
+ case "ClockFormat":
+ case "OverrideAMPMDesignators":
+ case "AMDesignator":
+ case "PMDesignator":
+ SetCurrentCulture();
+ break;
}
}
@@ -156,6 +166,24 @@ private void SetCurrentCulture()
iCi.DateTimeFormat.AMDesignator = (string)iKey.GetValue("s1159");
iCi.DateTimeFormat.PMDesignator = (string)iKey.GetValue("s2359");
+ // Override culture info if desired, inserting newlines where appropriate
+ if (Settings.Instance.OverrideClockFormat && Settings.Instance.ClockFormat != "")
+ {
+ iCi.DateTimeFormat.ShortTimePattern = Settings.Instance.ClockFormat.Replace("\\n", "\n");
+ }
+
+ if (Settings.Instance.OverrideAMPMDesignators)
+ {
+ if (Settings.Instance.AMDesignator != "")
+ {
+ iCi.DateTimeFormat.AMDesignator = Settings.Instance.AMDesignator;
+ }
+ if (Settings.Instance.PMDesignator != "")
+ {
+ iCi.DateTimeFormat.PMDesignator = Settings.Instance.PMDesignator;
+ }
+ }
+
CultureInfo.CurrentCulture = iCi;
SetConverterCultureRecursively(this);
SetConverterCultureRecursively(ClockTip);
diff --git a/RetroBar/Languages/English.xaml b/RetroBar/Languages/English.xaml
index dc5603c0..5b243ffc 100644
--- a/RetroBar/Languages/English.xaml
+++ b/RetroBar/Languages/English.xaml
@@ -4,6 +4,7 @@
RetroBar Properties
Taskbar
+ Clock
Advanced
Taskbar appearance
Notification area
@@ -57,6 +58,14 @@
Enable debug logging
OK
+ Clock appearance
+ What the notations mean:
h = hour; m = minute, s = second, tt = AM/PM
d = day; M = month; yy, yyyy = year
ddd, dddd = weekday; MMM, MMMM = month name
h/H = 12/24 hour
hh, mm, ss, dd, MM = display leading zero
h, m, s, d, M = do not display leading zero
\n = split clock into multiple lines
(not recommended on all themes)
Use "\" in front of other notations to use their actual characters
+ Note: Custom clock formatting may not be applied
if your selected theme specifies its own format.
+ Custom clock _format:
+ Custom _designators:
+ AM:
+ PM:
+
Customize Notifications
RetroBar displays icons for active and urgent notifications, and hides inactive ones. You can change this behavior for items in the list below.
Select an item, then choose its notification behavior:
diff --git a/RetroBar/PropertiesWindow.xaml b/RetroBar/PropertiesWindow.xaml
index de94965b..0eefcd3c 100644
--- a/RetroBar/PropertiesWindow.xaml
+++ b/RetroBar/PropertiesWindow.xaml
@@ -87,6 +87,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -229,53 +273,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -298,6 +297,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RetroBar/Utilities/Settings.cs b/RetroBar/Utilities/Settings.cs
index 064879d8..49904917 100644
--- a/RetroBar/Utilities/Settings.cs
+++ b/RetroBar/Utilities/Settings.cs
@@ -121,6 +121,91 @@ public bool ShowClock
}
}
+ private bool _overrideClockFormat = false;
+ public bool OverrideClockFormat
+ {
+ get
+ {
+ return _overrideClockFormat;
+ }
+ set
+ {
+ if (_overrideClockFormat != value)
+ {
+ _overrideClockFormat = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private string _clockFormat = "h:mm:ss tt | ddd, MMM d, yyyy";
+ public string ClockFormat
+ {
+ get
+ {
+ return _clockFormat;
+ }
+ set
+ {
+ if (_clockFormat != value)
+ {
+ _clockFormat = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private bool _overrideAMPMDesignators = false;
+ public bool OverrideAMPMDesignators
+ {
+ get
+ {
+ return _overrideAMPMDesignators;
+ }
+ set
+ {
+ if (_overrideAMPMDesignators != value)
+ {
+ _overrideAMPMDesignators = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private string _amDesignator = "a.m.";
+ public string AMDesignator
+ {
+ get
+ {
+ return _amDesignator;
+ }
+ set
+ {
+ if (_amDesignator != value)
+ {
+ _amDesignator = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ private string _pmDesignator = "p.m.";
+ public string PMDesignator
+ {
+ get
+ {
+ return _pmDesignator;
+ }
+ set
+ {
+ if (_pmDesignator != value)
+ {
+ _pmDesignator = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
private bool _showDesktopButton = false;
public bool ShowDesktopButton
{