public override void FillRectangle(Brush brush, RectangleF rect) { SetPatternFromBrush(brush); if (brush is TextureBrush) { _canvas.CurrentColor = Color.White; _canvas.Texture2DEnabled = true; TextureBrush textureBrush = (TextureBrush)brush; var texture = GetCachedTexture(textureBrush); texture.DrawTiled(rect.ToRectangle()); _canvas.Texture2DEnabled = false; } else { _canvas.FillRectangle(rect, ColorsFromBrush(brush)); } _canvas.ResetPolygonStipplePattern(); }
private static void DrawRectangle(Graphics g, String prefixtext, RectangleF drawthis, Pen RectPen, Brush RectBrush, Brush TextBrush, Font usefont) { g.FillRectangle(RectBrush, drawthis); g.DrawRectangle(RectPen, drawthis.ToRectangle()); //also paint coordinate information. //cachestate.Blocks.Count.ToString() + " Blocks;\n" String BlockInfotext = prefixtext + "(" + Math.Round(drawthis.Left, 1) + "," + Math.Round(drawthis.Top, 1) + ")-(" + "(" + Math.Round(drawthis.Right, 1) + "," + Math.Round(drawthis.Bottom, 1) + ")"; Size measurestring = TextRenderer.MeasureText(g, BlockInfotext, usefont); Point getcenter = drawthis.CenterPoint().ToPoint(); Point DrawHere = new Point(getcenter.X - measurestring.Width / 2, getcenter.Y - measurestring.Height / 2); g.DrawString(BlockInfotext, usefont, TextBrush, DrawHere.X, DrawHere.Y); }