Example #1
0
        private void CloseWindow()
        {
            using (this.MTBusy.Section())
            {
                try
                {
                    // -- 9000

                    BusyDlgTools.Show("Prime4096", "アプリケーションを終了しています...", () =>
                    {
                        Prime53Lite.RemovePrimeDat();
                    },
                                      true
                                      );

                    Ground.Destroy();

                    // ----
                }
                catch (Exception e)
                {
                    MessageBox.Show("" + e, "Error @ CloseWindow()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                this.MTBusy.Enter();
                this.Close();
            }
        }
Example #2
0
        private void Btn判定_Click(object sender, EventArgs e)
        {
            string text = "";

            using (this.MTBusy.Section())
            {
                try
                {
                    string value = this.T判定_入力.Text;

                    if (value == "")
                    {
                        throw new Exception("未入力です。");
                    }

                    if (StringTools.LiteValidate(value, StringTools.DECIMAL) == false)
                    {
                        throw new Exception("[0-9] 以外の文字が含まれています。");
                    }

                    if (Ground.TCalc_Int.Calc(Consts.S2P4096_1, "-", value)[0] == '-')
                    {
                        throw new LongMessageException(Utils.AutoInsertNewLine("0 以上 " + Consts.S2P4096_1 + " 以下の整数を入力して下さい。", Consts.MaxLineLen_LongMessageDlg));
                    }

                    this.Visible = false;

                    BusyDlgTools.Show("Prime4096", "素数かどうか判定しています...", () =>
                    {
                        text = value + "\r\n----> " + (Prime4096.IsPrime(value) ? "素数です。" : "素数ではありません。");
                    }
                                      );
                }
                catch (Exception ex)
                {
                    this.CommonCought(ex);
                }
            }
            this.Visible = true;             // 復元

            this.T判定_結果.Text           = text;
            this.T判定_結果.SelectionStart = this.T判定_結果.TextLength;
            this.T判定_結果.ScrollToCaret();
        }
Example #3
0
        private void DrawGrph(GrphCond cond)
        {
            if (Ground.I.GrphData == null || cond.CurrPair != Ground.I.GrphData.CurrPair)             // ? グラフデータ更新の必要あり
            {
                Ground.I.GrphData = null;
                GC.Collect();

                BusyDlgTools.Show(Program.APP_TITLE, "グラフデータをロードしています。(通貨ペア:" + cond.CurrPair + ")", () =>
                {
                    Ground.I.GrphData = new GrphData(cond.CurrPair);
                });

                GC.Collect();
            }

            Ground.I.GrphData.SetRange(cond.DateTimeSt, cond.DateTimeEd);

            // ---- グラフの描画ここから

            this.MChart.Series.Clear();
            this.MChart.ChartAreas.Clear();

            double yMin = double.MaxValue;
            double yMax = double.MinValue;

            // Low
            {
                Series srs = new Series();
                srs.ChartType   = SeriesChartType.Line;
                srs.Color       = Color.LightGray;
                srs.BorderWidth = 2;

                for (int index = Ground.I.GrphData.Start; index <= Ground.I.GrphData.End; index += Ground.I.GrphData.Step)
                {
                    GrphData.PriceInfo price = Ground.I.GrphData.GetPrice(index);
                    double             low   = price.Low;

                    yMin = Math.Min(yMin, low);
                    yMax = Math.Max(yMax, low);

                    srs.Points.AddXY(price.TTSec / 86400.0, low);
                }
                this.MChart.Series.Add(srs);
            }

            // Hig
            {
                Series srs = new Series();
                srs.ChartType   = SeriesChartType.Line;
                srs.Color       = Color.LightGray;
                srs.BorderWidth = 2;

                for (int index = Ground.I.GrphData.Start; index <= Ground.I.GrphData.End; index += Ground.I.GrphData.Step)
                {
                    GrphData.PriceInfo price = Ground.I.GrphData.GetPrice(index);
                    double             hig   = price.Hig;

                    yMin = Math.Min(yMin, hig);
                    yMax = Math.Max(yMax, hig);

                    srs.Points.AddXY(price.TTSec / 86400.0, hig);
                }
                this.MChart.Series.Add(srs);
            }

            // Mid
            {
                Series srs = new Series();
                srs.ChartType = SeriesChartType.Line;
                srs.Color     = Color.Green;

                for (int index = Ground.I.GrphData.Start; index <= Ground.I.GrphData.End; index += Ground.I.GrphData.Step)
                {
                    GrphData.PriceInfo price = Ground.I.GrphData.GetPrice(index);
                    double             mid   = price.Mid;

                    yMin = Math.Min(yMin, mid);
                    yMax = Math.Max(yMax, mid);

                    srs.Points.AddXY(price.TTSec / 86400.0, mid);
                }
                this.MChart.Series.Add(srs);
            }

            Color[] maColors = new Color[]
            {
                Color.Red,
                Color.Blue,
                Color.Purple,
                Color.DarkCyan,
                Color.DarkOrange,
            };

            for (int maIndex = 0; maIndex < cond.MaDays.Length; maIndex++)
            {
                GrphCond.MaDayInfo maDay = cond.MaDays[maIndex];
                int   maColorIndex       = Math.Min(maIndex, maColors.Length - 1);
                Color maColor            = maColors[maColorIndex];

                // ma
                {
                    Series srs = new Series();
                    srs.ChartType = SeriesChartType.Line;
                    srs.Color     = maColor;

                    for (int index = Ground.I.GrphData.Start; index <= Ground.I.GrphData.End; index += Ground.I.GrphData.Step)
                    {
                        GrphData.PriceInfo price = Ground.I.GrphData.GetPrice(index);
                        double             maVal = price.MaVals[maDay.Index];

                        yMin = Math.Min(yMin, maVal);
                        yMax = Math.Max(yMax, maVal);

                        srs.Points.AddXY(price.TTSec / 86400.0, maVal);
                    }
                    this.MChart.Series.Add(srs);
                }
            }

            // ca
            {
                ChartArea ca = new ChartArea();
                double    axInterval;

                {
                    long span = Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).TTSec - Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).TTSec;

                    if (span < 86400)
                    {
                        axInterval = 1.0 / 24;
                    }
                    else if (span < 86400 * 2)
                    {
                        axInterval = 0.5;
                    }
                    else if (span < 86400 * 20)
                    {
                        axInterval = 1.0;
                    }
                    else
                    {
                        axInterval = 10.0;
                    }
                }

                ca.AxisX.Minimum  = Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).TTSec / 86400.0;
                ca.AxisX.Maximum  = Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).TTSec / 86400.0;
                ca.AxisX.Interval = axInterval;
                ca.AxisY.Minimum  = yMin;
                ca.AxisY.Maximum  = yMax;

                this.MChart.ChartAreas.Add(ca);
            }

            // ---- グラフの描画ここまで
        }