Files
rookie/Transparenter.cs
SytheZN d3a2c4012c Release/RSL-2.17 (#128)
* fix: pull to desktop not resetting work status.

resolves #104

* Create Text File with upload size for verification

* bump version

* better public config handling

* code cleanup

Co-authored-by: Fenopy <Fenopie@Gmail.com>
2022-12-05 23:42:59 +02:00

44 lines
1.2 KiB
C#

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();
}
}
}