예제 #1
0
        List <Char> lstChars = new List <Char>(); //减字列表
        public FormPreviewer()
        {
            InitializeComponent();

            DataTranslator translator = new DataTranslator();

            foreach (CharNotationDataSet.CharRow row in translator.CharTable)
            {
                lstChars.Add(translator.GetChar(row));
            }
        }
예제 #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
            }
        }