From 2563f1593b6e989d8043748909344ddd88b5c906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peyronnet?= Date: Sat, 3 Oct 2020 09:56:34 +0200 Subject: [PATCH] Added a prompt before clearing data (#141) --- InternetTest/Classes/Branches.cs | 2 +- InternetTest/Forms/Settings.cs | 42 +++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/InternetTest/Classes/Branches.cs b/InternetTest/Classes/Branches.cs index 6e8aafbd..be32c7ee 100644 --- a/InternetTest/Classes/Branches.cs +++ b/InternetTest/Classes/Branches.cs @@ -8,7 +8,7 @@ namespace InternetTest.Classes { public class Branches { - string branch = "master"; + string branch = "Version_Next"; // branch peut être égal à // - master // - Version_Next diff --git a/InternetTest/Forms/Settings.cs b/InternetTest/Forms/Settings.cs index 37ff449b..6f3c63b8 100644 --- a/InternetTest/Forms/Settings.cs +++ b/InternetTest/Forms/Settings.cs @@ -207,24 +207,38 @@ private void gunaWinSwitch2_CheckedChanged(object sender, EventArgs e) private void gunaLinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - Properties.Settings.Default.Reset(); - Properties.Settings.Default.Save(); - UpdateSite(); - if (gunaComboBox1.Text.Contains("fr-FR")) + string promptBeforeRemove = ""; + + if (gunaComboBox1.Text.Contains("fr-FR")) // If the lang is french { - gunaComboBox1.Text = "Français (fr-FR)"; - gunaWinSwitch1.Checked = false; - gunaWinSwitch2.Checked = true; - MessageBox.Show("Les données ont été effacées.", "Terminé", MessageBoxButtons.OK, MessageBoxIcon.Information); + promptBeforeRemove = "Êtes-vous sûr de vouloir effacer toutes les données d'InternetTest ?"; } - else if (gunaComboBox1.Text.Contains("EN")) + else if (gunaComboBox1.Text.Contains("EN")) // If the lang is english { - gunaComboBox1.Text = "French (fr-FR)"; - gunaWinSwitch1.Checked = false; - gunaWinSwitch2.Checked = true; - MessageBox.Show("Data has been removed.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); + promptBeforeRemove = "Are you sure you wanna erase all InternetTest's data?"; + } + + if (MessageBox.Show(promptBeforeRemove, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + Properties.Settings.Default.Reset(); + Properties.Settings.Default.Save(); + UpdateSite(); + if (gunaComboBox1.Text.Contains("fr-FR")) + { + gunaComboBox1.Text = "Français (fr-FR)"; + gunaWinSwitch1.Checked = false; + gunaWinSwitch2.Checked = true; + MessageBox.Show("Les données ont été effacées.", "Terminé", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else if (gunaComboBox1.Text.Contains("EN")) + { + gunaComboBox1.Text = "French (fr-FR)"; + gunaWinSwitch1.Checked = false; + gunaWinSwitch2.Checked = true; + MessageBox.Show("Data has been removed.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + gunaComboBox2.Text = Properties.Settings.Default.MapsProvider; // Mettre à jour le texte } - gunaComboBox2.Text = Properties.Settings.Default.MapsProvider; // Mettre à jour le texte } private void gunaComboBox1_SelectedIndexChanged(object sender, EventArgs e)