private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            List <JsFile> selectedJsFiles = new List <JsFile>();

            foreach (var group in jsFilesGroupList)
            {
                selectedJsFiles.AddRange(group.JsFiles.Where(jsFile => jsFile.Selected == true));
            }

            if (selectedJsFiles.Count == 0)
            {
                MessageBox.Show("Please select at least one month from the twitter archive",
                                "Twitter Archive Eraser", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            var settings = ApplicationSettings.GetApplicationSettings();

            settings.JsFiles = selectedJsFiles;

            DeleteTweets page = new DeleteTweets();

            this.Hide();
            page.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            page.ShowDialog();
            this.Show();
            //Application.Current.Shutdown();
        }
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            List <JsFile> selectedJsFiles = new List <JsFile>();

            foreach (var itemYear in yearsOfTweets)
            {
                selectedJsFiles.AddRange(itemYear.TweetJsFiles.Where(jsFile => jsFile.Selected == true));
            }

            if (selectedJsFiles.Count == 0)
            {
                MessageBox.Show("Please select at least one month from the twitter archive",
                                "Twitter Archive Eraser", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            var settings = ApplicationSettings.GetApplicationSettings();

            settings.JsFiles = selectedJsFiles;

            WebUtils.ReportMonthsToDelete(settings.Username,
                                          settings.SessionId.ToString(),
                                          selectedJsFiles.Select(jsFile => String.Format("{0}_{1}", jsFile.TweetYear, jsFile.TweetMonth)).ToList());

            DeleteTweets page = new DeleteTweets();

            this.Hide();
            page.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            page.ShowDialog();
            this.Show();
            //Application.Current.Shutdown();
        }
        void DeleteTweets_Loaded(object sender, RoutedEventArgs e)
        {
            this.Title = ApplicationSettings.GetApplicationSettings().GetApplicationTitle();

            // Show/Hide options depending on what the user wants to delete
            var settings = ApplicationSettings.GetApplicationSettings();

            switch (settings.EraseType)
            {
            case ApplicationSettings.EraseTypes.TweetsAndRetweets:
                chkSearchByUsername.Visibility = System.Windows.Visibility.Collapsed;
                break;

            case ApplicationSettings.EraseTypes.Favorites:
            case ApplicationSettings.EraseTypes.DirectMessages:
                chkShowRetweetOnly.Visibility = System.Windows.Visibility.Collapsed;
                btnBack.IsEnabled             = false;
                break;

            default:
                break;
            }

            startTime = DateTime.Now;
            new Thread(LoadTweetsFromJsFiles).Start();
            //Thread.CurrentThread.CurrentCulture = new CultureInfo("es-PE");

            // Hide DM sender/receiver column when deleting tweets/favorites
            var column = gridTweets.Columns.Where(c => c.FieldName == "Username").FirstOrDefault();

            if (column != null && TweetsEraseType == ApplicationSettings.EraseTypes.TweetsAndRetweets)
            {
                column.Visible = false;
            }
        }
Example #4
0
        void SendTweet_Loaded(object sender, RoutedEventArgs e)
        {
            var appSettings = ApplicationSettings.GetApplicationSettings();

            //this.Title += " v" + appSettings.Version;

            if (appSettings.NumTeetsDeleted < 10)
            {
                shouldExit = true;
                btnSendTweetInnerText.Text = "Exit!";
                btnSendTweet.ToolTip       = "Not enough tweets to share... :(";
            }

            int mins    = (int)appSettings.TotalRunningMillisec / 1000 / 60;
            int seconds = (int)(appSettings.TotalRunningMillisec - (mins * 60 * 1000)) / 1000;

            string type = appSettings.EraseType == ApplicationSettings.EraseTypes.TweetsAndRetweets ? "tweets" :
                          (appSettings.EraseType == ApplicationSettings.EraseTypes.Favorites ? "favorites" : "DMs");

            string totalTime = "";

            if (mins == 0)
            {
                totalTime = seconds + " seconds";
            }
            else
            {
                totalTime = mins + ":" + seconds + " min:sec";
            }

            txtTweetText.Text = String.Format("Just deleted {0} {1} using Twitter Archive Eraser by @martani_net (in {2}). Check it out here http://martani.github.io/Twitter-Archive-Eraser/",
                                              appSettings.NumTeetsDeleted,
                                              type,
                                              totalTime);
        }
        async void FetchTweets_Loaded(object sender, RoutedEventArgs e)
        {
            var settings = ApplicationSettings.GetApplicationSettings();

            twitterCtx      = settings.Context;
            TweetsEraseType = settings.EraseType;

            //this.Title += " v" + settings.Version;

            if (twitterCtx == null)
            {
                MessageBox.Show("Internal error: Twitter context is null", "Twitter Archive Eraser");
            }

            switch (TweetsEraseType)
            {
            case ApplicationSettings.EraseTypes.TweetsAndRetweets:
                throw new Exception("EraseTye should never be EraseTypes.TweetsAndRetweets here");
                break;

            case ApplicationSettings.EraseTypes.Favorites:
                var user =
                    await
                        (from tweet in twitterCtx.User
                        where tweet.Type == UserType.Show &&
                        tweet.UserID == settings.UserID
                        select tweet)
                    .SingleOrDefaultAsync();

                int totalFavCount = 0;
                if (user != null)
                {
                    totalFavCount = user.FavoritesCount;
                }

                lblTweetsType.Text    = "favorites";
                lblTweetsType2.Text   = "favorites";
                lblTweetsMax.Text     = "3000";
                lblTotalTweetsNB.Text = string.Format("(Your favorites count: {0})", totalFavCount);
                break;

            case ApplicationSettings.EraseTypes.DirectMessages:
                lblTweetsType.Text    = "direct messages";
                lblTweetsType2.Text   = "DMs";
                lblTweetsMax.Text     = "1000 (800 sent, 200 received)";
                lblTotalTweetsNB.Text = string.Format("(Your DM count: {0})", "N/A");

                imgTwitterAuth2.Source = new BitmapImage(new Uri(@"pack://application:,,,/Twitter Archive Eraser;component/dm-icon.png"));
                imgTwitterAuth2.Margin = new Thickness(5);

                break;

            default:
                break;
            }
            //int numFavs = twitterCtx.User.Where(user => user.UserID == settings.UserID).FirstOrDefault().FavoritesCount;
            //txtTotalTweetsNB.Text = string.Format("(Your favorites count: {0})", numFavs);
        }
Example #6
0
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            isQueryingTwitter  = false;
            btnFetch.IsEnabled = false;

            if (dmsTweetList.Count == 0 && favsTweetList.Count == 0)
            {
                MessageBox.Show("No tweets to delete! Please click start to fetch tweets.", "Twitter Archive Eraser");
                btnFetch.IsEnabled = true;
                return;
            }

            DeleteTweets page = new DeleteTweets();

            if (TweetsEraseType == ApplicationSettings.EraseTypes.Favorites)
            {
                page.SetTweetsList(favsTweetList.Select(t => new Tweet()
                {
                    ID       = t.StatusID.ToString(),
                    Username = "******" + t.User.Name,
                    Text     = t.Text,
                    ToErase  = true,
                    Type     = TweetType.Favorite,
                    Date     = DateTime.SpecifyKind(t.CreatedAt, DateTimeKind.Local)
                }));
            }

            if (TweetsEraseType == ApplicationSettings.EraseTypes.DirectMessages)
            {
                page.SetTweetsList(dmsTweetList.Select(t => new Tweet()
                {
                    ID       = t.IDResponse.ToString(),
                    Username = t.Type == DirectMessageType.SentBy ? "[To] @" + t.RecipientScreenName : "[From] @" + t.SenderScreenName,
                    Text     = t.Text,
                    ToErase  = true,
                    Type     = TweetType.DM,
                    Date     = DateTime.SpecifyKind(t.CreatedAt, DateTimeKind.Local)
                }));
            }

            // Free memory
            dmsTweetList.Clear();
            favsTweetList.Clear();
            dmsTweetList  = null;
            favsTweetList = null;

            page.areTweetsFetchedThroughAPI = true;

            this.Hide();
            page.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            ApplicationSettings.GetApplicationSettings().TotalRunningMillisec = stopWatch.ElapsedMilliseconds;

            stopWatch.Reset();

            page.ShowDialog();
            this.Show();
        }
Example #7
0
        private void btnRemoveDM_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            var settings = ApplicationSettings.GetApplicationSettings();

            settings.EraseType = ApplicationSettings.EraseTypes.DirectMessages;

            FetchTweets page = new FetchTweets();

            this.Hide();
            page.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            page.ShowDialog();
        }
Example #8
0
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            var settings = ApplicationSettings.GetApplicationSettings();

            settings.EraseType = ApplicationSettings.EraseTypes.TweetsAndRetweets;

            ArchiveFiles page = new ArchiveFiles();

            this.Hide();
            page.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            page.ShowDialog();
        }
Example #9
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);
        }
Example #10
0
        void SendTweet_Loaded(object sender, RoutedEventArgs e)
        {
            var appSettings = ApplicationSettings.GetApplicationSettings();

            this.Title = ApplicationSettings.GetApplicationSettings().GetApplicationTitle();

            if (appSettings.NumTeetsDeleted < 10)
            {
                shouldExit = true;
                btnSendTweetInnerText.Text = "Exit!";
                btnSendTweet.ToolTip       = "Not enough tweets to share... :(";
            }

            int mins    = (int)appSettings.TotalRunningMillisec / 1000 / 60;
            int seconds = (int)(appSettings.TotalRunningMillisec - (mins * 60 * 1000)) / 1000;

            string type = appSettings.EraseType == ApplicationSettings.EraseTypes.TweetsAndRetweets ? "tweets" :
                          (appSettings.EraseType == ApplicationSettings.EraseTypes.Favorites ? "favorites" : "DMs");

            string totalTime = "";

            if (mins == 0)
            {
                totalTime = seconds + " seconds";
            }
            else
            {
                totalTime = mins + ":" + seconds + " min:sec";
            }

            txtTweetText.Text = String.Format("Just deleted {0} {1} using Twitter Archive Eraser (in {2}). Check it out here https://github.com/Z1488/Twitter-Archive-Eraser",
                                              appSettings.NumTeetsDeleted,
                                              type,
                                              totalTime);

            FocusManager.SetFocusedElement(txtTweetTextParent, txtTweetText);
        }
Example #11
0
        private void btnSendTweet_Click(object sender, RoutedEventArgs e)
        {
            if (!shouldExit)
            {
                btnSendTweet.IsEnabled = false;
                TwitterContext ctx = ApplicationSettings.GetApplicationSettings().Context;

                Status tweet = null;

                try
                {
                    tweet = ctx.TweetAsync(txtTweetText.Text).Result;
                }
                catch (Exception)
                {
                };

                if (tweet != null)
                {
                    txtTweetUpdateStatus.Text = "Sent ...";
                    Thread.Sleep(1000);
                    DialogResult = true;
                    this.Close();
                }
                else
                {
                    txtTweetUpdateStatus.Text = "Failed to send tweet, please try again";
                    btnSendTweet.IsEnabled    = true;
                }
            }
            else
            {
                DialogResult = true;
                this.Close();
            }
        }
 void ArchiveFiles_Loaded(object sender, RoutedEventArgs e)
 {
     this.Title = ApplicationSettings.GetApplicationSettings().GetApplicationTitle();
 }
Example #13
0
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     this.Title += " v" + ApplicationSettings.GetApplicationSettings().Version;
 }
 void PinWindow_Loaded(object sender, RoutedEventArgs e)
 {
     this.Title = ApplicationSettings.GetApplicationSettings().GetApplicationTitle();
 }
 public Information()
 {
     InitializeComponent();
     this.Title = ApplicationSettings.GetApplicationSettings().GetApplicationTitle();
 }