Esempio n. 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            // 如果未指定任何點字碼,則繼續編輯。
            if (txtChar.Text == String.Empty || txtBraille.Text == String.Empty)
            {
                return;
            }

            // 判斷點字碼是否有更動,若有,則設定新的點字碼。

            string fontStr = StrHelper.ToHexString(txtBraille.Text);

            if (!m_BrWord.CellList.ToString().Equals(fontStr))  // 有更動?
            {
                m_BrWord.CellList.Clear();

                string brCode;
                for (int i = 0; i < fontStr.Length; i += 2)
                {
                    brCode = BrailleFontConverter.ToBrailleCode(fontStr.Substring(i, 2));
                    m_BrWord.CellList.Add(brCode);
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 2
0
        private void PickBrailleForm_Load(object sender, EventArgs e)
        {
            m_ClickController = new CellClickEvent(this);

            brGrid.Redim(4, 16);

            int    row;
            int    col;
            int    brCodeNum = 0;
            string brCodeStr;
            char   brChar;

            for (row = 0; row < brGrid.RowsCount; row++)
            {
                for (col = 0; col < brGrid.ColumnsCount; col++)
                {
                    brCodeStr        = brCodeNum.ToString("X2");
                    brChar           = BrailleFontConverter.ToChar(brCodeStr);
                    brGrid[row, col] = new SourceGrid.Cells.Cell(brChar);
                    brGrid[row, col].AddController(m_ClickController);

                    brCodeNum++;
                }
            }

            brGrid.AutoSizeCells();
        }
Esempio n. 3
0
        // 當注音符號有變動
        private void cboPhCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_IsUpdatingUI || m_BrWord == null)
            {
                return;
            }
            if (cboPhCode.SelectedIndex < 0)
            {
                return;
            }

            m_BrWord.PhoneticCode = cboPhCode.Text;
            BrailleCellList cellList = m_ChtWordCvt.CreatePhoneticCellList(m_BrWord.PhoneticCode);

            m_BrWord.CellList.Assign(cellList);
            txtBraille.Text = BrailleFontConverter.ToString(cellList);
        }
Esempio n. 4
0
        private void UpdateUI()
        {
            m_IsUpdatingUI = true;
            try
            {
                txtChar.Text = m_BrWord.Text;
                cboPhCode.Items.Clear();

                if (m_BrWord.IsPolyphonic)
                {
                    string[] zhuyinCodes = ZhuyinQueryHelper.GetZhuyinSymbols(txtChar.Text, true);
                    cboPhCode.Items.AddRange(zhuyinCodes);
                }

                cboPhCode.SelectedIndex = cboPhCode.Items.IndexOf(m_BrWord.PhoneticCode);
                txtBraille.Text         = BrailleFontConverter.ToString(m_BrWord);
            }
            finally
            {
                m_IsUpdatingUI = false;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 更新指定的點字方格。
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="brWord"></param>
        private void UpdateCell(int row, int col, BrailleWord brWord)
        {
            // 處理點字
            string brFontText = null;

            try
            {
                if (brWord.IsContextTag)
                {
                    brFontText = " ";
                }
                else
                {
                    brFontText = BrailleFontConverter.ToString(brWord);
                }
            }
            catch (Exception e)
            {
                MsgBoxHelper.ShowError(e.Message + "\r\n" +
                                       "列:" + row.ToString() + ", 行: " + col.ToString());
                brFontText = "";
            }

            row = GetBrailleRowIndex(row);              // 確保列索引為點字列。

            //若每個 cell 一方點字,就用以下迴圈填入點字
            //for (int i = 0; i < brFontText.Length; i++)
            //{
            //    brGrid[row, col+i].Value = brFontText[i];
            //}
            brGrid[row, col].Value = brFontText;
            brGrid[row, col].Tag   = brWord;

            brGrid[row + 1, col].Value = brWord.Text;
            brGrid[row + 1, col].Tag   = brWord;

            brGrid[row + 2, col].Value = brWord.PhoneticCode;
            brGrid[row + 2, col].Tag   = brWord;
        }
Esempio n. 6
0
        /// <summary>
        /// 把一列點字填入指定的 grid 列(影響三列)。
        /// </summary>
        /// <param name="brLine">點字串列。</param>
        /// <param name="row">欲填入 grid 中的哪一列。</param>
        /// <param name="autoSize">填完之後,是否要自動重新調整儲存格大小。</param>
        private void FillRow(BrailleLine brLine, int row, bool autoSize)
        {
            string brFontText;
            int    col = brGrid.FixedColumns;

            // 確保列索引是點字所在的列。
            row = GetBrailleRowIndex(row);

            brGrid.SuspendLayout();
            try
            {
                foreach (BrailleWord brWord in brLine.Words)
                {
                    // 處理點字
                    try
                    {
                        if (brWord.IsContextTag)
                        {
                            brFontText = " ";
                        }
                        else
                        {
                            brFontText = BrailleFontConverter.ToString(brWord);
                        }
                    }
                    catch (Exception e)
                    {
                        MsgBoxHelper.ShowError(e.Message + "\r\n" +
                                               "列:" + row.ToString() + ", 行: " + col.ToString());
                        brFontText = "";
                    }

                    brGrid[row, col]            = new SourceGrid.Cells.Cell(brFontText);
                    brGrid[row, col].ColumnSpan = brFontText.Length;
                    brGrid[row, col].View       = m_BrView;
                    brGrid[row, col].Tag        = brWord;
                    brGrid[row, col].AddController(m_MenuController);
                    brGrid[row, col].AddController(m_ClickController);

                    // 處理明眼字
                    brGrid[row + 1, col]            = new SourceGrid.Cells.Cell(brWord.Text);
                    brGrid[row + 1, col].ColumnSpan = brFontText.Length;
                    brGrid[row + 1, col].View       = m_MingViewCJK; // TODO: 確認音標字形可以正確顯示. 否則要分開判斷,音標符號改用 m_MingView
                    brGrid[row + 1, col].Tag        = brWord;
                    brGrid[row + 1, col].AddController(m_MenuController);
                    brGrid[row + 1, col].AddController(m_ClickController);

                    // 處理注音碼
                    brGrid[row + 2, col]            = new SourceGrid.Cells.Cell(brWord.PhoneticCode);
                    brGrid[row + 2, col].ColumnSpan = brFontText.Length;
                    if (brWord.IsPolyphonic)
                    {
                        if (AppGlobals.Config.Braille.ErrorProneWords.IndexOf(brWord.Text) >= 0)
                        {
                            // 容易判斷錯誤的破音字用顯眼的紅色標示。
                            brGrid[row + 2, col].View = m_PhonView3;
                        }
                        else
                        {
                            // 一般破音字用黃色標示。
                            brGrid[row + 2, col].View = m_PhonView2;
                        }
                    }
                    else
                    {
                        brGrid[row + 2, col].View = m_PhonView;
                    }
                    brGrid[row + 2, col].Tag = brWord;

                    col += brFontText.Length;
                }
            }
            finally
            {
                brGrid.Rows.AutoSizeRow(row);
                brGrid.Rows.AutoSizeRow(row + 1);
                brGrid.Rows.AutoSizeRow(row + 2);

                brGrid.ResumeLayout();
            }
        }