CollabVMDesktopClient/CollabVMClient/Views/AddServer.axaml.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2023-08-29 08:52:35 -04:00
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();
}
}
}