Beispiel #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // Fallback to ICS if there's no apiKey
                ReaderType readerTypeToCreate = (!String.IsNullOrEmpty(m_apiKey)) ? ReaderType.GoogleApi : ReaderType.GoogleIcs;

                // Get reader and init
                m_planReader = new ReaderFactory().CreateReader(m_calendarId, readerTypeToCreate);
                if (m_planReader is GoogleApiReader)
                {
                    ((GoogleApiReader)m_planReader).ApiKey = m_apiKey;
                }

                bool r = m_planReader.Init().Result;
                Init();

                // load event async (not waiting time for gui)
                new Thread(new ThreadStart(LoadEvents)).Start();

                m_checkDateTimeForNotify = new System.Threading.Timer(CheckDateTimeForNotify, null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
            }
            catch (Exception ex)
            {
                if (Event_OnError != null)
                {
                    Event_OnError.Invoke(this, new OnErrorEventArgs(ex));
                }
            }
            bigForm = new BigPlanForm(this);
            this.Hide();
            activeForm = bigForm;
            bigForm.ShowDialog();
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        private void CheckDateTimeForNotify(object sender)
        {
            if (m_events != null)
            {
                try
                {
                    foreach (RbtvEvent currentEvent in m_events)
                    {
                        // just events which where never pushed to tooltip/tray icon
                        if (!currentEvent.WasPushedToTrayIcon)
                        {
                            // 5 minutes before the show, trigger notify
                            if (DateTime.Now >= currentEvent.Start.AddMinutes(0) && DateTime.Now <= currentEvent.Start)
                            {
                                if (this.WindowState == FormWindowState.Minimized)
                                {
                                    // notifyicon should be already there (see MainForm_Resize)
                                    NotifyIcon.BalloonTipTitle = "[RBTV] Sendeplan";
                                    NotifyIcon.BalloonTipText  = currentEvent.Name.Trim() + " | " + currentEvent.Start.ToString("HH:mm") + " - " + currentEvent.End.ToString("HH:mm") + " | " + currentEvent.EventType.ToString().ToUpper();
                                    NotifyIcon.ShowBalloonTip(1500);

                                    currentEvent.WasPushedToTrayIcon = true;
                                    currentEvent.LastTrayIconNotify  = DateTime.Now;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (Event_OnError != null)
                    {
                        Event_OnError.Invoke(this, new OnErrorEventArgs(ex));
                    }
                }
            }


            bool r = m_planReader.Init().Result;

            Init();

            // load event async (not waiting time for gui)
            new Thread(new ThreadStart(LoadEvents)).Start();

            //notificator.ShowMbNotification();
        }
Beispiel #3
0
 private void LoadEvents()
 {
     try
     {
         m_events = m_planReader.FetchEvents();
         SortEvents(m_events);
         if (Event_OnEventsLoaded != null)
         {
             Event_OnEventsLoaded.Invoke(this, null);
         }
     }
     catch (Exception ex)
     {
         if (Event_OnError != null)
         {
             Event_OnError.Invoke(this, new OnErrorEventArgs(ex));
         }
     }
 }