(Twenty-three) c # Winform custom control - waiting for the form (XVII) c # Winform custom control - the base class form

premise

The bank has 7, 8 years, and always wanted to do a nice custom control points, so there is this series of articles.

Open Source Address: https://gitee.com/kwwwvagaa/net_winform_custom_control

If you feel that writing was okay, please support the point of a star about it

Come and explore the exchange: Penguins 568 015 492 Penguins 568 015 492

Ready to work

Following Cheng Zaiji this form class form FrmBase, if you do not know FrmBase, the venue  (xvii) c # Winform custom control - the base class Form  View

Start

Add a Form, named FrmWaiting, inherited from FrmBase

Code much, all the code directly on

1  // Copyright Huangzheng Hui exchange group: 568 015 492 QQ: 623 128 629
 2  // File name: FrmWaiting.cs
 3  // Creation Date: 2019-08-15 16:05:09
 4  // Function Description: FrmWaiting
 5  // Project Address : https://gitee.com/kwwwvagaa/net_winform_custom_control 
. 6  the using the System;
 . 7  the using the System.Collections.Generic;
 . 8  the using the System.ComponentModel;
 . 9  the using the System.Data;
 10  the using the System.Drawing;
 . 11  the using the System.Linq;
 12 is  the using System.Text;
 13 using System.Windows.Forms;
14 
15 namespace HZH_Controls.Forms
16 {
17     public partial class FrmWaiting : FrmBase
18     {
19         public string Msg { get { return label2.Text; } set { label2.Text = value; } }
20         public FrmWaiting()
21         {
22             base.SetStyle(ControlStyles.UserPaint, true);
23             base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
24             base.SetStyle(ControlStyles.DoubleBuffer, true);
25             InitializeComponent();
26         }
27 
28         private void timer1_Tick(object sender, EventArgs e)
29         {
30             if (this.label1.ImageIndex == this.imageList1.Images.Count - 1)
31                 this.label1.ImageIndex = 0;
32             else
33                 this.label1.ImageIndex++;
34 
35         }
36 
37         private void FrmWaiting_VisibleChanged(object sender, EventArgs e)
38         {
39             //this.timer1.Enabled = this.Visible;
40         }
41 
42         protected override void DoEsc()
43         {
44 
45         }
46 
47         private void timer2_Tick(object sender, EventArgs e)
48         {
49             base.Opacity = 1.0;
50             this.timer2.Enabled = false;
51         }
52 
53         public void ShowForm(int intSleep = 1)
54         {
55             base.Opacity = 0.0;
56             if (intSleep <= 0)
57             {
58                 intSleep = 1;
59             }
60             base.Show();
61             this.timer2.Interval = intSleep;
62             this.timer2.Enabled = true;
63         }
64     }
65 }
View Code
  1 namespace HZH_Controls.Forms
  2 {
  3     partial class FrmWaiting
  4     {
  5         /// <summary>
  6         /// Required designer variable.
  7         /// </summary>
  8         private System.ComponentModel.IContainer components = null;
  9 
 10         /// <summary>
 11         /// Clean up any resources being used.
 12         /// </summary>
 13         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 14         protected override void Dispose(bool disposing)
 15         {
 16             if (disposing && (components != null))
 17             {
 18                 components.Dispose();
 19             }
 20             base.Dispose(disposing);
 21         }
 22 
 23         #region Windows Form Designer generated code
 24 
 25         /// <summary>
 26         /// Required method for Designer support - do not modify
 27         /// the contents of this method with the code editor.
 28         /// </summary>
 29         private void InitializeComponent()
 30         {
 31             this.components = new System.ComponentModel.Container();
 32             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmWaiting));
 33             this.imageList1 = new System.Windows.Forms.ImageList(this.components);
 34             this.label1 = new System.Windows.Forms.Label();
 35             this.timer1 = new System.Windows.Forms.Timer(this.components);
 36             this.label2 = new System.Windows.Forms.Label();
 37             this.timer2 = new System.Windows.Forms.Timer(this.components);
 38             this.SuspendLayout();
 39             // 
 40             // imageList1
 41             // 
 42             this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
 43             this.imageList1.TransparentColor = System.Drawing.Color.White;
 44             this.imageList1.Images.SetKeyName(0, "0.png");
 45             this.imageList1.Images.SetKeyName(1, "1.png");
 46             this.imageList1.Images.SetKeyName(2, "2.png");
 47             this.imageList1.Images.SetKeyName(3, "3.png");
 48             this.imageList1.Images.SetKeyName(4, "4.png");
 49             this.imageList1.Images.SetKeyName(5, "5.png");
 50             this.imageList1.Images.SetKeyName(6, "6.png");
 51             this.imageList1.Images.SetKeyName(7, "7.png");
 52             this.imageList1.Images.SetKeyName(8, "8.png");
 53             this.imageList1.Images.SetKeyName(9, "9.png");
 54             this.imageList1.Images.SetKeyName(10, "10.png");
 55             this.imageList1.Images.SetKeyName(11, "11.png");
 56             this.imageList1.Images.SetKeyName(12, "12.png");
 57             this.imageList1.Images.SetKeyName(13, "13.png");
 58             this.imageList1.Images.SetKeyName(14, "14.png");
 59             this.imageList1.Images.SetKeyName(15, "15.png");
 60             this.imageList1.Images.SetKeyName(16, "16.png");
 61             this.imageList1.Images.SetKeyName(17, "17.png");
 62             this.imageList1.Images.SetKeyName(18, "18.png");
 63             this.imageList1.Images.SetKeyName(19, "19.png");
 64             // 
 65             // label1
 66             // 
 67             this.label1.Dock = System.Windows.Forms.DockStyle.Top;
 68             this.label1.Image = global::HZH_Controls.Properties.Resources.loading;
 69             this.label1.Location = new System.Drawing.Point(0, 0);
 70             this.label1.Name = "label1";
 71             this.label1.Size = new System.Drawing.Size(276, 196);
 72             this.label1.TabIndex = 0;
 73             // 
 74             // timer1
 75             // 
 76             this.timer1.Interval = 20;
 77             this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
 78             // 
 79             // label2
 80             // 
 81             this.label2.Dock = System.Windows.Forms.DockStyle.Top;
 82             this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
 83             this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
 84             this.label2.Location = new System.Drawing.Point(0, 196);
 85              the this .label2.Name = " label2 " ;
 86              the this .label2.Size = new new a System.Drawing.Size ( 276 , 30 );
 87              the this .label2.TabIndex = . 1 ;
 88              the this .label2.Text = " Processing is in progress. Please wait ... " ;
 89              the this .label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
 90              //  
91 is              // Timer2
 92              //  
93              the this .timer2.Tick + = new new System.EventHandler(this.timer2_Tick);
 94             // 
 95             // FrmWaiting
 96             // 
 97             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
 98             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
 99             this.ClientSize = new System.Drawing.Size(276, 244);
100             this.Controls.Add(this.label2);
101             this.Controls.Add(this.label1);
102             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
103             this.IsFullSize = false;
104             this.Name = "FrmWaiting";
105             this.Opacity = 0D;
106             this.RegionRadius = 20;
107             this.ShowIcon = false;
108             this.ShowInTaskbar = false;
109             this.Text = "";
110             this.TopMost = true;
111             this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
112             this.VisibleChanged += new System.EventHandler(this.FrmWaiting_VisibleChanged);
113             this.ResumeLayout(false);
114 
115         }
116 
117         #endregion
118 
119         private System.Windows.Forms.ImageList imageList1;
120         private System.Windows.Forms.Label label1;
121         private System.Windows.Forms.Timer timer1;
122         private System.Windows.Forms.Label label2;
123         private System.Windows.Forms.Timer timer2;
124 
125 
126     }
127 }
View Code

The main is the reality of a gif image and a text

Usefulness and effectiveness

Use: generally used in multi-threaded consuming operations waiting to be displayed

effect:

 

Last words

If you like it, please  https://gitee.com/kwwwvagaa/net_winform_custom_control  point stars right

Guess you like

Origin www.cnblogs.com/bfyx/p/11364072.html