Skip to content

Commit d87a326

Browse files
committed
Initial support for Dark Mode; Minor code cleanup.
1 parent 0b812b0 commit d87a326

19 files changed

Lines changed: 295 additions & 44 deletions

FrmAboutBox.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ internal partial class FrmAboutBox : Form
1717
public FrmAboutBox()
1818
{
1919
InitializeComponent();
20+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
21+
? ThemeColour.Dark
22+
: ThemeColour.Light, parentControl: this);
2023
HelperNonStatic helperNonstatic = new();
2124
HelperControlAndMessageBoxHandling.ReturnControlText(cItem: this, senderForm: this);
2225

FrmEditFileData.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public FrmEditFileData()
4040

4141
InitializeComponent();
4242
logger.Trace(message: "InitializeComponent OK");
43+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
44+
? ThemeColour.Dark
45+
: ThemeColour.Light, parentControl: this);
4346
}
4447

4548
/// <summary>

FrmImportGpx.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public partial class FrmImportGpx : Form
3030
public FrmImportGpx()
3131
{
3232
InitializeComponent();
33+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
34+
? ThemeColour.Dark
35+
: ThemeColour.Light, parentControl: this);
36+
3337
// set defaults
3438
rbt_importOneFile.Checked = true;
3539
pbx_importFromAnotherFolder.Enabled = false;

FrmMainApp.Startup.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Globalization;
4-
using System.Linq;
54
using System.Windows.Forms;
65
using GeoTagNinja.Helpers;
76

@@ -56,8 +55,12 @@ private void AppStartupEnableDoubleBuffering()
5655
}
5756
}
5857

58+
5959
/// <summary>
60-
/// Assigns the various labels to objects (such as buttons, labels etc.)
60+
/// Assigns labels to various objects in the application during startup. This includes buttons, labels, checkboxes, and
61+
/// other UI elements.
62+
/// It also sets up tooltips for specific controls. The labels and tooltips are fetched from a data source using the
63+
/// HelperDataLanguageTZ.DataReadDTObjectText method.
6164
/// </summary>
6265
private void AppStartupAssignLabelsToObjects()
6366
{
@@ -176,7 +179,7 @@ private void AppStartupAssignLabelsToObjects()
176179
objectName = cItem.Name;
177180
objectText = HelperDataLanguageTZ.DataReadDTObjectText(
178181
objectType: cItem.GetType()
179-
.Name,
182+
.Name,
180183
objectName: cItem.Name
181184
);
182185
cItem.Text = objectText;
@@ -190,20 +193,20 @@ private void AppStartupAssignLabelsToObjects()
190193
);
191194

192195
Logger.Trace(message: "Setting Tooltips");
193-
List<(ToolTip, Control, string)> ttpLabelsList = new List<(ToolTip, Control, string)>()
196+
List<(ToolTip, Control, string)> ttpLabelsList = new()
194197
{
195198
(ttp_loctToFile, btn_loctToFile, "ttp_loctToFile"),
196199
(ttp_loctToFileDestination, btn_loctToFileDestination, "ttp_loctToFileDestination"),
197200
(ttp_NavigateMapGo, btn_NavigateMapGo, "ttp_NavigateMapGo"),
198201
(ttp_SaveFavourite, btn_SaveFavourite, "ttp_SaveFavourite"),
199202
(ttp_LoadFavourite, btn_LoadFavourite, "ttp_LoadFavourite"),
200-
(ttp_ManageFavourites, btn_ManageFavourites, "ttp_ManageFavourites"),
203+
(ttp_ManageFavourites, btn_ManageFavourites, "ttp_ManageFavourites")
201204
};
202205
foreach ((ToolTip, Control, string) valueTuple in ttpLabelsList)
203206
{
204-
ToolTip ttp = (ToolTip)valueTuple.Item1;
205-
ttp.SetToolTip((Control)valueTuple.Item2,
206-
HelperDataLanguageTZ.DataReadDTObjectText(
207+
ToolTip ttp = valueTuple.Item1;
208+
ttp.SetToolTip(control: valueTuple.Item2,
209+
caption: HelperDataLanguageTZ.DataReadDTObjectText(
207210
objectType: "ToolTip",
208211
objectName: valueTuple.Item3
209212
));
@@ -261,8 +264,8 @@ private void AppStartupPullLastLatLngFromSettings()
261264
nud_lat.Text = defaultLat;
262265
nud_lng.Text = defaultLng;
263266

264-
nud_lat.Value = Convert.ToDecimal(value: defaultLat, CultureInfo.InvariantCulture);
265-
nud_lng.Value = Convert.ToDecimal(value: defaultLng, CultureInfo.InvariantCulture);
267+
nud_lat.Value = Convert.ToDecimal(value: defaultLat, provider: CultureInfo.InvariantCulture);
268+
nud_lng.Value = Convert.ToDecimal(value: defaultLng, provider: CultureInfo.InvariantCulture);
266269
}
267270

268271
HelperVariables.HsMapMarkers.Clear();

FrmMainApp.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ private async void FrmMainApp_Load(object sender,
281281
// initialise webView2
282282
await InitialiseWebView();
283283

284+
// adds colour/theme
285+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
286+
? ThemeColour.Dark
287+
: ThemeColour.Light, parentControl: this);
288+
284289
// assign labels to objects
285290
AppStartupAssignLabelsToObjects();
286291

FrmManageFavourites.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public partial class FrmManageFavourites : Form
1414
public FrmManageFavourites()
1515
{
1616
InitializeComponent();
17+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
18+
? ThemeColour.Dark
19+
: ThemeColour.Light, parentControl: this);
1720
}
1821

1922
private void FrmManageFavourites_Load(object sender,

FrmPasteWhat.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public FrmPasteWhat(string initiator)
3131
{
3232
_initiatorName = initiator;
3333
InitializeComponent();
34+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
35+
? ThemeColour.Dark
36+
: ThemeColour.Light, parentControl: this);
3437

3538
ListView lvw;
3639
List<ElementAttribute> tagsToPasteAttributeList = new();

FrmSettings.Designer.cs

Lines changed: 31 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FrmSettings.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public partial class FrmSettings : Form
2626
public FrmSettings()
2727
{
2828
InitializeComponent();
29+
HelperControlThemeManager.SetThemeColour(themeColour: HelperVariables.SUseDarkMode
30+
? ThemeColour.Dark
31+
: ThemeColour.Light, parentControl: this);
2932

3033
// this one is largely responsible for disabling the detection of "new" (changed) data. (ie when going from "noting" to "something")
3134
_nowLoadingSettingsData = true;
@@ -474,7 +477,8 @@ private void Btn_OK_Click(object sender,
474477
{
475478
if ((ckb.Font.Style & FontStyle.Bold) != 0)
476479
{
477-
if (ckb.Name == "ckb_UseImperialNotMetric")
480+
// strictly speaking for ckb_UseDarkMode we don't need to restart the app and the checker could be called here but it'd need another loop.
481+
if (ckb.Name == "ckb_UseImperialNotMetric" || ckb.Name == "ckb_UseDarkMode")
478482
{
479483
warnUserToRestartApp();
480484
}
@@ -562,6 +566,12 @@ private void Btn_OK_Click(object sender,
562566
settingId: "ckb_UpdateCheckPreRelease"
563567
);
564568

569+
HelperVariables.SUseDarkMode = HelperDataApplicationSettings.DataReadCheckBoxSettingTrueOrFalse(
570+
tableName: "settings",
571+
settingTabPage: "tpg_Application",
572+
settingId: "ckb_UseDarkMode"
573+
);
574+
565575
HelperGenericAppStartup.AppStartupPullOverWriteBlankToponomy();
566576
HelperGenericAppStartup.AppStartupPullToponomyRadiusAndMaxRows();
567577
HelperDataCustomRules.DataWriteSQLiteCustomRules();

FrmSettings.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
138138
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
139139
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAE
140-
DAAAAk1TRnQBSQFMAgEBBAEAAWABAQFgAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
140+
DAAAAk1TRnQBSQFMAgEBBAEAAWgBAQFoAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
141141
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
142142
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
143143
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

0 commit comments

Comments
 (0)