dim mouse_x as integer = 0, mouse_y as integer = 0
private sub picturebox1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
if e.button = mousebuttons.left then
if mouse_x = 0 and mouse_y = 0 then
mouse_x = e.X *记录坐标x和y
mouse_y = e.Y
else
***画线
*picturebox1.creategraphics().drawline(pens.black, mouse_x, mouse_y, e.x, e.y)
***向右下角画矩形
*picturebox1.creategraphics().drawrectangle(pens.black, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
***画圆
*picturebox1.creategraphics().drawellipse(pens.black, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
mouse_x = 0 *恢复空坐标
mouse_y = 0
end if
else
mouse_x = 0 *当用户使用右键时,撤销之前的记录
mouse_y = 0
end if
end sub
***向右下角画实心矩形
pictureBox1.creategraphics().fillrectangle(brushes.lime, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
*轮廓 picturebox1.creategraphics().drawrectangle(pens.black, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
private sub picturebox1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
if e.button = mousebuttons.left then
if mouse_x = 0 and mouse_y = 0 then
mouse_x = e.X *记录坐标x和y
mouse_y = e.Y
else
***画线
*picturebox1.creategraphics().drawline(pens.black, mouse_x, mouse_y, e.x, e.y)
***向右下角画矩形
*picturebox1.creategraphics().drawrectangle(pens.black, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
***画圆
*picturebox1.creategraphics().drawellipse(pens.black, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
mouse_x = 0 *恢复空坐标
mouse_y = 0
end if
else
mouse_x = 0 *当用户使用右键时,撤销之前的记录
mouse_y = 0
end if
end sub
***向右下角画实心矩形
pictureBox1.creategraphics().fillrectangle(brushes.lime, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)
*轮廓 picturebox1.creategraphics().drawrectangle(pens.black, mouse_x, mouse_y, e.x - mouse_x, e.y - mouse_y)