-
Notifications
You must be signed in to change notification settings - Fork 51
/
Transparenter.cs
44 lines (39 loc) · 1.2 KB
/
Transparenter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Drawing;
using System.Windows.Forms;
namespace AndroidSideloader
{
public class Transparenter
{
public static void MakeTransparent(Control control, Graphics g)
{
Control parent = control.Parent;
if (parent == null)
{
return;
}
Rectangle bounds = control.Bounds;
Control.ControlCollection siblings = parent.Controls;
int index = siblings.IndexOf(control);
Bitmap behind = null;
for (int i = siblings.Count - 1; i > index; i--)
{
Control c = siblings[i];
if (!c.Bounds.IntersectsWith(bounds))
{
continue;
}
if (behind == null)
{
behind = new Bitmap(control.Parent.ClientSize.Width, control.Parent.ClientSize.Height);
}
c.DrawToBitmap(behind, c.Bounds);
}
if (behind == null)
{
return;
}
g.DrawImage(behind, control.ClientRectangle, bounds, GraphicsUnit.Pixel);
behind.Dispose();
}
}
}