C# 如何设计一个标准的等待窗体
C# 如何设计一个标准的等待窗体
加载大批量数据时往往需要用户焦急等待,这不是好办法,比如系统在加载数据时暂停时刻放首曲子或显示一段迷人动画,我想用户不再那么焦急了。
加载大批量数据时往往需要用户焦急等待,这不是好办法,比如系统在加载数据时暂停时刻放首曲子或显示一段迷人动画,我想用户不再那么焦急了。
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 ShowWaiting
{
public partial class frmWaiting : Form
{
public static frmWaiting _Instance = null;
/// <summary>
/// 私有构造器,禁止外部实例化frmWaiting类
/// </summary>
private frmWaiting()
{
InitializeComponent();
}
/// <summary>
/// 显示等待窗体
/// </summary>
/// <param name="owner"></param>
public static void Show(Form owner)
{
owner.UseWaitCursor = true;
if (_Instance == null) _Instance = new frmWaiting();
_Instance.Owner = owner;
_Instance.Show();
Application.DoEvents();
}
/// <summary>
/// 显示等待窗体
/// </summary>
/// <param name="owner"></param>
public static void Show(Form owner, bool disableOwner)
{
owner.UseWaitCursor = true;
owner.Enabled = !disableOwner;
if (_Instance == null) _Instance = new frmWaiting();
_Instance.Owner = owner;
_Instance.Show();
Application.DoEvents();
}
/// <summary>
/// 隐藏等待窗体
/// </summary>
/// <param name="owner"></param>
public static void Hide(Form owner)
{
owner.UseWaitCursor = false;
owner.Enabled = true;
if (_Instance != null) _Instance.Hide();
Application.DoEvents();
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ShowWaiting
{
public partial class frmWaiting : Form
{
public static frmWaiting _Instance = null;
/// <summary>
/// 私有构造器,禁止外部实例化frmWaiting类
/// </summary>
private frmWaiting()
{
InitializeComponent();
}
/// <summary>
/// 显示等待窗体
/// </summary>
/// <param name="owner"></param>
public static void Show(Form owner)
{
owner.UseWaitCursor = true;
if (_Instance == null) _Instance = new frmWaiting();
_Instance.Owner = owner;
_Instance.Show();
Application.DoEvents();
}
/// <summary>
/// 显示等待窗体
/// </summary>
/// <param name="owner"></param>
public static void Show(Form owner, bool disableOwner)
{
owner.UseWaitCursor = true;
owner.Enabled = !disableOwner;
if (_Instance == null) _Instance = new frmWaiting();
_Instance.Owner = owner;
_Instance.Show();
Application.DoEvents();
}
/// <summary>
/// 隐藏等待窗体
/// </summary>
/// <param name="owner"></param>
public static void Hide(Form owner)
{
owner.UseWaitCursor = false;
owner.Enabled = true;
if (_Instance != null) _Instance.Hide();
Application.DoEvents();
}
}
}
// 来源:www.CSFramework.com, C/S结构框架学习网
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网