官网

http://www.hzhcontrols.com

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 

idkey=6e08741ef16fe53bf0314c1c9e336c4f626047943a8b76bac062361bab6b4f8d">

目录

https://www.cnblogs.com/bfyx/p/11364884.html

准备工作

这个窗体继承子基类窗体FrmBase,如果你对FrmBase还不了解,请移步 (十七)c#Winform自定义控件-基类窗体 查看

开始

添加一个Form,命名FrmWaiting,继承自FrmBase

代码不多,直接上全部代码

 // 版权所有  黄正辉  交流群:568015492   QQ:623128629
// 文件名称:FrmWaiting.cs
// 创建日期:2019-08-15 16:05:09
// 功能描述:FrmWaiting
// 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; namespace HZH_Controls.Forms
{
public partial class FrmWaiting : FrmBase
{
public string Msg { get { return label2.Text; } set { label2.Text = value; } }
public FrmWaiting()
{
base.SetStyle(ControlStyles.UserPaint, true);
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
base.SetStyle(ControlStyles.DoubleBuffer, true);
InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)
{
if (this.label1.ImageIndex == this.imageList1.Images.Count - )
this.label1.ImageIndex = ;
else
this.label1.ImageIndex++; } private void FrmWaiting_VisibleChanged(object sender, EventArgs e)
{
//this.timer1.Enabled = this.Visible;
} protected override void DoEsc()
{ } private void timer2_Tick(object sender, EventArgs e)
{
base.Opacity = 1.0;
this.timer2.Enabled = false;
} public void ShowForm(int intSleep = )
{
base.Opacity = 0.0;
if (intSleep <= )
{
intSleep = ;
}
base.Show();
this.timer2.Interval = intSleep;
this.timer2.Enabled = true;
}
}
}
 namespace HZH_Controls.Forms
{
partial class FrmWaiting
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region Windows Form Designer generated code /// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmWaiting));
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.label1 = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.White;
this.imageList1.Images.SetKeyName(, "0.png");
this.imageList1.Images.SetKeyName(, "1.png");
this.imageList1.Images.SetKeyName(, "2.png");
this.imageList1.Images.SetKeyName(, "3.png");
this.imageList1.Images.SetKeyName(, "4.png");
this.imageList1.Images.SetKeyName(, "5.png");
this.imageList1.Images.SetKeyName(, "6.png");
this.imageList1.Images.SetKeyName(, "7.png");
this.imageList1.Images.SetKeyName(, "8.png");
this.imageList1.Images.SetKeyName(, "9.png");
this.imageList1.Images.SetKeyName(, "10.png");
this.imageList1.Images.SetKeyName(, "11.png");
this.imageList1.Images.SetKeyName(, "12.png");
this.imageList1.Images.SetKeyName(, "13.png");
this.imageList1.Images.SetKeyName(, "14.png");
this.imageList1.Images.SetKeyName(, "15.png");
this.imageList1.Images.SetKeyName(, "16.png");
this.imageList1.Images.SetKeyName(, "17.png");
this.imageList1.Images.SetKeyName(, "18.png");
this.imageList1.Images.SetKeyName(, "19.png");
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Image = global::HZH_Controls.Properties.Resources.loading;
this.label1.Location = new System.Drawing.Point(, );
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(, );
this.label1.TabIndex = ;
//
// timer1
//
this.timer1.Interval = ;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Top;
this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.label2.Location = new System.Drawing.Point(, );
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(, );
this.label2.TabIndex = ;
this.label2.Text = "处理正在进行中,请稍候...";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// timer2
//
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// FrmWaiting
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.ClientSize = new System.Drawing.Size(, );
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.IsFullSize = false;
this.Name = "FrmWaiting";
this.Opacity = 0D;
this.RegionRadius = ;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "";
this.TopMost = true;
this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
this.VisibleChanged += new System.EventHandler(this.FrmWaiting_VisibleChanged);
this.ResumeLayout(false); } #endregion private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Timer timer2; }
}

主要就是现实一个gif图片和一个文本

用处及效果

用途:一般用在多线程耗时操作时等待显示

效果:

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星 星吧

(二十三)c#Winform自定义控件-等待窗体的更多相关文章

  1. (二十二)c#Winform自定义控件-半透明窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  2. (三十二)c#Winform自定义控件-表格

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  3. (八十二)c#Winform自定义控件-穿梭框

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  4. C#Winform之等待窗体

    窗体主要代码: ? 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 ...

  5. (二)c#Winform自定义控件-按钮

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  6. (四十二)c#Winform自定义控件-进度条扩展

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  7. (十九)c#Winform自定义控件-停靠窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  8. (十二)c#Winform自定义控件-分页控件

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  9. (五十二)c#Winform自定义控件-LED数字

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

随机推荐

  1. python输出带颜色详解

    书写格式:     开头部分:\033[显示方式;前景色;背景色m + 结尾部分:\033[0m      注意:开头部分的三个参数:显示方式,前景色,背景色是可选参数,可以只写其中的某一个:另外由于 ...

  2. android_layout_relativelayout(一)

    android的相对布局relativelayout也是一个值得研究的部分.先归纳下最近的几个心得. 相对布局中,xml文件第一个控件总是在屏幕的左上角为它的位置,别管你手机是竖着的还是横着的. 从第 ...

  3. GitHub使用整理——关于上传Keil工程一些注意的点

    git上传警告warning: LF will be replaced by CRLF 在上传keil工程时,会遇到warning: LF will be replaced by CRLF警告: wa ...

  4. Maven(一)Maven 的概念和安装

    Maven 的概念和安装 Maven 是什么 首先 Maven 肯定是一个造福人类的好东西,它可以省去我们构建项目中引入 jar 包时的麻烦,还有利于项目的模块化开发等等等好处.在如今项目中大体都是使 ...

  5. Spring 注解编程之 AnnotationMetadata

    在上篇文章 Spring 注解编程之模式注解 中我们讲到 Spring 模式注解底层原理,依靠 AnnotationMetadata 接口判断是否存在指定元注解. 这篇文章我们主要深入 Annotat ...

  6. Python登录豆瓣并爬取影评

    上一篇我们讲过Cookie相关的知识,了解到Cookie是为了交互式web而诞生的,它主要用于以下三个方面: 会话状态管理(如用户登录状态.购物车.游戏分数或其它需要记录的信息) 个性化设置(如用户自 ...

  7. Git更改提交

    提交记录我们的工作历史记录,提交自身是一成不变的.Git提供了几个工具和命令,抓门用来帮助修改完善版本库中的提交. 实际工作中存在很多情况需要我们去修改或返工某个提交或者整个提交序列: 1,可以在某个 ...

  8. 解决springmvc返回中文乱码问题

  9. Git学习笔记 (二)

    Git学习笔记(二) 突然发现,学习新知识新技能,都得经常温故使用,这样才能日益精进.最近学习的Git是因为加入了课题组,在学习做一些后台,由于后台开发会牵扯到多人开发,所以学会Git这一代码管理工具 ...

  10. Python基础总结之第三天开始重新认识‘字符串’(新手可相互督促)

    年薪20万的梦想,又进了一步... 戏好多 ’字符串‘开始啦~ 字符串的定义:字符串可以用英文单引号或双引号又或者三引号包围起来. 为毛有单引号,还要有双引号和三引号??? 看案例吧: 字符串的其他使 ...