So what am I doing wrong?
P.S. It works fine if the curve height is less then the object height.
Expand|Select|Wrap|Line Numbers
- public class BottomCurve
- {
- public BottomCurve(int Width, int Height, int CurveHeight)
- {
- if (CurveHeight >= Height) throw new System.Exception("The curve height cannot be greater then or equal to the height of this object");
- this.ISize = new System.Drawing.Size(Width, Height);
- this.ICurve = new System.Drawing.Point[]
- {
- new System.Drawing.Point(0, this.Height),
- new System.Drawing.Point(this.Width / 2, this.Height - CurveHeight),
- new System.Drawing.Point(this.Width, this.Height)
- };
- this.IGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
- this.IGraphicsPath.StartFigure();
- this.IGraphicsPath.AddLine(0, 0, 0, this.Height);
- this.IGraphicsPath.AddCurve(ICurve);
- this.IGraphicsPath.AddLine(this.Width, this.Height, this.Width, 0);
- this.IGraphicsPath.AddLine(this.Width, 0, 0, 0);
- this.IGraphicsPath.CloseFigure();
- }
- internal System.Drawing.Point[] ICurve;
- internal System.Drawing.Drawing2D.GraphicsPath IGraphicsPath;
- public System.Drawing.Drawing2D.GraphicsPath GraphicsPath { get { return this.IGraphicsPath; } }
- internal System.Drawing.Size ISize;
- public System.Drawing.Size Size { get { return this.ISize; } }
- public int Width { get { return this.Size.Width; } }
- public int Height { get { return this.Size.Height; } }
- }
HOW TO USE:
Expand|Select|Wrap|Line Numbers
- public void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
- {
- BottomCurve BC = new BottomCurve(this.Width, 100, 40);
- e.Graphics.FillPath(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(255, 255, 0, 0)), BC.GraphicsPath);
- }