Renamed DeepL mode setting
This commit is contained in:
		
							parent
							
								
									87c12de066
								
							
						
					
					
						commit
						b74367aa6f
					
				@ -1,6 +1,6 @@
 | 
			
		||||
namespace DataModel.Database;
 | 
			
		||||
 | 
			
		||||
public enum SettingDeepL
 | 
			
		||||
public enum SettingDeepLMode
 | 
			
		||||
{
 | 
			
		||||
    DISABLED,
 | 
			
		||||
    
 | 
			
		||||
@ -9,7 +9,7 @@ public static class AppSettings
 | 
			
		||||
{
 | 
			
		||||
    #region DeepL Mode
 | 
			
		||||
 | 
			
		||||
    public static async Task SetDeepLMode(SettingDeepL mode)
 | 
			
		||||
    public static async Task SetDeepLMode(SettingDeepLMode mode)
 | 
			
		||||
    {
 | 
			
		||||
        // Convert the enum to its int value:
 | 
			
		||||
        var intValue = (int)mode;
 | 
			
		||||
@ -38,26 +38,26 @@ public static class AppSettings
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static async Task<SettingDeepL> GetDeepLMode()
 | 
			
		||||
    public static async Task<SettingDeepLMode> GetDeepLMode()
 | 
			
		||||
    {
 | 
			
		||||
        // Get the database:
 | 
			
		||||
        await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
 | 
			
		||||
        
 | 
			
		||||
        // Check, if the setting is already set:
 | 
			
		||||
        if (await db.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.DEEPL_MODE) is { } existingSetting)
 | 
			
		||||
            return (SettingDeepL) existingSetting.IntegerValue;
 | 
			
		||||
            return (SettingDeepLMode) existingSetting.IntegerValue;
 | 
			
		||||
 | 
			
		||||
        // Does not exist, so create it:
 | 
			
		||||
        var setting = new Setting
 | 
			
		||||
        {
 | 
			
		||||
            Code = SettingNames.DEEPL_MODE,
 | 
			
		||||
            IntegerValue = (int)SettingDeepL.DISABLED,
 | 
			
		||||
            IntegerValue = (int)SettingDeepLMode.DISABLED,
 | 
			
		||||
        };
 | 
			
		||||
            
 | 
			
		||||
        await db.Settings.AddAsync(setting);
 | 
			
		||||
        await db.SaveChangesAsync();
 | 
			
		||||
        
 | 
			
		||||
        return (SettingDeepL) setting.IntegerValue;
 | 
			
		||||
        return (SettingDeepLMode) setting.IntegerValue;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
@ -60,9 +60,9 @@ public partial class Setting : UserControl
 | 
			
		||||
                dropdown.Items.Add("Pro version");
 | 
			
		||||
                dropdown.SelectedIndex = currentSetting switch
 | 
			
		||||
                {
 | 
			
		||||
                    SettingDeepL.DISABLED => 0,
 | 
			
		||||
                    SettingDeepL.USE_FREE_ACCOUNT => 1,
 | 
			
		||||
                    SettingDeepL.USE_PRO_ACCOUNT => 2,
 | 
			
		||||
                    SettingDeepLMode.DISABLED => 0,
 | 
			
		||||
                    SettingDeepLMode.USE_FREE_ACCOUNT => 1,
 | 
			
		||||
                    SettingDeepLMode.USE_PRO_ACCOUNT => 2,
 | 
			
		||||
 | 
			
		||||
                    _ => 0,
 | 
			
		||||
                };
 | 
			
		||||
@ -70,11 +70,11 @@ public partial class Setting : UserControl
 | 
			
		||||
                // Setup the change event handler:
 | 
			
		||||
                dropdown.SelectedValueChanged += async (sender, args) => await AppSettings.SetDeepLMode(dropdown.SelectedIndex switch
 | 
			
		||||
                {
 | 
			
		||||
                    0 => SettingDeepL.DISABLED,
 | 
			
		||||
                    1 => SettingDeepL.USE_FREE_ACCOUNT,
 | 
			
		||||
                    2 => SettingDeepL.USE_PRO_ACCOUNT,
 | 
			
		||||
                    0 => SettingDeepLMode.DISABLED,
 | 
			
		||||
                    1 => SettingDeepLMode.USE_FREE_ACCOUNT,
 | 
			
		||||
                    2 => SettingDeepLMode.USE_PRO_ACCOUNT,
 | 
			
		||||
 | 
			
		||||
                    _ => SettingDeepL.DISABLED,
 | 
			
		||||
                    _ => SettingDeepLMode.DISABLED,
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                // Apply the desired layout:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user