/// <summary>
        /// 檢視模式:只顯示點字。
        /// </summary>
        private void ViewBrailleOnly()
        {
            MsgBoxHelper.ShowWarning("注意! 此為測試功能,若發現任何問題,請切回預設模式:\n" +
                                     "從主選單點選「檢視 > 模式 > 顯示全部」。");

            int row;

            brGrid.SuspendLayout();
            CursorHelper.ShowWaitCursor();
            try
            {
                for (row = 1; row < brGrid.RowsCount; row += 3)
                {
                    brGrid.Rows.HideRow(row + 1);
                    brGrid.Rows.HideRow(row + 2);
                }
                miViewBrailleOnly.Checked = true;
                miViewTextZhuyin.Checked  = false;
                miViewAll.Checked         = false;
            }
            finally
            {
                brGrid.ResumeLayout();
                ResizeCells();
                CursorHelper.RestoreCursor();
            }
        }
        /// <summary>
        /// 檢視模式:顯示全部。
        /// </summary>
        private void ViewAll()
        {
            int row;

            brGrid.SuspendLayout();
            CursorHelper.ShowWaitCursor();
            try
            {
                for (row = 1; row < brGrid.RowsCount; row += 3)
                {
                    brGrid.Rows.ShowRow(row);
                    brGrid.Rows.ShowRow(row + 1);
                    brGrid.Rows.ShowRow(row + 2);
                    brGrid.Rows.AutoSizeRow(row);
                    brGrid.Rows.AutoSizeRow(row + 1);
                    brGrid.Rows.AutoSizeRow(row + 2);
                }
                miViewAll.Checked         = true;
                miViewBrailleOnly.Checked = false;
                miViewTextZhuyin.Checked  = false;
            }
            finally
            {
                brGrid.ResumeLayout();
                ResizeCells();
                CursorHelper.RestoreCursor();
            }
        }
        public void FillGrid()
        {
            if (m_BrDoc.LineCount < 1)
            {
                return;
            }

            int cnt = 0;

            //StatusText = "正在準備顯示資料...";
            //StatusProgress = 0;
            brGrid.SuspendLayout();
            CursorHelper.ShowWaitCursor();
            try
            {
                int row = FixedRows;
                foreach (BrailleLine brLine in m_BrDoc.Lines)
                {
                    FillRow(brLine, row, false);                        // 填一列,先不要調整列高。

                    row += 3;

                    cnt++;
                    //StatusProgress = cnt * 100 / brDoc.Lines.Count;
                }
            }
            finally
            {
                //StatusText = "重新調整儲存格大小...";
                ResizeCells();
                brGrid.ResumeLayout();
                //StatusProgress = 0;
                CursorHelper.RestoreCursor();
            }
        }
        /// <summary>
        /// 縮放顯示比例。
        /// </summary>
        /// <param name="ratio"></param>
        private void Zoom(int ratio)
        {
            if (!m_IsInitialized)
            {
                return;
            }

            if (ratio > 200 || ratio < 30)
            {
                MsgBoxHelper.ShowInfo("指定的縮放比例太小或太大: " + ratio.ToString() + "%");
                return;
            }

            double r    = ratio / 100.0;
            float  size = 0.0f;

            StatusText = "正在調整顯示比例...";
            CursorHelper.ShowWaitCursor();
            try
            {
                // 標題字型
                size = (float)(DualEditForm.DefaultHeaderFontSize * r);
                m_HeaderView.Font = new Font(brGrid.Font.FontFamily, size);
                //brGrid[0, 1].View.Font = new Font(brGrid[0, 1].View.Font.FontFamily, size);

                m_HeaderView2.Font = m_HeaderView.Font;

                // 點字字型
                size          = (float)(DualEditForm.DefaultBrailleFontSize * r);
                m_BrView.Font = new Font(m_BrView.Font.FontFamily, size);
                //brGrid[1, 1].View.Font = new Font(brGrid[1, 1].View.Font.FontFamily, size);

                // 明眼字字型
                size               = (float)(DualEditForm.DefaultTextFontSize * r);
                m_MingView.Font    = new Font(m_MingFont.FontFamily, size, m_MingFont.Style, m_MingFont.Unit);
                m_MingViewCJK.Font = new Font("PMingLiU", size, m_MingFontCJK.Style, m_MingFontCJK.Unit, 1);
                //brGrid[2, 1].View.Font = new Font(brGrid[2, 1].View.Font.FontFamily, size);

                // 注音符號字型
                size             = (float)(DualEditForm.DefaultPhoneticFontSize * r);
                m_PhonView.Font  = new Font(m_PhonView.Font.FontFamily, size, m_PhonView.Font.Style, m_PhonView.Font.Unit, m_PhonView.Font.GdiCharSet);
                m_PhonView2.Font = m_PhonView.Font;
                m_PhonView3.Font = m_PhonView.Font;
                //brGrid[3, 1].View.Font = new Font(brGrid[3, 1].View.Font.FontFamily, size);

                brGrid.Columns.AutoSizeView();
            }
            finally
            {
                CursorHelper.RestoreCursor();
                StatusText = "";
            }
        }
        /// <summary>
        /// 將 BrailleDocument 文件內容填入 grid。
        /// </summary>
        /// <param name="brDoc">BrailleDocument 文件。</param>
        private void FillGrid(BrailleDocument brDoc)
        {
            if (brDoc.Lines.Count < 1)
            {
                return;
            }

            int cnt = 0;

            StatusText     = "正在準備顯示資料...";
            StatusProgress = 0;
            CursorHelper.ShowWaitCursor();
            brGrid.SuspendLayout();
            try
            {
                int row = DualEditForm.FixedRows;
                foreach (BrailleLine brLine in brDoc.Lines)
                {
                    FillRow(brLine, row, false);                        // 填一列,先不要調整列高。

                    // 把沒有資料的儲存格填入空白字元。
                    //for (int x = col; x < maxWordCount; x++)
                    //{
                    //    brGrid[row, x] = new SourceGrid.Cells.Cell(" ");
                    //    brGrid[row, x].View = brView;
                    //    brGrid[row, x].Editor = txtEditor;
                    //    brGrid[row + 1, x] = new SourceGrid.Cells.Cell(" ");
                    //    brGrid[row + 1, x].View = mingView;
                    //    brGrid[row + 1, x].Editor = txtEditor;
                    //    brGrid[row + 2, x] = new SourceGrid.Cells.Cell(" ");
                    //    brGrid[row + 2, x].View = phonView;
                    //    brGrid[row + 2, x].Editor = txtEditor;
                    //}

                    row += 3;

                    cnt++;
                    StatusProgress = cnt * 100 / brDoc.Lines.Count;
                }
            }
            finally
            {
                StatusText = "重新調整儲存格大小...";
                ResizeCells();
                brGrid.ResumeLayout();
                StatusProgress = 0;
                CursorHelper.RestoreCursor();
            }
        }
Exemple #6
0
        private void InternalLoadFile(string filename)
        {
            CursorHelper.ShowWaitCursor();
            try
            {
                StatusText = "正在載入資料...";

                BrailleDocument newBrDoc = BrailleDocument.LoadBrailleFile(filename);

                if (m_BrDoc != null)
                {
                    m_BrDoc.Clear();
                }
                m_BrDoc = newBrDoc;

                FileName = filename;
                IsDirty  = false;

                // 2009-6-23: 防錯處理,有的檔案因為程式的 bug 而存入空的 BrailleLine,在此處自動濾掉.
                for (int i = m_BrDoc.LineCount - 1; i >= 0; i--)
                {
                    // 把空的 BrailleLine 移除.
                    if (m_BrDoc.Lines[i].CellCount < 1)
                    {
                        m_BrDoc.RemoveLine(i);
                        IsDirty = true;
                    }
                }

                StatusText = "正在準備顯示資料...";
                brGrid.Rows.Clear();
                brGrid.Columns.Clear();
                m_IsInitialized = false;

                InitializeGrid();

                FillGrid(m_BrDoc);

                // 焦點移至第一列的第一個儲存格。
                SourceGrid.Position pos = new SourceGrid.Position(brGrid.FixedRows, brGrid.FixedColumns);
                GridFocusCell(pos, true);
            }
            finally
            {
                CursorHelper.RestoreCursor();
                StatusText = "";
            }
        }