This commit is contained in:
2022-06-07 11:13:03 +03:00
parent 195c082cd7
commit c66ff52d94
8 changed files with 131 additions and 31 deletions

View 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>

View 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";
}
}
}