protected override void OnPaint(PaintEventArgs e) { if (this.PointsStack == null) { return; } if (this.PointsStack.Count() <= 0) { return; } Graphics g = e.Graphics; foreach (KeyValuePair <string, float[]> KeyValues in this.PointsStack) { Point[] ps = new Point[this.Nbin]; string Stackname = KeyValues.Key; Pen pen = Pens.Black; switch (Stackname) { case "R": pen = Pens.Red; pen = new Pen(Color.FromArgb(255, 80, 30, 120)); pen = new Pen(Color.FromArgb(255, 200, 30, 120)); break; case "G": pen = Pens.Green; pen = new Pen(Color.FromArgb(255, 30, 120, 81)); pen = new Pen(Color.FromArgb(255, 30, 220, 81)); break; case "B": pen = Pens.Blue; pen = new Pen(Color.FromArgb(255, 74, 106, 147)); pen = new Pen(Color.FromArgb(255, 74, 106, 220)); break; default: pen = Pens.Black; break; } float[] hist = KeyValues.Value; hist[0] = 0; for (int i = 0; i < hist.Length; i++) { int xi = Xi(i); int yi = Yi(hist[i]); ps[i] = new Point(xi, yi); } // 戻り点 ps[hist.Length - 1] = new Point(Xi(xmax), Yi(ymin)); // ------------ // ------------ 塗りつぶし Color gC1 = Color.FromArgb(1, pen.Color); float h1 = pen.Color.GetHue() / 360f; float s1 = pen.Color.GetSaturation(); float v1 = pen.Color.GetBrightness(); s1 = 1.0f; v1 = 0.5f; Color GradColor1 = Color.FromArgb(64, ImageColorProc.HSVtoRGB(h1, s1, v1)); Color gC2 = Color.FromArgb(200, pen.Color); float h2 = pen.Color.GetHue() / 360f; float s2 = pen.Color.GetSaturation(); float v2 = pen.Color.GetBrightness(); s2 = 0.3f; v2 = 1.0f; Color GradColor2 = Color.FromArgb(128, ImageColorProc.HSVtoRGB(h2, s2, v2)); LinearGradientBrush gBrush = new LinearGradientBrush(this.ClientRectangle, GradColor1, GradColor2, LinearGradientMode.Vertical); // 塗りつぶし g.FillPolygon(gBrush, ps, FillMode.Winding); // ------------ 折れ線を引く g.DrawLines(pen, ps); // 後処理 gBrush.Dispose(); } }
protected override void OnPaint(PaintEventArgs e) { if (this.PointsStack == null) { return; } if (this.PointsStack.Count() <= 0) { return; } Graphics g = e.Graphics; foreach (KeyValuePair <string, float[]> KeyValues in this.PointsStack) { Debug.WriteLine(KeyValues.ToString()); Point[] ps = new Point[this.Nbin]; string Stackname = KeyValues.Key; Pen pen = Pens.White; switch (Stackname) { case "H": pen = null; break; case "S": pen = Pens.Yellow; break; case "V": pen = Pens.White; break; default: pen = Pens.White; break; } float[] hist = KeyValues.Value; hist[0] = 0; xmin = -1; xmax = hist.Length + 1; for (int i = 0; i < hist.Length; i++) { int xi = Xi(i); int yi = Yi(hist[i]); ps[i] = new Point(xi, yi); // H の場合の処理 if (Stackname == "H") { Point p0 = new Point(xi, Yi(0)); float h = (float)i / hist.Length; Color col = Color.FromArgb(128, ImageColorProc.HSVtoRGB(h, 1, 1)); pen = new Pen(col); g.DrawLine(pen, p0, ps[i]); } } // ------------ 折れ線を引く // H の場合の処理 if (Stackname == "H") { g.DrawLines(Pens.Gray, ps); continue; } // 折れ線を引く g.DrawLines(pen, ps); } }