本文介绍了在WinForms应用程序填充的橡胶带的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎么可以得出一个零透明度橡皮筋过窗户,0.3不透明形成的?
(橡皮筋是例如
how can i draw a zero opacity rubber band over a windows form with 0.3 opacity?(The rubber band is made after a Microsoft example
更新:的
Update:
我需要橡皮筋的工作像一个面具。如果你使用敬或任何其他屏幕截图工具,你会看到正是我需要的,当你试图做一个屏幕截图的事:屏幕变成半透明的,当你做出选择,你会看到0混浊选择
I need that rubber band to work something like a mask. If you use Jing or any other screen shot tool, you will see EXACTLY what I need to do when do you try to make a screenshot: the screen goes semi-opaque and when you make the selection, you will see the 0 opacity selection
推荐答案
这是你要找的机器人?
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);
}
}
这篇关于在WinForms应用程序填充的橡胶带的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!