165 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			165 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
/*********************************************************************************************
 | 
						|
 * Copyright 2004 - Volian Enterprises, Inc. All rights reserved.
 | 
						|
 * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
 | 
						|
 * ------------------------------------------------------------------------------
 | 
						|
 * $Workfile: SpinnerFrm.cs $     $Revision: 2 $
 | 
						|
 * $Author: Kathy $   $Date: 7/26/04 1:20p $
 | 
						|
 *
 | 
						|
 * $History: SpinnerFrm.cs $
 | 
						|
 * 
 | 
						|
 * *****************  Version 2  *****************
 | 
						|
 * User: Kathy        Date: 7/26/04    Time: 1:20p
 | 
						|
 * Updated in $/LibSource/VlnStatus
 | 
						|
 * doevents for cancel button click
 | 
						|
 * 
 | 
						|
 * *****************  Version 1  *****************
 | 
						|
 * User: Kathy        Date: 5/11/04    Time: 9:56a
 | 
						|
 * Created in $/LibSource/VlnStatus
 | 
						|
 * volian spinner control
 | 
						|
 *********************************************************************************************/
 | 
						|
 | 
						|
using System;
 | 
						|
using System.Drawing;
 | 
						|
using System.Collections;
 | 
						|
using System.ComponentModel;
 | 
						|
using System.Windows.Forms;
 | 
						|
 | 
						|
namespace VlnStatus
 | 
						|
{
 | 
						|
	/// <summary>
 | 
						|
	/// Create a status window with a progress bar
 | 
						|
	/// </summary>
 | 
						|
	public class SpinnerFrm : System.Windows.Forms.Form
 | 
						|
	{
 | 
						|
		private System.Windows.Forms.Button btnCancel;
 | 
						|
		private System.Windows.Forms.Label lblMsg;
 | 
						|
		/// <summary>
 | 
						|
		/// Required designer variable.
 | 
						|
		/// </summary>
 | 
						|
		private System.ComponentModel.Container components = null;
 | 
						|
		private System.Windows.Forms.ProgressBar progressBar1;
 | 
						|
 | 
						|
		private bool abortFlag;
 | 
						|
		public SpinnerFrm(bool ab, bool canCancel)
 | 
						|
		{
 | 
						|
			abortFlag = ab;
 | 
						|
			//
 | 
						|
			// Required for Windows Form Designer support
 | 
						|
			//
 | 
						|
			InitializeComponent();
 | 
						|
			if (!canCancel) this.btnCancel.Visible=false;
 | 
						|
			
 | 
						|
			this.progressBar1.Minimum=0;
 | 
						|
			this.progressBar1.Maximum=100;
 | 
						|
			this.progressBar1.Value=1;
 | 
						|
		}
 | 
						|
 | 
						|
		/// <summary>
 | 
						|
		/// Clean up any resources being used.
 | 
						|
		/// </summary>
 | 
						|
		protected override void Dispose( bool disposing )
 | 
						|
		{
 | 
						|
			if( disposing )
 | 
						|
			{
 | 
						|
				if(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.lblMsg = new System.Windows.Forms.Label();
 | 
						|
			this.btnCancel = new System.Windows.Forms.Button();
 | 
						|
			this.progressBar1 = new System.Windows.Forms.ProgressBar();
 | 
						|
			this.SuspendLayout();
 | 
						|
			// 
 | 
						|
			// lblMsg
 | 
						|
			// 
 | 
						|
			this.lblMsg.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
 | 
						|
			this.lblMsg.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
 | 
						|
			this.lblMsg.Location = new System.Drawing.Point(16, 16);
 | 
						|
			this.lblMsg.Name = "lblMsg";
 | 
						|
			this.lblMsg.Size = new System.Drawing.Size(288, 48);
 | 
						|
			this.lblMsg.TabIndex = 2;
 | 
						|
			this.lblMsg.Tag = "msg1";
 | 
						|
			this.lblMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
 | 
						|
			// 
 | 
						|
			// btnCancel
 | 
						|
			// 
 | 
						|
			this.btnCancel.Location = new System.Drawing.Point(128, 112);
 | 
						|
			this.btnCancel.Name = "btnCancel";
 | 
						|
			this.btnCancel.Size = new System.Drawing.Size(64, 24);
 | 
						|
			this.btnCancel.TabIndex = 3;
 | 
						|
			this.btnCancel.Text = "Cancel";
 | 
						|
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
 | 
						|
			// 
 | 
						|
			// progressBar1
 | 
						|
			// 
 | 
						|
			this.progressBar1.Location = new System.Drawing.Point(16, 72);
 | 
						|
			this.progressBar1.Name = "progressBar1";
 | 
						|
			this.progressBar1.Size = new System.Drawing.Size(288, 24);
 | 
						|
			this.progressBar1.TabIndex = 4;
 | 
						|
			// 
 | 
						|
			// SpinnerFrm
 | 
						|
			// 
 | 
						|
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
 | 
						|
			this.ClientSize = new System.Drawing.Size(318, 149);
 | 
						|
			this.ControlBox = false;
 | 
						|
			this.Controls.Add(this.progressBar1);
 | 
						|
			this.Controls.Add(this.btnCancel);
 | 
						|
			this.Controls.Add(this.lblMsg);
 | 
						|
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
 | 
						|
			this.MaximizeBox = false;
 | 
						|
			this.MinimizeBox = false;
 | 
						|
			this.Name = "SpinnerFrm";
 | 
						|
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
 | 
						|
			this.Text = "VE-PROMS";
 | 
						|
			this.TopMost = true;
 | 
						|
			this.ResumeLayout(false);
 | 
						|
 | 
						|
		}
 | 
						|
		#endregion
 | 
						|
 | 
						|
 | 
						|
		public void UpdateSpin()
 | 
						|
		{		
 | 
						|
			if (this.progressBar1.Value==this.progressBar1.Maximum) this.progressBar1.Value=0;
 | 
						|
			this.progressBar1.Value=this.progressBar1.Value++;
 | 
						|
			this.progressBar1.PerformStep();
 | 
						|
			System.Windows.Forms.Application.DoEvents();
 | 
						|
		}
 | 
						|
 | 
						|
		public void UpdateSpinMsg(string txt)
 | 
						|
		{
 | 
						|
			this.lblMsg.Text = txt;
 | 
						|
			this.lblMsg.Refresh();
 | 
						|
			this.Refresh();
 | 
						|
		}
 | 
						|
 | 
						|
		private void btnCancel_Click(object sender, System.EventArgs e)
 | 
						|
		{
 | 
						|
			if( abortFlag ) 
 | 
						|
			{
 | 
						|
				string message = "Are you sure you want to Cancel?";
 | 
						|
				string caption = "Network Update";
 | 
						|
				MessageBoxButtons buttons = MessageBoxButtons.YesNo;
 | 
						|
				DialogResult result;
 | 
						|
				result = MessageBox.Show(this, message, caption, buttons);
 | 
						|
						
 | 
						|
				if(result == DialogResult.Yes)
 | 
						|
				{
 | 
						|
					Environment.Exit(-1);
 | 
						|
				}
 | 
						|
			}
 | 
						|
		}
 | 
						|
	}
 | 
						|
}
 |