alielie
2025-11-24 9211ec11c112e18cd99e77f889a01110a70031ce
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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;
        }
 
    }
}