CHΔNGΕ
CHΔNGΕ
CC#
Created by CHΔNGΕ on 7/19/2024 in #help
drawing Rectangles in winforms c# help
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;
}
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;
}
This code is flawed as when u drag the cursor from bottom to up it stills draws the rectangle upwards. Any suggestions?
14 replies