private void SetRevert(TreeNode node, TreeNodeDragEventArgs e) { switch (GetTarget(node, e)) { case TreeNodeDDTarget.Self: { Gdi::Rectangle rect = new Gdi::Rectangle(node.ClientPosition, node.ContentSize); rect.X += node.ContentOffsetX; node.View.dropArea.RevertRect(rect); break; } case TreeNodeDDTarget.Prev: { Gdi::Point p = node.ClientPosition; p.X += node.ContentOffsetX; node.View.dropArea.RevertLine(p); break; } case TreeNodeDDTarget.Next: { Gdi::Point p = node.ClientPosition; p.X += node.ContentOffsetX; p.Y += node.ContentSize.Height; node.View.dropArea.RevertLine(p); break; } case TreeNodeDDTarget.Child: { Gdi::Point p = node.ClientPosition; p.X += node.ContentOffsetX + node.ChildIndent.Width; p.Y += node.ContentSize.Height; node.View.dropArea.RevertLine(p); break; } } }
/// <summary> /// Indent 領域の内容を描画します。 /// </summary> /// <param name="g">描画する対象の Graphics を指定します。 /// 原点は Indent 領域の右上に設定されます。</param> /// <param name="node">描画される node を指定します。</param> /// <param name="areaheight">描画する対象の領域の高さを指定します。</param> public void DrawIndentArea(System.Drawing.Graphics g, TreeNode node, int areaheight) { int oy = y_origin(areaheight); /* 枝模様を描く */ if (node.IsLastChild) { g.DrawLine(pen_g, -TWIG_LENGTH, 0, -TWIG_LENGTH, oy); } else { g.DrawLine(pen_g, -TWIG_LENGTH, 0, -TWIG_LENGTH, areaheight); } g.DrawLine(pen_g, 1 - TWIG_LENGTH, oy, 0, oy); if (node.HasChildren) { Gdi::Rectangle srcRect; if (node.IsExpanded) { srcRect = new Gdi::Rectangle(85, 1, ICON_W, ICON_H); } else { srcRect = new Gdi::Rectangle(71, 1, ICON_W, ICON_H); } g.DrawImage( _resource.TreeIcons, -TWIG_LENGTH - ICON_W / 2, oy - ICON_H / 2, srcRect, Gdi::GraphicsUnit.Pixel ); } }
/// <summary> /// 指定した状態に応じた CheckBox を表示します。 /// </summary> /// <param name="g">描画先の Graphics を指定します。</param> /// <param name="state">Check 状態を指定します。</param> /// <param name="enabled">CheckBox が有効になっているかどうかを指定します。</param> public void DrawBox(Gdi::Graphics g, bool?state, bool enabled) { Gdi::Rectangle src = rect; src.X += 14 * (state == null?1: (bool)state?2: 0); src.Y += 14 * (enabled?0:1); g.DrawImage(this.image, 0, 0, src, Gdi::GraphicsUnit.Pixel); }
/// <summary> /// 指定した点から右へ線を引きます。 /// </summary> /// <param name="pt">線の開始点を指定します。</param> public void RevertLine(Gdi::Point pt) { Gdi::Rectangle rect = new Gdi::Rectangle( pt.X, pt.Y - 1, this.ctrl.ClientRectangle.Width - pt.X, 3 ); this.RevertRect(rect); }
public GraphicsClipRectStore(Gdi::Graphics g) { this.g = g; Gdi::RectangleF rectF = g.ClipBounds; this.rect = new Gdi::Rectangle( (int)rectF.X, (int)rectF.Y, (int)rectF.Width, (int)rectF.Height ); }
/// <summary> /// 文字列を描画します。 /// </summary> /// <param name="text">描画する文字列を指定します。</param> /// <param name="rect">文字列を描画する対象の矩形を指定します。</param> /// <param name="flags">文字列を描画する際の詳細な指定を行います。</param> public int DrawString(string text, Gdi::Rectangle rect, StringFormat flags) { RECT rc = rect; int ret = DrawText(this.hdc, text, text.Length, ref rc, flags); if (ret == 0) { throw new System.Exception("文字列の描画に失敗しました。"); } return(ret); }
/// <summary> /// 指定した矩形領域を反転します。 /// </summary> /// <param name="rect">反転する領域を指定します。</param> public void RevertRect(Gdi::Rectangle rect) { if (!currentState || currentRect != rect) { this.Clear(); currentState = true; currentRect = rect; Forms::ControlPaint.FillReversibleRectangle( this.ctrl.RectangleToScreen(currentRect), Gdi::Color.Black); } }
public BicubicInterpolatedImage(Gdi::Bitmap bmp) { this.bmp = bmp; this.width = bmp.Width; this.height = bmp.Height; Gdi::Rectangle rect = new Gdi::Rectangle(Gdi::Point.Empty, bmp.Size); this.data = bmp.LockBits(rect, Gdi::Imaging.ImageLockMode.ReadOnly, Gdi::Imaging.PixelFormat.Format24bppRgb); this.p0 = (byte *)this.data.Scan0; this.stride = this.data.Stride; }
/// <summary> /// このノードの内容を描画します。 /// </summary> /// <param name="g">描画先の Graphics を指定します。</param> protected override void DrawContent(System.Drawing.Graphics g) { this.DrawContentBackground(g); Gdi::Rectangle rect = new Gdi::Rectangle(Gdi::Point.Empty, this.ContentSize); Gdi::Brush brush; if (this.IsEnabled) { brush = this.IsActivated?Gdi::Brushes.White:Gdi::Brushes.Black; } else { brush = this.IsActivated?Gdi::Brushes.Gray:Gdi::Brushes.Silver; } g.DrawString(this.text, this.Font, brush, new Gdi::PointF(0, 1)); }
void ITreeNodeIcon.DrawIcon(Gdi::Graphics g, Gdi::Rectangle rect, TreeNode node) { switch (this.type) { case IconType.Image: g.DrawImage(this.img, rect); break; case IconType.Icon: g.DrawIcon(this.icon, rect); break; case IconType.ImageList: g.DrawImage(this.list.Images[this.index], rect); break; case IconType.ClippedImage: g.DrawImage(this.img, rect, this.rect, Gdi::GraphicsUnit.Pixel); break; } }
public static Gdi::Rectangle Translate(this Gdi::Rectangle self, int dx, int dy) { self.X += dx; self.Y += dy; return(self); }
/// <summary> /// 矩形を塗り潰し、反転色で枠を描画します。 /// </summary> /// <param name="g">描画対象の矩形を指定します。</param> /// <param name="fill">塗り潰すのに使用する色を指定します。</param> /// <param name="rect">対象の矩形を指定します。</param> public static void FillRectangleReverseDotFramed(Gdi::Graphics g, Gdi::Color fill, Gdi::Rectangle rect) { using (Gdi::SolidBrush brush = new Gdi::SolidBrush(fill)) using (Gdi::Pen pen = new Gdi::Pen(~(afh.Drawing.Color32Argb)fill)){ pen.DashStyle = Gdi::Drawing2D.DashStyle.Dot; FillRectangleFramed(g, brush, pen, rect); } }
/// <summary> /// 指定した色の反転色で矩形枠を描画します。 /// </summary> /// <param name="g">描画対象の矩形を指定します。</param> /// <param name="fill">矩形枠の反転色を指定します。</param> /// <param name="rect">対象の矩形を指定します。</param> public static void DrawRectangleReverseDotFramed(Gdi::Graphics g, Gdi::Color fill, Gdi::Rectangle rect) { using (Gdi::Pen pen = new Gdi::Pen(~(afh.Drawing.Color32Argb)fill)){ pen.DashStyle = Gdi::Drawing2D.DashStyle.Dot; rect.Width--; rect.Height--; g.DrawRectangle(pen, rect); } }
public unsafe static Gdi::Bitmap Transform( Gdi::Bitmap src, int width, int height, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 q1, Vector2 q2, Vector2 q3, Vector2 q4 ) { Gdi::Bitmap dst = new Gdi::Bitmap(width, height); Gdi::Rectangle dstRect = new Gdi::Rectangle(Gdi::Point.Empty, dst.Size); Gdi::Imaging.BitmapData dstData = dst.LockBits(dstRect, Gdi::Imaging.ImageLockMode.WriteOnly, Gdi::Imaging.PixelFormat.Format32bppRgb); byte *pdst = (byte *)dstData.Scan0; int stride = dstData.Stride; double[] x_st_table1 = new double[width]; double[] x_st_table2 = new double[width]; double[] y_st_table1 = new double[height]; double[] y_st_table2 = new double[height]; new BezierArcMeasure(p1, p2, q1).InitializeTable(x_st_table1); new BezierArcMeasure(p4, p3, q3).InitializeTable(x_st_table2); new BezierArcMeasure(p1, p4, q4).InitializeTable(y_st_table1); new BezierArcMeasure(p2, p3, q2).InitializeTable(y_st_table2); BezierLine p12 = new BezierLine(p1, p2, q1); BezierLine p43 = new BezierLine(p4, p3, q3); BezierLine p14 = new BezierLine(p1, p4, q4); BezierLine p23 = new BezierLine(p2, p3, q2); using (BicubicInterpolatedImage srcImage = new BicubicInterpolatedImage(src)){ for (int ix = 0; ix < width; ix++) { double xt1 = x_st_table1[ix]; double xt2 = x_st_table2[ix]; double dxt = xt2 - xt1; for (int iy = 0; iy < height; iy++) { double yt1 = y_st_table1[iy]; double yt2 = y_st_table2[iy]; double dyt = yt2 - yt1; double xt = (xt1 + yt1 * dxt) / (1 - dxt * dyt); double yt = (yt1 + xt1 * dyt) / (1 - dxt * dyt); // linear interpolation Vector2 pl = (1 - xt1) * (1 - yt1) * p1 + xt1 * (1 - yt2) * p2 + xt2 * yt2 * p3 + (1 - xt2) * yt1 * p4; // bezier interpolation Vector2 pBx = p43.GetPoint(xt2) * yt + p12.GetPoint(xt1) * (1 - yt); Vector2 pBy = p23.GetPoint(yt2) * xt + p14.GetPoint(yt1) * (1 - xt); Vector2 p = pBx + pBy - pl; *(int *)(pdst + 4 * ix + stride * iy) = srcImage.Get(p.x, p.y); } } } dst.UnlockBits(dstData); return(dst); }
/// <summary> /// 枠付で矩形を塗り潰します。 /// </summary> /// <param name="g">描画対象の矩形を指定します。</param> /// <param name="fill">矩形を塗り潰すのに使用するブラシを指定します。</param> /// <param name="frame">矩形の枠を描画する為のペンを指定します。</param> /// <param name="rect">矩形を指定します。</param> public static void FillRectangleFramed(Gdi::Graphics g, Gdi::Brush fill, Gdi::Pen frame, Gdi::Rectangle rect) { g.FillRectangle(fill, rect); rect.Width--; rect.Height--; g.DrawRectangle(frame, rect); }
/// <summary> /// 画像の一部をアイコンとして設定します。 /// </summary> /// <param name="image">元となる画像を指定します。</param> /// <param name="rect">アイコンとして使用する画像の部分を指定する矩形を指定します。</param> public void SetImage(Gdi::Image image, Gdi::Rectangle rect) { this.type = IconType.ClippedImage; this.img = image; this.rect = rect; }
private TreeNodeCheckBox(Gdi::Image image, Gdi::Rectangle rect) { this.image = image; this.rect = rect; }