Exemplo n.º 1
0
        //sets subject, button, random object
        public Observer(SubjectWithEvent subject, String observerName, Button buttonToClick, Random random)
        {
            this.subject = subject;
            this.observerName = observerName;
            this.random = random;
            buttonString = buttonToClick.ToString();

            //adds delegate instance containing "DoStuff" to the buttons click event
            buttonToClick.Click += new System.EventHandler(DoStuff);
        }
Exemplo n.º 2
0
        //sets subject, button, random object
        public Observer(SubjectWithEvent subject, String observerName, Button buttonToClick, Random random)
        {
            this.subject      = subject;
            this.observerName = observerName;
            this.random       = random;
            buttonString      = buttonToClick.ToString();

            //adds delegate instance containing "DoStuff" to the buttons click event
            buttonToClick.Click += new System.EventHandler(DoStuff);
        }
Exemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            random = new Random();

            subjectWithEvent = new SubjectWithEvent();

            //creates observers (already bound to button.Click)
            observer1 = new Observer(subjectWithEvent, "One", buttonTestHandlers, random);
            observer2 = new Observer(subjectWithEvent, "Two", buttonTestHandlers, random);
        }
Exemplo n.º 4
0
        public Form1()
        {
            InitializeComponent();

            random = new Random();

            subjectWithEvent = new SubjectWithEvent();

            //creates observers (already bound to button.Click)
            observer1 = new Observer(subjectWithEvent, "One", buttonTestHandlers, random);
            observer2 = new Observer(subjectWithEvent, "Two", buttonTestHandlers, random);
        }