示例#1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ran = new Random();
     subjectWithEvent = new CustomControlSubject();
     inst_1           = new CustomControlObserver(subjectWithEvent, btn1, ran);
     inst_2           = new CustomControlObserver(subjectWithEvent, btn1, ran);
 }
示例#2
0
 public CustomControlObserver(CustomControlSubject subject, Button btn, Random ran)
 {
     this.ran     = ran;
     code         = ran.Next(100);
     this.subject = subject;
     this.btn     = btn;
     CustomControlSubject.ControlEventHandler handler = new CustomControlSubject.ControlEventHandler(CustomHandlerMethod);
     subject.CustomEvent += handler;
 }