예제 #1
0
        private void Btn_US_Click(object sender, EventArgs e)
        {
            try
            {
                this.US_Changed(true);

                long l;
                long t;
                long r;
                long b;

                try
                {
                    l = IntTools.GetLongRange(this.US_L, US_X_MIN, US_X_MAX).Value;
                    t = IntTools.GetLongRange(this.US_T, US_Y_MIN, US_Y_MAX).Value;
                    r = IntTools.GetLongRange(this.US_R, US_X_MIN, US_X_MAX).Value;
                    b = IntTools.GetLongRange(this.US_B, US_Y_MIN, US_Y_MAX).Value;
                }
                catch
                {
                    throw new Exception("座標の書式に問題があります。");
                }

                if (Gnd.I.SettingData.USCheckOff == false)
                {
                    if (r < l)
                    {
                        throw new Exception("[右下X] < [左上X] になっています。");
                    }

                    if (b < t)
                    {
                        throw new Exception("[右下Y] < [左上Y] になっています。");
                    }

                    long w = r - l + 1;
                    long h = b - t + 1;

                    if (US_W_H_MAX < w)
                    {
                        throw new Exception("[幅] は " + US_W_H_MAX + " 以下でなければなりません。");
                    }

                    if (US_W_H_MAX < h)
                    {
                        throw new Exception("[高さ] は " + US_W_H_MAX + " 以下でなければなりません。");
                    }

                    long wxh = w * h;

                    if (US_WXH_MAX < wxh)
                    {
                        throw new Exception("[幅×高さ] は " + US_WXH_MAX + " 以下でなければなりません。");
                    }
                }

                this.EC_Load(this.BtnPrimeColor);
                string primeColor = this.EC_RefStrColor;
                this.EC_Load(this.BtnNotPrimeColor);
                string notPrimeColor = this.EC_RefStrColor;
                this.EC_Load(this.BtnCenterColor);
                string centerColor = this.EC_RefStrColor;

                string outFile = SaveLoadDialogs.SaveFile(
                    "出力ファイルを指定してください",
                    "ビットマップ:bmp",
                    Directory.GetCurrentDirectory(),
                    "UlamSpiral_" + l + "_" + t + "_" + r + "_" + b + ".bmp"
                    );

                if (outFile == null)
                {
                    return;
                }

                AppTools.CheckOutputFile(outFile);

                this.Visible = false;

                using (UlamSpiralOutputDlg f = new UlamSpiralOutputDlg(l, t, r, b, primeColor, notPrimeColor, centerColor, outFile))
                {
                    f.ShowDialog();
                }
                this.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "BMPファイルを出力できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            finally
            {
                this.US_L.Focus();
                //this.US_L.SelectAll(); // 勝手に全セレクトされる。
            }
        }
예제 #2
0
        private void BtnPrimeCount_Click(object sender, EventArgs e)
        {
            try
            {
                //IntTools.Normalize(this.PrimeCountMinval);
                //IntTools.Normalize(this.PrimeCountMaxval);

                string strmin = this.PrimeCountMinval.Text;
                string strmax = this.PrimeCountMaxval.Text;

                if (IntTools.IsULongString(strmin) == false)
                {
                    throw new Exception("[最小値] に 0 ~ " + ulong.MaxValue + " の整数を入力して下さい。");
                }

                if (IntTools.IsULongString(strmax) == false)
                {
                    throw new Exception("[最大値] に 0 ~ " + ulong.MaxValue + " の整数を入力して下さい。");
                }

                ulong minval = ulong.Parse(strmin);
                ulong maxval = ulong.Parse(strmax);

                if (maxval < minval)
                {
                    throw new Exception("[最小値] に [最大値] より大きな値が入力されています。");
                }

                string outFile = SaveLoadDialogs.SaveFile(
                    "出力ファイルを指定してください",
                    "テキスト:txt",
                    Directory.GetCurrentDirectory(),
                    "PrimeCount_" + minval + "-" + maxval + ".txt"
                    );

                if (outFile == null)
                {
                    return;
                }

                AppTools.CheckOutputFile(outFile);

                this.Visible = false;

                using (PrimeRangeOutputDlg f = new PrimeRangeOutputDlg(minval, maxval, outFile, true))
                {
                    f.ShowDialog();
                }
                this.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    ex.Message,
                    "出力できません",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
            finally
            {
                this.PrimeCountMinval.Focus();
                //this.PrimeCountMinval.SelectAll(); // 勝手に全セレクトされる。
            }
        }