📄 progressform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace YariSoft.Utils
{
public class YProgress : System.Windows.Forms.Form
{
#region Local variables
private bool _cancel = false;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.ProgressBar progressBar;
private System.Windows.Forms.Label operationLabel;
private System.ComponentModel.Container components = null;
#endregion
#region Properties
public bool Cancel
{
set{
if( value == true ){
this.Close();
}
}
get{ return this._cancel; }
}
public int Maximum
{
set{ this.progressBar.Maximum = value; }
get{ return this.progressBar.Maximum; }
}
public string OperationCaption
{
set{ this.operationLabel.Text = value; this.operationLabel.Refresh(); }
}
public int Value
{
set{
Application.DoEvents();
this.progressBar.Value = value;
if( this.progressBar.Value >= this.progressBar.Maximum ){
this.Close();
}
}
get{ return this.progressBar.Value; }
}
#endregion
#region Constructor/Destructor
public YProgress()
{
InitializeComponent();
this.Show();
this.Refresh();
YariSoft.Utils.YMessages.ChangeCursor ( Cursors.WaitCursor );
}
protected override void Dispose( bool disposing )
{
YariSoft.Utils.YMessages.ChangeCursor ( Cursors.Default );
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#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.cancelButton = new System.Windows.Forms.Button();
this.progressBar = new System.Windows.Forms.ProgressBar();
this.operationLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// cancelButton
//
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(200, 80);
this.cancelButton.Name = "cancelButton";
this.cancelButton.TabIndex = 0;
this.cancelButton.Text = "Cancel";
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// progressBar
//
this.progressBar.Location = new System.Drawing.Point(16, 40);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(440, 23);
this.progressBar.TabIndex = 1;
//
// operationLabel
//
this.operationLabel.AutoSize = true;
this.operationLabel.Location = new System.Drawing.Point(16, 12);
this.operationLabel.Name = "operationLabel";
this.operationLabel.Size = new System.Drawing.Size(0, 13);
this.operationLabel.TabIndex = 2;
//
// YProgress
//
this.AcceptButton = this.cancelButton;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(472, 109);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.operationLabel,
this.progressBar,
this.cancelButton});
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "YProgress";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ProgressForm";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
#region Private functions
private void cancelButton_Click(object sender, System.EventArgs e)
{
this._cancel = true;
this.Close();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -