Пример #1
0
        private void MainForm_CurrentPagePanelChanged(object sender, ManagerPagePanelChangedEventArgs e)
        {
            if (e.NewValue != null)
            {
                if (e.NewValue == this.loginSucceededPagePanel)
                {
                    this.cmsNotifyIcon_tsmiLogin.Enabled  = false;
                    this.cmsNotifyIcon_tsmiLogout.Enabled = false;
                    this.cmsNotifyIcon_tsmiLogin.Checked  = false;
                    this.cmsNotifyIcon_tsmiLogout.Checked = false;


                    // 在登录成功时更新用户信息。
                    #region 更新用户信息
                    var dic = CommandLine.Console.AccountDictionary;
                    CommandLine.Console._accounts._account account;
                    if (dic.ContainsKey(this.loginInfoPagePanel.UserName))
                    {
                        account = dic[this.loginInfoPagePanel.UserName];
                        if (this.loginInfoPagePanel.RememberMe)
                        {
                            if (this.loginInfoPagePanel.AutoLogin)
                            {
                                foreach (var _account in CommandLine.Console.Accounts.accounts)
                                {
                                    if (_account.autologin)
                                    {
                                        _account.autologin = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            dic.Remove(this.loginInfoPagePanel.UserName);
                        }
                    }
                    else
                    {
                        account = new CommandLine.Console._accounts._account();
                    }

                    account.username   = this.loginInfoPagePanel.UserName;
                    account.userpwd    = this.loginInfoPagePanel.UserPwd;
                    account.rememberme = this.loginInfoPagePanel.RememberMe;
                    account.autologin  = this.loginInfoPagePanel.AutoLogin;
                    if (this.loginInfoPagePanel.RememberMe && !dic.ContainsKey(this.loginInfoPagePanel.UserName))
                    {
                        dic.Add(this.loginInfoPagePanel.UserName, account);
                    }

                    CommandLine.Console.SaveConfig();
                    #endregion


                    this.loginSucceededPagePanel.userName = this.loginInfoPagePanel.UserName;
                    if (this.loginInfoPagePanel.AutoLogin)
                    {
                        this.loginSucceeded_cbCancelAutoLogin.Enabled = true;
                    }
                    else
                    {
                        this.loginSucceeded_cbCancelAutoLogin.Enabled = false;
                        this.loginSucceeded_cbCancelAutoLogin.Checked = false;
                    }

                    this.statusBar.ShowStatus(5000, $"用户 {this.loginSucceededPagePanel.UserName} 成功登录。", this.Invoke);

                    this.timer.Start();
                    var wlanInfoLines = ((ILoginSucceededPage)Program.manager.CurrentPage).WlanInfos
                                        .Select(pair => $"{pair.Key}:{pair.Value}");

                    this.lblWlanInfos.Text = string.Join(Environment.NewLine, wlanInfoLines.ToArray());
                }
                else
                {
                    this.cmsNotifyIcon_tsmiLogin.Enabled  = true;
                    this.cmsNotifyIcon_tsmiLogout.Enabled = true;

                    if (e.NewValue == this.loginInfoPagePanel)
                    {
                        this.cmsNotifyIcon_tsmiLogout.Checked = false;
                        this.cmsNotifyIcon_tsmiLogin.Checked  = true;

                        this.notifyIcon.Text = "Wlan-edu 登录";
                    }
                    else if (e.NewValue == this.logoutInfoPagePanel)
                    {
                        this.cmsNotifyIcon_tsmiLogin.Checked  = false;
                        this.cmsNotifyIcon_tsmiLogout.Checked = true;

                        this.notifyIcon.Text = "Wlan-edu 下线";
                    }
                    this.statusBar.StatusBarState = StatusBarState.None;
                }
            }
        }
Пример #2
0
 protected virtual void OnCurrentPagePanelChanged(ManagerPagePanelChangedEventArgs e) =>
 this.CurrentPagePanelChanged?.Invoke(this, e);