/// <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="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 void Draw() { using (Gdi::Pen penGrid = new Gdi::Pen(sender.GridColor)) using (Gdi::Brush brBack = new Gdi::SolidBrush(cBack)) using (Gdi::Brush brFore = new Gdi::SolidBrush(cFore)){ // Clear e.Graphics.FillRectangle(brBack, e.CellBounds); e.Graphics.DrawLine(penGrid, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, e.CellBounds.Bottom - 1); e.Graphics.DrawLine(penGrid, e.CellBounds.Right - 1, e.CellBounds.Top, e.CellBounds.Right - 1, e.CellBounds.Bottom); int h = (e.CellBounds.Height - e.CellStyle.Font.Height) / 2; e.Graphics.DrawString( text, e.CellStyle.Font, brFore, e.CellBounds.X + 1, e.CellBounds.Y + h, Gdi::StringFormat.GenericDefault ); } }