Winforms应用程序中填充的橡皮筋
如何在0.3窗口的窗体上绘制零不透明橡皮筋? (橡胶带一个Microsoft例如后作出Winforms应用程序中填充的橡皮筋
更新:
我需要橡皮筋的工作有点像面膜如果你使用敬或任何其他屏幕截图工具,当您尝试制作屏幕截图时,您会看到我需要做的事情:屏幕变得半透明,当您进行选择时,您将看到0不透明度选择
这是你要找的机器人?
public Form1()
{
InitializeComponent();
DoubleBuffered = true;
}
bool mouseDown = false;
Point mouseDownPoint = Point.Empty;
Point mousePoint = Point.Empty;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
mouseDown = true;
mousePoint = mouseDownPoint = e.Location;
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
mouseDown = false;
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
mousePoint = e.Location;
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (mouseDown)
{
Region r = new Region(this.ClientRectangle);
Rectangle window = new Rectangle(
Math.Min(mouseDownPoint.X, mousePoint.X),
Math.Min(mouseDownPoint.Y, mousePoint.Y),
Math.Abs(mouseDownPoint.X - mousePoint.X),
Math.Abs(mouseDownPoint.Y - mousePoint.Y));
r.Xor(window);
e.Graphics.FillRegion(Brushes.Red, r);
Console.WriteLine("Painted: " + window);
}
}
您需要使用部分不透明颜色绘图时:从链接文章
更新线,在MyDrawReversibleRectangle
方法:
ControlPaint.DrawReversibleFrame(rc, Color.FromArgb(80, 120, 120, 120), FrameStyle.Dashed);
抱歉,这不起作用。我不知道为什么,但这里是一个屏幕拍摄http://screencast.com/t/NjM1NjBkZTc。灰色的颜色来自我的.4不透明度全屏幕形式,而虚线矩形是完全忽略背景色参数的DrawReversibleFrame方法。谢谢你,原谅我的英语。 – andySF 2010-01-15 06:45:45
我使用@Dearmash在我的开源应用程序BugTracker.NET附带的屏幕捕获实用程序中提供的代码。该应用程序不是很大,所以如果你正在做屏幕截图的话,这可能是一个很好的起点。这里更多的信息:
http://ifdefined.com/blog/post/Screen-capture-utility-in-C-NET.aspx
零不透明度表示完全透明。我认为你的意思是不透明的。 – SLaks 2010-01-14 15:28:10
你将如何看到它? – Matt 2010-01-14 15:29:15
顺便说一下,那篇文章是错误的。你可以简单地调用'ControlPaint.DrawReversibleFrame':http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint.drawreversibleframe.aspx。 (虽然在.Net 1.0中不存在) – SLaks 2010-01-14 15:30:40