Esempio n. 1
0
        /// <summary>
        /// 点击“添加减字”按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddChar_Click(object sender, EventArgs e)
        {
            //未指定减字名称
            if (txtName.Text == "")
            {
                toolTipWarning.Show("名称还没起呢", txtName, 1000);
                return;
            }
            else if (txtCharName.Text == "")
            {
                toolTipWarning.Show("名称还没起呢", txtCharName, 1000);
                return;
            }
            //检查列表是否重复
            foreach (var item in lstChar.Items)
            {
                CharNotationDataSet.CharRow currentRow = (CharNotationDataSet.CharRow)(item as DataRowView).Row;
                if (currentRow.name.Trim() == txtName.Text)
                {
                    toolTipWarning.Show("名称已存在", txtName, 1000);
                    return;
                }
                else if (currentRow.char_name.Trim() == txtCharName.Text)
                {
                    toolTipWarning.Show("名称已存在", txtCharName, 1000);
                    return;
                }
            }
            //新建减字,必须使用深复制
            charEditor.CharName = txtCharName.Text;
            charEditor.Name     = txtName.Text;
            charEditor.Segment  = (int)numUDSegment.Value;
            charEditor.ResetModifyStatus();
            Char charTemp = charEditor.Clone() as Char;

            dataTranslator.AddChar(charTemp);
            lstChar.SelectedIndex = lstChar.FindStringExact(charEditor.CharName);
        }