static void DrawControlPoint(Gdi::Graphics g, Vector2 p1) { const int W = 3; Gdi::PointF pp1 = p1.ToPointF(); pp1.X -= W; pp1.Y -= W; Gdi::PointF pp2 = p1.ToPointF(); pp2.X += W; pp2.Y -= W; Gdi::PointF pp3 = p1.ToPointF(); pp3.X += W; pp3.Y += W; Gdi::PointF pp4 = p1.ToPointF(); pp4.X -= W; pp4.Y += W; g.DrawPolygon(Gdi::Pens.Red, new[] { pp1, pp2, pp3, pp4 }); }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { if (this.mouseDown_active) { this.pictureBox1.Capture = false; this.mouseDown_active = false; Gdi::PointF mouseDown_end = new Gdi::PointF(e.X, e.Y); if (this.deform.NotifyDrag(mouseDown_start, mouseDown_end)) { this.deform.Draw(this.foreGraphics); this.pictureBox1.Invalidate(); } } }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.pictureBox1.Capture = true; this.mouseDown_active = true; this.mouseDown_start = new Gdi::PointF(e.X, e.Y); } else { this.pictureBox1.Capture = false; this.mouseDown_active = false; } }
/// <summary> /// 内容を指定した位置に描画します。 /// </summary> /// <param name="g">描画先のグラフィックスを指定します。</param> public void Draw(Drawer g) { float x = g.DeltaX, y = g.DeltaY; // 背景 // TODO: Background class を作る? color, image, repeat-x,y, position, stretch // 内容 g.DeltaX = x + this.marginL + this.borderL + this.paddingL; g.DeltaY = y + this.marginT + this.borderT + this.paddingT; this.DrawContent(g); // 境界 g.DeltaX = x; g.DeltaY = y; float t = this.marginT + this.borderT / 2; float b = this.areaH - this.marginB - this.borderB / 2; float l = this.marginL + this.borderL / 2; float r = this.areaW - this.marginR - this.borderR / 2; Gdi::PointF lt = new Gdi::PointF(l, t); Gdi::PointF rt = new Gdi::PointF(r, t); Gdi::PointF lb = new Gdi::PointF(l, b); Gdi::PointF rb = new Gdi::PointF(r, b); if (this.borderT > 0) { g.DrawLine(lt, rt, this.borderCT, this.borderT); } if (this.borderR > 0) { g.DrawLine(rt, rb, this.borderCR, this.borderR); } if (this.borderB > 0) { g.DrawLine(lb, rb, this.borderCB, this.borderB); } if (this.borderL > 0) { g.DrawLine(lt, lb, this.borderCL, this.borderL); } }
public abstract void DrawString(string text, Gdi::PointF p2, FontManager f, Color color);
/// <summary> /// 線の描画を行います。 /// </summary> /// <param name="p1">線の起点を指定します。</param> /// <param name="p2">線の終点を指定します。</param> /// <param name="color">線の色を指定します。</param> /// <param name="width">線の太さを指定します。</param> public abstract void DrawLine(Gdi::PointF p1, Gdi::PointF p2, Color color, float width);
public override void DrawString(string text, Gdi::PointF p, FontManager f, Color color) { this.g.DrawString(text, f.Font, new Gdi::SolidBrush((Gdi::Color)color), p); }
public Vector2(Gdi::PointF p) { this.x = p.X; this.y = p.Y; }
/// <summary> /// 指定した System.Drawing.Font を使用し、指定した System.Drawing.StringFormat で書式指定して描画した場合の、指定した文字列を計測します。 /// </summary> /// <param name="text">計測する文字列。</param> /// <param name="font">文字列のテキスト形式を定義する System.Drawing.Font。</param> /// <param name="origin">文字列の左上隅を表す System.Drawing.PointF 構造体。</param> /// <param name="stringFormat">行間など、文字列の書式情報を表す System.Drawing.StringFormat。</param> /// <returns>このメソッドは、text パラメータに指定された文字列のサイズを System.Drawing.Graphics.PageUnit プロパティで指定された単位で表す /// System.Drawing.SizeF 構造体を、font パラメータおよび stringFormat パラメータで描画されたとおりに返します。</returns> public static Gdi::SizeF MeasureString(string text, Gdi::Font font, Gdi::PointF origin, Gdi::StringFormat stringFormat) { return(g.MeasureString(text, font, origin, stringFormat)); }