private void Form1_Load(object sender, EventArgs e) { subjectWithEvent = new ProgressSubject(); TrackBar = new ProgressObserver(subjectWithEvent, null, trackBar1, null); ProgressBar = new ProgressObserver(subjectWithEvent, null, null, progressBar1); UpDown = new ProgressObserver(subjectWithEvent, numericUpDown1, null, null); }
public ProgressObserver(ProgressSubject subject, NumericUpDown updown, TrackBar bar, ProgressBar pbar) { this.updown = updown; this.bar = bar; this.pbar = pbar; this.subject = subject; ProgressSubject.ProgressEventHandler handler = new ProgressSubject.ProgressEventHandler(ProgressHandlerMethod); subject.progressEvent += handler; }