Exemplo n.º 1
0
        public void RunClock()
        {
            Thread.Sleep(5000);
            while (true)
            {
                Thread.Sleep(100);
                DateTime currentTime = DateTime.Now;
                if (currentTime.Second != this.second)
                {
                    TimeEventsArgs timeEventsArgs = new TimeEventsArgs()
                    {
                        Year   = currentTime.Year,
                        Month  = currentTime.Month,
                        Day    = currentTime.Day,
                        Hour   = currentTime.Hour,
                        Second = currentTime.Second,
                        Minute = currentTime.Minute
                    };

                    if (TimeChanged == null)
                    {
                        TimeChanged(this, timeEventsArgs);
                    }
                    this.year   = currentTime.Year;
                    this.month  = currentTime.Month;
                    this.day    = currentTime.Day;
                    this.hour   = currentTime.Hour;
                    this.minute = currentTime.Minute;
                    this.second = currentTime.Second;
                }
            }
        }
Exemplo n.º 2
0
        private void NewTime(object sender, TimeEventsArgs e)
        {
            if (e.Hour > 11)
            {
                timeZone = "PM";
            }
            else
            {
                timeZone = "AM";
            }
            timeFormat_24h = e.Hour.ToString() + ":" + e.Minute.ToString();
            if (timeZone == "PM" && e.Hour != 12)
            {
                Decrese_by_12 = e.Hour - 12;
            }

            timeFormat_12h = Decrese_by_12.ToString() + ":" + e.Minute.ToString() + " " + timeZone;
        }
 private void NewCalendar(object sender, TimeEventsArgs e)
 {
     YearMontDayFormat = e.Month.ToString() + "/" + e.Day.ToString() +
                         "/" + e.Year.ToString();
 }