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(); }
public IPlanReader CreateReader(String calendarId, ReaderType readerTypeToCreate) { IPlanReader planReader = null; switch (readerTypeToCreate) { case ReaderType.GoogleApi: planReader = new GoogleApiReader(calendarId); break; case ReaderType.GoogleIcs: planReader = new GoogleIcsReader(calendarId); break; } return(planReader); }