Exemplo n.º 1
0
        private async void btnAuthorize_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            chkAcceptToShare.IsEnabled = false;
            btnAuthorize.IsEnabled     = false;

            var auth = PerformAuthorization();

            try
            {
                await auth.AuthorizeAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show("\n\nPlease make sure that:"
                                + "\n\t- your computer's date/time is accurate;"
                                + "\n\t- you entered the exact PIN returned by Twitter."
                                + "\n\n\nTwitter error message: " + ex.Message,
                                "Twitter Archive Eraser");

                btnAuthorize.IsEnabled = true;
                return;
            }

            if (auth == null)
            {
                return;
            }

            var settings = ApplicationSettings.GetApplicationSettings();

            settings.Context   = new TwitterContext(auth);
            settings.Username  = auth.CredentialStore.ScreenName;
            settings.UserID    = auth.CredentialStore.UserID;
            settings.SessionId = Guid.NewGuid();

            userName.Text          = "@" + settings.Username;
            btnAuthorize.IsEnabled = false;

            WebUtils.ReportNewUser(settings.Username, settings.SessionId.ToString());

            stackWelcome.Opacity    = 0.0;
            stackWelcome.Visibility = System.Windows.Visibility.Visible;
            FadeAnimation(stackAuthorize, 1.0, 0.0, 200);
            FadeAnimation(stackWelcome, 0.0, 1.0, 2000);
        }
        private async void btnAuthorize_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            chkAcceptToShare.IsEnabled = false;

            var auth = PerformAuthorization();

            try
            {
                await auth.AuthorizeAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show("\n\nPlease make sure that:"
                                + "\n\t- your computer's date/time is accurate;"
                                + "\n\t- you entered the exact PIN returned by Twitter."
                                + "\n\n\nTwitter error message: " + ex.Message,
                                "Twitter Archive Eraser");

                return;
            }


            if (auth == null)
            {
                return;
            }

            var ctx        = new TwitterContext(auth);
            var screenName = auth.CredentialStore.ScreenName;

            Application.Current.Properties["context"]     = ctx;
            Application.Current.Properties["userName"]    = screenName;
            Application.Current.Properties["sessionGUID"] = Guid.NewGuid().ToString();

            userName.Text           = "@" + screenName;
            stackWelcome.Visibility = System.Windows.Visibility.Visible;
            btnAuthorize.IsEnabled  = false;

            WebUtils.ReportNewUser(screenName, (string)Application.Current.Properties["sessionGUID"]);
        }
        private void btnAuthorize_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            chkAcceptToShare.IsEnabled = false;

            ITwitterAuthorizer auth = PerformAuthorization();

            if (auth == null)
            {
                return;
            }

            var ctx = new TwitterContext(auth);

            Application.Current.Properties["context"]     = ctx;
            Application.Current.Properties["userName"]    = ctx.UserName;
            Application.Current.Properties["sessionGUID"] = Guid.NewGuid().ToString();

            userName.Text           = "@" + ctx.UserName;
            stackWelcome.Visibility = System.Windows.Visibility.Visible;
            btnAuthorize.IsEnabled  = false;

            WebUtils.ReportNewUser(ctx.UserName, (string)Application.Current.Properties["sessionGUID"]);
        }