private void ExpandSpan(double rate) { long sec1 = DateTimeToSec.ToSec(long.Parse(this.DateTimeSt.Text)); long sec2 = DateTimeToSec.ToSec(long.Parse(this.DateTimeEd.Text)); long span = sec2 - sec1; span = Math.Max(span, 120); // 2 min <= span = DoubleTools.ToLong(span * rate); sec1 = sec2 - span; long st = DateTimeToSec.ToDateTime(sec1); st = Math.Max(st, Ground.I.Period_DateTimeSt); sec1 = DateTimeToSec.ToSec(st); sec2 = sec1 + span; long ed = DateTimeToSec.ToDateTime(sec2); ed = Math.Min(ed, Ground.I.Period_DateTimeEd); this.DateTimeSt.Text = st.ToString(); this.DateTimeEd.Text = ed.ToString(); }
private void ChartMoveMove(Chart chart, int x, int y) { try { double aX = chart.ChartAreas[0].AxisX.PixelPositionToValue(x); double aY = chart.ChartAreas[0].AxisY.PixelPositionToValue(y); long ttSec = DoubleTools.ToLong(aX * 86400.0); long dt = TTCommon.TTSecToDateTime(ttSec); this.TTip.SetToolTip( chart, DateTimeUnit.FromDateTime(dt).ToString() + "\n" + aY.ToString("F9") ); } catch { } }
private void MChart_MouseMove(object sender, MouseEventArgs e) { int x = e.X; int y = e.Y; if (this.MCMM_LastX == x && this.MCMM_LastY == y) { return; } this.MCMM_LastX = x; this.MCMM_LastY = y; if (this.MChart.ChartAreas.Count == 0) // ? 未表示 { return; } if (Ground.I.GrphData == null) // ? 未表示 { return; } if (Ground.I.GrphData.Start == -1) // ? 未表示 { return; } try { double aX = this.MChart.ChartAreas[0].AxisX.PixelPositionToValue(x); double aY = this.MChart.ChartAreas[0].AxisY.PixelPositionToValue(y); long ttSec = DoubleTools.ToLong(aX * 86400.0); long dt = TTCommon.TTSecToDateTime(ttSec); this.TTip.SetToolTip( this.MChart, DateTimeUnit.FromDateTime(dt).ToString() + "\n" + aY.ToString("F9") ); } catch { } }
// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // public static void Save() { List <byte[]> blocks = new List <byte[]>(); // Donut3 用のセーブデータ { List <string> lines = new List <string>(); lines.Add(Program.APP_IDENT); lines.Add(Program.APP_TITLE); lines.Add("" + DDGround.RealScreen_W); lines.Add("" + DDGround.RealScreen_H); lines.Add("" + DDGround.RealScreenDraw_L); lines.Add("" + DDGround.RealScreenDraw_T); lines.Add("" + DDGround.RealScreenDraw_W); lines.Add("" + DDGround.RealScreenDraw_H); lines.Add("" + DoubleTools.ToLong(DDGround.MusicVolume * IntTools.IMAX)); lines.Add("" + DoubleTools.ToLong(DDGround.SEVolume * IntTools.IMAX)); lines.Add("" + DDInput.DIR_2.BtnId); lines.Add("" + DDInput.DIR_4.BtnId); lines.Add("" + DDInput.DIR_6.BtnId); lines.Add("" + DDInput.DIR_8.BtnId); lines.Add("" + DDInput.A.BtnId); lines.Add("" + DDInput.B.BtnId); lines.Add("" + DDInput.C.BtnId); lines.Add("" + DDInput.D.BtnId); lines.Add("" + DDInput.E.BtnId); lines.Add("" + DDInput.F.BtnId); lines.Add("" + DDInput.L.BtnId); lines.Add("" + DDInput.R.BtnId); lines.Add("" + DDInput.PAUSE.BtnId); lines.Add("" + DDInput.START.BtnId); lines.Add("" + DDInput.DIR_2.KeyId); lines.Add("" + DDInput.DIR_4.KeyId); lines.Add("" + DDInput.DIR_6.KeyId); lines.Add("" + DDInput.DIR_8.KeyId); lines.Add("" + DDInput.A.KeyId); lines.Add("" + DDInput.B.KeyId); lines.Add("" + DDInput.C.KeyId); lines.Add("" + DDInput.D.KeyId); lines.Add("" + DDInput.E.KeyId); lines.Add("" + DDInput.F.KeyId); lines.Add("" + DDInput.L.KeyId); lines.Add("" + DDInput.R.KeyId); lines.Add("" + DDInput.PAUSE.KeyId); lines.Add("" + DDInput.START.KeyId); lines.Add("" + (DDGround.RO_MouseDispMode ? 1 : 0)); // 新しい項目をここへ追加... blocks.Add(DDUtils.SplitableJoin(lines.ToArray())); } // アプリ固有のセーブデータ { List <string> lines = new List <string>(); // app > @ Save //lines.Add("G4NovelAdv-Dummy"); // Dummy lines.Add("" + Ground.I.MessageSpeed); // 新しい項目をここへ追加... // < app blocks.Add(DDUtils.SplitableJoin(lines.ToArray())); } File.WriteAllBytes(DDConsts.SaveDataFile, DDJammer.Encode(BinTools.SplittableJoin(blocks.ToArray()))); }
// // copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c // public static void Save() { List <byte[]> blocks = new List <byte[]>(); // for Donut2 { List <string> lines = new List <string>(); lines.Add(Program.APP_IDENT); lines.Add(Program.APP_TITLE); lines.Add("" + DDGround.RealScreen_W); lines.Add("" + DDGround.RealScreen_H); lines.Add("" + DDGround.RealScreenDraw_L); lines.Add("" + DDGround.RealScreenDraw_T); lines.Add("" + DDGround.RealScreenDraw_W); lines.Add("" + DDGround.RealScreenDraw_H); lines.Add("" + DoubleTools.ToLong(DDGround.MusicVolume * IntTools.IMAX)); lines.Add("" + DoubleTools.ToLong(DDGround.SEVolume * IntTools.IMAX)); lines.Add("" + DDInput.DIR_2.BtnId); lines.Add("" + DDInput.DIR_4.BtnId); lines.Add("" + DDInput.DIR_6.BtnId); lines.Add("" + DDInput.DIR_8.BtnId); lines.Add("" + DDInput.A.BtnId); lines.Add("" + DDInput.B.BtnId); lines.Add("" + DDInput.C.BtnId); lines.Add("" + DDInput.D.BtnId); lines.Add("" + DDInput.E.BtnId); lines.Add("" + DDInput.F.BtnId); lines.Add("" + DDInput.L.BtnId); lines.Add("" + DDInput.R.BtnId); lines.Add("" + DDInput.PAUSE.BtnId); lines.Add("" + DDInput.START.BtnId); lines.Add("" + DDInput.DIR_2.KeyId); lines.Add("" + DDInput.DIR_4.KeyId); lines.Add("" + DDInput.DIR_6.KeyId); lines.Add("" + DDInput.DIR_8.KeyId); lines.Add("" + DDInput.A.KeyId); lines.Add("" + DDInput.B.KeyId); lines.Add("" + DDInput.C.KeyId); lines.Add("" + DDInput.D.KeyId); lines.Add("" + DDInput.E.KeyId); lines.Add("" + DDInput.F.KeyId); lines.Add("" + DDInput.L.KeyId); lines.Add("" + DDInput.R.KeyId); lines.Add("" + DDInput.PAUSE.KeyId); lines.Add("" + DDInput.START.KeyId); lines.Add("" + (DDGround.RO_MouseDispMode ? 1 : 0)); // 新しい項目をここへ追加... blocks.Add(DDUtils.SplitableJoin(lines.ToArray())); } // for app { List <string> lines = new List <string>(); DDAdditionalEvents.Save(lines); blocks.Add(DDUtils.SplitableJoin(lines.ToArray())); } File.WriteAllBytes(DDConsts.SaveDataFile, DDJammer.Encode(BinTools.SplittableJoin(blocks.ToArray()))); }
private void DrawCharts() { long ttSecStart = this.TTSecEnd - this.TTSecStep * (Consts.PLOT_NUM - 1); this.MaChart.Series.Clear(); this.MaChart.Legends.Clear(); this.MaChart.ChartAreas.Clear(); double maYMin = double.MaxValue; double maYMax = double.MinValue; // Low { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = Color.LightGray; srs.BorderWidth = 2; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = ChartSrvc.I.Ttc.GetPrice(ttSec).Low; maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } // Hig { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = Color.LightGray; srs.BorderWidth = 2; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = ChartSrvc.I.Ttc.GetPrice(ttSec).Hig; maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } // Mid { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = Color.Green; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = ChartSrvc.I.Ttc.GetPrice(ttSec).Mid; maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } for (int maIndex = 0; maIndex < ChartSrvc.I.Macs.Length; maIndex++) { ChartSrvc.MacInfo mac = ChartSrvc.I.Macs[maIndex]; Color maColor = Consts.MaColors[maIndex]; // ma { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = maColor; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double y = mac.Mac.GetPrice(ttSec); maYMin = Math.Min(maYMin, y); maYMax = Math.Max(maYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.MaChart.Series.Add(srs); } } // ca { ChartArea ca = new ChartArea(); ca.AxisX.Minimum = ttSecStart / 86400.0; ca.AxisX.Maximum = this.TTSecEnd / 86400.0; ca.AxisY.Minimum = maYMin; ca.AxisY.Maximum = maYMax; { double q = (ca.AxisX.Maximum - ca.AxisX.Minimum) / 6.0; double x1 = ca.AxisX.Minimum; double x2 = ca.AxisX.Minimum + q * 2.0; double x3 = ca.AxisX.Minimum + q * 4.0; double x4 = ca.AxisX.Maximum; double xVal1 = ca.AxisX.Minimum + q * 1.0; double xVal2 = ca.AxisX.Minimum + q * 3.0; double xVal3 = ca.AxisX.Minimum + q * 5.0; #if true #if true long xSec1 = DoubleTools.ToLong(xVal1 * 86400.0); long xSec2 = DoubleTools.ToLong(xVal2 * 86400.0); long xSec3 = DoubleTools.ToLong(xVal3 * 86400.0); string xL1 = StringUtils.SecSpanToUIString(0); string xL2 = StringUtils.SecSpanToUIString(xSec2 - xSec1); string xL3 = StringUtils.SecSpanToUIString(xSec3 - xSec1); #else // old string xL1 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal1 * 86400.0))).ToString(); string xL2 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal2 * 86400.0))).ToString(); string xL3 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal3 * 86400.0))).ToString(); #endif ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xL1, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xL2, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xL3, 0, LabelMarkStyle.None, GridTickTypes.All)); #else // old ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); #endif } { double q = (ca.AxisY.Maximum - ca.AxisY.Minimum) / 6.0; double y1 = ca.AxisY.Minimum; double y2 = ca.AxisY.Minimum + q * 2.0; double y3 = ca.AxisY.Minimum + q * 4.0; double y4 = ca.AxisY.Maximum; double yVal1 = ca.AxisY.Minimum + q * 1.0; double yVal2 = ca.AxisY.Minimum + q * 3.0; double yVal3 = ca.AxisY.Minimum + q * 5.0; ca.AxisY.CustomLabels.Add(new CustomLabel(y1, y2, yVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y2, y3, yVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y3, y4, yVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); } this.MaChart.ChartAreas.Add(ca); } this.DmaChart.Series.Clear(); this.DmaChart.Legends.Clear(); this.DmaChart.ChartAreas.Clear(); double dmaYMin = Consts.DMA_LOW_03; double dmaYMax = Consts.DMA_HIG_03; { Action <double, int, Color> drawHorizontallyLine = (y, width, color) => { double x1 = ttSecStart / 86400.0; double x2 = this.TTSecEnd / 86400.0; Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = color; srs.BorderWidth = width; srs.Points.AddXY(x1, y); srs.Points.AddXY(x2, y); this.DmaChart.Series.Add(srs); }; drawHorizontallyLine(Consts.DMA_HIG_03, 7, Color.LightBlue); drawHorizontallyLine(Consts.DMA_HIG_02, 5, Color.LightBlue); drawHorizontallyLine(Consts.DMA_HIG_01, 3, Color.LightBlue); drawHorizontallyLine(0.0, 3, Color.LightGray); drawHorizontallyLine(Consts.DMA_LOW_01, 3, Color.LightPink); drawHorizontallyLine(Consts.DMA_LOW_02, 5, Color.LightPink); drawHorizontallyLine(Consts.DMA_LOW_03, 7, Color.LightPink); } for (int maIndex = 0; maIndex < ChartSrvc.I.Macs.Length; maIndex++) { ChartSrvc.MacInfo mac = ChartSrvc.I.Macs[maIndex]; Color maColor = Consts.MaColors[maIndex]; // ma { Series srs = new Series(); srs.ChartType = SeriesChartType.Line; srs.Color = maColor; for (int index = 0; index < Consts.PLOT_NUM; index++) { long ttSec = this.TTSecEnd - this.TTSecStep * index; double prY = ChartSrvc.I.Ttc.GetPrice(ttSec).Mid; double maY = mac.Mac.GetPrice(ttSec); double y = (prY - maY) / maY; dmaYMin = Math.Min(dmaYMin, y); dmaYMax = Math.Max(dmaYMax, y); srs.Points.AddXY(ttSec / 86400.0, y); } this.DmaChart.Series.Add(srs); } } // ca { ChartArea ca = new ChartArea(); ca.AxisX.Minimum = ttSecStart / 86400.0; ca.AxisX.Maximum = this.TTSecEnd / 86400.0; ca.AxisY.Minimum = dmaYMin; ca.AxisY.Maximum = dmaYMax; { double q = (ca.AxisX.Maximum - ca.AxisX.Minimum) / 6.0; double x1 = ca.AxisX.Minimum; double x2 = ca.AxisX.Minimum + q * 2.0; double x3 = ca.AxisX.Minimum + q * 4.0; double x4 = ca.AxisX.Maximum; double xVal1 = ca.AxisX.Minimum + q * 1.0; double xVal2 = ca.AxisX.Minimum + q * 3.0; double xVal3 = ca.AxisX.Minimum + q * 5.0; #if true string xL1 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal1 * 86400.0))).ToString(); string xL2 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal2 * 86400.0))).ToString(); string xL3 = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(DoubleTools.ToLong(xVal3 * 86400.0))).ToString(); ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xL1, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xL2, 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xL3, 0, LabelMarkStyle.None, GridTickTypes.All)); #else // old ca.AxisX.CustomLabels.Add(new CustomLabel(x1, x2, xVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x2, x3, xVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisX.CustomLabels.Add(new CustomLabel(x3, x4, xVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); #endif } { double q = (ca.AxisY.Maximum - ca.AxisY.Minimum) / 6.0; double y1 = ca.AxisY.Minimum; double y2 = ca.AxisY.Minimum + q * 2.0; double y3 = ca.AxisY.Minimum + q * 4.0; double y4 = ca.AxisY.Maximum; double yVal1 = ca.AxisY.Minimum + q * 1.0; double yVal2 = ca.AxisY.Minimum + q * 3.0; double yVal3 = ca.AxisY.Minimum + q * 5.0; ca.AxisY.CustomLabels.Add(new CustomLabel(y1, y2, yVal1.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y2, y3, yVal2.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); ca.AxisY.CustomLabels.Add(new CustomLabel(y3, y4, yVal3.ToString("F3"), 0, LabelMarkStyle.None, GridTickTypes.All)); } this.DmaChart.ChartAreas.Add(ca); } { string text = DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(ttSecStart)).ToString() + " ~ " + DateTimeUnit.FromDateTime(TTCommon.TTSecToDateTime(this.TTSecEnd)).ToString() + ", Range: " + (this.TTSecEnd - ttSecStart) + " sec (" + ((this.TTSecEnd - ttSecStart) / 86400.0) + " days), Step: " + this.TTSecStep + " sec, MA: { " + string.Join(", ", ChartSrvc.I.Macs.Select(v => v.SecSpan + "s_" + (v.SecSpan / 86400.0).ToString("F3") + "d")) + " } MA_Step: " + this.MaStep + " sec"; if (this.South.Text != text) { this.South.Text = text; } } }