Ejemplo n.º 1
0
        /// <summary>
        /// 執行點字轉檔。
        /// </summary>
        /// <param name="inFileName">輸入的明眼字檔名。</param>
        /// <param name="outFileName">輸出的點字檔名。</param>
        /// <param name="cellsPerLine">每列最大方數。</param>
        /// <param name="verboseMode">冗長資訊模式。</param>
        public void ConvertFile(string inFileName, string outFileName,
                                int cellsPerLine, bool verboseMode)
        {
            m_OutFileName = outFileName;

            PrepareConvertion();

            try
            {
                _doc.CellsPerLine = cellsPerLine;

                _doc.LoadAndConvert(inFileName);

                if (!_processor.HasError)                       // 轉換過程都沒錯誤才輸出點字檔
                {
                    _doc.SaveBrailleFile(outFileName);
                }

                _doc.Clear();
                _doc = null;

                WriteInvalidCharsToFile();

                WriteResultToFile();
            }
            finally
            {
                FinalizeConversion();
            }
        }
Ejemplo n.º 2
0
        private bool m_DebugMode = true;           // 除錯模式

        public DualEditForm(BrailleDocument brDoc)
            : base()
        {
            m_BrDoc = brDoc;

            InitializeComponent();
        }
Ejemplo n.º 3
0
        public DualEditTitleForm(BrailleDocument brDoc)
            : this()
        {
            m_OrgBrDoc = brDoc;

            m_TmpBrDoc = new BrailleDocument(brDoc.Processor, brDoc.CellsPerLine);

            m_Titles = new List <BraillePageTitle>();

            // 複製所有標題列,並將標題列塞進暫存文件。
            BraillePageTitle newTitle = null;

            foreach (BraillePageTitle t in brDoc.PageTitles)
            {
                newTitle = t.Clone() as BraillePageTitle;
                m_Titles.Add(newTitle);

                m_TmpBrDoc.Lines.Add(newTitle.TitleLine);               // 塞進暫存文件。
            }

            m_DualEditController = new DualEditController(m_TmpBrDoc, brGrid);

            m_DualEditController.DataChanged += new EventHandler(DualEditControler_DataChanged);

            m_IsDirty = false;
        }
Ejemplo n.º 4
0
        private void btnFormat_Click(object sender, EventArgs e)
        {
            BrailleDocument brDoc = new BrailleDocument(m_Processer, 32);

            brDoc.Load(txtSrc.Text);

            txtFormatted.Text = brDoc.ToString();
        }
        public void LoadTest()
        {
            BrailleProcessor processor =
                BrailleProcessor.GetInstance(
                    new ZhuyinReverseConverter(
                        new ZhuyinReverseConversionProvider()));

            string          filename = Shared.TestDataPath + "TestData_Braille.txt";
            BrailleDocument brDoc    = new BrailleDocument(filename, processor, 32);

            brDoc.LoadAndConvert();
        }
Ejemplo n.º 6
0
        public DualPrintHelper(BrailleDocument brDoc, PrintOptions prnOpt)
        {
            m_BrDoc        = brDoc;
            m_PrintOptions = prnOpt;

            m_PrintDoc                    = new PrintDocument();
            m_PrintDoc.BeginPrint        += new PrintEventHandler(BrailleText_BeginPrint);
            m_PrintDoc.QueryPageSettings += new QueryPageSettingsEventHandler(BrailleText_QueryPageSettings);
            m_PrintDoc.PrintPage         += new PrintPageEventHandler(BrailleText_PrintPage);
            m_PrintDoc.EndPrint          += new PrintEventHandler(BrailleText_EndPrint);

            m_PreviewOnly = false;
        }
Ejemplo n.º 7
0
        /// <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();
            }
        }
Ejemplo n.º 8
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 = "";
            }
        }
Ejemplo n.º 9
0
        public BrailleConverter()
        {
            _zhuyinConverter = CreateZhuyinConverter(AppGlobals.Config.PreferIFELanguage);
            _processor       = BrailleProcessor.GetInstance(_zhuyinConverter);
            _doc             = new BrailleDocument(_processor);

            _processor.ConvertionFailed += new ConvertionFailedEventHandler(BrailleProcessor_ConvertionFailed);
            _processor.TextConverted    += new TextConvertedEventHandler(BrailleProcessor_TextConverted);

            //m_Processor.ChineseConverter = null;	// 保護

            m_CvtResultFileName    = Path.Combine(AppGlobals.TempPath, Constant.Files.CvtResultFileName);
            m_CvtErrorCharFileName = Path.Combine(AppGlobals.TempPath + Constant.Files.CvtErrorCharFileName);

            _verboseMode = false;

            LoadPhraseFiles();

            // TODO: 還需要這個嗎?
            ZhuyinQueryHelper.Initialize(); // 初始化注音字根查詢器(載入注音字根表)。
        }
Ejemplo n.º 10
0
 public DualPrintDialog(string filename)
     : this()
 {
     m_BrDoc = BrailleDocument.LoadBrailleFile(filename);
 }
Ejemplo n.º 11
0
 public DualPrintDialog(BrailleDocument brDoc)
     : this()
 {
     m_BrDoc = brDoc;
 }
Ejemplo n.º 12
0
 public DualEditController(BrailleDocument brDoc, SourceGrid.Grid grid)
 {
     m_BrDoc    = brDoc;
     brGrid     = grid;
     m_ViewMode = ViewMode.All;
 }