Exemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            // 紙張大小
            if (rdoUserDefinedPaper.Checked)
            {
                // 由 user 指定
                if (cboPaper.SelectedIndex < 0)
                {
                    MsgBoxHelper.ShowInfo("請選擇紙張大小!");
                    return;
                }
            }
            else
            {
                // 由程式指定
                //m_PrnDoc.DefaultPageSettings.PaperSize = new PaperSize("custom",
                //    DualPrintHelper.PaperWidth, DualPrintHelper.PaperHeight);
            }

            // 紙張來源
            if (cboPaperSource.SelectedIndex < 0)
            {
                MsgBoxHelper.ShowInfo("請選擇紙張來源!");
                cboPaperSource.Focus();
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 2
0
        private static void UpdateOnFirstRun()
        {
            if (!IsFirstLaunch())
            {
                return;
            }

            using (var form = new Splash())
            {
                form.ShowInTaskbar      = true;
                form.Icon               = Resources.qsp_icon;
                form.SmallTitleLbl.Text = "Checking for updates ...";
                form.SmallTitleLbl.Font =
                    new Font("Segoe UI", 12F, FontStyle.Italic, GraphicsUnit.Point, 0);

                form.Shown += (s, e) =>
                {
                    form.Refresh();

                    var status = new Updater().Update();
                    if (status.Status == Updater.Status.Success)
                    {
                        form.Close();
                        MsgBoxHelper.ShowInfo(null, "QSimPlanner has been successfully updated" +
                                              " and will restart now.");
                        StartLauncher();
                        Environment.Exit(0);
                    }

                    form.Close();
                };

                form.ShowDialog();
            }
        }
Exemplo n.º 3
0
 private void FindNext()
 {
     if (!m_FindForm.FindNext())
     {
         MsgBoxHelper.ShowInfo("已搜尋至文件結尾。");
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 直接預覽明眼字,而不顯示列印對話窗。
        /// </summary>
        public void PreviewText()
        {
            LoadSettings();     // 載入先前儲存的設定。

            if (m_BrDoc.Lines.Count < 1)
            {
                MsgBoxHelper.ShowInfo("沒有資料可供列印!");
                return;
            }

            if (cboPrinters.SelectedIndex < 0)
            {
                MsgBoxHelper.ShowInfo("尚未選擇印表機!");
                return;
            }

            m_DontSaveSettings = true;                          // 視窗關閉時不要儲存設定
            cboPrintTextManualDoubleSide.SelectedIndex = 0;

            PrintOptions prnOpt = GetPrintOptions();

            if (prnOpt == null)
            {
                return;
            }

            DualPrintHelper prn = new DualPrintHelper(m_BrDoc, prnOpt);

            prn.PrintText(true);
        }
Exemplo n.º 5
0
        private void btnPrintText_Click(object sender, EventArgs e)
        {
            if (m_BrDoc.Lines.Count < 1)
            {
                MsgBoxHelper.ShowInfo("沒有資料可供列印!");
                return;
            }

            if (cboPrinters.SelectedIndex < 0)
            {
                MsgBoxHelper.ShowInfo("尚未選擇印表機!");
                return;
            }

            PrintOptions prnOpt = GetPrintOptions();

            if (prnOpt == null)
            {
                return;
            }

            DualPrintHelper prn = new DualPrintHelper(m_BrDoc, prnOpt);

            prn.PrintText(false);
        }
Exemplo n.º 6
0
 private void btnFind_Click(object sender, EventArgs e)
 {
     m_CaseSensitive = chkCaseSensitive.Checked;
     if (!FindNext())
     {
         MsgBoxHelper.ShowInfo("已搜尋至文件結尾。");
     }
 }
Exemplo n.º 7
0
        private void btnRemovePhraseTbl_Click(object sender, EventArgs e)
        {
            if (clbPhraseTbl.SelectedIndex < 0)
            {
                MsgBoxHelper.ShowInfo("請先選擇欲移除的詞庫檔案!");
                return;
            }

            clbPhraseTbl.Items.RemoveAt(clbPhraseTbl.SelectedIndex);
        }
Exemplo n.º 8
0
        /// <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 = "";
            }
        }
        private void EndPrintBraille(bool toBrailler, bool toFile)
        {
            StringBuilder sb = new StringBuilder("點字已輸出至指定的");

            if (toBrailler && toFile)
            {
                sb.Append("點字印表機和檔案。");
            }
            else
            {
                sb.Append(toBrailler ? "點字印表機。" : "檔案。");
            }
            MsgBoxHelper.ShowInfo(sb.ToString());
        }
Exemplo n.º 10
0
        private void DoPrint()
        {
            if (m_BrDoc.LineCount < 1)
            {
                MsgBoxHelper.ShowInfo("沒有資料可供列印!");
                return;
            }

            m_BrDoc.UpdateTitlesLineIndex();

            DualPrintDialog prnDlg = new DualPrintDialog(m_BrDoc);

            prnDlg.ShowDialog();
        }
Exemplo n.º 11
0
        private void btnPickBraille_Click(object sender, EventArgs e)
        {
            PickBrailleForm form = new PickBrailleForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                int newLen = txtBraille.Text.Length - txtBraille.SelectionLength + form.BrailleText.Length;
                if (newLen > 3)
                {
                    MsgBoxHelper.ShowInfo("點字最多只能輸入三方!");
                    return;
                }

                ControlHelper.InputText(txtBraille, form.BrailleText);
            }
        }
Exemplo n.º 12
0
        private async Task CheckUpdateAsync()
        {
            if (!SysInfo.IsNetworkConnected())
            {
                MsgBoxHelper.ShowInfo("未偵測到網路連線,無法執行線上更新!");
                return;
            }

            if (await DoUpdateAsync(false))
            {
                string msg = "應用程式必須重新啟動才能完成更新程序,是否立即重新啟動?\r\n若您有資料尚未儲存,請選擇【否】。";
                if (MsgBoxHelper.ShowYesNo(msg) == DialogResult.Yes)
                {
                    Process.Start(Application.ExecutablePath);
                    Application.Exit();
                    return;
                }
            }
        }
Exemplo n.º 13
0
        private void btnPrintBraille_Click(object sender, EventArgs e)
        {
            if (m_BrDoc.Lines.Count < 1)
            {
                MsgBoxHelper.ShowInfo("沒有資料可供列印!");
                return;
            }

            bool   isToFile = chkPrintBrailleToFile.Checked;
            string fileName = txtBrailleFileName.TextBox.Text.Trim();

            if (isToFile && String.IsNullOrEmpty(fileName))
            {
                MsgBoxHelper.ShowInfo("請指定欲輸出的檔案名稱。");
                txtBrailleFileName.Focus();
                return;
            }

            if (chkPrintBraille.Checked)
            {
                if (String.IsNullOrWhiteSpace(cboPrintersForBraille.Text))
                {
                    MessageBox.Show("請指定欲輸出點字的印表機!");
                    cboPrintersForBraille.Focus();
                    return;
                }
            }

            PrintOptions prnOpt = GetPrintOptions();

            if (prnOpt == null)
            {
                return;
            }
            DualPrintHelper prn = new DualPrintHelper(m_BrDoc, prnOpt);

            prn.PrintBraille(chkPrintBraille.Checked, chkPrintBrailleToFile.Checked, fileName);
        }
Exemplo n.º 14
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     MsgBoxHelper.ShowInfo("此功能尚未完成!");
 }
Exemplo n.º 15
0
        /// <summary>
        /// 將目前的列印參數蒐集並集中存入 PrintOptions 物件。
        /// </summary>
        /// <returns></returns>
        private PrintOptions GetPrintOptions()
        {
            PrintOptions prnOpt = new PrintOptions
            {
                LinesPerPage  = AppGlobals.Config.Braille.LinesPerPage,
                PrintPageFoot = chkPrintPageFoot.Checked,

                // 列印範圍
                AllPages = rdoPrintAll.Checked
            };

            if (!prnOpt.AllPages)
            {
                string[] pageRange = txtPageRange.Text.Split(new char[] { '-' });
                if (pageRange.Length != 2)
                {
                    MsgBoxHelper.ShowInfo("列印範圍無效: " + txtPageRange.Text);
                    txtPageRange.Focus();
                    return(null);
                }

                prnOpt.FromPage = Convert.ToInt32(pageRange[0]);
                prnOpt.ToPage   = Convert.ToInt32(pageRange[1]);

                if (prnOpt.FromPage <= 0 || prnOpt.ToPage <= 0 || prnOpt.FromPage > prnOpt.ToPage)
                {
                    MsgBoxHelper.ShowInfo("列印範圍無效: " + txtPageRange.Text);
                    txtPageRange.Focus();
                    return(null);
                }
                int totalPages = AppGlobals.CalcTotalPages(m_BrDoc.Lines.Count, prnOpt.LinesPerPage, prnOpt.PrintPageFoot);
                if (prnOpt.FromPage > totalPages || prnOpt.ToPage > totalPages)
                {
                    MsgBoxHelper.ShowInfo("列印範圍無效! 起始頁或終止頁超出總頁數。");
                    txtPageRange.Focus();
                    return(null);
                }
            }

            // 起始頁碼
            prnOpt.ReassignStartPageNumber = chkChangeStartPageNum.Checked;
            if (prnOpt.ReassignStartPageNumber)
            {
                try
                {
                    prnOpt.StartPageNumber = Convert.ToInt32(txtStartPageNumber.Text);
                    if (prnOpt.StartPageNumber < 1)
                    {
                        MsgBoxHelper.ShowInfo("無效的起始頁碼: " + txtStartPageNumber.Text);
                        return(null);
                    }
                }
                catch
                {
                    MsgBoxHelper.ShowInfo("無效的起始頁碼: " + txtStartPageNumber.Text);
                    return(null);
                }
            }

            // 手動雙面列印
            switch (cboPrintTextManualDoubleSide.SelectedIndex)
            {
            case 1:
                prnOpt.DoubleSideEffect = DoubleSideEffect.OddPages;
                break;

            case 2:
                prnOpt.DoubleSideEffect = DoubleSideEffect.EvenPages;
                break;

            default:
                prnOpt.DoubleSideEffect = DoubleSideEffect.None;
                break;
            }

            prnOpt.PrinterName           = cboPrinters.Text;
            prnOpt.PrinterNameForBraille = cboPrintersForBraille.Text;
            prnOpt.PaperSourceName       = m_PaperSourceName;
            prnOpt.PaperName             = m_PaperName;
            prnOpt.OddPageMargins        = m_OddPageMargins;
            prnOpt.EvenPageMargins       = m_EvenPageMargins;

            prnOpt.BrSendPageBreakAtEndOfDoc = chkSendPageBreakAtEof.Checked;

            return(prnOpt);
        }
Exemplo n.º 16
0
        private async Task <bool> DoUpdateAsync(bool autoMode)
        {
            HttpUpdater updater = new HttpUpdater()
            {
                ClientPath        = Application.StartupPath,
                ServerUri         = AppGlobals.Config.AutoUpdateFilesUrl,
                ChangeLogFileName = "ChangeLog.txt"
            };

            // debug using local update feed.
            //updater.ServerUri = "http://localhost/ebeupdate/";

            try
            {
                await updater.GetUpdateListAsync();
            }
            catch (Exception ex)
            {
                // 無法取得檔案更新清單(可能是網際網路無法連線)
                string msg = "無法取得檔案更新清單: " + ex.Message;
                if (autoMode)
                {
                    StatusText = msg;
                }
                else
                {
                    MsgBoxHelper.ShowError(msg);
                }
                return(false);
            }

            if (updater.HasUpdates())
            {
                if (MsgBoxHelper.ShowYesNo("「易點雙視」有新版本,是否立即更新?") == DialogResult.Yes)
                {
                    UpdateProgressForm updForm = new UpdateProgressForm();
                    updForm.Show();

                    try
                    {
                        updater.FileUpdating            += updForm.updator_FileUpdating;
                        updater.FileUpdated             += updForm.updator_FileUpdated;
                        updater.DownloadProgressChanged += updForm.updator_DownloadProgressChanged;

                        if (await updater.UpdateAsync() > 0)
                        {
                            updForm.TopMost = false;
                            var fvi = FileVersionInfo.GetVersionInfo(Application.ExecutablePath);

                            MsgBoxHelper.ShowInfo("「易點雙視」更新完成!");
                            return(true);
                        }
                    }
                    catch (Exception ex)
                    {
                        updForm.TopMost = false;
                        MsgBoxHelper.ShowError("更新失敗!\r\n" + ex.Message);
                    }
                    finally
                    {
                        updForm.Close();
                        updForm.Dispose();
                    }
                }
            }
            else
            {
                if (!autoMode)
                {
                    MsgBoxHelper.ShowInfo("您使用的已經是最新版,無須更新。");
                }
            }
            return(false);
        }