Click here to Skip to main content
15,886,075 members
Articles / Programming Languages / C#

Strategy Pattern Primer (Layman to Laymen)

Rate me:
Please Sign up or sign in to vote.
4.94/5 (66 votes)
19 Mar 2010CPOL7 min read 56.3K   264   55  
This article takes a scenario based approach to make the reader understand this pattern.
namespace EMRApplication
{
    partial class frmBsaCalculator
    {
        /// <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.lblHeight = new System.Windows.Forms.Label();
            this.lblWeight = new System.Windows.Forms.Label();
            this.lblTemperature = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.txtHeight = new System.Windows.Forms.MaskedTextBox();
            this.txtWeight = new System.Windows.Forms.MaskedTextBox();
            this.txtTemperature = new System.Windows.Forms.MaskedTextBox();
            this.cboFormula = new System.Windows.Forms.ComboBox();
            this.lblBsa = new System.Windows.Forms.Label();
            this.txtBsa = new System.Windows.Forms.TextBox();
            this.cmdClose = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // lblHeight
            // 
            this.lblHeight.AutoSize = true;
            this.lblHeight.Location = new System.Drawing.Point(12, 9);
            this.lblHeight.Name = "lblHeight";
            this.lblHeight.Size = new System.Drawing.Size(64, 13);
            this.lblHeight.TabIndex = 0;
            this.lblHeight.Text = "Height (cm):";
            // 
            // lblWeight
            // 
            this.lblWeight.AutoSize = true;
            this.lblWeight.Location = new System.Drawing.Point(12, 34);
            this.lblWeight.Name = "lblWeight";
            this.lblWeight.Size = new System.Drawing.Size(65, 13);
            this.lblWeight.TabIndex = 0;
            this.lblWeight.Text = "Weight (kg):";
            // 
            // lblTemperature
            // 
            this.lblTemperature.AutoSize = true;
            this.lblTemperature.Location = new System.Drawing.Point(12, 66);
            this.lblTemperature.Name = "lblTemperature";
            this.lblTemperature.Size = new System.Drawing.Size(67, 13);
            this.lblTemperature.TabIndex = 0;
            this.lblTemperature.Text = "Temperature";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 105);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(86, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Choose Formula:";
            // 
            // txtHeight
            // 
            this.txtHeight.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.txtHeight.Location = new System.Drawing.Point(120, 2);
            this.txtHeight.Mask = "###.##";
            this.txtHeight.Name = "txtHeight";
            this.txtHeight.Size = new System.Drawing.Size(121, 20);
            this.txtHeight.TabIndex = 0;
            // 
            // txtWeight
            // 
            this.txtWeight.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.txtWeight.Location = new System.Drawing.Point(120, 32);
            this.txtWeight.Mask = "###.##";
            this.txtWeight.Name = "txtWeight";
            this.txtWeight.Size = new System.Drawing.Size(121, 20);
            this.txtWeight.TabIndex = 1;
            // 
            // txtTemperature
            // 
            this.txtTemperature.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.txtTemperature.Location = new System.Drawing.Point(120, 59);
            this.txtTemperature.Mask = "###.##";
            this.txtTemperature.Name = "txtTemperature";
            this.txtTemperature.Size = new System.Drawing.Size(121, 20);
            this.txtTemperature.TabIndex = 2;
            // 
            // cboFormula
            // 
            this.cboFormula.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.cboFormula.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.cboFormula.FormattingEnabled = true;
            this.cboFormula.Items.AddRange(new object[] {
            "==Select One==",
            "Boyd",
            "Moststeller",
            "Haycock",
            "Gehan and George"});
            this.cboFormula.Location = new System.Drawing.Point(120, 97);
            this.cboFormula.Name = "cboFormula";
            this.cboFormula.Size = new System.Drawing.Size(121, 21);
            this.cboFormula.TabIndex = 3;
            this.cboFormula.SelectedIndexChanged += new System.EventHandler(this.cboFormula_SelectedIndexChanged);
            // 
            // lblBsa
            // 
            this.lblBsa.AutoSize = true;
            this.lblBsa.Location = new System.Drawing.Point(12, 147);
            this.lblBsa.Name = "lblBsa";
            this.lblBsa.Size = new System.Drawing.Size(81, 13);
            this.lblBsa.TabIndex = 0;
            this.lblBsa.Text = "Calculated Bsa:";
            // 
            // txtBsa
            // 
            this.txtBsa.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.txtBsa.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.txtBsa.Location = new System.Drawing.Point(120, 140);
            this.txtBsa.Name = "txtBsa";
            this.txtBsa.ReadOnly = true;
            this.txtBsa.Size = new System.Drawing.Size(121, 20);
            this.txtBsa.TabIndex = 4;
            // 
            // cmdClose
            // 
            this.cmdClose.Location = new System.Drawing.Point(166, 186);
            this.cmdClose.Name = "cmdClose";
            this.cmdClose.Size = new System.Drawing.Size(75, 23);
            this.cmdClose.TabIndex = 5;
            this.cmdClose.Text = "Exit";
            this.cmdClose.UseVisualStyleBackColor = true;
            // 
            // frmBsaCalculator
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(293, 251);
            this.Controls.Add(this.cmdClose);
            this.Controls.Add(this.txtBsa);
            this.Controls.Add(this.cboFormula);
            this.Controls.Add(this.txtTemperature);
            this.Controls.Add(this.txtWeight);
            this.Controls.Add(this.txtHeight);
            this.Controls.Add(this.lblBsa);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.lblTemperature);
            this.Controls.Add(this.lblWeight);
            this.Controls.Add(this.lblHeight);
            this.Name = "frmBsaCalculator";
            this.Text = "BSA Calculation Demo";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label lblHeight;
        private System.Windows.Forms.Label lblWeight;
        private System.Windows.Forms.Label lblTemperature;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.MaskedTextBox txtHeight;
        private System.Windows.Forms.MaskedTextBox txtWeight;
        private System.Windows.Forms.MaskedTextBox txtTemperature;
        private System.Windows.Forms.ComboBox cboFormula;
        private System.Windows.Forms.Label lblBsa;
        private System.Windows.Forms.TextBox txtBsa;
        private System.Windows.Forms.Button cmdClose;
    }
}

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
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions