Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show(LangPack.GetMongolian("Please enter the CG title."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tbName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tbText.Text))
            {
                MessageBox.Show(LangPack.GetMongolian("Please enter the CG text."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tbText.Focus();
                return;
            }

            if (bAdd)
            {
                BoardInfo info = brdMng.dicBrd[cbKind.Text];
                if (info.dicText != null && info.dicText.ContainsKey(tbName.Text))
                {
                    MessageBox.Show(LangPack.GetMongolian("The same title already exists. Please enter check again after."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    tbName.Focus();
                    return;
                }

                BoardInfoDetail dinfo = new BoardInfoDetail();
                dinfo.name    = tbName.Text;
                dinfo.text    = tbText.Text;
                dinfo.kindNum = info.kindNum;
                dinfo.kind    = cbKind.Text;
                dinfo.isBlack = (cbBlack.SelectedIndex == 0 ? false : true);

                if (this.cutInfoD != null)
                {
                    for (int i = 0; i < 9; i++)
                    {
                        dinfo.cut[i] = this.cutInfoD.cut[i];
                    }
                }

                brdMng.dicBrd[cbKind.Text].dicText.Add(tbName.Text, dinfo);

                MessageBox.Show(LangPack.GetMongolian("Stored."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                ResetCtrl();
            }
            else
            {
                // Name(Key) 수정
                if (this.oldName != tbName.Text)
                {
                    // 기존 Name(Key) 삭제
                    brdMng.dicBrd[cbKind.Text].dicText.Remove(this.oldName);

                    // 새로운 Name(Key) 등록
                    BoardInfoDetail dinfo = new BoardInfoDetail();
                    dinfo.name    = tbName.Text;
                    dinfo.text    = tbText.Text;
                    dinfo.kind    = cbKind.Text;
                    dinfo.kindNum = infoD.kindNum;
                    dinfo.isBlack = (cbBlack.SelectedIndex == 0 ? false : true);

                    for (int i = 0; i < 9; i++)
                    {
                        dinfo.cut[i] = this.cutInfoD.cut[i];
                    }

                    brdMng.dicBrd[cbKind.Text].dicText.Add(tbName.Text, dinfo);
                }
                else
                {
                    brdMng.dicBrd[cbKind.Text].dicText[tbName.Text].text    = tbText.Text;
                    brdMng.dicBrd[cbKind.Text].dicText[tbName.Text].isBlack = (cbBlack.SelectedIndex == 0 ? false : true);

                    for (int i = 0; i < 9; i++)
                    {
                        brdMng.dicBrd[cbKind.Text].dicText[tbName.Text].cut[i] = this.cutInfoD.cut[i];
                    }
                }

                brdMng.SaveBrdData();
                MessageBox.Show(LangPack.GetMongolian("Modified."), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Close();
            }

            if (this.OnCGChangeEvt != null)
            {
                this.OnCGChangeEvt(this, new CGChangeEventArgs());
            }
        }