Exemplo n.º 1
0
        public static void ShowFromTray()
        {
            var montior = new DDNSMonitorWindow();

            montior.Show();
            CloseAllWindowsBut(new [] { montior });
        }
Exemplo n.º 2
0
        private async void UserLogin()
        {
            UserInfoReturnValue userInfo;

            try
            {
                userInfo = await CommonService.GetUserInfo();
            }
            catch (WebException)
            {
                MessageBox.Show("无法连接至服务器.");
                return;
            }
            if (userInfo.Status.Code == 1)
            {
                _runtime.UserInfo = userInfo.Info;
                DDnsSharpRuntime.SaveAppConfig();

                var mwin = new DDNSMonitorWindow();
                mwin.Show();
                foreach (Window win in App.Current.Windows)
                {
                    if (win != mwin)
                    {
                        win.Close();
                    }
                }
            }
            else
            {
                _loginFailedCount++;
                if (_loginFailedCount == 10)
                {
                    ErrorMessage = "登陆次数超过已达10次,请5分钟后再试.";
                    if (_loginTimer == null)
                    {
                        _loginTimer = new Timer();
                    }
                    _loginTimer.Interval = 300000;
                    _loginTimer.Start();
                    _loginTimer.Elapsed += (o, e) =>
                    {
                        _ableToLogin = true;
                        LoginCommand.RaiseCanExecuteChanged();
                        _loginTimer.Stop();
                        _loginTimer.Dispose();
                        _loginTimer = null;
                    };
                    _ableToLogin = false;
                    LoginCommand.RaiseCanExecuteChanged();
                }
                else
                {
                    ErrorMessage = userInfo.Status.Message;
                }
            }
        }