Skip to content

Commit 15f4e35

Browse files
committed
Add Map Dark Mode options
1 parent 9f80c08 commit 15f4e35

9 files changed

Lines changed: 136 additions & 19 deletions

File tree

FrmMainApp.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,27 @@ private void Request_Map_NavigateGo()
825825
string showPointsStr = "";
826826
string showFOVStr = "";
827827
string showDestinationPolyLineStr = "";
828+
string mapStyleFiter = HelperVariables.SMapColourMode switch
829+
{
830+
"DarkInverse" => "filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);",
831+
"DarkPale" => "filter: brightness(55%) contrast(90%);",
832+
_ => ""
833+
};
834+
835+
string mapStyleCSS = """
836+
#map {
837+
border: 3px !important;
838+
border-color: black;
839+
bottom: 0;
840+
height: 100% !important;
841+
left: 0;
842+
position: fixed;
843+
right: 0;
844+
top: 0;
845+
width: 100% !important;
846+
#replaceMe#
847+
}
848+
""".Replace(oldValue: "#replaceMe#", newValue: mapStyleFiter);
828849

829850
// check there is one and only one DE selected and add ImgDirection if there's any
830851
ListView lvw = lvw_FileList;
@@ -1068,6 +1089,7 @@ private void Request_Map_NavigateGo()
10681089
htmlReplacements.Add(key: "replaceMaxLng", value: HelperVariables.MaxLng.ToString()
10691090
.Replace(oldChar: ',', newChar: '.'));
10701091

1092+
htmlReplacements.Add(key: "{ HTMLMapStyleCSS }", value: mapStyleCSS);
10711093
htmlReplacements.Add(key: "{ HTMLCreatePoints }", value: createPointsStr);
10721094
htmlReplacements.Add(key: "{ HTMLShowLines }", value: showLinesStr);
10731095
htmlReplacements.Add(key: "{ HTMLShowPoints }", value: showPointsStr);

FrmSettings.Designer.cs

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

FrmSettings.cs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,20 @@ private void FrmSettings_Load(object sender,
261261
cbx_TryUseGeoNamesLanguage.Enabled = true;
262262
}
263263

264+
// (re)set the map colour mode
265+
if (rbt_MapColourModeDarkPale.Checked)
266+
{
267+
HelperVariables.SMapColourMode = "DarkPale";
268+
}
269+
else if (rbt_MapColourModeDarkInverse.Checked)
270+
{
271+
HelperVariables.SMapColourMode = "DarkInverse";
272+
}
273+
else
274+
{
275+
HelperVariables.SMapColourMode = "Normal"; // technically we could just ignore this
276+
}
277+
264278
_nowLoadingSettingsData = false;
265279

266280
LoadCustomRulesDGV();
@@ -480,6 +494,19 @@ private void Btn_Cancel_Click(object sender,
480494
private void Btn_OK_Click(object sender,
481495
EventArgs e)
482496
{
497+
List<string> rbtGeoNamesLanguage = new()
498+
{
499+
"rbt_UseGeoNamesLocalLanguage",
500+
"rbt_TryUseGeoNamesLanguage"
501+
};
502+
503+
List<string> rbtMapColourOptions = new()
504+
{
505+
"rbt_MapColourModeNormal",
506+
"rbt_MapColourModeDarkInverse",
507+
"rbt_MapColourModeDarkPale"
508+
};
509+
483510
HelperNonStatic helperNonstatic = new();
484511
IEnumerable<Control> c = helperNonstatic.GetAllControls(control: this);
485512
if (c != null)
@@ -521,8 +548,9 @@ private void Btn_OK_Click(object sender,
521548
if (cItem is RadioButton rbt)
522549
{
523550
// this needs to be an IF rather than an ELSE IF
524-
if (rbt.Name == "rbt_UseGeoNamesLocalLanguage" || rbt.Name == "rbt_TryUseGeoNamesLanguage")
551+
if (rbtGeoNamesLanguage.Contains(item: rbt.Name))
525552
{
553+
// (rbt.Font.Style & FontStyle.Bold) here means that there has been a change of state and it needs saving
526554
if ((rbt.Font.Style & FontStyle.Bold) != 0 && rbt.Checked)
527555
{
528556
ComboBox cbxLng = cbx_TryUseGeoNamesLanguage;
@@ -534,14 +562,26 @@ private void Btn_OK_Click(object sender,
534562
else if (rbt.Name == "rbt_TryUseGeoNamesLanguage")
535563
{
536564
cbxLng.Enabled = true;
537-
IEnumerable<KeyValuePair<string, string>> result = HelperGenericAncillaryListsArrays.GetISO_639_1_Languages()
538-
.Where(predicate: kvp => kvp.Value == cbxLng.SelectedItem.ToString());
565+
IEnumerable<KeyValuePair<string, string>> result = HelperGenericAncillaryListsArrays
566+
.GetISO_639_1_Languages()
567+
.Where(
568+
predicate: kvp =>
569+
kvp.Value ==
570+
cbxLng.SelectedItem
571+
.ToString());
539572

540573
HelperVariables.APILanguageToUse = result.FirstOrDefault()
541574
.Key;
542575
}
543576
}
544577
}
578+
else if (rbtMapColourOptions.Contains(item: rbt.Name))
579+
{
580+
if ((rbt.Font.Style & FontStyle.Bold) != 0 && rbt.Checked)
581+
{
582+
HelperVariables.SMapColourMode = rbt.Name.Replace(oldValue: "rbt_MapColourMode", newValue: "");
583+
}
584+
}
545585
}
546586
}
547587
}

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
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABI
140-
DQAAAk1TRnQBSQFMAgEBBQEAAYABAQGAAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
140+
DQAAAk1TRnQBSQFMAgEBBQEAAZABAQGQAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
141141
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
142142
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
143143
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

Helpers/HelperVariables.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ internal static class HelperVariables
1818
internal static bool SUseDarkMode;
1919
internal static bool SUpdatePreReleaseGTN;
2020
internal static bool SOnlyShowFCodePPL = false;
21+
internal static string SMapColourMode; // DarkInverse or DarkPale (could be Normal too but not relevant)
2122

2223
internal static string _sErrorMsg = "";
2324
internal static string _sOutputMsg = "";

Resources/Languages/CheckBox.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ ckb_PopulatedPlacesOnly,"Only display API data filtered to ""Populated places""
3232
ckb_QuestionStopProcessingRows,Stop Processing further rows?,
3333
ckb_UseImperialNotMetric,Use Imperial (Feet) for Altitude (rather than Metric [Metres]),
3434
ckb_UpdateCheckPreRelease,Check for Pre-release [beta] updates as well?,
35-
ckb_UseDarkMode,Use Dark Mode?,
35+
ckb_UseDarkMode,Use Dark Mode in the App UI?,

Resources/Languages/GroupBox.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ gbx_GetToponomy,Get Toponomy data,Obtenir les données de toponymie
1212
gbx_AppSettings,Application Settings,
1313
gbx_GeoNamesSettings,GeoNames Settings,
1414
gbx_GeoNamesLanguageSettings,GeoNames Language Settings,
15+
gbx_MapColourMode,Map Colour Mode,

Resources/Languages/RadioButton.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ rbt_PasteCreateDateActual,Actual (Fixed values),Réel (valeurs fixes)
1212
rbt_PasteCreateDateShift,Time Shift,Décalage dans le temps
1313
rbt_TryUseGeoNamesLanguage,Try to use this language when retrieving location names:,
1414
rbt_UseGeoNamesLocalLanguage,"Try to use the ""local language"" when retrieving location names",
15+
rbt_MapColourModeNormal,Normal,
16+
rbt_MapColourModeDarkInverse,Dark (Inverse),
17+
rbt_MapColourModeDarkPale,Dark (Pale),

Resources/map.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,7 @@
1919
<script src="./leaflet.polylineDecorator.js"></script>
2020

2121
<style>
22-
#map {
23-
border: 3px !important;
24-
border-color: black;
25-
bottom: 0;
26-
height: 100% !important;
27-
left: 0;
28-
position: fixed;
29-
right: 0;
30-
top: 0;
31-
width: 100% !important;
32-
}
22+
{ HTMLMapStyleCSS }
3323

3424
.geocoder-control-expanded { width: 400px !important; }
3525

0 commit comments

Comments
 (0)