Esempio n. 1
0
        private void LoadTaskbarIcon(TrayIconViewModel trayVm, AuthenticationDialog authDialog)
        {
            trayVm.OnExitApplication         += (s, e) => Application.Current.Shutdown();
            trayVm.OnAuthenticationRequested += (s, e) => authDialog.Show();

            _tb.DataContext = trayVm;
            _tb?.BringIntoView();
        }
Esempio n. 2
0
        public async Task <bool> RequestAuthentication()
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                _dialog.Show();
            });
            // This is a little clunky - block the whole thread from continuing until the close event is triggered

            var result = await Observable.FromEventPattern <AuthenticationDialogEventArgs>(
                h => _vm.OnAuthenticationCompleted += h,
                h => _vm.OnAuthenticationCompleted -= h
                )
                         .Select(x => x.EventArgs.AuthenticationSuccess)
                         .FirstAsync();

            Application.Current.Dispatcher.Invoke(() =>
            {
                _dialog.Hide();
            });

            return(result);
        }