예제 #1
0
 /// <summary>
 /// 复制构造函数。执行浅复制。
 /// </summary>
 /// <param name="t"></param>
 public CharEditor(CharEditor t)
 {
     imgBackground        = new Bitmap(t.imgBackground);
     selectedStrokeIndex  = t.selectedStrokeIndex;
     selectedRectIndex    = t.selectedRectIndex;
     modified             = t.modified;
     selectedIndicesIndex = t.selectedIndicesIndex;
 }
예제 #2
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
            }
        }
예제 #3
0
        bool mouseDown; //记录鼠标是否按下

        public FormDesigner()
        {
            InitializeComponent();

            //准备编辑区域内容
            basicStrokes = BasicStrokesInit(); //基础笔画部件
            //将数据绑定到combo上。此处无需新建binding,因为该数据不会更新
            comboStrokes.DataSource    = basicStrokes;
            comboStrokes.DisplayMember = "type";

            //CharEditor.BasicStrokes = basicStrokes; //将笔画信息传入chareditor
            Stroke.setWidth(3, 15);
            charEditor = new CharEditor();
            mouseDown  = false;

            dataTranslator = new DataTranslator();

            lstChar.DataSource    = dataTranslator.CharTable;
            lstChar.DisplayMember = "char_name";
        }