Click here to Skip to main content
15,889,096 members
Articles / Programming Languages / C# 4.0

Propagator in C# - An Alternative to the Observer Design Pattern

Rate me:
Please Sign up or sign in to vote.
4.94/5 (19 votes)
13 Jul 2009CPOL9 min read 55.8K   368   53  
Re-usable implementation of the Propagator Design Pattern in C#, a potentially more powerful alternative to the well-known Observer Design Pattern.
namespace PropagatorDemo
{
    partial class DemoForm
    {
        /// <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.buttonReset = new System.Windows.Forms.Button();
            this.labelExample = new System.Windows.Forms.Label();
            this.colorControl = new PropagatorDemo.ColorControl();
            this.fontControl = new PropagatorDemo.FontControl();
            this.SuspendLayout();
            // 
            // buttonReset
            // 
            this.buttonReset.Location = new System.Drawing.Point(12, 9);
            this.buttonReset.Name = "buttonReset";
            this.buttonReset.Size = new System.Drawing.Size(88, 32);
            this.buttonReset.TabIndex = 3;
            this.buttonReset.Text = "Reset";
            this.buttonReset.UseVisualStyleBackColor = true;
            this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click);
            // 
            // labelExample
            // 
            this.labelExample.AutoSize = true;
            this.labelExample.Location = new System.Drawing.Point(115, 19);
            this.labelExample.Name = "labelExample";
            this.labelExample.Size = new System.Drawing.Size(94, 13);
            this.labelExample.TabIndex = 4;
            this.labelExample.Text = "This is an example";
            // 
            // colorControl
            // 
            this.colorControl.Location = new System.Drawing.Point(296, 48);
            this.colorControl.Name = "colorControl";
            this.colorControl.Size = new System.Drawing.Size(287, 175);
            this.colorControl.TabIndex = 2;
            // 
            // fontControl
            // 
            this.fontControl.AutoSize = true;
            this.fontControl.Location = new System.Drawing.Point(3, 48);
            this.fontControl.Name = "fontControl";
            this.fontControl.Size = new System.Drawing.Size(287, 175);
            this.fontControl.TabIndex = 0;
            // 
            // DemoForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(586, 225);
            this.Controls.Add(this.labelExample);
            this.Controls.Add(this.buttonReset);
            this.Controls.Add(this.colorControl);
            this.Controls.Add(this.fontControl);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Name = "DemoForm";
            this.Text = "Propagator Demo";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private FontControl fontControl;
        private ColorControl colorControl;
        private System.Windows.Forms.Button buttonReset;
        private System.Windows.Forms.Label labelExample;
    }
}

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
Software Developer (Senior) Phi International
Canada Canada
Grew up in Amsterdam, now living in downtown Vancouver. There are definitely more mountains here.

My first internship was with the first company in the Netherlands to teach C++ (www.datasim.nl). During this internship I got to know Object Oriented Design, which kept my interest until this day. In the mean time, I have worked for different companies in the Netherlands and Canada. I have done most of my recent work in C#, developing Database/Web/Desktop applications.

I am currently working as a freelance Software Developer for PHI International in Amsterdam.

The CodeProject rocks!

Comments and Discussions