/// <summary> /// multithreading method to login google account /// </summary> /// <returns>true if successful</returns> public bool GoogleLogin() { RemoveTemp(); if (ChangingUser.Username == null) { throw new InvalidOperationException("This operation is without UserName not supported"); } //login GUtil.GLogin(ChangingUser, "temp"); WasGLogin = true; //multithreading change of CalendarsBox var calendars = GUtil.GetCalendars(ChangingUser, tempDir); Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Items.Clear())); foreach (var calendar in calendars) { Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Items.Add(calendar))); } Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.SelectedIndex = -1)); Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Text = "(select)")); Form.EmailLabel.Invoke(new Action(() => Form.EmailLabel.Text = GetGoogleEmail())); return(true); }
/// <summary> /// Load calendars to CalendarsBox /// </summary> public void LoadCalendars() { var calendars = GUtil.GetCalendars(ChangingUser); foreach (var calendar in calendars) { Form.CalendarsBox.Items.Add(calendar); } var actualCalendar = calendars.Where(c => c.ID == ChangingUser.googleCalendarId); if ((actualCalendar.ToList().Count) == 1) { Form.CalendarsBox.SelectedItem = actualCalendar.First(); } }
/// <summary> /// Return true if Google login was successful /// </summary> /// <returns></returns> public bool GoogleLogin() { if (NewUser.Username == null) { throw new InvalidOperationException("This operation is without UserName not supported"); } GUtil.GLogin(NewUser); WasGLogin = true; // multithreaded add calendars to CalendarsBox var calendars = GUtil.GetCalendars(NewUser); Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Items.Clear())); foreach (var calendar in calendars) { Form.CalendarsBox.Invoke(new Action(() => Form.CalendarsBox.Items.Add(calendar))); } return(true); }