drawing Rectangles in winforms c# help
This code is flawed as when u drag the cursor from bottom to up it stills draws the rectangle upwards. Any suggestions?
Point shapestartP = new Point(0, 0);
private void picBoxMain_MouseUp(object sender, MouseEventArgs e)
{
flagDraw = false;
g = Graphics.FromImage(bm);
if (flagDrawingTool == "Rectangle")
{
g.DrawRectangle(pen, shapestartP.X, shapestartP.Y,Math.Abs(e.Location.X - shapestartP.X ),Math.Abs(e.Location.Y - shapestartP.Y));
}
g.Dispose();
picBoxMain.Invalidate();
}
private void picBoxMain_MouseDown(object sender, MouseEventArgs e)
{
shapestartP = e.Location;
}