Move modsettingsProfileDropdown fully to a DataStore

pull/45/head
Miepee 4 years ago
parent f560919817
commit 5b22daf4ac

@ -40,7 +40,7 @@ public partial class MainForm : Form
private void ProfileLayoutLoadComplete(object sender, EventArgs e) private void ProfileLayoutLoadComplete(object sender, EventArgs e)
{ {
// Safety check // Safety check
if ((modSettingsProfileDropDown == null) || (modSettingsProfileDropDown.Items.Count != 0)) return; if ((modSettingsProfileDropDown == null) || (modSettingsProfileDropDown.DataStore.Any())) return;
addModButton.Enabled = false; addModButton.Enabled = false;
settingsProfileLabel.TextColor = LauncherColors.Inactive; settingsProfileLabel.TextColor = LauncherColors.Inactive;
modSettingsProfileDropDown.Enabled = false; modSettingsProfileDropDown.Enabled = false;
@ -792,12 +792,12 @@ public partial class MainForm : Form
/// </summary> /// </summary>
private void ModSettingsProfileDropDownSelectedIndexChanged(object sender, EventArgs e) private void ModSettingsProfileDropDownSelectedIndexChanged(object sender, EventArgs e)
{ {
if (modSettingsProfileDropDown.SelectedIndex == -1 && modSettingsProfileDropDown.Items.Count == 0) return; if (modSettingsProfileDropDown.SelectedIndex == -1 && !modSettingsProfileDropDown.DataStore.Any()) return;
string profileName = modSettingsProfileDropDown.Items[modSettingsProfileDropDown.SelectedIndex].Text; string profileName = modSettingsProfileDropDown.SelectedKey;
log.Info("SettingsProfileDropDown.SelectedIndex has been changed to " + modSettingsProfileDropDown.SelectedIndex + "."); log.Info("SettingsProfileDropDown.SelectedIndex has been changed to " + modSettingsProfileDropDown.SelectedIndex + ".");
if (modSettingsProfileDropDown.SelectedIndex <= 0 || modSettingsProfileDropDown.Items.Count == 0) if (modSettingsProfileDropDown.SelectedIndex <= 0 || !modSettingsProfileDropDown.DataStore.Any())
{ {
deleteModButton.Enabled = false; deleteModButton.Enabled = false;
deleteModButton.ToolTip = null; deleteModButton.ToolTip = null;

@ -1,5 +1,6 @@
using Eto.Drawing; using Eto.Drawing;
using System; using System;
using System.Linq;
using AM2RLauncherLib; using AM2RLauncherLib;
using AM2RLauncherLib.XML; using AM2RLauncherLib.XML;
using AM2RLauncher.Language; using AM2RLauncher.Language;
@ -167,7 +168,7 @@ public partial class MainForm
private void UpdateModSettingsState() private void UpdateModSettingsState()
{ {
// Safety check // Safety check
if (modSettingsProfileDropDown == null || modSettingsProfileDropDown.Items.Count <= 0) return; if (modSettingsProfileDropDown == null || modSettingsProfileDropDown.DataStore.Any()) return;
bool enabled = false; bool enabled = false;
switch (updateState) switch (updateState)
@ -183,7 +184,7 @@ public partial class MainForm
} }
if (apkButtonState == ApkButtonState.Creating) enabled = false; if (apkButtonState == ApkButtonState.Creating) enabled = false;
string selectedProfileName = modSettingsProfileDropDown.Items[modSettingsProfileDropDown.SelectedIndex].Text; string selectedProfileName = modSettingsProfileDropDown.SelectedKey;
settingsProfileLabel.TextColor = LauncherColors.Green; settingsProfileLabel.TextColor = LauncherColors.Green;
modSettingsProfileDropDown.Enabled = enabled; modSettingsProfileDropDown.Enabled = enabled;
@ -205,16 +206,12 @@ public partial class MainForm
} }
Color col = enabled ? LauncherColors.Green : LauncherColors.Inactive; Color col = enabled ? LauncherColors.Green : LauncherColors.Inactive;
if (OS.IsWindows) if (OS.IsWindows)
modSettingsProfileDropDown.TextColor = col; modSettingsProfileDropDown.TextColor = col;
settingsProfileLabel.TextColor = col; settingsProfileLabel.TextColor = col;
if (enabled)
modSettingsProfileDropDown.SelectedIndex = profileDropDown.SelectedIndex;
} }
/// <summary> /// <summary>

@ -552,7 +552,7 @@ public partial class MainForm : Form
if (OS.IsLinux) if (OS.IsLinux)
modSettingsProfileDropDown = new DropDown(); modSettingsProfileDropDown = new DropDown();
modSettingsProfileDropDown.DataStore = profileDropDown.DataStore; // It's actually more comfortable if it's outside, because of GTK shenanigans modSettingsProfileDropDown.DataStore = profileDropDown.DataStore;
modSettingsProfileDropDown.Bind(m => m.SelectedIndex, profileDropDown, p => p.SelectedIndex); modSettingsProfileDropDown.Bind(m => m.SelectedIndex, profileDropDown, p => p.SelectedIndex);
desktopShortcutButton = new SmallColorButton(Text.CreateShortcut); desktopShortcutButton = new SmallColorButton(Text.CreateShortcut);

Loading…
Cancel
Save