This commit is contained in:
23
DiscordBotGUI/Settings/ApplicationVariables.axaml
Normal file
23
DiscordBotGUI/Settings/ApplicationVariables.axaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="DiscordBotGUI.Settings.ApplicationVariables"
|
||||
Title="ApplicationVariables">
|
||||
<StackPanel>
|
||||
<Label Content="Available commands"/>
|
||||
<TextBox x:Name="textBox1" x:Class="DiscordBotGUI.Settings.ApplicationVariables"/>
|
||||
<Label Content="Insert a new variable"/>
|
||||
<Border Background="White" BorderThickness="3" Margin="10"/>
|
||||
<Label Content="New Variable Name"/>
|
||||
<TextBox x:Name="textBox2" x:Class="DiscordBotGUI.Settings.ApplicationVariables"/>
|
||||
<Label Content="New Variable Value"/>
|
||||
<TextBox x:Name="textBox3" x:Class="DiscordBotGUI.Settings.ApplicationVariables"/>
|
||||
<Label Content="New Variable IsReadOnly"/>
|
||||
<CheckBox x:Class="DiscordBotGUI.Settings.ApplicationVariables" x:Name="checkBox1"/>
|
||||
<Button Content="Add command" x:Class="DiscordBotGUI.Settings.ApplicationVariables" x:Name="button1"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
</Window>
|
||||
44
DiscordBotGUI/Settings/ApplicationVariables.axaml.cs
Normal file
44
DiscordBotGUI/Settings/ApplicationVariables.axaml.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using PluginManager;
|
||||
|
||||
namespace DiscordBotGUI.Settings
|
||||
{
|
||||
public partial class ApplicationVariables : Window
|
||||
{
|
||||
public ApplicationVariables()
|
||||
{
|
||||
InitializeComponent();
|
||||
Load();
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
ClearEverything();
|
||||
button1.Click += (sedner, e) =>
|
||||
{
|
||||
string key = textBox2.Text;
|
||||
if (Config.ContainsKey(key))
|
||||
{
|
||||
ClearEverything();
|
||||
return;
|
||||
}
|
||||
|
||||
string value = textBox3.Text;
|
||||
Config.AddValueToVariables(key, value, checkBox1.IsChecked!.Value);
|
||||
ClearEverything();
|
||||
};
|
||||
}
|
||||
|
||||
private void ClearEverything()
|
||||
{
|
||||
textBox1.Text = "";
|
||||
textBox2.Text = "";
|
||||
textBox3.Text = "";
|
||||
checkBox1.IsChecked = false;
|
||||
var allvars = Config.GetAllVariables();
|
||||
foreach (var kvp in allvars) textBox1.Text += kvp.Key + " => " + kvp.Value + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user