Esempio n. 1
0
        public void AddDefaultEvents()
        {
            //Could add interface to edit and persist in the future
            ep.Events.Add(new SunEvent
            {
                Name        = "Sleep 8 hours before sunrise (civil)",
                IsSunrise   = true,
                Offset      = new TimeSpan(-8, 0, 0),
                Command     = "psshutdown",
                CommandArgs = "-d -t 0",
                RetryPeriod = new TimeSpan(1, 0, 0),
                IsCivil     = true
            });

            //Test event to fire 5 seconds after start
            Twilight       c        = new Twilight();
            SunAndMoonData Tomorrow = c.GetData(DateTime.Now.Date, lat, lon, (DateTime.Now - DateTime.UtcNow).TotalHours);
            TimeSpan       OffsetForImmediateEvent = Tomorrow.CivalTwilightStart - DateTime.Now.AddSeconds(5);

            ep.Events.Add(new SunEvent
            {
                Name        = "Immediate Test event",
                IsSunrise   = true,
                Offset      = OffsetForImmediateEvent.Negate(),
                RetryPeriod = new TimeSpan(0, 1, 0),
                IsCivil     = true,
                Disabled    = false
            });
        }
Esempio n. 2
0
        public void UpdateSummary()
        {
            Twilight c = new Twilight();

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("Sunrise and Sunset Data\r\n");

            // Get back the data
            SunAndMoonData dataToday    = c.GetData(DateTime.Now.Date, lat, lon, (DateTime.Now - DateTime.UtcNow).TotalHours);
            SunAndMoonData dataTomorrow = c.GetData(DateTime.Now.AddDays(1).Date, lat, lon, (DateTime.Now.AddDays(1) - DateTime.UtcNow.AddDays(1)).TotalHours);

            sb.AppendFormat("Today\r\n");
            c.RenderData(0, dataToday, sb);

            sb.AppendFormat("Tomorrow\r\n");
            c.RenderData(0, dataTomorrow, sb);

            sb.Append(Environment.NewLine + "Next Event: " + (ep.NextEvent != null ? ep.NextEvent.ToString() : "None"));

            sb.Append(Environment.NewLine + Environment.NewLine + ep.ToString());

            MainTextBox.Text = sb.ToString();

            if (ep.NextEvent != null)
            {
                TrayIcon.Text = "Next Event: " + ep.NextEvent.Time();
            }
        }