public GraphicsCache(Graphics graphics, Rectangle clipRectangle, int pensCapacity, int brushsCapacity) { mGraphics = graphics; mClipRectangle = clipRectangle; mPensCache = new PensCache(pensCapacity); mBrushsCache = new BrushsCache(brushsCapacity); }
public GraphicsCache(Graphics graphics) { mGraphics = graphics; mClipRectangle = Rectangle.Empty; mPensCache = new PensCache(20); mBrushsCache = new BrushsCache(20); }
public GraphicsCache(Graphics graphics, Rectangle clipRectangle) { mGraphics = graphics; mClipRectangle = clipRectangle; mPensCache = new PensCache(20); mBrushsCache = new BrushsCache(20); }
public void Dispose() { mPensCache.Dispose(); mPensCache = null; mBrushsCache.Dispose(); mBrushsCache = null; mGraphics = null; }
//public void Draw(GraphicsCache graphics, RectangleF rectangle) //{ // RectangleBorder border = this; // //Calculate the padding // rectangle = new RectangleF(rectangle.X + Left.Padding, rectangle.Y + Top.Padding, rectangle.Width - (Left.Padding + Right.Padding), rectangle.Height - (Top.Padding + Bottom.Padding)); // if (rectangle.Width <= 0 || rectangle.Height <= 0) // return; // PensCache pens = graphics.PensCache; // if (border.Left.Width > 0) // { // Pen leftPen = pens.GetPen(border.Left.Color, 1, border.Left.DashStyle); // for (int i = 0; i < border.Left.Width; i++) // graphics.Graphics.DrawLine(leftPen, rectangle.X + i, rectangle.Y, rectangle.X + i, rectangle.Bottom - 1); // } // if (border.Bottom.Width > 0) // { // Pen bottomPen = pens.GetPen(border.Bottom.Color, 1, border.Bottom.DashStyle); // for (int i = 1; i <= border.Bottom.Width; i++) // graphics.Graphics.DrawLine(bottomPen, rectangle.X, rectangle.Bottom - i, rectangle.Right - 1, rectangle.Bottom - i); // } // if (border.Right.Width > 0) // { // Pen rightPen = pens.GetPen(border.Right.Color, 1, border.Right.DashStyle); // for (int i = 1; i <= border.Right.Width; i++) // graphics.Graphics.DrawLine(rightPen, rectangle.Right - i, rectangle.Y, rectangle.Right - i, rectangle.Bottom - 1); // } // if (border.Top.Width > 0) // { // Pen topPen = pens.GetPen(border.Top.Color, 1, border.Top.DashStyle); // for (int i = 0; i < border.Top.Width; i++) // graphics.Graphics.DrawLine(topPen, rectangle.X, rectangle.Y + i, rectangle.Right - 1, rectangle.Y + i); // } //} public void Draw(GraphicsCache graphics, RectangleF rectangle) { RectangleBorder border = this; //Calculate the padding rectangle = new RectangleF(rectangle.X + Left.Padding, rectangle.Y + Top.Padding, rectangle.Width - (Left.Padding + Right.Padding), rectangle.Height - (Top.Padding + Bottom.Padding)); if (rectangle.Width <= 0 || rectangle.Height <= 0) { return; } PensCache pens = graphics.PensCache; if (border.Left.Width > 0) { Pen leftPen = pens.GetPen(border.Left.Color, border.Left.Width, border.Left.DashStyle); float x; float bottom; if (border.Left.Width > 1) { x = rectangle.X + ((float)border.Left.Width) / 2; bottom = rectangle.Bottom; } else { x = rectangle.X; bottom = rectangle.Bottom - 1; } graphics.Graphics.DrawLine(leftPen, new PointF(x, rectangle.Y), new PointF(x, bottom)); } if (border.Right.Width > 0) { Pen rightPen = pens.GetPen(border.Right.Color, border.Right.Width, border.Right.DashStyle); float x; float bottom; if (border.Right.Width > 1) { x = rectangle.Right - border.Right.Width / 2; bottom = rectangle.Bottom; } else { x = rectangle.Right - 1; bottom = rectangle.Bottom - 1; } graphics.Graphics.DrawLine(rightPen, new PointF(x, rectangle.Y), new PointF(x, bottom)); } if (border.Top.Width > 0) { Pen topPen = pens.GetPen(border.Top.Color, border.Top.Width, border.Top.DashStyle); float y; float right; if (border.Top.Width > 1) { y = rectangle.Y + border.Top.Width / 2; right = rectangle.Right; } else { y = rectangle.Y; right = rectangle.Right - 1; } graphics.Graphics.DrawLine(topPen, new PointF(rectangle.X, y), new PointF(right, y)); } if (border.Bottom.Width > 0) { Pen bottomPen = pens.GetPen(border.Bottom.Color, border.Bottom.Width, border.Bottom.DashStyle); float y; float right; if (border.Bottom.Width > 1) { y = rectangle.Bottom - border.Bottom.Width / 2; right = rectangle.Right; } else { y = rectangle.Bottom - 1; right = rectangle.Right - 1; } graphics.Graphics.DrawLine(bottomPen, new PointF(rectangle.X, y), new PointF(right, y)); } }