Click here to Skip to main content
15,895,283 members
Articles / Programming Languages / C#

Dealing with Progressive Operations

Rate me:
Please Sign up or sign in to vote.
4.92/5 (26 votes)
10 May 2010CPOL30 min read 38.6K   319   60  
Through a clean OOP solution to deal with progressive operations, I will implicitly show you how OOP principles can work together to make a full, clean solution.
namespace MultipleThreadsSample
{
    partial class frmSearch
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (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.components = new System.ComponentModel.Container();
            this.label1 = new System.Windows.Forms.Label();
            this.txtSearchText = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.txtSearchPath = new System.Windows.Forms.TextBox();
            this.btnBrowse = new System.Windows.Forms.Button();
            this.tip = new System.Windows.Forms.ToolTip(this.components);
            this.tab = new System.Windows.Forms.TabControl();
            this.pgResults = new System.Windows.Forms.TabPage();
            this.lstFiles = new System.Windows.Forms.ListBox();
            this.pgRunningThreads = new System.Windows.Forms.TabPage();
            this.lstFolders = new System.Windows.Forms.ListBox();
            this.pgb = new System.Windows.Forms.ProgressBar();
            this.btnStart = new System.Windows.Forms.Button();
            this.chkIncludeSubFolders = new System.Windows.Forms.CheckBox();
            this.lblStatus = new System.Windows.Forms.Label();
            this.dlg = new System.Windows.Forms.FolderBrowserDialog();
            this.tab.SuspendLayout();
            this.pgResults.SuspendLayout();
            this.pgRunningThreads.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(14, 17);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(59, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "&Search for:";
            // 
            // txtSearchText
            // 
            this.txtSearchText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtSearchText.Location = new System.Drawing.Point(88, 14);
            this.txtSearchText.Name = "txtSearchText";
            this.txtSearchText.Size = new System.Drawing.Size(273, 20);
            this.txtSearchText.TabIndex = 1;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(14, 43);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(68, 13);
            this.label2.TabIndex = 2;
            this.label2.Text = "Search &path:";
            // 
            // txtSearchPath
            // 
            this.txtSearchPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtSearchPath.Location = new System.Drawing.Point(88, 40);
            this.txtSearchPath.Name = "txtSearchPath";
            this.txtSearchPath.Size = new System.Drawing.Size(234, 20);
            this.txtSearchPath.TabIndex = 3;
            // 
            // btnBrowse
            // 
            this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnBrowse.Location = new System.Drawing.Point(331, 40);
            this.btnBrowse.Name = "btnBrowse";
            this.btnBrowse.Size = new System.Drawing.Size(30, 20);
            this.btnBrowse.TabIndex = 4;
            this.btnBrowse.Text = "...";
            this.tip.SetToolTip(this.btnBrowse, "Browse folder");
            this.btnBrowse.UseVisualStyleBackColor = true;
            this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
            // 
            // tab
            // 
            this.tab.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.tab.Controls.Add(this.pgResults);
            this.tab.Controls.Add(this.pgRunningThreads);
            this.tab.Location = new System.Drawing.Point(17, 104);
            this.tab.Name = "tab";
            this.tab.SelectedIndex = 0;
            this.tab.Size = new System.Drawing.Size(343, 267);
            this.tab.TabIndex = 5;
            // 
            // pgResults
            // 
            this.pgResults.Controls.Add(this.lstFiles);
            this.pgResults.Location = new System.Drawing.Point(4, 22);
            this.pgResults.Name = "pgResults";
            this.pgResults.Padding = new System.Windows.Forms.Padding(3);
            this.pgResults.Size = new System.Drawing.Size(335, 241);
            this.pgResults.TabIndex = 0;
            this.pgResults.Text = "Search results";
            this.pgResults.UseVisualStyleBackColor = true;
            // 
            // lstFiles
            // 
            this.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lstFiles.FormattingEnabled = true;
            this.lstFiles.Location = new System.Drawing.Point(3, 3);
            this.lstFiles.Name = "lstFiles";
            this.lstFiles.Size = new System.Drawing.Size(329, 225);
            this.lstFiles.TabIndex = 0;
            // 
            // pgRunningThreads
            // 
            this.pgRunningThreads.Controls.Add(this.lstFolders);
            this.pgRunningThreads.Location = new System.Drawing.Point(4, 22);
            this.pgRunningThreads.Name = "pgRunningThreads";
            this.pgRunningThreads.Padding = new System.Windows.Forms.Padding(3);
            this.pgRunningThreads.Size = new System.Drawing.Size(335, 241);
            this.pgRunningThreads.TabIndex = 1;
            this.pgRunningThreads.Text = "Folders being processed";
            this.pgRunningThreads.UseVisualStyleBackColor = true;
            // 
            // lstFolders
            // 
            this.lstFolders.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lstFolders.FormattingEnabled = true;
            this.lstFolders.Location = new System.Drawing.Point(3, 3);
            this.lstFolders.Name = "lstFolders";
            this.lstFolders.Size = new System.Drawing.Size(329, 225);
            this.lstFolders.TabIndex = 0;
            // 
            // pgb
            // 
            this.pgb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.pgb.Location = new System.Drawing.Point(20, 383);
            this.pgb.Name = "pgb";
            this.pgb.Size = new System.Drawing.Size(336, 20);
            this.pgb.TabIndex = 6;
            this.pgb.Visible = false;
            // 
            // btnStart
            // 
            this.btnStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.btnStart.Location = new System.Drawing.Point(284, 75);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(76, 19);
            this.btnStart.TabIndex = 7;
            this.btnStart.Text = "Start";
            this.btnStart.UseVisualStyleBackColor = true;
            this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
            // 
            // chkIncludeSubFolders
            // 
            this.chkIncludeSubFolders.AutoSize = true;
            this.chkIncludeSubFolders.Location = new System.Drawing.Point(17, 75);
            this.chkIncludeSubFolders.Name = "chkIncludeSubFolders";
            this.chkIncludeSubFolders.Size = new System.Drawing.Size(112, 17);
            this.chkIncludeSubFolders.TabIndex = 8;
            this.chkIncludeSubFolders.Text = "Include subfolders";
            this.chkIncludeSubFolders.UseVisualStyleBackColor = true;
            // 
            // lblStatus
            // 
            this.lblStatus.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.lblStatus.AutoSize = true;
            this.lblStatus.Location = new System.Drawing.Point(21, 387);
            this.lblStatus.Name = "lblStatus";
            this.lblStatus.Size = new System.Drawing.Size(161, 13);
            this.lblStatus.TabIndex = 9;
            this.lblStatus.Text = "Search operation has not started";
            // 
            // frmSearch
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(376, 424);
            this.Controls.Add(this.pgb);
            this.Controls.Add(this.lblStatus);
            this.Controls.Add(this.chkIncludeSubFolders);
            this.Controls.Add(this.btnStart);
            this.Controls.Add(this.tab);
            this.Controls.Add(this.btnBrowse);
            this.Controls.Add(this.txtSearchPath);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.txtSearchText);
            this.Controls.Add(this.label1);
            this.Name = "frmSearch";
            this.Text = "Search...";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmSearch_FormClosing);
            this.tab.ResumeLayout(false);
            this.pgResults.ResumeLayout(false);
            this.pgRunningThreads.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox txtSearchText;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox txtSearchPath;
        private System.Windows.Forms.Button btnBrowse;
        private System.Windows.Forms.ToolTip tip;
        private System.Windows.Forms.TabControl tab;
        private System.Windows.Forms.TabPage pgResults;
        private System.Windows.Forms.TabPage pgRunningThreads;
        private System.Windows.Forms.ProgressBar pgb;
        private System.Windows.Forms.ListBox lstFiles;
        private System.Windows.Forms.ListBox lstFolders;
        private System.Windows.Forms.Button btnStart;
        private System.Windows.Forms.CheckBox chkIncludeSubFolders;
        private System.Windows.Forms.Label lblStatus;
        private System.Windows.Forms.FolderBrowserDialog dlg;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions