예제 #1
0
        private void btnMkAndPrint_Click(object sender, EventArgs e)
        {
            this.mtEnabled = false;
            this.Visible   = false;
            Gnd.i.mkAndPrintWinParentWin.Visible = false;

            try
            {
                CancellableBusyDlg.perform(false, delegate
                {
                    if (_historyData == null)                     // ? 作成未完了
                    {
                        if (Gnd.i.mkSudokuProc == null)
                        {
                            throw null;
                        }

                        Gnd.i.cancellableBusyDlg.setTitle("ナンプレを作成しています... (印刷は自動的に開始されます)");

                        while (Gnd.i.mkSudokuProc.isEnded() == false)
                        {
                            if (Gnd.i.cancelled)
                            {
                                Gnd.i.cancellableBusyDlg.setTitle("キャンセルしています...");
                                Gnd.i.mkSudokuProc.bCancel();
                                throw new Cancelled();
                            }
                            Thread.Sleep(2000);
                        }
                        Gnd.i.cancellableBusyDlg.setTitle("作成した問題を画像に変換しています...");

                        _historyData = Gnd.i.mkSudokuProc.getResult();
                        //historyDataCreated(); // もうこのフォームを表示しないので、呼ばなくて良い。

                        if (Gnd.i.cancelled)
                        {
                            throw new Cancelled();
                        }
                    }
                    Gnd.i.cancellableBusyDlg.setTitle("ナンプレを印刷しています...");

                    {
                        ImagePrinter imgPrn = new ImagePrinter();

                        if (this.cbUseDefaultMargin.Checked == false)
                        {
                            imgPrn.setMargin(getMaringLTRB());
                        }

                        if (this.cbUseDefaultPrinter.Checked == false)
                        {
                            imgPrn.setPrinterName(this.cmbPrinterName.SelectedItem.ToString());
                        }

                        if (this.cbUseDefaultPaperSize.Checked == false)
                        {
                            imgPrn.setPaperSizeName(this.cmbPaperSizeName.SelectedItem.ToString());
                        }

                        if (this.cbPrintProblem.Checked)
                        {
                            imgPrn.addImage(_historyData.getProblemImage());
                        }

                        if (this.cbPrintAnswer.Checked)
                        {
                            imgPrn.addImage(_historyData.getAnswerImage());
                        }

                        imgPrn.doPrint();
                    }

                    throw new Completed("印刷しました。");
                });
            }
            catch (Exception ex)
            {
                FaultOperation.caught(ex);
            }

            Gnd.i.mkAndPrintWinParentWin.Visible = true;
            //this.Visible = true;
            this.Close();
        }
예제 #2
0
 private void PreviewDlg_Shown(object sender, EventArgs e)
 {
     imgProblem.Image = _historyData.getProblemImage();
     imgAnswer.Image  = _historyData.getAnswerImage();
 }