private void ButtonAuthenticate_Click(object sender, EventArgs e) { if (AuthTokenResponse == null) { AppendLineToOutput("Already authenticated. Check ratelimiting details."); return; } AuthTokenResponse = OAuthUtility.GetAccessToken(Settings.Default.ConsumerKey, Settings.Default.ConsumerSecret, AuthTokenResponse.Token, TextBoxInput.Text); var tokenResponse = AuthTokenResponse; Settings.Default.UserAccessToken = tokenResponse.Token; Settings.Default.UserAccessSecret = tokenResponse.TokenSecret; Settings.Default.Save(); Tokens.AccessToken = Settings.Default.UserAccessToken; Tokens.AccessTokenSecret = Settings.Default.UserAccessSecret; CommandManagement.Init(this, Tokens); AppendLineToOutput("Authentication succeeded."); }
private void ButtonGetFollowerList_Click(object sender, EventArgs e) { string[] screennames; if (TextBoxInput.Text.Trim().Length > 0) { RadioAirNZ.Checked = false; RadioJetStar.Checked = false; RadioQantas.Checked = false; RadioVirginAustralia.Checked = false; screennames = TextBoxInput.Lines; } else { screennames = new string[1]; screennames[0] = GetSelectedAccount(); if (screennames[0] == "") { AppendLineToOutput(string.Format("No user selected"), Color.Maroon); return; } } DisableFollowerControls(); CommandResult result = CommandResult.Failure; BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += delegate { AppendLineToOutput(string.Format("Starting task [{0}]", "Get Follower List"), Color.Maroon); AppendLineToOutput(string.Format("{0} users to be processed.", screennames.Length), Color.Maroon); try { result = CommandManagement.GetFollowerList(screennames); } catch (Exception ex) { AppendLineToOutput(ex.Message, Color.Maroon); AppendLineToOutput(ex.StackTrace, Color.Maroon); } }; bgw.RunWorkerCompleted += delegate { AppendLineToOutput(result, Color.Maroon); //AppendLineToOutput(string.Format("Completed task [{0}] for [@{1}]", "Get Follower List", screenname), Color.Maroon); AppendLineToOutput(string.Format("Completed task [{0}]", "Get Follower List"), Color.Maroon); EnableFollowerControls(); }; bgw.RunWorkerAsync(); }
private void ButtonLookUpUsers_Click(object sender, EventArgs e) { CommandResult result = CommandResult.Failure; DisableUserLookUpControls(); BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += delegate { AppendLineToOutput(string.Format("Starting task [{0}]", "Add Users by Id or Screenname"), Color.DarkGreen); object[] list = new object[0]; ListType listType = ListType.Unknown; if (RadioById.Checked) { listType = ListType.Ids; List <object> validIds = new List <object>(); decimal tmp = -1; foreach (var StringId in TextBoxInput.Lines) { decimal.TryParse(StringId, out tmp); if (tmp > 0) { validIds.Add(tmp); } } list = validIds.ToArray(); AppendLineToOutput(string.Format("{0} ids to be processed out of {1} lines given.", validIds.Count, list.Length), Color.DarkGreen); } else if (RadioByScreenname.Checked) { listType = ListType.Screennames; list = TextBoxInput.Lines; } result = CommandManagement.LookUpUsers(list, listType); }; bgw.RunWorkerCompleted += delegate { AppendLineToOutput(result, Color.DarkGreen); AppendLineToOutput(string.Format("Completed task [{0}]", "Add Users by Id"), Color.DarkGreen); EnableUserLookUpControls(); }; bgw.RunWorkerAsync(); }
private void ButtonCheckRateLimit_Click(object sender, EventArgs e) { try { var result = CommandManagement.ShowRateLimitDetails(); AppendLineToOutput(result, Color.Black); } catch (Exception ex) { AppendLineToOutput("Error : " + ex.Message); AppendLineToOutput(ex.StackTrace); } }
private void button3_Click(object sender, EventArgs e) { CommandResult result = CommandResult.Failure; DisableReplyControls(); BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += delegate { AppendLineToOutput(string.Format("Starting task [{0}]", "Get Tweets for InReplyToIds"), Color.DarkMagenta); decimal[] ids = new decimal[TextBoxInput.Lines.Length]; decimal tmp = -1; int i = 0; foreach (var StringId in TextBoxInput.Lines) { decimal.TryParse(StringId, out tmp); if (tmp > 0) { ids[i] = tmp; i++; } } AppendLineToOutput(string.Format("{0} ids to be processed out of {1} lines given.", i, ids.Length), Color.DarkMagenta); result = CommandManagement.GetRepliedToTweets(ids); }; bgw.RunWorkerCompleted += delegate { AppendLineToOutput(result, Color.Black); AppendLineToOutput(string.Format("Completed task [{0}]", "Get Tweets for InReplyToIds"), Color.DarkMagenta); EnableReplyControls(); }; bgw.RunWorkerAsync(); }
public FormMain() { InitializeComponent(); //this.Text = this.Text + System.IO.Path.g(Environment.CurrentDirectory); //this.Text += "::" + .GetFileName(GetDirectoryName(Application.ExecutablePath); this.toolStripMenuItemPath.Text = Path.GetDirectoryName(Application.ExecutablePath); this.Text += string.Format(":: (opened from {0})", Path.GetFileName(Path.GetDirectoryName(Application.ExecutablePath))); this.ContextMenuStrip = contextMenuStripMain; this.TextBoxInput.ContextMenuStrip = contextMenuInput; this.flowLayoutPanel1.ContextMenuStrip = contextMenuRadio; Tokens = new OAuthTokens { ConsumerKey = Settings.Default.ConsumerKey, ConsumerSecret = Settings.Default.ConsumerSecret }; if (!string.IsNullOrEmpty(Settings.Default.UserAccessToken) && !string.IsNullOrEmpty(Settings.Default.UserAccessSecret)) { Tokens.AccessToken = Settings.Default.UserAccessToken; Tokens.AccessTokenSecret = Settings.Default.UserAccessSecret; } else { AuthTokenResponse = OAuthUtility.GetRequestToken(Settings.Default.ConsumerKey, Settings.Default.ConsumerSecret, "oob"); TextBoxInput.Text = "Enter pin here. Make sure the pin is the only text in this textbox. Click Authenticate."; Process process = new Process(); process.StartInfo.FileName = getDefaultBrowser(); process.StartInfo.Arguments = "http://twitter.com/oauth/authorize?oauth_token=" + AuthTokenResponse.Token; process.Start(); } CommandManagement.Init(this, Tokens); }