예제 #1
0
 private void changeModeBtn_Click(object sender, EventArgs e)
 {
     if (mode == ClockMode.Digital) //to analog mode
     {
         clock = new AnologTimeDecorator();
         mode  = ClockMode.Analog;
         changeModeBtn.Text = "Digital";
     }
     else // to digital mode
     {
         clock = new DigitalTimeDecorator();
         mode  = ClockMode.Digital;
         changeModeBtn.Text = "Analog";
     }
     Draw();
 }
예제 #2
0
        public ClockForm()
        {
            InitializeComponent();
            watch = new Watch();
            clock = new DigitalTimeDecorator();
            clock.SetWatch(watch);
            graphics           = pictureBox.CreateGraphics();
            changeModeBtn.Text = "Analog";

            timer           = new System.Timers.Timer();
            timer.Interval  = 1000;
            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Start();
        }