public MainWindow() { InitializeComponent(); // To improve... Temporary version GalaSoft.MvvmLight.Messaging.Messenger.Default.Register <OpenWindowMessage>(this, (message) => { Window window = null; if (message.WindowToOpen == WindowsToOpen.Login) { window = new LogonWindow(); } else if (message.WindowToOpen == WindowsToOpen.MessageBox) { MessageBox.Show(message.Text, message.Caption); return; } if (window == null) { return; } if (message.IsModal) { window.ShowDialog(); return; } window.Show(); }); }
private void EnterINWindow() { if (this.dataService.LoginWindow != null) { this.dataService.LoginWindow.Close(); this.dataService.RemoveWindow(DataService.WindowType.Login); } this.dataService.INWindow = new INWindow(); if (this.dataService.INWindow != null) { INWindow inWindow = this.dataService.INWindow as INWindow; if (inWindow != null) { inWindow.Show(); LogonWindow logonWindow2 = this.dataService.LoginWindow as LogonWindow; if (logonWindow2 != null) { logonWindow2.LogonPanel.StopAnimation(); } inWindow.InitData(); this.sessionService.IsEnable = true; SystemWindow sysWindow = this.dataService.SystemWindow as SystemWindow; sysWindow.optionItem.Enabled = this.sessionService.IsEnable; sysWindow.aboutItem.Enabled = this.sessionService.IsEnable; sysWindow.logoutItem.Enabled = this.sessionService.IsEnable; } } }
private void LogonSettingHandler(object sender, RoutedEventArgs e) { try { LogonSettingWindow logonSettingWindow = WindowModel.Instance.LogonSettingWindow; this.logonWindow = (this.dataService.LoginWindow as LogonWindow); if (logonSettingWindow != null && this.logonWindow != null && this.logonWindow.IsActive) { logonSettingWindow.Owner = this.logonWindow; logonSettingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; logonSettingWindow.tbxServer.Focus(); DoubleAnimation animate = new DoubleAnimation(); animate.FillBehavior = FillBehavior.HoldEnd; animate.From = new double?(0.0); animate.To = new double?(0.5); animate.Duration = new Duration(System.TimeSpan.FromSeconds(0.8)); this.logonWindow.RootBorder.Visibility = Visibility.Visible; this.logonWindow.RootBorder.Background.BeginAnimation(System.Windows.Media.Brush.OpacityProperty, animate); logonSettingWindow.ShowDialog(); logonSettingWindow.Activate(); this.logonWindow.RootBorder.Visibility = Visibility.Collapsed; } } catch (System.Exception ex) { this.logger.Error(ex.ToString()); } }
/// <summary> /// Стандартный конструктор /// </summary> /// <param name="users">списко пользователей</param> /// <param name="id">идентификатор пользователя для доступа к аккаунту</param> /// <param name="link">ссылка на форму ввод логина и пароля</param> public LogonViewModel(ObservableCollection <UserContract> users, int id, LogonWindow link) { Id = id; UserList = users; //Команды CloseWindowCommand = new BaseCommandRelay(parameter => link.Close()); }
private void LogonButtonClick(object sender, RoutedEventArgs e) { UserCredentials creds = new UserCredentials(); UserCredentialsViewModel vm = new UserCredentialsViewModel(creds); LogonWindow win = new LogonWindow(vm); win.Show(); }
/// <summary> /// Вывод окна ввода логина и пароля /// </summary> /// <param name="parameter"></param> private void ShowLogonView(object parameter) { if (!(parameter is int id)) { return; } var logonView = new LogonWindow(UserDataProfiles, id); logonView.ShowDialog(); }
private void LogOnEventHandle(LogOnResponse response) { try { if (response != null) { switch (response.code) { case 0: { LogonWindow logonWindow = this.dataService.LoginWindow as LogonWindow; if (logonWindow != null) { logonWindow.LogonPanel.LogonButtonEnable(); } this.logOnMsg.Message = "验证失败,用户名不存在!"; this.connection.Disconnect(); break; } case 1: this.logOnMsg.Message = "验证成功,正在获取数据..."; this.InitUserInfo(response); this.dataService.ServerInfo.AESKey = System.Convert.FromBase64String(response.key); this.EnterINWindow(); break; case 2: { LogonWindow logonWindow2 = this.dataService.LoginWindow as LogonWindow; if (logonWindow2 != null) { logonWindow2.LogonPanel.LogonButtonEnable(); } this.logOnMsg.Message = "验证失败,密码错误!"; this.connection.Disconnect(); break; } } } } catch (System.Exception e) { this.logger.Error(e.ToString()); } }
public void RELogOn(string message) { try { if (this.sessionService.IsLogin) { this.CloseWindows(); if (DataModel.Instance.EmailList != null && DataModel.Instance.EmailList.Count > 0) { DataModel.Instance.EmailList.Clear(); } this.isTaskClose = false; this.sessionService.IsReLogOn = true; this.sessionService.IsLogin = false; this.sessionService.IsEnable = false; this.sessionService.Ticket = string.Empty; this.sessionService.Uid = 0L; this.dataService.ClearAll(); DataModel.Instance.ClearAll(); WindowModel.Instance.ClearAll(); this.ClearAll(); base.Close(); NotifyIconUtil.Instance.SetFlashIcon(FlashIconType.Default); LogonWindow logonWindow = new LogonWindow(); this.dataService.LoginWindow = logonWindow; logonWindow.Show(); this.ShowNotifyIconGray(); this.connection.EventHandler.SocketErrorEvent = null; logonWindow.AddMessage(message); this.inViewModel.LogOff(); this.inViewModel.Disconnect(); SystemWindow sysWindow = this.dataService.SystemWindow as SystemWindow; sysWindow.optionItem.Enabled = this.sessionService.IsEnable; sysWindow.aboutItem.Enabled = this.sessionService.IsEnable; sysWindow.logoutItem.Enabled = this.sessionService.IsEnable; } } catch (System.Exception ex) { if (this.logger != null) { this.logger.Error(ex.ToString()); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { this.InitTray(); this.InitEventHandler(); ServiceUtil.Instance.Connection = this.connection; ServiceUtil.Instance.DataService = this.dataService; ServiceUtil.Instance.ImageService = this.imageService; ServiceUtil.Instance.Logger = this.logger; ServiceUtil.Instance.SessionService = this.sessionService; ServiceUtil.Instance.WsClient = this.wsClient; ServiceUtil.Instance.FileService = this.fileService; ServiceUtil.Instance.utilService = this.utilService; AppUtil.Instance.StartAtLogon(AppUtil.FilePath, Settings.Default.SystemSetup_Base_AutoStart); this.logonWindow = new LogonWindow(); this.logonWindow.Show(); this.dataService.LoginWindow = this.logonWindow; if (Settings.Default.SystemSetup_Base_AutoLogin) { if (!string.IsNullOrEmpty(this.logonWindow.LogonPanel.tbUserName.Text) && !string.IsNullOrEmpty(this.logonWindow.LogonPanel.tbPassword.Password)) { this.logonWindow.LogonPanel.LogOn(); } } this.InitAppHotKey(); }