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(); }
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(); }