Beispiel #1
0
        public Form1()
        {
            InitializeComponent();

            //Create subject
            slowWorker = new ProgressSubject();

            //Create observers
            new NumericUpDownObserver(slowWorker, numericUpDown);
            new ProgressBarObserver(slowWorker, probOutput);
            new TrackBarObserver(slowWorker, trackBar1);
        }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            progressSubject = new ProgressSubject();

            spinBoxHandler = new EventHandler(UpdateSpinBox);
            trackBarHandler = new EventHandler(UpdateTrackBar);
            progressBarHandler = new EventHandler(UpdateProgressBar);

            progressSubject.OnUpdateEvent += spinBoxHandler;
            progressSubject.OnUpdateEvent += progressBarHandler;
            progressSubject.OnUpdateEvent += trackBarHandler;
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            progressSubject = new ProgressSubject();

            spinBoxHandler     = new EventHandler(UpdateSpinBox);
            trackBarHandler    = new EventHandler(UpdateTrackBar);
            progressBarHandler = new EventHandler(UpdateProgressBar);

            progressSubject.OnUpdateEvent += spinBoxHandler;
            progressSubject.OnUpdateEvent += progressBarHandler;
            progressSubject.OnUpdateEvent += trackBarHandler;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="subject">Subject to observe</param>
        public ProgressObserverBase(ProgressSubject subject, object thingToUpdate)
        {
            //Keep reference to the subject
            this.subject = subject;
            //Keep reference to the object to update
            this.thingToUpdate = thingToUpdate;

            //Create a new handler
            EventHandler handler = new EventHandler(incrementDisplay);
            //Register handler with subject;
            subject.updateEvent+=handler;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="subject">Subject to observe</param>
 /// <param name="thingToUpdate">Object that is updated</param>
 public TrackBarObserver(ProgressSubject subject, object thingToUpdate)
     : base(subject, thingToUpdate)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="subject">Subject to observe</param>
 /// <param name="thingToUpdate">Object that is updated</param>
 public NumericUpDownObserver(ProgressSubject subject, object thingToUpdate)
     : base(subject,thingToUpdate)
 {
 }