コード例 #1
0
 private void LblSettings_Click(object sender, EventArgs e)
 {
     if (SettingsActive == false)
     {
         SettingsActive = true;
         TxtDrive.Clear();
         LoadSettings();
     }
     else if (SettingsActive == true)
     {
         SettingsActive = false;
     }
 }
コード例 #2
0
        private void SaveSettings()
        {
            LblSettings.Enabled = true;
            if (ChckAutoUpdate.Checked == true)
            {
                Properties.Settings.Default.AutoUpdate = true;
            }
            else if (ChckAutoUpdate.Checked == false)
            {
                Properties.Settings.Default.AutoUpdate = false;
            }
            if (ChckConsoleWind.Checked == true)
            {
                Properties.Settings.Default.Console = true;
            }
            else if (ChckConsoleWind.Checked == false)
            {
                Properties.Settings.Default.Console = false;
            }
            if (ChckClean.Checked == true)
            {
                Properties.Settings.Default.Clean = true;
            }
            else if (ChckClean.Checked == false)
            {
                Properties.Settings.Default.Clean = false;
            }
            if (ChckNotif.Checked == true)
            {
                Properties.Settings.Default.Notif = true;
            }
            else if (ChckNotif.Checked == false)
            {
                Properties.Settings.Default.Notif = false;
            }
            if (RdCanary.Checked == true)
            {
                Properties.Settings.Default.Branch = "Canary";
            }
            else if (RdStable.Checked == true)
            {
                Properties.Settings.Default.Branch = "Stable";
            }

            if (Properties.Settings.Default.FirstTime == true)
            {
                Properties.Settings.Default.FirstTime = false;
            }

            Properties.Settings.Default.Save();
            //Write values to JSON

            if (String.IsNullOrEmpty(TxtDrive.Text.ToString()) == false && Properties.Settings.Default.FirstTime == true || TxtDrive.Text == String.Empty)
            {
                Core.ILogging.Output(true, false, false, false, "The Drive text field cannot be left empty!", true);
                MessageBox.Show("The Drive text field cannot be left empty!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                TxtDrive.Focus();
                SettingsActive = true;
                return;
            }
            if (TxtDrive.Text.Contains(":") || TxtDrive.Text.Contains("\\") || TxtDrive.Text.Contains("/") || TxtDrive.Text.Contains(","))
            {
                Core.ILogging.Output(true, false, false, false, "The Drive text field contains invalid character/s. Please only input the drive letter!", true);
                MessageBox.Show("The Drive text field contains invalid character/s. Please only input the drive letter!", "Error: Invalid character/s", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                TxtDrive.Focus();
                SettingsActive = true;
                NotifTitle     = "GetMyBru";
                NotifText      = "Failed to save the settings to the Config";
                NotifTime      = 40000;
                ShowToast      = true;
                return;
            }
            else
            {
                if (String.IsNullOrEmpty(TxtDrive.Text.ToString()))
                {
                    Core.ILogging.Output(true, false, false, false, "The Drive text field is empty!", true);
                    MessageBox.Show("The Drive text field is empty!", "Error: ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    TxtDrive.Focus();
                    SettingsActive = true;
                    return;
                }
                else
                {
                    Properties.Settings.Default.Drive = TxtDrive.Text;
                    Properties.Settings.Default.Save();
                }
            }

            NotifTitle = "GetMyBru";
            NotifText  = "Saved the settings to the Config";
            NotifTime  = 40000;
            ShowToast  = true;
            Core.ILogging.Output(false, true, false, false, "Saved Settings", true);
        }