【发布时间】:2016-02-07 16:38:51
【问题描述】:
我正在尝试编写一个透明的可拖动矩形缩放框,一旦鼠标再次向上,它会放大该区域并删除绘制的矩形。
我已经进行了缩放并绘制了矩形,但是我不能 1) 弄清楚如何使其透明,以及 2) 弄清楚如何删除矩形放大后。一旦向下单击鼠标以在放大的图像上绘制另一个缩放框(我正在绘制分形),它就会再次被删除,但我不知道在放大后要写什么来删除它。
绘画
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics windowG = e.Graphics;
windowG.DrawImageUnscaled(picture, 0, 0);
if (rectangle == true)
{
e.Graphics.FillRectangle(Brushes.Aquamarine, rec);
}
if (rectangle == false)
{
Invalidate();
}
}
鼠标向下
rectangle = true;
if (e.Button == MouseButtons.Left)
{
rec = new Rectangle(e.X, e.Y, 0, 0);
Invalidate();
}
鼠标向上
{
rectangle = false;
}
鼠标移动
if (e.Button == MouseButtons.Left)
{
rec.Width = e.X - rec.X;
rec.Height = e.Y - rec.Y;
Invalidate();
}
【问题讨论】: