Example #1
0
        private void refreshList()
        {
            DateTime searchTime = new DateTime(dateTimePicker.Value.Year, dateTimePicker.Value.Month, dateTimePicker.Value.Day,
                                               23, 59, 59).ToUniversalTime();
            LunarPhase lp = new LunarPhase(searchTime);             //dateTimePicker.Value);

            listView.Items.Clear();
            int cp = lp.PhaseNum(searchTime);             //dateTimePicker.Value);

            while (cp == -1)
            {
                lp = new LunarPhase(searchTime.AddDays(-1));  //.AddDays(28));//dateTimePicker.Value.AddDays(28));
                cp = lp.PhaseNum(searchTime);                 //dateTimePicker.Value);
                //	if (cp == -1)
                //		cp = 0;
            }
            for (int i = 0; i < 8; i++)
            {
                string[]     s   = { conf.GetString(LunarPhase.PhaseName[i]), lp.PhaseTimes[i].ToLocalTime().ToString("ddd") + " " + lp.PhaseTimes[i].ToLocalTime().ToShortDateString() + " " + conf.FormatTime(lp.PhaseTimes[i].ToLocalTime()) };
                ListViewItem lsi = new ListViewItem(s);
                if (cp == i)
                {
                    lsi.Font = new Font(listView.Font, FontStyle.Bold);
                }
                listView.Items.Add(lsi);
            }
        }
Example #2
0
        /// <summary>
        /// Update the tray icon
        /// </summary>
        private void updateTray()
        {
            if (conf.Caption == Config.CaptionType.LunarPhase && localPhases == null)
            {
                localPhases  = new LunarPhase(DateTime.UtcNow);
                currentPhase = localPhases.CurrentPhase(DateTime.UtcNow);
            }

            if (currentHour == (PlanetaryHours.Planet)(-1))
            {
                pHours      = new PlanetaryHours(conf);
                currentHour = pHours.CurrentHour();
            }

            if (currentHour == (PlanetaryHours.Planet)(-1))
            {
                trayIcon.Icon = new Icon(conf.Fx.ResourceStream("Exclamation.ico"));
                ErrorMessage("A serious internal error has occured; please report this error to the author of ChronosXP at " + Config.Email,
                             new Exception("ChronosXP.PlanetaryHours failed twice at " + DateTime.Now.ToString() + "; unable to determine planetary hour."),
                             conf);
            }
            else
            {
                try
                {
                    if (conf.Fx.IconSet.Equals("Silver") && pHours.CurrentHour() == PlanetaryHours.Planet.Saturn)
                    {
                        trayIcon.Icon = conf.Fx.GlyphIconSmall("Tray.Saturn");
                    }
                    else
                    {
                        trayIcon.Icon = conf.Fx.GlyphIconSmall(pHours.CurrentEnglishHour());
                    }
                    string stat;
                    switch (conf.Caption)
                    {
                    default:
                    case Config.CaptionType.HourNumber:
                        stat = pHours.HourOfDay(DateTime.Now);
                        break;

                    case Config.CaptionType.HouseOfMoment:
                        stat = pHours.HouseOfMoment(DateTime.Now);
                        break;

                    case Config.CaptionType.LunarPhase:
                        int i = localPhases.PhaseNum(DateTime.UtcNow);
                        if (i == -1)
                        {
                            i = 7;
                        }
                        stat = conf.GetString(LunarPhase.PhaseName[i]);
                        break;
                    }
                    string s = pHours.DayString() + "\r\n" + pHours.CurrentHourString() + "\r\n" + stat;
                    // Too bad we're limited to 64 chars, because this would be nice...
                    //string s = pHours.DayString() +  ", " + pHours.CurrentHourString() + "\r\n" +
                    //	pHours.HourOfDay(DateTime.Now) + ", " + pHours.HouseOfMoment(DateTime.Now) + "\r\n" +
                    //	localPhases.PhaseNum(DateTime.UtcNow);
                    if (s.Length >= 64)
                    {
                        s = s.Remove(60, s.Length - 60) + "...";
                    }
                    trayIcon.Text = s;
                }
                catch (Exception ex)
                {
                    trayIcon.Icon = new Icon(conf.Fx.ResourceStream("Exclamation.ico"));
                    ErrorMessage("Unable to set glyph icon.  [CurrentEnglishHour=" + pHours.CurrentEnglishHour() + "]", ex);
                }
            }
        }