static void Main(string[] args) { Console.WriteLine("OBSERVER DESIGN PATTERN\n"); Console.WriteLine("----------"); IObserver headerstyle = new HeaderColor(); IObserver footerstyle = new FooterColor(); ColorSubject colorNotifier = new ColorSubject(); colorNotifier.Register(headerstyle); colorNotifier.Register(footerstyle); colorNotifier.Color = "red"; Console.WriteLine("----------"); colorNotifier.Color = "yellow"; }
private void SetCommonProperties(Form form) { form.Left = nextLeft; form.Top = nextTop; form.StartPosition = FormStartPosition.Manual; (form as IObserver).ColorChanged(_subject.Color); form.Show(); _subject.Register(form as IObserver); nextTop += form.Height; }