Ejemplo n.º 1
0
        public CtlClock()
        {
            InitializeComponent();

            mode       = ClockMode.Analog;
            timeOffset = 0;

            watch          = new WatchPatterns.Watch(timeOffset);
            watchDecorator = new WatchPatterns.DigitalTimeDecorator();
            watchDecorator.SetWatch(watch);

            timer           = new System.Timers.Timer();
            timer.Interval  = 1000;
            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Start();
        }
Ejemplo n.º 2
0
        private void Draw(Graphics graphics)
        {
            if (!isDrawing) // if isDrawing==false // если не рисуется, то можно рисовать
            {
                isDrawing = true;

                if (mode.Equals(ClockMode.Analog))
                {
                    watchDecorator = new WatchPatterns.AnologTimeDecorator();
                }
                else
                {
                    watchDecorator = new WatchPatterns.DigitalTimeDecorator();
                }

                watchDecorator.SetWatch(watch);
                graphics.Clear(Color.White);
                watchDecorator.Draw(this.Size, graphics);

                isDrawing = false;
            }
        }