using Avalonia.Controls; using MsBox.Avalonia; using System; namespace CollabVMClient.Views { public partial class AddServer : Window { private string? url = null; public string? URL => url; public AddServer() { InitializeComponent(); cancel.Click += Cancel_Click; confirm.Click += Confirm_Click; } private void Confirm_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { Uri u; if (!Uri.TryCreate(urlTextBox.Text, UriKind.Absolute, out u) || (u.Scheme != "ws" && u.Scheme != "wss")) { MessageBoxManager.GetMessageBoxStandard("Error", "URL must be a valid WebSocket url.", MsBox.Avalonia.Enums.ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error).ShowWindowDialogAsync(this); return; } url = urlTextBox.Text; Close(); } private void Cancel_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { Close(); } } }