using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace WPFProject.Controls
|
{
|
public partial class MaskControl : Panel
|
{
|
public MaskControl()
|
{
|
SetStyle(ControlStyles.Opaque, true);//设置背景透明
|
SetStyle(ControlStyles.SupportsTransparentBackColor, true);//设置背景透明
|
base.CreateControl();
|
this.BackColor = Color.White;
|
this.Visible = false;
|
}
|
|
//protected override CreateParams CreateParams
|
//{
|
// get
|
// {
|
// CreateParams cp = base.CreateParams;
|
// cp.ExStyle |= 0x00000020; // 开启 WS_EX_TRANSPARENT,使控件支持透明
|
// return cp;
|
// }
|
//}
|
|
protected override void OnPaint(PaintEventArgs pe)
|
{
|
Pen labelBorderPen;
|
SolidBrush labelBackColorBrush;
|
Color cl = Color.FromArgb(128, this.BackColor);
|
labelBorderPen = new Pen(cl, 0);
|
labelBackColorBrush = new SolidBrush(cl);
|
base.OnPaint(pe);
|
pe.Graphics.DrawRectangle(labelBorderPen, 0, 0, this.Width, this.Height);
|
pe.Graphics.FillRectangle(labelBackColorBrush, 0, 0, this.Width, this.Height);
|
}
|
|
/// <summary>
|
/// 显示加载
|
/// </summary>
|
public void ShowLoad(Point location, Size size)
|
{
|
this.Location = location;
|
this.Size = size;
|
this.BringToFront();
|
this.Dock = DockStyle.Fill;
|
this.Visible = true;
|
}
|
|
|
|
/// <summary>
|
|
/// 隐藏加载
|
|
/// </summary>
|
|
public void HideLoad()
|
{
|
this.Visible = false;
|
}
|
|
}
|
}
|