Esempio n. 1
0
        private void LoginOnClosing(object sender, CancelEventArgs cancelEventArgs)
        {
            var dialog = sender as Login;

            if (dialog != null)
            {
                var vm = dialog.DataContext as LoginViewModel;
                if (vm != null)
                {
                    if (vm.DialogResult == DialogResult.OK)
                    {
                        try
                        {
                            ExchangeManager.LoadSettings(vm.Password);
                            OnSettingsLoaded();
                        }
                        catch
                        {
                            vm.PasswordWrongVisibility = Visibility.Visible;
                            cancelEventArgs.Cancel     = true;
                            vm.DialogResult            = DialogResult.None;
                        }
                    }
                    if (vm.DialogResult == DialogResult.Cancel)
                    {
                        dialog.Closing -= LoginOnClosing;
                    }
                }
            }
        }