[Adapdev-commits] Adapdev/src/Adapdev.Windows.Forms/Progress ProgressWindow.cs,NONE,1.1 ProgressWind
Status: Beta
Brought to you by:
intesar66
From: Trevor L. <tre...@us...> - 2005-04-12 10:23:12
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Windows.Forms/Progress In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23402/src/Adapdev.Windows.Forms/Progress Added Files: ProgressWindow.cs ProgressWindow.resx Log Message: Added Progress Dialog and threaded control for loading tables. --- NEW FILE: ProgressWindow.resx --- <?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 1.3 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">1.3</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1">this is my long string</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> [base64 mime encoded serialized .NET Framework object] </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> [base64 mime encoded string representing a byte array form of the .NET Framework object] </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used forserialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>1.3</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="progressBar.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="progressBar.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="progressBar.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="txtMessage1.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="txtMessage1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="txtMessage1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="cancelButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="cancelButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="cancelButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="morelessButton.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="morelessButton.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="morelessButton.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="imageList.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="imageList.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="imageList.Location" type="System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </data> <data name="imageList.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64"> <value> AAEAAAD/////AQAAAAAAAAAMAgAAAFpTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0xLjAuNTAw MC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZT eXN0ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMA AAAGDgAAAk1TRnQBSQFMAgEBBAEAAQkBAAEEAQABEAEAARABAAT/AREBEAj/AUIBTQE2BwABNgMAASgD AAFAAwABMAMAAQEBAAEQBgABGP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AMAABlAE1AZQB NQGUATUBlAE1AZQBNQGUATUBlAE1AZQBNQGUATUKAAEgAQEBYAEFAaABBQGgAQUBYAEFASABARQAAUYB AAFoAQABigEAAYoBAAFoAQABRhYAARABAAEYAQABIAEAASABAAEYAQABFBgAAZMBMQGeAWMBfgFbAV0B UwE9AUsBHgFDAR0BQwFeAUMBlAE1BgABgAEFAYABBQFBAQoBwQEOAcEBDgHBAQ4BwQEOAUABCgGgAQUB oAEFDAABaQEAAWkBAAHQAQABFAEBARUBAQEVAQEBFAEBAdABAAFqAQABag4AARwBAAEcAQABMAEAAUAB AAFEAQABRAEAAUQBAAEwAQABHAEAARwUAAFxAS0BOwFbARoBUwH6AU4B+wFKARwBSwH8AUIBHgFDAZQB NQQAAaEBCQHhAQkBwQEOAeEBDgHBAQ4BwAEKAcEBDgHBAQ4B4QEOAeEBDgEAAQoBIAEBCAABiwEAAa0B AAEVAQEBFgEBARUBAQEUAQEBF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WwBkgF+AS4BfgEAAWABAAFcAQABWAEAAVwBAAFIAQABLAIAAXsBOgH/AX8B /wF/Af8BfwH/AX8BXAFnAbQBLQEZASIBtQEpEgABpAEeAXABTwHbAXcBtQFjAU0BSwEqAUMBKAE/ASkB PwEpAT8BJwE3AcQBJgHhAQ0IAAE4AQEBfwEiAZ8BYwH/AT4BHwEWAd8BBQG/AQEBvwEFAb8BBQGfAQEB OQEBAa4KAAFQASUBcQFYAX8BbwF+AQMBeQGBAXgBYAF0AWABdAEgAXABAAFwAQABVAEAASgEAAG8AT4B /wF/Af8BfwH/AX8B/wF/AVwBbwG0AS0BOgEuFgABLAFDASwBQwG1AWMB2QFvAbcBawGUAWMBkgFbAUwB SwHFASoBxQEqDAABHwEOAR8BDgH/AT4BXwFXAR8BSwHfAToBnwEuAR8BEgFaAQEBWgEBDAABgAFwAcIB eAFPAX4B9QF+AZIBfgEuAX4BygF9AaABcAEAAVwBAAFcBgABvAE+AVoBNgFaATYBWgE2AVoBNgFaATYB tAEtHAABxgEmAQoBNwEsAUMBKwE/AegBMgGEASIUAAF8AQEB3wEFAf8BDQH/AQkBnwEBARYBARQAASAB aAFgAXQBwQF4AaEBeAEgAXQBAAFQCgABQgFNAT4HAAE+AwABKAMAAUADAAEwAwABAQEAAQEFAAGAAQEW AAP//wACAAH+AQAB+AEfAfgBHwH4AR8B/gEAAeABBwHgAQcB4AEHAf4BAAHAAQMBwAEDAcABAwH+AQAB gAEBAYABAQGAAQEB/AEAAYABAQGAAQEBgAEBIQABAQcAAQMHAAE/AYABAQGAAQEBgAEBAQABfwGAAQEB gAEBAYABAQEAAX8BwAEDAcABAwHAAQMBAAH/AeABBwHgAQcB4AEHAQEB/wH4AR8B+AEfAfgBHxYACw== </value> </data> <data name="txtMessage2.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="txtMessage2.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="txtMessage2.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="listView.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="listView.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="listView.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="ColumnHeader1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="ColumnHeader1.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> <data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>(Default)</value> </data> <data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </data> <data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>8, 8</value> </data> <data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </data> <data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>80</value> </data> <data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>True</value> </data> <data name="$this.Name"> <value>ProgressWindow</value> </data> <data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> </root> --- NEW FILE: ProgressWindow.cs --- // // This code based on functions from http://www.codeproject.com/cs/miscctrl/progressdialog.asp // Original Author: About Matthew Adams // using System; using System.Windows.Forms; namespace Adapdev.Windows.Forms.Progress { /// <summary> /// Summary description for ProgressWindow. /// </summary> public class ProgressWindow : System.Windows.Forms.Form, IProgressCallback { private System.Windows.Forms.ProgressBar progressBar; private System.ComponentModel.IContainer components; public delegate void SetTextInvoker(String text1, String text2); public delegate void IncrementInvoker( int val ); public delegate void StepToInvoker( int val ); public delegate void RangeInvoker( int minimum, int maximum ); public delegate void MoreLessInvoker( bool state ); public delegate void AddMessageInvoker (ProgressMessageTypes type, string message); private System.Threading.ManualResetEvent initEvent = new System.Threading.ManualResetEvent(false); private System.Threading.ManualResetEvent abortEvent = new System.Threading.ManualResetEvent(false); private System.Windows.Forms.ImageList imageList; private System.Windows.Forms.Button cancelButton; private System.Windows.Forms.Button morelessButton; private bool requiresClose = true; private bool morelessOpen = false; private bool completed = false; private ProgressAutoCloseTypes autoClose = ProgressAutoCloseTypes.AutoClose; private readonly int minWidth = 232; private readonly int openSize; private readonly int closedSize; private int totalErrors = 0; private System.Windows.Forms.Label txtMessage1; private System.Windows.Forms.ListView listView; private System.Windows.Forms.ColumnHeader ColumnHeader1; private System.Windows.Forms.Label txtMessage2; public ProgressWindow() { // // Required for Windows Form Designer support // InitializeComponent(); openSize = this.Height; closedSize = this.Height - (this.listView.Height + 16); DoSetMoreLess(false); } #region Implementation of IProgressCallback /// <summary> /// Call this method from the worker thread to initialize /// the progress meter. /// </summary> /// <param name="minimum">The minimum value in the progress range (e.g. 0)</param> /// <param name="maximum">The maximum value in the progress range (e.g. 100)</param> public void Begin( int minimum, int maximum ) { initEvent.WaitOne(); Invoke( new RangeInvoker( DoBegin ), new object[] { minimum, maximum } ); } /// <summary> /// Call this method from the worker thread to initialize /// the progress meter. /// </summary> /// <param name="minimum">The minimum value in the progress range (e.g. 0)</param> /// <param name="maximum">The maximum value in the progress range (e.g. 100)</param> public void Begin(ProgressAutoCloseTypes autoClose, int minimum, int maximum ) { initEvent.WaitOne(); this.autoClose = autoClose; Invoke( new RangeInvoker( DoBegin ), new object[] { minimum, maximum } ); } /// <summary> /// Call this method from the worker thread to initialize /// the progress callback, without setting the range /// </summary> public void Begin() { initEvent.WaitOne(); Invoke( new MethodInvoker( DoBegin ) ); } /// <summary> /// Call this method from the worker thread to reset the range in the progress callback /// </summary> /// <param name="minimum">The minimum value in the progress range (e.g. 0)</param> /// <param name="maximum">The maximum value in the progress range (e.g. 100)</param> /// <remarks>You must have called one of the Begin() methods prior to this call.</remarks> public void SetRange( int minimum, int maximum ) { initEvent.WaitOne(); Invoke( new RangeInvoker( DoSetRange ), new object[] { minimum, maximum } ); } /// <summary> /// Call this method to set the Autoclose flag /// </summary> public void SetAutoClose( ProgressAutoCloseTypes autoClose ) { this.autoClose = autoClose; } /// <summary> /// Call this method from the worker thread to update the progress text. /// </summary> /// <param name="text1">The progress heading text to display</param> /// <param name="text2">The progress sub-heading text to display</param> public void SetText( String text1, String text2 ) { Invoke( new SetTextInvoker(DoSetText), new object[] { text1, text2 } ); } public void SetText( String text ) { SetText (null, text); } /// <summary> /// Call this method from the worker thread to increase the progress counter by a specified value. /// </summary> /// <param name="val">The amount by which to increment the progress indicator</param> public void Increment( int val ) { Invoke( new IncrementInvoker( DoIncrement ), new object[] { val } ); } /// <summary> /// Call this method from the worker thread to step the progress meter to a particular value. /// </summary> /// <param name="val"></param> public void StepTo( int val ) { Invoke( new StepToInvoker( DoStepTo ), new object[] { val } ); } /// <summary> /// Call this method from the worker thread to step the progress meter to a particular value. /// </summary> public void AddMessage( string message ) { Invoke( new AddMessageInvoker( DoAddMessage), new object[] { ProgressMessageTypes.Info, message } ); } /// <summary> /// Call this method from the worker thread to step the progress meter to a particular value. /// </summary> public void AddMessage( ProgressMessageTypes type, string message ) { Invoke( new AddMessageInvoker( DoAddMessage), new object[] { type, message } ); } /// <summary> /// Called by the UI to update the UI /// </summary> private void morelessButton_Click(object sender, System.EventArgs e) { Invoke( new MoreLessInvoker(DoSetMoreLess), new object[] { !morelessOpen } ); } private void ProgressWindow_Resize(object sender, System.EventArgs e) { if (this.Height < closedSize) this.Height = closedSize; if (this.Width < minWidth) this.Width = minWidth; listView.Columns[0].Width = listView.Width; } private void cancelButton_Click(object sender, System.EventArgs e) { Invoke( new SetTextInvoker(DoSetText), new object[] { null, "Processing Cancelled!" } ); Invoke( new AddMessageInvoker( DoAddMessage), new object[] { ProgressMessageTypes.Critical, "Processing Cancelled!" } ); End(); } /// <summary> /// If this property is true, then you should abort work /// </summary> public bool IsAborting { get { return abortEvent.WaitOne( 0, false ); } } /// <summary> /// Call this method from the worker thread to finalize the progress meter /// </summary> public void End() { if( requiresClose ) { Invoke( new MethodInvoker( DoEnd ) ); } } #endregion #region Implementation members invoked on the owner thread private void DoSetText( String text1, String text2 ) { if (text1 != null) txtMessage1.Text = text1; txtMessage2.Text = text2; } private void DoIncrement( int val ) { progressBar.Increment( val ); UpdateStatusText(); } private void DoStepTo( int val ) { progressBar.Value = val; UpdateStatusText(); } private void DoBegin( int minimum, int maximum ) { DoBegin(); DoSetRange( minimum, maximum ); } private void DoBegin() { cancelButton.Enabled = true; } private void DoSetRange( int minimum, int maximum ) { progressBar.Minimum = minimum; progressBar.Maximum = maximum; progressBar.Value = minimum; UpdateStatusText(); } private void DoAddMessage( ProgressMessageTypes type, string message ) { ListViewItem li = new ListViewItem(); li.Text = message; switch (type) { case ProgressMessageTypes.Info: li.ImageIndex = 1; break; case ProgressMessageTypes.Warning: li.ImageIndex = 2; totalErrors += 1; break; case ProgressMessageTypes.Critical: li.ImageIndex = 3; totalErrors += 1; break; } listView.Items.Add(li); this.morelessButton.Enabled = !(this.listView.Items.Count == 0); } private void DoSetMoreLess (bool moreless) { morelessOpen = moreless; if (moreless){ this.Height = openSize; this.morelessButton.Text = @"<<< Less"; this.FormBorderStyle = FormBorderStyle.Sizable; this.SizeGripStyle = SizeGripStyle.Show; }else{ this.Height = closedSize; this.morelessButton.Text = @"More >>>"; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.SizeGripStyle = SizeGripStyle.Hide; } this.morelessButton.Enabled = !(this.listView.Items.Count == 0); } private void DoSetCompleted() { UpdateStatusText(); completed = true; this.cancelButton.Text = "Close"; } private void DoEnd() { if (!completed && requiresClose) { switch (autoClose) { case ProgressAutoCloseTypes.AutoClose: Close(); break; case ProgressAutoCloseTypes.WaitOnEnd: Invoke( new MethodInvoker( DoSetCompleted ) ); break; case ProgressAutoCloseTypes.WaitOnError: if (totalErrors == 0) { Close(); } else { Invoke( new MoreLessInvoker(DoSetMoreLess), new object[] { true } ); Invoke( new MethodInvoker( DoSetCompleted ) ); } break; } } else { Close(); } } #endregion #region Overrides /// <summary> /// Handles the form load, and sets an event to ensure that /// intialization is synchronized with the appearance of the form. /// </summary> /// <param name="e"></param> protected override void OnLoad(System.EventArgs e) { base.OnLoad( e ); ControlBox = false; initEvent.Set(); } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } /// <summary> /// Handler for 'Close' clicking /// </summary> /// <param name="e"></param> protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { requiresClose = false; AbortWork(); base.OnClosing( e ); } #endregion #region Implementation Utilities /// <summary> /// Utility function that formats and updates the title bar text /// </summary> private void UpdateStatusText() { this.Text = this.txtMessage1.Text.Trim() + String.Format( " - {0}% complete", (progressBar.Value * 100 ) / (progressBar.Maximum - progressBar.Minimum) ); } /// <summary> /// Utility function to terminate the thread /// </summary> private void AbortWork() { abortEvent.Set(); } #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.components = new System.ComponentModel.Container(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ProgressWindow)); this.progressBar = new System.Windows.Forms.ProgressBar(); this.txtMessage1 = new System.Windows.Forms.Label(); this.cancelButton = new System.Windows.Forms.Button(); this.morelessButton = new System.Windows.Forms.Button(); this.imageList = new System.Windows.Forms.ImageList(this.components); this.txtMessage2 = new System.Windows.Forms.Label(); this.listView = new System.Windows.Forms.ListView(); this.ColumnHeader1 = new System.Windows.Forms.ColumnHeader(); this.SuspendLayout(); // // progressBar // this.progressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.progressBar.Location = new System.Drawing.Point(8, 48); this.progressBar.Name = "progressBar"; this.progressBar.Size = new System.Drawing.Size(326, 16); this.progressBar.TabIndex = 1; // // txtMessage1 // this.txtMessage1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txtMessage1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.txtMessage1.Location = new System.Drawing.Point(8, 8); this.txtMessage1.Name = "txtMessage1"; this.txtMessage1.Size = new System.Drawing.Size(326, 16); this.txtMessage1.TabIndex = 0; this.txtMessage1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // cancelButton // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.cancelButton.Enabled = false; this.cancelButton.Location = new System.Drawing.Point(262, 72); this.cancelButton.Name = "cancelButton"; this.cancelButton.TabIndex = 2; this.cancelButton.Text = "Cancel"; this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click); // // morelessButton // this.morelessButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.morelessButton.Location = new System.Drawing.Point(182, 72); this.morelessButton.Name = "morelessButton"; this.morelessButton.TabIndex = 4; this.morelessButton.Text = "More >>>"; this.morelessButton.Click += new System.EventHandler(this.morelessButton_Click); // // imageList // this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth16Bit; this.imageList.ImageSize = new System.Drawing.Size(16, 16); this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream"))); this.imageList.TransparentColor = System.Drawing.Color.Transparent; // // txtMessage2 // this.txtMessage2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.txtMessage2.Location = new System.Drawing.Point(8, 24); this.txtMessage2.Name = "txtMessage2"; this.txtMessage2.Size = new System.Drawing.Size(326, 16); this.txtMessage2.TabIndex = 5; this.txtMessage2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // listView // this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.ColumnHeader1}); this.listView.FullRowSelect = true; this.listView.GridLines = true; this.listView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.listView.LabelWrap = false; this.listView.LargeImageList = this.imageList; this.listView.Location = new System.Drawing.Point(8, 104); this.listView.MultiSelect = false; this.listView.Name = "listView"; this.listView.Size = new System.Drawing.Size(328, 160); this.listView.SmallImageList = this.imageList; this.listView.StateImageList = this.imageList; this.listView.TabIndex = 6; this.listView.View = System.Windows.Forms.View.SmallIcon; // // ColumnHeader1 // this.ColumnHeader1.Text = "Message"; this.ColumnHeader1.Width = 500; // // ProgressWindow // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(344, 278); this.ControlBox = false; this.Controls.Add(this.listView); this.Controls.Add(this.txtMessage2); this.Controls.Add(this.morelessButton); this.Controls.Add(this.cancelButton); this.Controls.Add(this.progressBar); this.Controls.Add(this.txtMessage1); this.MaximizeBox = false; this.Name = "ProgressWindow"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "ProgressWindow"; this.Resize += new System.EventHandler(this.ProgressWindow_Resize); this.ResumeLayout(false); } #endregion } } |