Ejemplo n.º 1
0
        /// <summary>
        /// 修改减字。
        /// <para>实际上是移除对应减字后再添加一个同名的。</para>
        /// </summary>
        /// <param name="currentRow"></param>
        /// <param name="currentChar"></param>
        public void ModChar(CharNotationDataSet.CharRow currentRow, Char currentChar)
        {
            RemoveChar(currentRow);
            AddChar(currentChar);

            isModified = true;
        }
Ejemplo n.º 2
0
        public void RemoveChar(CharNotationDataSet.CharRow currentRow)
        {
            int strokeID = 0;

            while (true)
            {
                CharNotationDataSet.StrokeRow currentStroke = strokeTable.FindByIdchar_name(strokeID, currentRow.char_name);
                if (currentStroke == null)
                {
                    break;
                }
                int pointID = 0;
                while (true)
                {
                    CharNotationDataSet.PointRow currentPoint = pointTable.FindByIdstroke_idchar_name(pointID, strokeID, currentRow.char_name);
                    if (currentPoint == null)   //找不到对应点
                    {
                        break;
                    }
                    currentPoint.Delete();
                    pointID++;
                }
                currentStroke.Delete();
                strokeID++;
            }
            //删除内容框
            CharNotationDataSet.PointRow rectPoint = pointTable.FindByIdstroke_idchar_name(0, -1, currentRow.char_name);
            rectPoint.Delete();
            rectPoint = pointTable.FindByIdstroke_idchar_name(1, -1, currentRow.char_name);
            rectPoint.Delete();
            currentRow.Delete();

            isModified = true;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 点击“修改减字”按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnModChar_Click(object sender, EventArgs e)
 {
     //未指定减字名称
     if (txtName.Text == "")
     {
         toolTipWarning.Show("名称还没起呢", txtName, 1000);
         return;
     }
     else if (txtCharName.Text == "")
     {
         toolTipWarning.Show("名称还没起呢", txtCharName, 1000);
         return;
     }
     //取得当前选择的减字位置
     //int index = bindingListChar.IndexOf(lstChar.SelectedItem as Char);
     //if (index == -1)    //列表中不存在对应减字(列表为空)
     //    return;
     CharNotationDataSet.CharRow currentRow = null;
     if (lstChar.SelectedItem != null)
     {
         currentRow = (CharNotationDataSet.CharRow)(lstChar.SelectedItem as DataRowView).Row;
     }
     charEditor.Name     = txtName.Text;
     charEditor.CharName = txtCharName.Text;
     charEditor.Segment  = (int)numUDSegment.Value;
     //bindingListChar[index] = charEditor.Clone() as Char;
     charEditor.ResetModifyStatus();
     dataTranslator.ModChar(currentRow, charEditor.Clone() as Char);
     lstChar.SelectedIndex = lstChar.FindStringExact(charEditor.CharName);
     //bindingListChar.ResetBindings();    //bindingList内容已更改,以此通知listBox刷新
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 减字列表选择条目变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstChar_SelectedIndexChanged(object sender, EventArgs e)
        {
            //避免未保存的数据丢失,设置提醒
            if (charEditor.IsModified)
            {
                if (currentListIndex != lstChar.SelectedIndex)
                {
                    DialogResult result = MessageBox.Show("减字尚未保存,是否离开?", "警告",
                                                          System.Windows.Forms.MessageBoxButtons.YesNo);
                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        lstChar.SelectedIndex = currentListIndex;
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            currentListIndex = lstChar.SelectedIndex;
            CharNotationDataSet.CharRow currentRow = null;
            if (lstChar.SelectedItem != null)
            {
                currentRow = (CharNotationDataSet.CharRow)(lstChar.SelectedItem as DataRowView).Row;
            }
            //Char charCurrent = lstChar.SelectedItem as Char;
            Char charCurrent = null;

            if (currentRow != null)
            {
                charCurrent = dataTranslator.GetChar(currentRow);
            }
            //列表非空时必然会选择其中一项;但要避免出现空列表的情况
            if (charCurrent != null)
            {
                charEditor = new CharEditor(charCurrent.Clone() as Char);

                charEditor.ResetModifyStatus();

                txtName.Text              = charEditor.Name;
                txtCharName.Text          = charEditor.CharName;
                numUDSegment.Value        = (Decimal)charEditor.Segment;
                chkMain.Checked           = charEditor.IsMain;
                chkComplex.Checked        = charEditor.IsComplex;
                chkRestrictTop.Checked    = charEditor.RestrictTop;
                chkRestrictBottom.Checked = charEditor.RestrictBottom;
                chkRectTop.Checked        = charEditor.RestrictTopRect;
                chkRectBottom.Checked     = charEditor.RestrictBottomRect;

                picBoxEditor.Invalidate();  //重绘picbox
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 删除列表中的减字
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelChar_Click(object sender, EventArgs e)
        {
            //避免误删除,先确认
            DialogResult result = MessageBox.Show("将删除列表中当前选定的减字(请看清楚),\n无法恢复,是否继续?", "警告", System.Windows.Forms.MessageBoxButtons.YesNo);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            CharNotationDataSet.CharRow currentRow = null;
            if (lstChar.SelectedItem != null)
            {
                currentRow = (CharNotationDataSet.CharRow)(lstChar.SelectedItem as DataRowView).Row;
            }
            dataTranslator.RemoveChar(currentRow);
            //bindingListChar.Remove(lstChar.SelectedItem as Char);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取当前选定行的减字
        /// </summary>
        /// <param name="charName"></param>
        /// <returns></returns>
        public Char GetChar(CharNotationDataSet.CharRow currentRow)
        {
            Char result = new Char();

            //找到当前减字,并将信息传入
            //CharNotationDataSet.CharRow currentRow = charTable.FindBychar_name(charName);
            //if (currentRow == null)
            //    return null;
            result.Name               = currentRow.name.Trim();
            result.CharName           = currentRow.char_name.Trim();
            result.RestrictTop        = currentRow.restrict_top;
            result.RestrictBottom     = currentRow.restrict_bottom;
            result.RestrictTopRect    = currentRow.rect_resrict_top;
            result.RestrictBottomRect = currentRow.rect_restrict_bottom;
            result.Segment            = currentRow.segment;
            result.IsMain             = currentRow.is_main;
            result.IsComplex          = currentRow.is_complex;

            //内容框
            CharNotationDataSet.PointRow rectPoint = pointTable.FindByIdstroke_idchar_name(0, -1, currentRow.char_name);
            result.Rect.corners[0].X = (float)rectPoint.x;
            result.Rect.corners[0].Y = (float)rectPoint.y;
            rectPoint = pointTable.FindByIdstroke_idchar_name(1, -1, currentRow.char_name);
            result.Rect.corners[1].X = (float)rectPoint.x;
            result.Rect.corners[1].Y = (float)rectPoint.y;

            //找到当前减字所属笔画,并将信息传入
            List <Stroke> strokes  = new List <Stroke>();
            int           strokeID = 0;

            while (true)
            {
                CharNotationDataSet.StrokeRow currentStroke = strokeTable.FindByIdchar_name(strokeID, currentRow.char_name);
                if (currentStroke == null)
                {
                    break;
                }
                Stroke targetStroke = new Stroke((strokeType)currentStroke.type);
                //找到当前笔画所述点,并将信息传入
                List <System.Drawing.PointF> points = new List <System.Drawing.PointF>();
                int pointID = 0;
                while (true)
                {
                    CharNotationDataSet.PointRow currentPoint = pointTable.FindByIdstroke_idchar_name(pointID, strokeID, currentRow.char_name);
                    if (currentPoint == null)   //找不到对应点
                    {
                        break;
                    }
                    System.Drawing.PointF targetPoint = new System.Drawing.PointF();
                    targetPoint.X = (float)currentPoint.x;
                    targetPoint.Y = (float)currentPoint.y;
                    points.Add(targetPoint);    //将找到的点存入列表
                    pointID++;
                }
                targetStroke.Points = points;   //将点列表存入笔画
                strokes.Add(targetStroke);
                strokeID++;
            }
            result.Strokes = strokes;

            return(result);
        }