Пример #1
0
        private void MainWin_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Visible = false;

            // Programs.cs から移動してきた終了処理 ----->

            Utils.WriteLog("MainWin_FormClosed");

            CancellableBusyDlg.perform(true, delegate
            {
                Utils.WriteLog("CancellableBusyDlg.perform");

                Gnd.i.cancellableBusyDlg.setTitle("終了しています...");

                Gnd.i.n2Listener.Dispose();                 // n2Recver を使っているので、こっちを先に!
                Gnd.i.n2Listener = null;

                Gnd.i.n2Recver.Dispose();
                Gnd.i.n2Recver = null;

                Utils.WriteLog("CancellableBusyDlg.perform ended");
            });

            Utils.WriteLog("MainWin_FormClosed ended");
        }
Пример #2
0
        private void btnMkAndPrint_Click(object sender, EventArgs e)
        {
            ProblemInfo pi    = Gnd.i.problemInfos[lbKind.SelectedIndex];
            int         level = cmbDifficulty.SelectedIndex;

            Gnd.i.mkAndPrintWinParentWin = this;
            Gnd.i.mkSudokuProc           = new MkSudokuProc(pi, level);

            using (MkAndPrintWin f = new MkAndPrintWin(pi, level))
            {
                f.ShowDialog();
            }
            if (Gnd.i.mkSudokuProc.isEnded() == false)
            {
                CancellableBusyDlg.perform(true, delegate
                {
                    Gnd.i.cancellableBusyDlg.setTitle("問題作成プロセスを停止しています...");
                    Gnd.i.mkSudokuProc.bCancel();
                });
            }
            Gnd.i.mkSudokuProc.Dispose();
            Gnd.i.mkSudokuProc           = null;
            Gnd.i.mkAndPrintWinParentWin = null;

            HistoryDataUtils.trimHistories();

            GC.Collect();
        }
Пример #3
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();
        }