v2rayN/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs

33 lines
733 B
C#

using Avalonia.Controls;
using Avalonia.Threading;
using DialogHostAvalonia;
namespace v2rayN.Desktop.Views;
public partial class SudoPasswordInputView : UserControl
{
public SudoPasswordInputView()
{
InitializeComponent();
this.Loaded += (s, e) => txtPassword.Focus();
btnSave.Click += (_, _) =>
{
if (string.IsNullOrEmpty(txtPassword.Text))
{
txtPassword.Focus();
return;
}
Dispatcher.UIThread.Post(() =>
{
DialogHost.Close(null, txtPassword.Text);
});
};
btnCancel.Click += (_, _) =>
{
DialogHost.Close(null);
};
}
}