This commit is contained in:
@@ -16,6 +16,7 @@ namespace DiscordBotGUI
|
||||
public AppUpdater()
|
||||
{
|
||||
InitializeComponent();
|
||||
Config.LoadConfig().Wait();
|
||||
if (!File.Exists("./Version.txt"))
|
||||
{
|
||||
File.WriteAllText("./Version.txt", "DiscordBotVersion=0");
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
<MenuItem Header="Plugins">
|
||||
<MenuItem Header="Commands" x:Class="DiscordBotGUI.MainWindow" x:Name="commandsSettingMenuItem" />
|
||||
<MenuItem Header="Events" x:Class="DiscordBotGUI.MainWindow" x:Name="eventsSettingMenuItem" />
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Application Variables" x:Class="DiscordBotGUI.MainWindow" x:Name="applicationVariablesMenuItem"/>
|
||||
</Menu>
|
||||
<Label x:Class="DiscordBotGUI.MainWindow" x:Name="label1" Content="Discord Token" />
|
||||
<TextBox x:Class="DiscordBotGUI.MainWindow" x:Name="textBox1" IsReadOnly="True" TextAlignment="Center" Text=""/>
|
||||
|
||||
@@ -23,8 +23,6 @@ namespace DiscordBotGUI
|
||||
|
||||
private void LoadElements()
|
||||
{
|
||||
|
||||
|
||||
textBox3.Watermark = "Insert start arguments";
|
||||
if (File.Exists("./Version.txt")) label5.Content = Config.GetValue("Version");
|
||||
button1.Click += async (sender, e) =>
|
||||
@@ -48,9 +46,9 @@ namespace DiscordBotGUI
|
||||
|
||||
};
|
||||
|
||||
commandsSettingMenuItem.Click += (sender, e) => new Commands() /*{ Height = 200, Width = 550 }*/.ShowDialog(this);
|
||||
eventsSettingMenuItem.Click += (sender, e) => new Events() /*{ Height = 200, Width = 550 }*/.ShowDialog(this);
|
||||
|
||||
commandsSettingMenuItem.Click += (sender, e) => new Commands() /*{ Height = 200, Width = 550 }*/.ShowDialog(this);
|
||||
eventsSettingMenuItem.Click += (sender, e) => new Events() /*{ Height = 200, Width = 550 }*/.ShowDialog(this);
|
||||
applicationVariablesMenuItem.Click += (sender, e) => new ApplicationVariables().ShowDialog(this);
|
||||
|
||||
string folder = $"{Functions.dataFolder}DiscordBotCore.data";
|
||||
Directory.CreateDirectory(Functions.dataFolder);
|
||||
|
||||
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