Beispiel #1
0
        /// <summary>
        /// Invoked when a Noc notifies the Main form of an expired token.
        /// </summary>
        private void TokenExpiredWhileSaving()
        {
            Trace.WriteLine(DateTime.Now + " - Token expired: Reauthenticating with Google");
            Status(StatusType.Authorize, "Token expired: Reauthenticating with Google..");

            // disable menu options for changing the Google Account, for browsing Google Docs
            // and for saving while items are being retrieved
            menuGoogleAccount.Enabled = false;
            menuBrowse.Enabled        = false;
            menuSave.Enabled          = false;

            // run the backgroundworker for starting the service
            BgWorkerStartService.RunWorkerAsync(true);
        }
Beispiel #2
0
        private void MainFormLoad(object sender, EventArgs e)
        {
            // set window location, window size, editor's font, editor's word wrap setting,
            // encryption key, AutoSave and window's "always on top" option based on user settings

            if (Settings.Default.WindowLocation.X != 0 || Settings.Default.WindowLocation.Y != 0)
            {
                Location = Settings.Default.WindowLocation;
            }

            if (Location.X < 0 || Location.Y < 0)
            {
                Trace.WriteLine(string.Format("{0} - Location out of bounds: X: {1} - Y: {2}",
                                              DateTime.Now, Location.X, Location.Y));
                CenterToScreen();
                Settings.Default.WindowLocation = new Point(0, 0);
            }
            Size = Settings.Default.WindowSize;


            menuWordWrap.Checked = Settings.Default.WordWrap;
            TopMost = Settings.Default.AlwaysOnTop;
            menuAlwaysOnTop.Checked = Settings.Default.AlwaysOnTop;

            // ------------------------------------------------------------------------------------------------------

            // if Google login info hasn't been saved, let's show the Login form
            if (string.IsNullOrEmpty(Settings.Default.GoogleUsername) || string.IsNullOrEmpty(Settings.Default.GooglePassword))
            {
                var nocsLogin = new Login();
                nocsLogin.ShowDialog();

                // make sure user was validated
                if (!string.IsNullOrEmpty(NocsService.Username) && !string.IsNullOrEmpty(NocsService.Password))
                {
                    RetrieveDocuments();

                    // reset help variable
                    NocsService.AccountChanged = false;
                }
            }

            // if user has already used the application with proper Google credentials, we'll start the Google DocumentsList service
            else
            {
                // copy the account info from settings to NocsService
                NocsService.Username = Settings.Default.GoogleUsername;
                NocsService.Password = Tools.Decrypt(Settings.Default.GooglePassword);

                // if Google login info hasn't been saved, let's show the Login form
                if (string.IsNullOrEmpty(NocsService.Password))
                {
                    var nocsLogin = new Login();
                    nocsLogin.ShowDialog();

                    // make sure user was validated
                    if (!string.IsNullOrEmpty(NocsService.Username) && !string.IsNullOrEmpty(NocsService.Password))
                    {
                        RetrieveDocuments();

                        // reset help variable
                        NocsService.AccountChanged = false;
                    }
                }
                else
                {
                    // inform user that we are starting the service
                    Status(StatusType.Authorize, "Authenticating with Google..");

                    // disable menu options for changing the Google Account, for browsing Google Docs
                    // and for saving while items are being retrieved
                    menuGoogleAccount.Enabled = false;
                    menuBrowse.Enabled        = false;
                    menuSave.Enabled          = false;

                    // run the backgroundworker for starting the service
                    BgWorkerStartService.RunWorkerAsync(false);
                }
            }
        }