using Avalonia.Controls; using MsBox.Avalonia; using System; namespace CollabVMClient.Views { public partial class DirectConnect : Window { public DirectConnect() { InitializeComponent(); connectBtn.Click += ConnectBtn_Click; cancelBtn.Click += CancelBtn_Click; } private void CancelBtn_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { Close(); } private void ConnectBtn_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { Uri u; if (!Uri.TryCreate(url.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; } if (string.IsNullOrEmpty(node.Text)) { MessageBoxManager.GetMessageBoxStandard("Error", "Node must not be empty", MsBox.Avalonia.Enums.ButtonEnum.Ok, MsBox.Avalonia.Enums.Icon.Error).ShowWindowDialogAsync(this); return; } var cvm = new CollabVMViewer(url.Text, node.Text); cvm.Open(); Close(); } } }