Example #1
0
        private void MenuItem_MouseClick(object sender, MouseEventArgs e)
        {
            Control lab = (Control)sender;

            DrawButtonStyle(lab, false);
            if (lab.Equals(labClose))
            {
                if (MessageBox.Show("是否確定離開本程式?", _CaptionText, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Program.IsExit = true;
                    this.Close();
                }
            }
            else if (lab.Equals(labGameClose))
            {
                CloseGameList();
                this.Refresh();
            }
            else if (lab.Equals(labRegist))
            {
                using (RegForm reg = new RegForm())
                {
                    if (reg.ShowDialog(this) == DialogResult.OK)
                    {
                        _LoginedUserID = reg.UserID;
                        SetLogin(_LoginedUserID);
                        txtUser.Text = _LoginedUserID;
                        txtPwd.Text  = reg.Password;
                    }
                }
            }
            else if (lab.Equals(labLogin))
            {
                if (lab.Text.Equals("登入"))
                {
                    if (DataTier.UserLogin(txtUser.Text, txtPwd.Text))
                    {
                        SetLogin(txtUser.Text);
                    }
                    else
                    {
                        MessageBox.Show("帳號密碼錯誤!! 請重新輸入!!\n(請注意密碼有區分大小寫)", _CaptionText, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    SetLogout();
                }
            }
            else if (lab.Parent.Equals(panMenu))
            {
                if (!panRight.Visible)
                {
                    this.Width = Screen.PrimaryScreen.WorkingArea.Width;
                }
                _SelectedMenu = lab.Tag.ToString();
                ShowGameList(Program.Menus[_SelectedMenu]);
                this.Refresh();
            }
        }
Example #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;
            string id  = txtUserID.Text;
            string p1  = txtPwd1.Text;
            string p2  = txtPwd2.Text;

            if (id.Length < 3 || id.Length > 12)
            {
                MessageBox.Show("請輸入註冊帳號,且最少3個字,最多12個字!!", Program.Config["Caption"], MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.DialogResult = DialogResult.None;
                txtUserID.Focus();
            }
            else if (Encoding.Default.GetByteCount(id) != id.Length || Regex.Replace(id, @"[^\w\.@-]", "") != id)
            {
                MessageBox.Show("帳號必須為英數字且不得包含特殊符號,請重新輸入!!\n", Program.Config["Caption"], MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.DialogResult = DialogResult.None;
                txtUserID.Focus();
            }
            else if (p1.Length < 3 || p1.Length > 12)
            {
                MessageBox.Show("請輸入欲使用的密碼,且最少3個字,最多12個字!!", Program.Config["Caption"], MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.DialogResult = DialogResult.None;
                txtPwd1.Focus();
            }
            else if (Encoding.Default.GetByteCount(p1) != p1.Length || p1.IndexOf(' ') != -1)
            {
                MessageBox.Show("密碼必須為英數字且不得包含空白字元,請重新輸入!!\n", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                this.DialogResult = DialogResult.None;
                txtPwd1.Focus();
            }
            else if (!p1.Equals(p2))
            {
                MessageBox.Show("請再次輸入相同的帳號密碼,以確認您已記妥!!", Program.Config["Caption"], MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.DialogResult = DialogResult.None;
                txtPwd2.Focus();
            }
            else
            {
                if (DataTier.SaveNewUser(txtUserID.Text, txtPwd1.Text))
                {
                    this.DialogResult = DialogResult.OK;
                    this.UserID       = txtUserID.Text;
                    this.Password     = txtPwd1.Text;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("帳號已存在,請重新設定!!!", Program.Config["Caption"], MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtUserID.Focus();
                }
            }
        }
Example #3
0
        private static bool Startup()
        {
            bool isOK = false;
            int  ret  = -1;

            try
            {
                ret = DataTier.CheckConfig();
            }
            catch (Exception ex)
            {
                MessageBox.Show("程式錯誤,請聯絡管理員!\n\n" + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            switch (ret)
            {
            case 0:
                #region  入遊戲資料
            {
                using (DataTable dt = DataTier.LoadConfig())
                {
                    if (dt == null)
                    {
                        MessageBox.Show("遊戲資料檔中,參數資料有誤,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    else
                    {
                        Config = new NameValueCollection();
                        foreach (DataRow dr in dt.Rows)
                        {
                            Config.Add(dr["Key"].ToString(), dr["Value"].ToString());
                        }
                    }
                    //if (!Directory.Exists(Program.Config["SavesPath"]))
                    //{
                    //    MessageBox.Show("找不到遊戲進度備份目錄,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //    return false;
                    //}
                    //else if (!Directory.Exists(Program.Config["GameRoot"]))
                    //{
                    //    MessageBox.Show("找不到遊戲目錄,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //    return false;
                    //}
                }
                using (DataTable dt = DataTier.LoadMenus())
                {
                    if (dt == null)
                    {
                        MessageBox.Show("遊戲資料檔中,選單資料有誤,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    Menus = new MenuCollection(dt);
                }
                using (DataTable dt = DataTier.LoadGames())
                {
                    if (dt == null)
                    {
                        MessageBox.Show("遊戲資料檔中,遊戲資料有誤,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    Games = new GameCollection(dt);
                }
                isOK = true;
                break;
            }

                #endregion
            case 1:
                MessageBox.Show("找不到參數與遊戲資料檔,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 2:
            case 3:
                MessageBox.Show("參數遊戲資料檔錯誤,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 4:
                MessageBox.Show("找不到使用者帳號資料檔,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 5:
                MessageBox.Show("使用者帳號資料檔錯誤,請聯絡管理員!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            default:
                break;
            }
            return(isOK);
        }