Esempio n. 1
0
        private void US_Changed(bool normalizeFlag)
        {
            IntTools.CheckLongRange(this.US_L, US_X_MIN, US_X_MAX, normalizeFlag);
            IntTools.CheckLongRange(this.US_T, US_Y_MIN, US_Y_MAX, normalizeFlag);
            IntTools.CheckLongRange(this.US_R, US_X_MIN, US_X_MAX, normalizeFlag);
            IntTools.CheckLongRange(this.US_B, US_Y_MIN, US_Y_MAX, normalizeFlag);

            {
                long?w   = null;
                long?h   = null;
                long?wxh = null;

                try
                {
                    long l = IntTools.GetLongRange(this.US_L, US_X_MIN, US_X_MAX).Value;
                    long t = IntTools.GetLongRange(this.US_T, US_Y_MIN, US_Y_MAX).Value;
                    long r = IntTools.GetLongRange(this.US_R, US_X_MIN, US_X_MAX).Value;
                    long b = IntTools.GetLongRange(this.US_B, US_Y_MIN, US_Y_MAX).Value;

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

                    if (1 <= w && w < int.MaxValue && 1 <= h && h < int.MaxValue)
                    {
                        wxh = w * h;
                    }
                }
                catch
                { }

                this.SizeInfo.Text = "幅: " + w + "\n高さ: " + h + "\n幅×高さ: " + wxh;

                if (w == null || h == null || wxh == null)                 // ? 異常
                {
                    this.SizeInfo.ForeColor = Color.Red;
                }
                else if (US_W_H_MAX < w || US_W_H_MAX < h || US_WXH_MAX < wxh)                 // ? 大きすぎる
                {
                    this.SizeInfo.ForeColor = Color.OrangeRed;
                }
                else                 // ? 正常
                {
                    this.SizeInfo.ForeColor = IntTools.DEF_TB_FORECOLOR;
                }
            }
        }
Esempio n. 2
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(); // 勝手に全セレクトされる。
            }
        }