Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / C#

Revisit the Game of Life while Learning about Extension Methods in C#

Rate me:
Please Sign up or sign in to vote.
4.65/5 (8 votes)
24 Aug 2008CPOL11 min read 55.7K   594   40  
A fun variation of the Game of Life re-factored using extension methods
namespace LifeSimulation
{
    partial class EditForm
    {
        /// <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.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.label1 = new System.Windows.Forms.Label();
            this.spawnIndicatorsTextBox = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.deathIndicatorsTextBox = new System.Windows.Forms.TextBox();
            this.maximumAgeTextBox = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.lifeFormIdentifierTextBox = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
            this.neigbourhoodDistanceTextBox = new System.Windows.Forms.TextBox();
            this.maxNeighboursMessage = new System.Windows.Forms.Label();
            this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
            this.cancelButton = new System.Windows.Forms.Button();
            this.okButton = new System.Windows.Forms.Button();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.tableLayoutPanel1.SuspendLayout();
            this.flowLayoutPanel2.SuspendLayout();
            this.flowLayoutPanel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Name = "splitContainer1";
            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.tableLayoutPanel1);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.flowLayoutPanel1);
            this.splitContainer1.Size = new System.Drawing.Size(483, 301);
            this.splitContainer1.SplitterDistance = 257;
            this.splitContainer1.TabIndex = 0;
            this.splitContainer1.TabStop = false;
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 2;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70F));
            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 4);
            this.tableLayoutPanel1.Controls.Add(this.spawnIndicatorsTextBox, 1, 4);
            this.tableLayoutPanel1.Controls.Add(this.label2, 0, 5);
            this.tableLayoutPanel1.Controls.Add(this.label4, 0, 6);
            this.tableLayoutPanel1.Controls.Add(this.deathIndicatorsTextBox, 1, 5);
            this.tableLayoutPanel1.Controls.Add(this.maximumAgeTextBox, 1, 6);
            this.tableLayoutPanel1.Controls.Add(this.label5, 0, 1);
            this.tableLayoutPanel1.Controls.Add(this.lifeFormIdentifierTextBox, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.label6, 1, 2);
            this.tableLayoutPanel1.Controls.Add(this.label3, 0, 3);
            this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel2, 1, 3);
            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 8;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(483, 257);
            this.tableLayoutPanel1.TabIndex = 0;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label1.Location = new System.Drawing.Point(3, 110);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(138, 30);
            this.label1.TabIndex = 0;
            this.label1.Text = "Spawn indicators";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // spawnIndicatorsTextBox
            // 
            this.spawnIndicatorsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.spawnIndicatorsTextBox.Location = new System.Drawing.Point(147, 113);
            this.spawnIndicatorsTextBox.Name = "spawnIndicatorsTextBox";
            this.spawnIndicatorsTextBox.Size = new System.Drawing.Size(333, 20);
            this.spawnIndicatorsTextBox.TabIndex = 2;
            this.spawnIndicatorsTextBox.TextChanged += new System.EventHandler(this.spawnIndicatorsTextBox_TextChanged);
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label2.Location = new System.Drawing.Point(3, 140);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(138, 30);
            this.label2.TabIndex = 2;
            this.label2.Text = "Death indicators";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label4.Location = new System.Drawing.Point(3, 170);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(138, 30);
            this.label4.TabIndex = 4;
            this.label4.Text = "Maximum age";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // deathIndicatorsTextBox
            // 
            this.deathIndicatorsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.deathIndicatorsTextBox.Location = new System.Drawing.Point(147, 143);
            this.deathIndicatorsTextBox.Name = "deathIndicatorsTextBox";
            this.deathIndicatorsTextBox.Size = new System.Drawing.Size(333, 20);
            this.deathIndicatorsTextBox.TabIndex = 3;
            this.deathIndicatorsTextBox.TextChanged += new System.EventHandler(this.deathIndicatorsTextBox_TextChanged);
            // 
            // maximumAgeTextBox
            // 
            this.maximumAgeTextBox.Location = new System.Drawing.Point(147, 173);
            this.maximumAgeTextBox.Name = "maximumAgeTextBox";
            this.maximumAgeTextBox.Size = new System.Drawing.Size(100, 20);
            this.maximumAgeTextBox.TabIndex = 4;
            this.maximumAgeTextBox.TextChanged += new System.EventHandler(this.maximumAgeTextBox_TextChanged);
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label5.Location = new System.Drawing.Point(3, 20);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(138, 30);
            this.label5.TabIndex = 8;
            this.label5.Text = "Lifeform identifier (DNA)";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // lifeFormIdentifierTextBox
            // 
            this.lifeFormIdentifierTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lifeFormIdentifierTextBox.Location = new System.Drawing.Point(147, 23);
            this.lifeFormIdentifierTextBox.Name = "lifeFormIdentifierTextBox";
            this.lifeFormIdentifierTextBox.Size = new System.Drawing.Size(333, 20);
            this.lifeFormIdentifierTextBox.TabIndex = 0;
            this.lifeFormIdentifierTextBox.TextChanged += new System.EventHandler(this.lifeFormIdentifierTextBox_TextChanged);
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label6.Location = new System.Drawing.Point(147, 50);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(333, 30);
            this.label6.TabIndex = 9;
            this.label6.Text = "Or alternatively edit the parts";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label3.Location = new System.Drawing.Point(3, 80);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(138, 30);
            this.label3.TabIndex = 3;
            this.label3.Text = "Neighbourhood distance";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // flowLayoutPanel2
            // 
            this.flowLayoutPanel2.Controls.Add(this.neigbourhoodDistanceTextBox);
            this.flowLayoutPanel2.Controls.Add(this.maxNeighboursMessage);
            this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.flowLayoutPanel2.Location = new System.Drawing.Point(144, 80);
            this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
            this.flowLayoutPanel2.Name = "flowLayoutPanel2";
            this.flowLayoutPanel2.Size = new System.Drawing.Size(339, 30);
            this.flowLayoutPanel2.TabIndex = 10;
            // 
            // neigbourhoodDistanceTextBox
            // 
            this.neigbourhoodDistanceTextBox.Location = new System.Drawing.Point(3, 3);
            this.neigbourhoodDistanceTextBox.Name = "neigbourhoodDistanceTextBox";
            this.neigbourhoodDistanceTextBox.Size = new System.Drawing.Size(100, 20);
            this.neigbourhoodDistanceTextBox.TabIndex = 1;
            this.neigbourhoodDistanceTextBox.TextChanged += new System.EventHandler(this.neigbourhoodDistanceTextBox_TextChanged);
            // 
            // maxNeighboursMessage
            // 
            this.maxNeighboursMessage.AutoSize = true;
            this.maxNeighboursMessage.Dock = System.Windows.Forms.DockStyle.Left;
            this.maxNeighboursMessage.Location = new System.Drawing.Point(109, 0);
            this.maxNeighboursMessage.Name = "maxNeighboursMessage";
            this.maxNeighboursMessage.Size = new System.Drawing.Size(114, 26);
            this.maxNeighboursMessage.TabIndex = 2;
            this.maxNeighboursMessage.Text = "0 maximum neighbours";
            this.maxNeighboursMessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // flowLayoutPanel1
            // 
            this.flowLayoutPanel1.Controls.Add(this.cancelButton);
            this.flowLayoutPanel1.Controls.Add(this.okButton);
            this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
            this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
            this.flowLayoutPanel1.Name = "flowLayoutPanel1";
            this.flowLayoutPanel1.Size = new System.Drawing.Size(483, 40);
            this.flowLayoutPanel1.TabIndex = 0;
            // 
            // cancelButton
            // 
            this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.cancelButton.Location = new System.Drawing.Point(405, 3);
            this.cancelButton.Name = "cancelButton";
            this.cancelButton.Size = new System.Drawing.Size(75, 23);
            this.cancelButton.TabIndex = 6;
            this.cancelButton.Text = "Cancel";
            this.cancelButton.UseVisualStyleBackColor = true;
            this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
            // 
            // okButton
            // 
            this.okButton.Location = new System.Drawing.Point(324, 3);
            this.okButton.Name = "okButton";
            this.okButton.Size = new System.Drawing.Size(75, 23);
            this.okButton.TabIndex = 5;
            this.okButton.Text = "OK";
            this.okButton.UseVisualStyleBackColor = true;
            this.okButton.Click += new System.EventHandler(this.okButton_Click);
            // 
            // EditForm
            // 
            this.AcceptButton = this.okButton;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.CancelButton = this.cancelButton;
            this.ClientSize = new System.Drawing.Size(483, 301);
            this.Controls.Add(this.splitContainer1);
            this.Name = "EditForm";
            this.Text = "EditForm";
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.ResumeLayout(false);
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            this.flowLayoutPanel2.ResumeLayout(false);
            this.flowLayoutPanel2.PerformLayout();
            this.flowLayoutPanel1.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.SplitContainer splitContainer1;
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
        private System.Windows.Forms.TextBox spawnIndicatorsTextBox;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
        private System.Windows.Forms.Button cancelButton;
        private System.Windows.Forms.Button okButton;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox deathIndicatorsTextBox;
        private System.Windows.Forms.TextBox neigbourhoodDistanceTextBox;
        private System.Windows.Forms.TextBox maximumAgeTextBox;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox lifeFormIdentifierTextBox;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
        private System.Windows.Forms.Label maxNeighboursMessage;
    }
}

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

Comments and Discussions