示例#1
0
        private void mainForm_Load(object sender, EventArgs e)
        {
            textBoxUsername.Text            = Properties.Settings.Default.username;
            textBoxPassword.Text            = Properties.Settings.Default.password;
            checkBoxAutoLogin.Checked       = Properties.Settings.Default.autoLogin;
            checkBoxReconnectOnFail.Checked = Properties.Settings.Default.autoReconnect;

            OnlineMessage onlineState = OnlineState.getOnlineState();

            if (onlineState.reply_code == OnlineState.OPERATE_SUCCESS && onlineState.reply_msg != null)
            {
                GlobalFunction.showInfo(onlineState, this);
            }

            if (checkBoxAutoLogin.Checked)
            {
                if (!textBoxUsername.Text.Equals("") && !textBoxPassword.Text.Equals(""))
                {
                    OnlineMessage ret = null;
                    do
                    {
                        ret = AutoConnect.connect(textBoxUsername.Text, textBoxPassword.Text);
                    } while (ret == null || ret.userinfo == null);
                    GlobalFunction.showInfo(ret, this);
                }
                this.WindowState = FormWindowState.Minimized;
            }
            if (Properties.Settings.Default.autoReconnect)
            {
                timer.Enabled = true;
            }
        }
示例#2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            OnlineMessage onlineState = OnlineState.getOnlineState();

            GlobalFunction.showInfo(onlineState, this);

            if (onlineState.reply_code == OnlineState.NO_PORTAL_MESSAGE)            //未登录
            {
                OnlineMessage ret = null;
                if (Properties.Settings.Default.username == "" || Properties.Settings.Default.password == "")
                {
                    ret = AutoConnect.connect(Properties.Settings.Default.username, Properties.Settings.Default.password);
                }
                else
                {
                    ret = AutoConnect.connect(textBoxUsername.Text, textBoxPassword.Text);
                }
                GlobalFunction.showInfo(ret, this);
            }
        }
示例#3
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            saveOptions();

            if (textBoxUsername.Text.Equals("") || textBoxPassword.Text.Equals(""))
            {
                MessageBox.Show("用户名和密码不能为空!", "Auto p.nju", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (checkBoxAutoLogin.Checked)
            {
                saveUsernameAndPassword();
            }
            else
            {
                clearUsernameAndPassword();
            }
            OnlineMessage ret = null;

            do
            {
                ret = AutoConnect.connect(textBoxUsername.Text, textBoxPassword.Text);
            } while (ret == null);

            if (ret.reply_code == AutoConnect.INVALID_PASSWORD)
            {
                timer.Enabled = false;
                MessageBox.Show(ret.reply_msg, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //else if(ret.reply_code==AutoConnect.PROCESSING)
            //{
            //    timer.Enabled = false;
            //    MessageBox.Show(ret.reply_msg, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            else
            {
                Thread.Sleep(1000);
                GlobalFunction.showInfo(OnlineState.getOnlineStateStrict(), this);
            }
        }