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 45 46 47 48 49 50 51 52 53
| public class SemiTransparentPanel : Panel
{
internal int PaintNumber=0 ;
internal static void Hide(ref SxWFSemiTransparentPanel
ThePanel,Control ParentControl)
{
if (ThePanel!=null) ParentControl.Controls.Remove(ThePanel) ;
}
internal static void Show
(ref SxWFSemiTransparentPanel ThePanel,int X, int Y, int Width, int Height,
Color color, int Opacity,Control ParentControl)
{
Hide(ref ThePanel,ParentControl) ;
ThePanel=new SxWFSemiTransparentPanel(X,Y,Width,Height,
color,Opacity,ParentControl) ;
}
internal SxWFSemiTransparentPanel
(int X, int Y, int Width, int Height, Color color,
int Opacity, Control ParentControl)
{
SetStyle(ControlStyles.Opaque,false);
SetStyle(ControlStyles.SupportsTransparentBackColor,true);
UpdateStyles();
Location = new System.Drawing.Point(X, Y);
Size = new Size(Width, Height);
BackColor = Color.FromArgb (Opacity, color);
if (ParentControls!=null) ParentControl.Controls.Add(this);
BringToFront() ;
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x20; // Turn on WS_EX_TRANSPARENT
return cp;
}
}
protected override void OnPaint (PaintEventArgs pe)
{ // je ne me rappelle plus le pourquoi d'un maxi à 3 !!!
if (PaintNumber<3)
pe.Graphics.FillRectangle(new SolidBrush (BackColor),
this.ClientRectangle);
PaintNumber++ ;
}
}// SemiTransparentPanel |
Partager