@ -4,380 +4,379 @@ using AM2RLauncherLib;
using AM2RLauncherLib.XML ;
using AM2RLauncherLib.XML ;
using AM2RLauncher.Language ;
using AM2RLauncher.Language ;
namespace AM2RLauncher
namespace AM2RLauncher ;
/// <summary>
/// Everything UI/Form state machine-related goes in here
/// </summary>
public partial class MainForm
{
{
/// <summary>
/// <summary>
/// Everything UI/Form state machine-related goes in here
/// Updates <see cref="updateState"/>, <see cref="playButton"/>, <see cref="apkButtonState"/>, and <see cref="apkButton"/> according to the current conditions.
/// </summary>
private void UpdateStateMachine ( )
{
UpdatePlayState ( ) ;
UpdateApkState ( ) ;
UpdateProfileState ( ) ;
UpdateModSettingsState ( ) ;
}
/// <summary>
/// Determines current conditions and calls <see cref="SetPlayButtonState(PlayButtonState)"/> accordingly.
/// </summary>
/// </summary>
public partial class MainForm
p rivate void UpdatePlayState ( )
{
{
/// <summary>
// If we're downloading or installing, don't change anything
/// Updates <see cref="updateState"/>, <see cref="playButton"/>, <see cref="apkButtonState"/>, and <see cref="apkButton"/> according to the current conditions.
if ( ( updateState = = PlayButtonState . Downloading ) | | ( updateState = = PlayButtonState . Installing ) )
/// </summary>
return ;
private void UpdateStateMachine ( )
// If we're currently creating an APK, we disable the play button
if ( apkButtonState = = ApkButtonState . Creating )
{
{
UpdatePlayState ( ) ;
playButton . Enabled = false ;
UpdateApkState ( ) ;
return ;
UpdateProfileState ( ) ;
UpdateModSettingsState ( ) ;
}
}
/// <summary>
playButton . Enabled = true ;
/// Determines current conditions and calls <see cref="SetPlayButtonState(PlayButtonState)"/> accordingly.
// If PatchData isn't cloned, we still need to download
/// </summary>
if ( ! Profile . IsPatchDataCloned ( ) )
private void UpdatePlayState ( )
{
{
// If we're downloading or installing, don't change anything
SetPlayButtonState ( PlayButtonState . Download ) ;
if ( ( updateState = = PlayButtonState . Downloading ) | | ( updateState = = PlayButtonState . Installing ) )
return ;
return ;
}
// If we're currently creating an APK, we disable the play button
if ( apkButtonState = = ApkButtonState . Creating )
{
playButton . Enabled = false ;
return ;
}
playButton . Enabled = true ;
// If PatchData isn't cloned, we still need to download
if ( ! Profile . IsPatchDataCloned ( ) )
{
SetPlayButtonState ( PlayButtonState . Download ) ;
return ;
}
// If 1.1 isn't installed, we still need to select it
if ( ! Profile . Is11Installed ( ) )
{
SetPlayButtonState ( PlayButtonState . Select11 ) ;
return ;
}
var isProfileValid = IsProfileIndexValid ( ) ;
// If current profile is installed, we're ready to play!
if ( isProfileValid & & Profile . IsProfileInstalled ( profileList [ profileIndex . Value ] ) )
{
SetPlayButtonState ( PlayButtonState . Play ) ;
return ;
}
// Otherwise, if profile is NOT installable, we delete the profile because we can't install it and therefore holds no value!
if ( isProfileValid & & profileList [ profileIndex . Value ] . Installable = = false )
{
DeleteProfileAndAdjustLists ( profileList [ profileIndex . Value ] ) ;
return ;
}
// Otherwise, we still need to install.
// If 1.1 isn't installed, we still need to select it
SetPlayButtonState ( PlayButtonState . Install ) ;
if ( ! Profile . Is11Installed ( ) )
{
SetPlayButtonState ( PlayButtonState . Select11 ) ;
return ;
}
}
/// <summary>
var isProfileValid = IsProfileIndexValid ( ) ;
/// Determines current conditions and enables or disables <see cref="apkButton"/> accordingly.
// If current profile is installed, we're ready to play!
/// </summary>
if ( isProfileValid & & Profile . IsProfileInstalled ( profileList [ profileIndex . Value ] ) )
private void UpdateApkState ( )
{
{
// Safety check
SetPlayButtonState ( PlayButtonState . Play ) ;
if ( apkButton = = null )
return ;
return ;
}
// Otherwise, if profile is NOT installable, we delete the profile because we can't install it and therefore holds no value!
if ( isProfileValid & & profileList [ profileIndex . Value ] . Installable = = false )
{
DeleteProfileAndAdjustLists ( profileList [ profileIndex . Value ] ) ;
return ;
}
// Our default values
// Otherwise, we still need to install.
apkButton . Enabled = false ;
SetPlayButtonState ( PlayButtonState . Install ) ;
apkButton . ToolTip = Text . ApkButtonDisabledToolTip ;
}
// If profile supports Android and if we are NOT already creating an APK...
/// <summary>
if ( ! IsProfileIndexValid ( ) )
/// Determines current conditions and enables or disables <see cref="apkButton"/> accordingly.
return ;
/// </summary>
private void UpdateApkState ( )
{
// Safety check
if ( apkButton = = null )
return ;
var profile = profileList [ profileIndex . Value ] ;
// Our default values
if ( ! profile . SupportsAndroid | | ! profile . Installable | | apkButtonState ! = ApkButtonState . Create )
apkButton . Enabled = false ;
return ;
apkButton . ToolTip = Text . ApkButtonDisabledToolTip ;
// Switch status based on main button's state
// If profile supports Android and if we are NOT already creating an APK...
switch ( updateState )
if ( ! IsProfileIndexValid ( ) )
{
return ;
case PlayButtonState . Download :
case PlayButtonState . Downloading :
var profile = profileList [ profileIndex . Value ] ;
case PlayButtonState . Select11 :
if ( ! profile . SupportsAndroid | | ! profile . Installable | | apkButtonState ! = ApkButtonState . Create )
case PlayButtonState . Installing :
return ;
case PlayButtonState . Playing : return ;
// Switch status based on main button's state
case PlayButtonState . Install :
switch ( updateState )
case PlayButtonState . Play : apkButton . Enabled = true ; apkButton . ToolTip = HelperMethods . GetText ( Text . ApkButtonEnabledToolTip , profileDropDown ? . Items [ profileDropDown . SelectedIndex ] ? . Text ? ? "" ) ; break ;
{
}
case PlayButtonState . Download :
case PlayButtonState . Downloading :
case PlayButtonState . Select11 :
case PlayButtonState . Installing :
case PlayButtonState . Playing : return ;
case PlayButtonState . Install :
case PlayButtonState . Play : apkButton . Enabled = true ; apkButton . ToolTip = HelperMethods . GetText ( Text . ApkButtonEnabledToolTip , profileDropDown ? . Items [ profileDropDown . SelectedIndex ] ? . Text ? ? "" ) ; break ;
}
}
}
/// <summary>
/// <summary>
/// Determines current conditions and enables or disables the <see cref="profileDropDown"/> and related controls accordingly.
/// Determines current conditions and enables or disables the <see cref="profileDropDown"/> and related controls accordingly.
/// </summary>
/// </summary>
private void UpdateProfileState ( )
private void UpdateProfileState ( )
{
// Safety check
if ( profileDropDown = = null )
return ;
switch ( updateState )
{
{
// Safety check
case PlayButtonState . Download :
if ( profileDropDown = = null )
case PlayButtonState . Downloading :
return ;
case PlayButtonState . Select11 :
switch ( updateState )
case PlayButtonState . Installing :
{
case PlayButtonState . Playing : profileDropDown . Enabled = false ; break ;
case PlayButtonState . Download :
case PlayButtonState . Downloading :
case PlayButtonState . Select11 :
case PlayButtonState . Installing :
case PlayButtonState . Playing : profileDropDown . Enabled = false ; break ;
case PlayButtonState . Install :
case PlayButtonState . Install :
case PlayButtonState . Play : profileDropDown . Enabled = true ; break ;
case PlayButtonState . Play : profileDropDown . Enabled = true ; break ;
}
}
if ( apkButtonState = = ApkButtonState . Creating ) profileDropDown . Enabled = false ;
if ( apkButtonState = = ApkButtonState . Creating ) profileDropDown . Enabled = false ;
Color col = profileDropDown . Enabled ? colGreen : colInactive ;
Color col = profileDropDown . Enabled ? colGreen : colInactive ;
if ( OS . IsWindows )
if ( OS . IsWindows )
profileDropDown . TextColor = col ;
profileDropDown . TextColor = col ;
profileAuthorLabel . TextColor = col ;
profileAuthorLabel . TextColor = col ;
profileVersionLabel . TextColor = col ;
profileVersionLabel . TextColor = col ;
profileLabel . TextColor = col ;
profileLabel . TextColor = col ;
}
}
/// <summary>
/// <summary>
/// Determines current conditions and enables or disabled the mainPage controls accordingly.
/// Determines current conditions and enables or disabled the mainPage controls accordingly.
/// </summary>
/// </summary>
private void UpdateModSettingsState ( )
private void UpdateModSettingsState ( )
{
{
// Safety check
// Safety check
if ( modSettingsProfileDropDown = = null | | modSettingsProfileDropDown . Items . Count < = 0 ) return ;
if ( modSettingsProfileDropDown = = null | | modSettingsProfileDropDown . Items . Count < = 0 ) return ;
bool enabled = false ;
bool enabled = false ;
switch ( updateState )
switch ( updateState )
{
{
case PlayButtonState . Download :
case PlayButtonState . Download :
case PlayButtonState . Downloading :
case PlayButtonState . Downloading :
case PlayButtonState . Select11 :
case PlayButtonState . Select11 :
case PlayButtonState . Installing :
case PlayButtonState . Installing :
case PlayButtonState . Playing : enabled = false ; break ;
case PlayButtonState . Playing : enabled = false ; break ;
case PlayButtonState . Install :
case PlayButtonState . Install :
case PlayButtonState . Play : enabled = true ; break ;
case PlayButtonState . Play : enabled = true ; break ;
}
}
if ( apkButtonState = = ApkButtonState . Creating ) enabled = false ;
if ( apkButtonState = = ApkButtonState . Creating ) enabled = false ;
string selectedProfileName = modSettingsProfileDropDown . Items [ modSettingsProfileDropDown . SelectedIndex ] . Text ;
string selectedProfileName = modSettingsProfileDropDown . Items [ modSettingsProfileDropDown . SelectedIndex ] . Text ;
settingsProfileLabel . TextColor = colGreen ;
settingsProfileLabel . TextColor = colGreen ;
modSettingsProfileDropDown . Enabled = enabled ;
modSettingsProfileDropDown . Enabled = enabled ;
profileButton . Enabled = enabled ;
profileButton . Enabled = enabled ;
profileButton . ToolTip = HelperMethods . GetText ( Text . OpenProfileFolderToolTip , selectedProfileName ) ;
profileButton . ToolTip = HelperMethods . GetText ( Text . OpenProfileFolderToolTip , selectedProfileName ) ;
saveButton . Enabled = enabled ;
saveButton . Enabled = enabled ;
saveButton . ToolTip = HelperMethods . GetText ( Text . OpenSaveFolderToolTip , selectedProfileName ) ;
saveButton . ToolTip = HelperMethods . GetText ( Text . OpenSaveFolderToolTip , selectedProfileName ) ;
addModButton . Enabled = enabled ;
addModButton . Enabled = enabled ;
addModButton . ToolTip = Text . AddNewModToolTip ;
addModButton . ToolTip = Text . AddNewModToolTip ;
// Only enable these, when we're not on the community updates
// Only enable these, when we're not on the community updates
if ( modSettingsProfileDropDown . SelectedIndex > 0 )
if ( modSettingsProfileDropDown . SelectedIndex > 0 )
{
{
updateModButton . Enabled = profileList [ modSettingsProfileDropDown . SelectedIndex ] . Installable ;
updateModButton . Enabled = profileList [ modSettingsProfileDropDown . SelectedIndex ] . Installable ;
updateModButton . ToolTip = HelperMethods . GetText ( Text . UpdateModButtonToolTip , selectedProfileName ) ;
updateModButton . ToolTip = HelperMethods . GetText ( Text . UpdateModButtonToolTip , selectedProfileName ) ;
deleteModButton . Enabled = enabled ;
deleteModButton . Enabled = enabled ;
deleteModButton . ToolTip = HelperMethods . GetText ( Text . DeleteModButtonToolTip , selectedProfileName ) ;
deleteModButton . ToolTip = HelperMethods . GetText ( Text . DeleteModButtonToolTip , selectedProfileName ) ;
}
}
Color col = enabled ? colGreen : colInactive ;
Color col = enabled ? colGreen : colInactive ;
if ( OS . IsWindows )
if ( OS . IsWindows )
modSettingsProfileDropDown . TextColor = col ;
modSettingsProfileDropDown . TextColor = col ;
settingsProfileLabel . TextColor = col ;
settingsProfileLabel . TextColor = col ;
if ( enabled )
if ( enabled )
modSettingsProfileDropDown . SelectedIndex = profileDropDown . SelectedIndex ;
modSettingsProfileDropDown . SelectedIndex = profileDropDown . SelectedIndex ;
}
}
/// <summary>
/// <summary>
/// Sets the global <see cref="updateState"/> and then changes the state of <see cref="playButton"/> accordingly.
/// Sets the global <see cref="updateState"/> and then changes the state of <see cref="playButton"/> accordingly.
/// </summary>
/// </summary>
/// <param name="state">The state that should be set to.</param>
/// <param name="state">The state that should be set to.</param>
private void SetPlayButtonState ( PlayButtonState state )
private void SetPlayButtonState ( PlayButtonState state )
{
updateState = state ;
switch ( updateState )
{
{
updateState = state ;
case PlayButtonState . Download :
switch ( updateState )
case PlayButtonState . Downloading :
{
case PlayButtonState . Select11 :
case PlayButtonState . Download :
case PlayButtonState . Install :
case PlayButtonState . Downloading :
case PlayButtonState . Play : playButton . Enabled = true ; break ;
case PlayButtonState . Select11 :
case PlayButtonState . Install :
case PlayButtonState . Installing :
case PlayButtonState . Play : playButton . Enabled = true ; break ;
case PlayButtonState . Playing : playButton . Enabled = false ; break ;
}
case PlayButtonState . Installing :
playButton . Text = GetPlayButtonText ( ) ;
case PlayButtonState . Playing : playButton . Enabled = false ; break ;
playButton . ToolTip = GetPlayButtonTooltip ( ) ;
}
playButton . Text = GetPlayButtonText ( ) ;
playButton . ToolTip = GetPlayButtonTooltip ( ) ;
playButton . Invalidate ( ) ;
playButton . Invalidate ( ) ;
UpdateModSettingsState ( ) ;
UpdateModSettingsState ( ) ;
}
}
/// <summary>
/// <summary>
/// Sets the global <see cref="apkButtonState"/> and then changes the state of <see cref="apkButton"/> accordingly.
/// Sets the global <see cref="apkButtonState"/> and then changes the state of <see cref="apkButton"/> accordingly.
/// </summary>
/// </summary>
/// <param name="state">The state that should be set to.</param>
/// <param name="state">The state that should be set to.</param>
private void SetApkButtonState ( ApkButtonState state )
private void SetApkButtonState ( ApkButtonState state )
{
apkButtonState = state ;
switch ( apkButtonState )
{
{
apkButtonState = state ;
case ApkButtonState . Create : apkButton . Enabled = true ; break ;
switch ( apkButtonState )
case ApkButtonState . Creating : apkButton . Enabled = false ; break ;
{
case ApkButtonState . Create : apkButton . Enabled = true ; break ;
case ApkButtonState . Creating : apkButton . Enabled = false ; break ;
}
apkButton . Text = GetApkButtonText ( ) ;
}
}
apkButton . Text = GetApkButtonText ( ) ;
}
/// <summary>
/// <summary>
/// This returns the text that <see cref="playButton"/> should have depending on the global updateState.
/// This returns the text that <see cref="playButton"/> should have depending on the global updateState.
/// </summary>
/// </summary>
/// <returns>The text as a <see cref="String"/>, or <see langword="null"/> if the current State is invalid.</returns>
/// <returns>The text as a <see cref="String"/>, or <see langword="null"/> if the current State is invalid.</returns>
private string GetPlayButtonText ( )
private string GetPlayButtonText ( )
{
switch ( updateState )
{
{
switch ( updateState )
case PlayButtonState . Download : return Text . Download ;
{
case PlayButtonState . Downloading : return Text . Abort ;
case PlayButtonState . Download : return Text . Download ;
case PlayButtonState . Select11 : return Text . Select11 ;
case PlayButtonState . Downloading : return Text . Abort ;
case PlayButtonState . Install : return Text . Install ;
case PlayButtonState . Select11 : return Text . Select11 ;
case PlayButtonState . Installing : return Text . Installing ;
case PlayButtonState . Install : return Text . Install ;
case PlayButtonState . Play : return Text . Play ;
case PlayButtonState . Installing : return Text . Installing ;
case PlayButtonState . Playing : return Text . Playing ;
case PlayButtonState . Play : return Text . Play ;
default : return null ;
case PlayButtonState . Playing : return Text . Playing ;
default : return null ;
}
}
}
}
/// <summary>
/// <summary>
/// This returns the tooltip that <see cref="playButton"/> should have depending on the global updateState.
/// This returns the tooltip that <see cref="playButton"/> should have depending on the global updateState.
/// </summary>
/// </summary>
/// <returns>The tooltip as a <see cref="String"/>, or <see langword="null"/> if the current State is invalid.</returns>
/// <returns>The tooltip as a <see cref="String"/>, or <see langword="null"/> if the current State is invalid.</returns>
private string GetPlayButtonTooltip ( )
private string GetPlayButtonTooltip ( )
{
string profileName = ( ( profileDropDown ! = null ) & & ( profileDropDown . Items . Count > 0 ) ) ? profileDropDown . Items [ profileDropDown . SelectedIndex ] . Text : "" ;
switch ( updateState )
{
{
string profileName = ( ( profileDropDown ! = null ) & & ( profileDropDown . Items . Count > 0 ) ) ? profileDropDown . Items [ profileDropDown . SelectedIndex ] . Text : "" ;
case PlayButtonState . Download : return Text . PlayButtonDownloadToolTip ;
switch ( updateState )
case PlayButtonState . Downloading : return Text . PlayButtonDownloadToolTip ;
{
case PlayButtonState . Select11 : return Text . PlayButtonSelect11ToolTip ;
case PlayButtonState . Download : return Text . PlayButtonDownloadToolTip ;
case PlayButtonState . Install : return playButton . ToolTip = HelperMethods . GetText ( Text . PlayButtonInstallToolTip , profileName ) ;
case PlayButtonState . Downloading : return Text . PlayButtonDownloadToolTip ;
case PlayButtonState . Installing : return Text . PlayButtonInstallingToolTip ;
case PlayButtonState . Select11 : return Text . PlayButtonSelect11ToolTip ;
case PlayButtonState . Play : return HelperMethods . GetText ( Text . PlayButtonPlayToolTip , profileName ) ;
case PlayButtonState . Install : return playButton . ToolTip = HelperMethods . GetText ( Text . PlayButtonInstallToolTip , profileName ) ;
case PlayButtonState . Playing : return Text . PlayButtonPlayingToolTip ;
case PlayButtonState . Installing : return Text . PlayButtonInstallingToolTip ;
default : return null ;
case PlayButtonState . Play : return HelperMethods . GetText ( Text . PlayButtonPlayToolTip , profileName ) ;
case PlayButtonState . Playing : return Text . PlayButtonPlayingToolTip ;
default : return null ;
}
}
}
}
/// <summary>
/// <summary>
/// This returns the text that the apkButton should have depending on the global updateState.
/// This returns the text that the apkButton should have depending on the global updateState.
/// </summary>
/// </summary>
/// <returns>The text as a <see cref="String"/>, or <see langword="null"/> if the current State is invalid.</returns>
/// <returns>The text as a <see cref="String"/>, or <see langword="null"/> if the current State is invalid.</returns>
private string GetApkButtonText ( )
private string GetApkButtonText ( )
{
switch ( apkButtonState )
{
{
switch ( apkButtonState )
case ApkButtonState . Create : return Text . CreateAPK ;
{
case ApkButtonState . Creating : return Text . CreatingAPK ;
case ApkButtonState . Create : return Text . CreateAPK ;
default : return null ;
case ApkButtonState . Creating : return Text . CreatingAPK ;
default : return null ;
}
}
}
}
/// <summary>
/// <summary>
/// Loads valid profile entries and reloads the necessary UI components.
/// Loads valid profile entries and reloads the necessary UI components.
/// </summary>
/// </summary>
private void LoadProfilesAndAdjustLists ( )
private void LoadProfilesAndAdjustLists ( )
{
{
// Reset loaded profiles
// Reset loaded profiles
profileDropDown . Items . Clear ( ) ;
profileDropDown . Items . Clear ( ) ;
profileList . Clear ( ) ;
profileList . Clear ( ) ;
profileIndex = null ;
profileIndex = null ;
// Load the profileList
profileList = Profile . LoadProfiles ( ) ;
// Add profile names to the profileDropDown
foreach ( ProfileXML profile in profileList )
{
// Archive version notes
if ( ! profile . Installable )
{
if ( profile . Name . Contains ( "Community Updates" ) )
profile . ProfileNotes = Text . ArchiveNotesCommunityUpdates ;
else
profile . ProfileNotes = Text . ArchiveNotesMods + "\n\n" + profile . ProfileNotes ;
}
profileDropDown . Items . Add ( profile . Name ) ;
}
// Read the value from the config
string profIndexString = ReadFromConfig ( "ProfileIndex" ) ;
// Check if either no profile was found or the setting says that the last current profile didn't exist
if ( profileDropDown . Items . Count = = 0 )
profileIndex = null ;
else
{
// We know that profiles exist at this point, so we're going to point it to 0 instead so the following code doesn't fail
if ( profIndexString = = "null" )
profIndexString = "0" ;
// We parse from the settings, and check if profiles got deleted from the last time the launcher has been selected. if yes, we revert the last selection to 0;
int intParseResult = Int32 . Parse ( profIndexString ) ;
profileIndex = intParseResult ;
if ( profileIndex > = profileDropDown . Items . Count )
profileIndex = 0 ;
profileDropDown . SelectedIndex = profileIndex . Value ;
}
// Update stored profiles in the Profile Settings tab
// Load the profileList
modSettingsProfileDropDown . Items . Clear ( ) ;
profileList = Profile . LoadProfiles ( ) ;
modSettingsProfileDropDown . Items . AddRange ( profileDropDown . Items ) ;
modSettingsProfileDropDown . SelectedIndex = profileDropDown . Items . Count ! = 0 ? 0 : - 1 ;
// Refresh the author and version label on the main tab
// Add profile names to the profileDropDown
if ( profileList . Count > 0 )
foreach ( ProfileXML profile in profileList )
{
// Archive version notes
if ( ! profile . Installable )
{
{
profileAuthorLabel . Text = Text . Author + " " + profileList [ profileDropDown . SelectedIndex ] . Author ;
if ( profile . Name . Contains ( "Community Updates" ) )
profileVersionLabel . Text = Text . VersionLabel + " " + profileList [ profileDropDown . SelectedIndex ] . Version ;
profile . ProfileNotes = Text . ArchiveNotesCommunityUpdates ;
else
profile . ProfileNotes = Text . ArchiveNotesMods + "\n\n" + profile . ProfileNotes ;
}
}
log . Info ( "Reloading UI components after loading successful." ) ;
profileDropDown . Items . Add ( profile . Name ) ;
UpdateStateMachine ( ) ;
}
}
// Read the value from the config
string profIndexString = ReadFromConfig ( "ProfileIndex" ) ;
/// <summary>
// Check if either no profile was found or the setting says that the last current profile didn't exist
/// Deletes a profile and reloads the necessary UI components.
if ( profileDropDown . Items . Count = = 0 )
/// </summary>
profileIndex = null ;
/// <param name="profile">The profile to delete.</param>
else
private void DeleteProfileAndAdjustLists ( ProfileXML profile )
{
{
Profile . DeleteProfile ( profile ) ;
// We know that profiles exist at this point, so we're going to point it to 0 instead so the following code doesn't fail
LoadProfilesAndAdjustLists ( ) ;
if ( profIndexString = = "null" )
profIndexString = "0" ;
// We parse from the settings, and check if profiles got deleted from the last time the launcher has been selected. if yes, we revert the last selection to 0;
int intParseResult = Int32 . Parse ( profIndexString ) ;
profileIndex = intParseResult ;
if ( profileIndex > = profileDropDown . Items . Count )
profileIndex = 0 ;
profileDropDown . SelectedIndex = profileIndex . Value ;
}
}
private void ArchiveProfileAndAdjustLists ( ProfileXML profile )
// Update stored profiles in the Profile Settings tab
{
modSettingsProfileDropDown . Items . Clear ( ) ;
Profile . ArchiveProfile ( profile ) ;
modSettingsProfileDropDown . Items . AddRange ( profileDropDown . Items ) ;
LoadProfilesAndAdjustLists ( ) ;
modSettingsProfileDropDown . SelectedIndex = profileDropDown . Items . Count ! = 0 ? 0 : - 1 ;
}
/// <summary>Enables and changes colors for <see cref="customMirrorTextBox"/> and <see cref="mirrorDropDown"/> accordingly.</summary>
// Refresh the author and version label on the main tab
private void EnableMirrorControlsAccordingly ( )
if ( profileList . Count > 0 )
{
{
bool enabled = ( bool ) customMirrorCheck . Checked ;
profileAuthorLabel . Text = Text . Author + " " + profileList [ profileDropDown . SelectedIndex ] . Author ;
customMirrorTextBox . Enabled = enabled ;
profileVersionLabel . Text = Text . VersionLabel + " " + profileList [ profileDropDown . SelectedIndex ] . Version ;
mirrorDropDown . Enabled = ! enabled ;
// Not sure why the dropdown menu needs this hack, but the textBox does not.
//TODO: eto feature request
if ( OS . IsWindows )
mirrorDropDown . TextColor = mirrorDropDown . Enabled ? colGreen : colInactive ;
mirrorLabel . TextColor = ! enabled ? colGreen : colInactive ;
}
}
log . Info ( "Reloading UI components after loading successful." ) ;
UpdateStateMachine ( ) ;
}
/// <summary>
/// Deletes a profile and reloads the necessary UI components.
/// </summary>
/// <param name="profile">The profile to delete.</param>
private void DeleteProfileAndAdjustLists ( ProfileXML profile )
{
Profile . DeleteProfile ( profile ) ;
LoadProfilesAndAdjustLists ( ) ;
}
private void ArchiveProfileAndAdjustLists ( ProfileXML profile )
{
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 feature request
if ( OS . IsWindows )
mirrorDropDown . TextColor = mirrorDropDown . Enabled ? colGreen : colInactive ;
mirrorLabel . TextColor = ! enabled ? colGreen : colInactive ;
}
}
}
}