/// <summary> /// Creates a server entry creator. /// </summary> public NewServerEntry() { // Load the XAML. AvaloniaXamlLoader.Load(this); this.inputs = this.Get <StackPanel>("Inputs"); this.serverNameInput = this.Get <TextBox>("ServerNameInput"); this.serverAddressInput = this.Get <TextBox>("ServerAddressInput"); this.addButton = this.Get <RoundedButton>("AddButton"); this.cancelButton = this.Get <ImageButton>("CancelButton"); // Connect the inputs. this.addButton.ButtonPressed += (sender, args) => { if (this.addingOpen) { // Add the entry if the inputs are valid. if (this.addButton.Active) { // Add the entry. PersistentState.AddServerEntry(this.serverNameInput.Text.Trim(), this.serverAddressInput.Text.Trim()); // Clear the inputs. this.serverNameInput.Text = ""; this.serverAddressInput.Text = ""; // Close adding. this.addingOpen = false; this.Update(); } } else { // Open adding. this.addingOpen = true; this.Update(); } }; this.cancelButton.ButtonPressed += (sender, args) => { // Clear the inputs. this.serverNameInput.Text = ""; this.serverAddressInput.Text = ""; // Close adding. this.addingOpen = false; this.Update(); }; this.serverNameInput.PropertyChanged += (sender, args) => { this.Update(); }; this.serverAddressInput.PropertyChanged += (sender, args) => { this.Update(); }; // Update the initial display. this.Update(); }