mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Added a log level droplist
This commit is contained in:
parent
708031dcbb
commit
430bfe7bbb
21 changed files with 224 additions and 59 deletions
|
|
@ -33,6 +33,7 @@ namespace ServerManagerTool
|
|||
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelist>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
|
||||
public GlobalSettingsControl()
|
||||
|
|
@ -43,7 +44,11 @@ namespace ServerManagerTool
|
|||
this.CommonConfig = CommonConfig.Default;
|
||||
this.DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
PopulateWindowsStatesComboBox();
|
||||
PopulateDiscordBotLogLevelsComboBox();
|
||||
|
||||
DiscordBotWhitelist = new List<DiscordBotWhitelist>();
|
||||
if (Config.DiscordBotWhitelist != null)
|
||||
|
|
@ -54,9 +59,6 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
this.IsAdministrator = SecurityUtils.IsAdministrator();
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +92,12 @@ namespace ServerManagerTool
|
|||
set { SetValue(WindowStatesProperty, value); }
|
||||
}
|
||||
|
||||
public ComboBoxItemList DiscordBotLogLevels
|
||||
{
|
||||
get { return (ComboBoxItemList)GetValue(DiscordBotLogLevelsProperty); }
|
||||
set { SetValue(DiscordBotLogLevelsProperty, value); }
|
||||
}
|
||||
|
||||
public List<DiscordBotWhitelist> DiscordBotWhitelist
|
||||
{
|
||||
get { return (List<DiscordBotWhitelist>)GetValue(DiscordBotWhitelistProperty); }
|
||||
|
|
@ -476,21 +484,39 @@ namespace ServerManagerTool
|
|||
private void PopulateWindowsStatesComboBox()
|
||||
{
|
||||
var selectedValue = this.WindowStateComboBox?.SelectedValue ?? Config.MainWindow_WindowState;
|
||||
var windowStates = new ComboBoxItemList();
|
||||
var comboBoxList = new ComboBoxItemList();
|
||||
|
||||
foreach (WindowState windowState in Enum.GetValues(typeof(WindowState)))
|
||||
{
|
||||
var displayMember = _globalizer.GetResourceString($"WindowState_{windowState}") ?? windowState.ToString();
|
||||
windowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
|
||||
comboBoxList.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
|
||||
}
|
||||
|
||||
this.WindowStates = windowStates;
|
||||
this.WindowStates = comboBoxList;
|
||||
if (this.WindowStateComboBox != null)
|
||||
{
|
||||
this.WindowStateComboBox.SelectedValue = selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void PopulateDiscordBotLogLevelsComboBox()
|
||||
{
|
||||
var selectedValue = this.DiscordBotLogLevelComboBox?.SelectedValue ?? Config.DiscordBotLogLevel;
|
||||
var comboBoxList = new ComboBoxItemList();
|
||||
|
||||
foreach (DiscordBot.Enums.LogLevel logLevel in Enum.GetValues(typeof(DiscordBot.Enums.LogLevel)))
|
||||
{
|
||||
var displayMember = _globalizer.GetResourceString($"DiscordBotLogLevel_{logLevel}") ?? logLevel.ToString();
|
||||
comboBoxList.Add(new Common.Model.ComboBoxItem(logLevel.ToString(), displayMember));
|
||||
}
|
||||
|
||||
this.DiscordBotLogLevels = comboBoxList;
|
||||
if (this.DiscordBotLogLevelComboBox != null)
|
||||
{
|
||||
this.DiscordBotLogLevelComboBox.SelectedValue = selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
#region Discord Bot Whitelist
|
||||
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue