gemini icon indicating copy to clipboard operation
gemini copied to clipboard

How to add login screen before main window show up

Open gladxiao2015 opened this issue 10 years ago • 1 comments

user can input name and password. and do some authentication

gladxiao2015 avatar Sep 21 '15 09:09 gladxiao2015

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;
        }

Kibnet avatar Aug 12 '16 07:08 Kibnet