This is my first time using exceptions, and I can't seem to make the exception get thrown. This is meant for painting this shape on the form. If I have the curve height more then the height of the object, all my form does is creates red X's for all of the controls.
So what am I doing wrong?
P.S. It works fine if the curve height is less then the object height.
HOW TO USE:
So what am I doing wrong?
P.S. It works fine if the curve height is less then the object height.
Code:
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:
Code:
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);
}
Comment