Skip to content

Commit 24f818b

Browse files
committed
Introduce Settings Export; rewrite ShowDialogWithCheckBox; code cleanup
1 parent 740ae78 commit 24f818b

19 files changed

Lines changed: 901 additions & 231 deletions

FrmMainApp.cs

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public partial class FrmMainApp : Form
8888
internal static string _AppLanguage = "English"; // default to english
8989
internal static List<string> LstFavourites = new();
9090

91-
private static string _showLocToMapDialogChoice = "default";
91+
private static bool _showLocToMapDialogChoice = true;
92+
private static bool _rememberLocToMapDialogChoice;
9293

9394
// ReSharper disable once InconsistentNaming
9495
private FrmSettings FrmSettings;
@@ -510,7 +511,7 @@ private void btn_NavigateMapGo_Click(object sender,
510511
EventArgs e)
511512
{
512513
HelperVariables.HsMapMarkers.Clear();
513-
HelperVariables.HsMapMarkers.Add(item: parseLatLngTextBox());
514+
HelperVariables.HsMapMarkers.Add(item: ParseLatLngTextBox());
514515
Request_Map_NavigateGo();
515516
}
516517

@@ -582,14 +583,14 @@ private async void btn_loctToFile_Click(object sender,
582583
isMarkedForDeletion: false);
583584
}
584585

585-
if (!_showLocToMapDialogChoice.Contains(value: "_remember"))
586+
if (!_rememberLocToMapDialogChoice)
586587
{
587588
ShowLocToMapDialog();
588589
}
589590

590591
DataTable dtToponomy = new();
591592
DataTable dtAltitude = new();
592-
if (_showLocToMapDialogChoice.Contains(value: "yes"))
593+
if (_showLocToMapDialogChoice)
593594
{
594595
lvw_FileList_UpdateTagsFromWeb(strGpsLatitude: strGPSLatitudeOnTheMap, strGpsLongitude: strGPSLongitudeOnTheMap, lvi: lvi);
595596
}
@@ -628,29 +629,44 @@ private async void btn_loctToFile_Click(object sender,
628629

629630
void ShowLocToMapDialog()
630631
{
632+
Dictionary<string, string> checkboxDictionary = new()
633+
{
634+
{
635+
HelperDataLanguageTZ.DataReadDTObjectText(
636+
objectType: "CheckBox",
637+
objectName: "ckb_QuestionAddToponomyDontAskAgain"
638+
),
639+
"_remember"
640+
}
641+
};
642+
Dictionary<string, string> buttonsDictionary = new()
643+
{
644+
{
645+
HelperDataLanguageTZ.DataReadDTObjectText(
646+
objectType: "Button",
647+
objectName: "btn_Yes"
648+
),
649+
"yes"
650+
},
651+
{
652+
HelperDataLanguageTZ.DataReadDTObjectText(
653+
objectType: "Button",
654+
objectName: "btn_No"
655+
),
656+
"no"
657+
}
658+
};
659+
631660
// via https://stackoverflow.com/a/17385937/3968494
632-
_showLocToMapDialogChoice = HelperControlAndMessageBoxHandling.ShowDialogWithCheckBox(
661+
List<string> getLocToMapDialogChoice = HelperControlAndMessageBoxHandling.ShowDialogWithCheckBox(
633662
labelText: HelperDataLanguageTZ.DataReadDTObjectText(
634663
objectType: "Label",
635664
objectName: "lbl_QuestionAddToponomy"
636665
),
637-
caption: HelperControlAndMessageBoxHandling.GenericGetMessageBoxCaption(captionType: "Info"),
638-
checkboxText: HelperDataLanguageTZ.DataReadDTObjectText(
639-
objectType: "CheckBox",
640-
objectName: "ckb_QuestionAddToponomyDontAskAgain"
641-
),
642-
returnCheckboxText: "_remember",
643-
button1Text: HelperDataLanguageTZ.DataReadDTObjectText(
644-
objectType: "Button",
645-
objectName: "btn_Yes"
646-
),
647-
returnButton1Text: "yes",
648-
button2Text: HelperDataLanguageTZ.DataReadDTObjectText(
649-
objectType: "Button",
650-
objectName: "btn_No"
651-
),
652-
returnButton2Text: "no"
653-
);
666+
caption: HelperControlAndMessageBoxHandling.GenericGetMessageBoxCaption(captionType: "Info"), checkboxesDictionary: checkboxDictionary, buttonsDictionary: buttonsDictionary, orientation: "Horizontal");
667+
668+
_showLocToMapDialogChoice = getLocToMapDialogChoice.Contains(item: "yes");
669+
_rememberLocToMapDialogChoice = getLocToMapDialogChoice.Contains(item: "_remember");
654670
}
655671
}
656672

@@ -661,7 +677,7 @@ void ShowLocToMapDialog()
661677
/// with values as string and dec separator ".".
662678
/// Otherwise default "0" is returned for both.
663679
/// </summary>
664-
private (string, string) parseLatLngTextBox()
680+
private (string, string) ParseLatLngTextBox()
665681
{
666682
Logger.Trace(message: "Starting parseLatLngTextBox ...");
667683

@@ -714,7 +730,7 @@ void ShowLocToMapDialog()
714730
}
715731

716732

717-
private void updateWebView(IDictionary<string, string> replacements)
733+
private void UpdateWebView(IDictionary<string, string> replacements)
718734
{
719735
string htmlCode = _mapHtmlTemplateCode;
720736

@@ -1094,7 +1110,7 @@ private void Request_Map_NavigateGo()
10941110
htmlReplacements.Add(key: key, value: value);
10951111
}
10961112

1097-
updateWebView(replacements: htmlReplacements);
1113+
UpdateWebView(replacements: htmlReplacements);
10981114
}
10991115

11001116

@@ -1182,15 +1198,15 @@ private async Task InitialiseWebView()
11821198
}
11831199

11841200
// Parse coords from lat/lng text box
1185-
(string LatCoordinate, string LngCoordinate) = parseLatLngTextBox();
1201+
(string LatCoordinate, string LngCoordinate) = ParseLatLngTextBox();
11861202

11871203
// Set up replacements
11881204
IDictionary<string, string> htmlReplacements = new Dictionary<string, string>();
11891205
htmlReplacements.Add(key: "replaceLat", value: LatCoordinate);
11901206
htmlReplacements.Add(key: "replaceLng", value: LngCoordinate);
11911207

11921208
// Show on Map
1193-
updateWebView(replacements: htmlReplacements);
1209+
UpdateWebView(replacements: htmlReplacements);
11941210

11951211
// Set up event handler for clicks in map
11961212
try
@@ -1890,25 +1906,43 @@ private void lvw_FileList_UpdateTagsFromWeb(string strGpsLatitude,
18901906
}
18911907
else
18921908
{
1893-
string APIHandlingChoice = HelperControlAndMessageBoxHandling.ShowDialogWithCheckBox(
1894-
labelText: HelperControlAndMessageBoxHandling.GenericGetMessageBoxText(messageBoxName: "mbx_FrmMainApp_QuestionNoRowsFromAPI"),
1895-
caption: HelperControlAndMessageBoxHandling.GenericGetMessageBoxCaption(captionType: "Question"),
1896-
checkboxText: HelperDataLanguageTZ.DataReadDTObjectText(
1897-
objectType: "CheckBox",
1898-
objectName: "ckb_QuestionStopProcessingRows"
1899-
),
1900-
returnCheckboxText: "_stopprocessing",
1901-
button1Text: HelperDataLanguageTZ.DataReadDTObjectText(
1902-
objectType: "Button",
1903-
objectName: "btn_Yes"
1904-
),
1905-
returnButton1Text: "yes",
1906-
button2Text: HelperDataLanguageTZ.DataReadDTObjectText(
1907-
objectType: "Button",
1908-
objectName: "btn_No"
1909-
),
1910-
returnButton2Text: "no"
1911-
);
1909+
Dictionary<string, string> checkboxDictionary = new()
1910+
{
1911+
{
1912+
HelperDataLanguageTZ.DataReadDTObjectText(
1913+
objectType: "CheckBox",
1914+
objectName: "ckb_QuestionStopProcessingRows"
1915+
),
1916+
"_stopprocessing"
1917+
}
1918+
};
1919+
Dictionary<string, string> buttonsDictionary = new()
1920+
{
1921+
{
1922+
HelperDataLanguageTZ.DataReadDTObjectText(
1923+
objectType: "Button",
1924+
objectName: "btn_Yes"
1925+
),
1926+
"yes"
1927+
},
1928+
{
1929+
HelperDataLanguageTZ.DataReadDTObjectText(
1930+
objectType: "Button",
1931+
objectName: "btn_No"
1932+
),
1933+
"no"
1934+
}
1935+
};
1936+
1937+
// ReSharper disable once InconsistentNaming
1938+
List<string> APIHandlingChoice = HelperControlAndMessageBoxHandling.ShowDialogWithCheckBox(
1939+
labelText: HelperControlAndMessageBoxHandling.GenericGetMessageBoxText(
1940+
messageBoxName: "mbx_FrmMainApp_QuestionNoRowsFromAPI"),
1941+
caption: HelperControlAndMessageBoxHandling.GenericGetMessageBoxCaption(
1942+
captionType: "Question"),
1943+
checkboxesDictionary: checkboxDictionary,
1944+
buttonsDictionary: buttonsDictionary,
1945+
orientation: "Horizontal");
19121946

19131947
if (APIHandlingChoice.Contains(value: "yes"))
19141948
{

FrmSettings.Designer.cs

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

0 commit comments

Comments
 (0)