/// <summary>
 /// Adapts the clock from analog to digital
 /// </summary>
 /// <param name="analogClock">Analog clock</param>
 public AnalogClockToDigitalAdapter(AnalogClock analogClock)
 {
     _analogClock = analogClock;
     Hour         = (int)Math.Truncate(analogClock.ClockwiseAngle / 30.0);
     Minute       = (int)Math.Truncate(analogClock.MinuteHandAngle / 6.0);
     Second       = (int)Math.Truncate(analogClock.SecondHandAngle / 6.0);
 }
Beispiel #2
0
 // Обработка такта таймера
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (аналоговыеToolStripMenuItem.Checked)
     {
         A = new AnalogClock(секундыToolStripMenuItem.Checked, Col); //Инициализация аналоговых часов
         pictureBox1.Refresh();                                      //Очистка поля для рисования
         A.ShowTime(pictureBox1.CreateGraphics());                   //Отрисовка стрелок на поле для рисования
     }
     else
     {
         D = new DigitClock(датаToolStripMenuItem.Checked);          // Инициализация цифровых часов
         D.ShowTime(pictureBox1.CreateGraphics());
         label1.ForeColor = label2.ForeColor = Col1;
         label1.Text      = D.Time; // Вывод времени
         if (датаToolStripMenuItem.Checked)
         {
             int width = label2.Width;
             label2.Visible = true;
             label2.Text    = D.Date; // Вывод даты
             // Настройка размеров формы и положение надписей
             Height = 110 + 2 * label1.Height;
             if (width <= 200)
             {
                 Width           = 250;
                 label2.Location = new Point((int)((Width - width) / 2) - 5, 60 + label1.Height);
                 width           = label1.Width;
                 label1.Location = new Point((int)((Width - width) / 2) - 5, 40);
             }
             else
             {
                 Width           = width + 50;
                 label2.Location = new Point((int)((Width - width) / 2) - 5, 60 + label1.Height);
                 width           = label1.Width;
                 label1.Location = new Point((int)((Width - width) / 2) - 5, 40);
             }
         }
         else
         {
             // Настройка размеров формы и положение надписей
             int width = label1.Width;
             if (width <= 200)
             {
                 Width           = 250;
                 label1.Location = new Point((int)((Width - width) / 2) - 5, 40);
             }
             else
             {
                 Width           = width + 50;
                 label1.Location = new Point((int)((Width - width) / 2) - 5, 40);
             }
             Height = 90 + label1.Height;
         }
     }
 }
Beispiel #3
0
        public Form1()
        {
            InitializeComponent();

            try
            {
                log.Info("Elements initialization was started.");

                graphics = clockPanel.CreateGraphics();

                rectangle         = clockPanel.DisplayRectangle;
                hrHand            = rectangle.Height / 4;
                secHand           = hrHand * 1.5;
                minHand           = hrHand * 1.3;
                center            = new Point(clockPanel.Width / 2, clockPanel.Height / 2);
                secondBox.Enabled = false;
                minuteBox.Enabled = false;
                hourBox.Enabled   = false;

                digitalClock = new DigitalClock();
                clockAdapter = new ClockAdapter(digitalClock);
                analogClock  = new AnalogClock();
                log.Info("The Clocks have been initialized successfuly.");

                Paint         += new PaintEventHandler(DrawClock);
                timer          = new Timer();
                timer.Interval = 1000;
                timer.Tick    += new EventHandler(TimerTick);
                timer.Start();

                log.Info("Elements initialization was finished successfuly.");
            }
            catch (ArgumentNullException ex)
            {
                log.Error(ex.Message);
                log.Error(ex.StackTrace);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                log.Error(ex.StackTrace);
            }
        }
Beispiel #4
0
 public Analogue(AnalogClock analogClock)
 {
     this.analogClock = analogClock;
 }
Beispiel #5
0
 public Choser(AnalogClock alc)
 {
     clock = new Analogue(alc);
 }
Beispiel #6
0
 /*
  * The AnalogClockclass Constructer takes a AnalogClock and saves it as a datafield.
  */
 public AnalogClockclass(AnalogClock clock)
 {
     Clock = clock;
 }