Exemplo n.º 1
0
        public GReminder()
        {
            InitializeComponent();

            SetUserCredentials();
            Schedule.Current.Load();
            Selected = null;
            Schedule.Current.GventChanged += (sender, e) =>
            {
                if (e.Changes == GventChanges.Status)
                {
                    StatusAlert(e.Gvent);
                }
            };
            if (Schedule.Current.Count == 0)
            {
                HandleTrayCalendars(null, null);
            }
            UpdateStatus();
            StartCalendarRefresher();
            ApplyRefreshTimerInterval();
            var timer = new System.Windows.Forms.Timer();

            timer.Interval = 1;
            timer.Tick    += new EventHandler(Tray);
            timer.Start();
        }
Exemplo n.º 2
0
        private void DisplayEventDetails(Gvent gvent)
        {
            reminderFormTableLayoutPanel.SuspendLayout();

            if (gvent != null)
            {
                // Title
                eventWhat.Text = gvent.Title;

                DateTime start = gvent.Start;
                DateTime stop  = gvent.Stop;
                string   when;

                // Time
                if (start.Date == stop.AddSeconds(-1).Date)
                {
                    if (start.Hour == 0 && start.Minute == 0 && stop.Hour == 0 && stop.Minute == 0)
                    {
                        when = "{0:ddd}, {0:m}";
                    }
                    else
                    {
                        when = "{0:ddd}, {0:m} {0:t} - {1:t}";
                    }
                }
                else
                {
                    if (start.Hour == 0 && start.Minute == 0 && stop.Hour == 0 && stop.Minute == 0)
                    {
                        when = "{0:ddd}, {0:m} - {1:ddd}, {1:m}";
                    }
                    else
                    {
                        when = "{0:ddd}, {0:m} {0:t} - {1:ddd}, {1:m} {1:t}";
                    }
                }

                when = String.Format(when, start, stop);
                when = String.Format("{0}  ({1})", when, gvent.LengthString);

                eventWhen.Text = when;

                // Location
                eventWhere.Text = gvent.Location;
            }
            else
            {
                eventWhat.Text  = null;
                eventWhen.Text  = "No event selected";
                eventWhere.Text = null;
            }

            reminderFormTableLayoutPanel.ResumeLayout();
        }
Exemplo n.º 3
0
        private void StatusAlert(Gvent gvent)
        {
            try
            {
                switch (gvent.Status)
                {
                case GventStatus.Soon:
                    if (Properties.Settings.Default.SoonPopup)
                    {
                        Hidden = false;
                    }
                    if (Properties.Settings.Default.SoonSound)
                    {
                        Sound.MakeSound(Properties.Settings.Default.SoundPath);
                    }
                    if (Properties.Settings.Default.SoonVerbal)
                    {
                        Sound.Speak(gvent);
                    }
                    return;

                case GventStatus.Now:
                    if (Properties.Settings.Default.NowPopup)
                    {
                        Hidden = false;
                    }
                    if (Properties.Settings.Default.NowSound)
                    {
                        Sound.MakeSound(Properties.Settings.Default.SoundPath);
                    }
                    if (Properties.Settings.Default.NowVerbal)
                    {
                        Sound.Speak(gvent);
                    }
                    return;

                case GventStatus.Past:
                    if (Properties.Settings.Default.PastDismiss)
                    {
                        gvent.Dismiss();
                    }
                    return;
                }
            }
            catch (Exception e)
            {
                //Swallow exception to avoid any issues painting, etc
            }
        }
Exemplo n.º 4
0
        private void StatusAlert(Gvent gvent)
        {
            switch (gvent.Status)
            {
            case GventStatus.Soon:
                if (Properties.Settings.Default.SoonPopup)
                {
                    Hidden = false;
                }
                if (Properties.Settings.Default.SoonSound)
                {
                    Sound.MakeSound(Properties.Settings.Default.SoundPath);
                }
                if (Properties.Settings.Default.SoonVerbal)
                {
                    Sound.Speak(gvent);
                }
                return;

            case GventStatus.Now:
                if (Properties.Settings.Default.NowPopup)
                {
                    Hidden = false;
                }
                if (Properties.Settings.Default.NowSound)
                {
                    Sound.MakeSound(Properties.Settings.Default.SoundPath);
                }
                if (Properties.Settings.Default.NowVerbal)
                {
                    Sound.Speak(gvent);
                }
                return;

            case GventStatus.Past:
                if (Properties.Settings.Default.PastDismiss)
                {
                    gvent.Dismiss();
                }
                return;
            }
        }
Exemplo n.º 5
0
        private static void SpeakThread(Gvent gvent)
        {
            StringBuilder spoken = new StringBuilder(gvent.Title);
            DateTime      Now    = DateTime.Now;
            TimeSpan      timespan;
            Boolean       postfix = true;

            if (gvent.Start > Now)
            {
                timespan = gvent.Start - Now;
                if (timespan.Days != 0 || timespan.Hours != 0 || timespan.Minutes != 0)
                {
                    spoken.Append(" starts in ");
                }
                else
                {
                    postfix = false;
                    spoken.Append(" starts soon!");
                }
            }
            else
            {
                timespan = DateTime.Now - gvent.Start;
                if (timespan.Days != 0 || timespan.Hours != 0 || timespan.Minutes != 0)
                {
                    spoken.Append(" started ");
                }
                else
                {
                    postfix = false;
                    spoken.Append(" starts now!");
                }
            }

            if (timespan.Days > 0)
            {
                if (gvent.Start > Now)
                {
                    timespan = gvent.Start.Date - Now.Date;
                }
                else
                {
                    timespan = Now.Date - gvent.Start.Date;
                }

                spoken.Append(timespan.Days);
                if (timespan.Days == 1)
                {
                    spoken.Append(" day");
                }
                else
                {
                    spoken.Append(" days");
                }
            }
            else
            {
                if (timespan.Seconds > 30)
                {
                    timespan = new TimeSpan(0, timespan.Hours, timespan.Minutes + 1, 0);
                }
                if ((timespan.Minutes % 60 != 0) && (timespan.Hours >= 6))
                {
                    timespan = new TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes + (90 - timespan.Minutes) % 60 - 30, 0);
                }
                if ((timespan.Minutes % 15 != 0) && (timespan.Hours > 0))
                {
                    timespan = new TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes + (67 - timespan.Minutes) % 15 - 7, 0);
                }
                if ((timespan.Minutes % 5 != 0) && (timespan.Minutes > 10 || timespan.Hours > 0))
                {
                    timespan = new TimeSpan(timespan.Days, timespan.Hours, timespan.Minutes + (62 - timespan.Minutes) % 5 - 2, 0);
                }

                if (timespan.Days == 1)
                {
                    spoken.Append("1 day");
                }
                if (timespan.Hours > 0)
                {
                    spoken.Append(timespan.Hours);
                    if (timespan.Hours == 1)
                    {
                        spoken.Append(" hour");
                    }
                    else
                    {
                        spoken.Append(" hours");
                    }
                }
                if (timespan.Minutes > 0)
                {
                    if (timespan.Hours > 0)
                    {
                        spoken.Append(", ");
                    }
                    spoken.Append(timespan.Minutes);
                    if (timespan.Minutes == 1)
                    {
                        spoken.Append(" minute");
                    }
                    else
                    {
                        spoken.Append(" minutes");
                    }
                }
            }

            if (postfix)
            {
                if (gvent.Start > Now)
                {
                    spoken.Append('!');
                }
                else
                {
                    spoken.Append(" ago!");
                }
            }

            lock (voice)
            {
                voice.Speak(spoken.ToString());
            }
        }
Exemplo n.º 6
0
        public static void Speak(Gvent gvent)
        {
            WaitCallback callback = delegate(object o) { SpeakThread((Gvent)o); };

            ThreadPool.QueueUserWorkItem(callback, gvent);
        }
Exemplo n.º 7
0
 private void HandleAgendaSelectionChanged(object sender, EventArgs e)
 {
     Selected = agenda.Selected;
 }
Exemplo n.º 8
0
 public GventEventArgs(Gvent gvent, GventChanges changes)
 {
     Gvent   = gvent;
     Changes = changes;
 }