コード例 #1
0
ファイル: UserEditor.cs プロジェクト: kostejnv/TCGSync
        /// <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);
        }
コード例 #2
0
        /// <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);
        }