/********************************************************************************************* * Copyright 2002 - Volian Enterprises, Inc. All rights reserved. * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE * ------------------------------------------------------------------------------ * $Workfile: StatusBarFrm.cs $ $Revision: 3 $ * $Author: Jsj $ $Date: 4/08/04 9:50a $ * * $History: StatusBarFrm.cs $ * * ***************** Version 3 ***************** * User: Jsj Date: 4/08/04 Time: 9:50a * Updated in $/LibSource/VlnStatus * added profile code and try to optimize * * ***************** Version 2 ***************** * User: Jsj Date: 11/26/02 Time: 3:38p * Updated in $/LibSource/VlnStatus * Added overbounds check *********************************************************************************************/ using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; //using ROProfiler; //don't forget to add VlnProfiler to the reference list namespace VlnStatus { /// /// Create a status window with a progress bar /// public class StatusBarFrm : System.Windows.Forms.Form { private System.Windows.Forms.ProgressBar progressBar1; private System.Windows.Forms.Label lblBar; private System.Windows.Forms.Label StatMsg; // private string strLblLast=""; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public StatusBarFrm() { // // Required for Windows Form Designer support // InitializeComponent(); Text = "Status"; } public StatusBarFrm(string StatusBoxTitle) { // // Required for Windows Form Designer support // InitializeComponent(); Text = StatusBoxTitle; } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.progressBar1 = new System.Windows.Forms.ProgressBar(); this.lblBar = new System.Windows.Forms.Label(); this.StatMsg = new System.Windows.Forms.Label(); this.SuspendLayout(); // // progressBar1 // this.progressBar1.Location = new System.Drawing.Point(29, 83); this.progressBar1.Name = "progressBar1"; this.progressBar1.Size = new System.Drawing.Size(297, 27); this.progressBar1.TabIndex = 0; // // lblBar // this.lblBar.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.lblBar.Location = new System.Drawing.Point(29, 136); this.lblBar.Name = "lblBar"; this.lblBar.Size = new System.Drawing.Size(297, 16); this.lblBar.TabIndex = 1; this.lblBar.Text = "% Complete"; this.lblBar.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // StatMsg // this.StatMsg.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.StatMsg.Location = new System.Drawing.Point(29, 18); this.StatMsg.Name = "StatMsg"; this.StatMsg.Size = new System.Drawing.Size(307, 56); this.StatMsg.TabIndex = 2; this.StatMsg.Text = "Progress Bar"; this.StatMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // StatusBarFrm // this.AutoScaleBaseSize = new System.Drawing.Size(6, 15); this.ClientSize = new System.Drawing.Size(350, 171); this.ControlBox = false; this.Controls.Add(this.StatMsg); this.Controls.Add(this.lblBar); this.Controls.Add(this.progressBar1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "StatusBarFrm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Status"; this.TopMost = true; this.Load += new System.EventHandler(this.StatusBarFrm_Load); this.ResumeLayout(false); } #endregion private void StatusBarFrm_Load(object sender, System.EventArgs e) { } public int Value { get { return progressBar1.Value; } set { if (value >= progressBar1.Maximum) progressBar1.Value = progressBar1.Maximum; else progressBar1.Value = value; UpateLabel(); } } public int Maximum { get { return progressBar1.Maximum; } set { progressBar1.Maximum = value; } } public int Step { get { return progressBar1.Step; } set { progressBar1.Step = value; } } public void PerformStep() { progressBar1.PerformStep(); } private void UpateLabel() { lblBar.Text = (Math.Round((decimal)(progressBar1.Value * 100) / progressBar1.Maximum)).ToString(); lblBar.Text += "% Complete"; // if( lblBar.Text != strLblLast) // { // Profiler.Start("UpdateLabel"); lblBar.Refresh(); // lblBar.Update(); // Profiler.End("UpdateLabel"); // } // strLblLast = lblBar.Text; } public string StatusMessage { get { return StatMsg.Text; } set { StatMsg.Text = value; // Profiler.Start("StatusMessage"); StatMsg.Refresh(); // StatMsg.Update(); // Profiler.End("StatusMessage"); } } public string StatusBoxTitle { get { return Text; } set { Text = value; } } } }