wenxiangchao
2026-11-02 fe2aa4880d5c9fd88088ad0ed81ebaca05629f5f
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
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;
using System.Windows.Threading;
 
namespace WPFProject.Controls
{
    public partial class HolderForm : Form
    {
        private MaskControl maskPanel = new MaskControl
        {
            Dock = DockStyle.Fill,
            Visible = false
        };
        public HolderForm()
        {
            InitializeComponent();
            this.Controls.Add(maskPanel);
        }
 
        public object Content { get; private set; }
 
        public void UpdateChild(object content)
        {
            this.Content = content;
            if (content is Form form)
            {
                form.TopLevel = false;
                form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                form.Dock = System.Windows.Forms.DockStyle.Fill;
                this.Controls.Clear();
                this.Controls.Add(maskPanel);
                this.Controls.Add(form);
                form.Show();
            }
        }
 
        public void ShowMask()
        {
            maskPanel.ShowLoad(this.Location, this.Size);
        }
 
        public void HideMask()
        {
            maskPanel.HideLoad();
        }
    }
}