condense mirror state calls into a method

pull/32/head
Miepee 4 years ago
parent 1b6d1469f9
commit 6c27eb4202

@ -634,16 +634,10 @@ namespace AM2RLauncher
log.Info("Use Custom Mirror option has been set to " + customMirrorCheck.Checked + ".");
CrossPlatformOperations.WriteToConfig("CustomMirrorEnabled", (bool)customMirrorCheck.Checked);
bool enabled = (bool)customMirrorCheck.Checked;
customMirrorTextBox.Enabled = enabled;
mirrorDropDown.Enabled = !enabled;
// Not sure why the dropdown menu needs this hack, but the textBox does not.
if (OS.IsWindows)
mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive;
mirrorLabel.TextColor = !enabled ? colGreen : colInactive;
EnableMirrorControlsAccordingly();
// Create warning dialog when enabling
if (enabled)
if ((bool)customMirrorCheck.Checked)
{
MessageBox.Show(this, Text.WarningWindowText, Text.WarningWindowTitle, MessageBoxType.Warning);
currentMirror = customMirrorTextBox.Text;
@ -655,18 +649,6 @@ namespace AM2RLauncher
}
}
//TODO: why exactly do we need this?
/// <summary>Gets called when <see cref="customMirrorCheck"/> gets loaded.
/// Enables and changes colors for <see cref="customMirrorTextBox"/> and <see cref="mirrorDropDown"/> accordingly.</summary>
private void CustomMirrorCheckLoadComplete(object sender, EventArgs e)
{
bool enabled = (bool)customMirrorCheck.Checked;
customMirrorTextBox.Enabled = enabled;
mirrorDropDown.Enabled = !enabled;
if (OS.IsWindows)
mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive;
}
/// <summary>
/// If the <see cref="customMirrorTextBox"/> has lost focus, we set its text as the new <see cref="currentMirror"/>.
/// </summary>

@ -85,5 +85,18 @@ namespace AM2RLauncher
fileDialog.Filters.Add(new FileFilter(Text.ZipArchiveText, ".zip"));
return fileDialog;
}
/// <summary>Enables and changes colors for <see cref="customMirrorTextBox"/> and <see cref="mirrorDropDown"/> accordingly.</summary>
private void EnableMirrorControlsAccordingly()
{
bool enabled = (bool)customMirrorCheck.Checked;
customMirrorTextBox.Enabled = enabled;
mirrorDropDown.Enabled = !enabled;
// Not sure why the dropdown menu needs this hack, but the textBox does not.
//TODO: eto issue?
if (OS.IsWindows)
mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive;
mirrorLabel.TextColor = !enabled ? colGreen : colInactive;
}
}
}

@ -366,5 +366,18 @@ namespace AM2RLauncher
Profile.ArchiveProfile(profile);
LoadProfilesAndAdjustLists();
}
/// <summary>Enables and changes colors for <see cref="customMirrorTextBox"/> and <see cref="mirrorDropDown"/> accordingly.</summary>
private void EnableMirrorControlsAccordingly()
{
bool enabled = (bool)customMirrorCheck.Checked;
customMirrorTextBox.Enabled = enabled;
mirrorDropDown.Enabled = !enabled;
// Not sure why the dropdown menu needs this hack, but the textBox does not.
//TODO: eto issue?
if (OS.IsWindows)
mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colGreen : colInactive;
mirrorLabel.TextColor = !enabled ? colGreen : colInactive;
}
}
}

@ -634,6 +634,8 @@ namespace AM2RLauncher
TextColor = colGreen
};
EnableMirrorControlsAccordingly();
settingsLayout.BeginHorizontal();
settingsLayout.AddSpace();
settingsLayout.AddColumn(null, languageLabel, languageDropDown, autoUpdateAM2RCheck, autoUpdateLauncherCheck, hqMusicPCCheck, hqMusicAndroidCheck, profileDebugLogCheck, customEnvVarLabel, (Control)customEnvVarTextBox ?? new Label(), mirrorLabel, mirrorDropDown, customMirrorCheck, customMirrorTextBox, null);
@ -799,7 +801,6 @@ namespace AM2RLauncher
hqMusicAndroidCheck.CheckedChanged += HqMusicAndroidCheckChanged;
hqMusicPCCheck.CheckedChanged += HqMusicPCCheckChanged;
customMirrorCheck.CheckedChanged += CustomMirrorCheckChanged;
customMirrorCheck.LoadComplete += CustomMirrorCheckLoadComplete;
apkButton.Click += ApkButtonClickEvent;
apkButton.LoadComplete += (sender, e) => UpdateApkState();
profileDropDown.LoadComplete += (sender, e) => UpdateProfileState();

Loading…
Cancel
Save