gemini
gemini copied to clipboard
How to add login screen before main window show up
user can input name and password. and do some authentication
This code to work.
public Task<LoginDialogData> ShowLoginAsync(LoginDialogSettings settings = null)
{
TaskCompletionSource<LoginDialogData> tcs = new TaskCompletionSource<LoginDialogData>();
Application.Current.Dispatcher.InvokeAsync((Action)(async () =>
{
var mainview = Application.Current.MainWindow as MetroWindow;
var result = await mainview.ShowLoginAsync("Login", "Enter you name and password", settings ?? defaultLoginDialogSettings);
tcs.SetResult(result);
if(result!= null)
defaultLoginDialogSettings.InitialUsername = result?.Username;
}), DispatcherPriority.Normal, new CancellationToken());
return tcs.Task;
}