public void init() { service.ListDirectMessagesReceived(30, (tweets, response) => { if (response.StatusCode == HttpStatusCode.OK) { foreach (var tweet in tweets) { if (tweet.Author.ScreenName == sender_id) { sender_int_id = tweet.SenderId; Tweet tv = new Tweet(); tv.id = tweet.Id; tv.name = tweet.Author.ScreenName; tv.thumb_img = tweet.Author.ProfileImageUrl; tv.text = tweet.Text; tv.dtime = tweet.CreatedDate; lists.Add(tv); } } } Dispatcher.BeginInvoke(delegate() { send_load(); }); }); }
private void appbar_button1_Click(object sender, EventArgs e) { listdata.Visibility = Visibility.Collapsed; listdata2.Visibility = Visibility.Collapsed; listdata3.Visibility = Visibility.Collapsed; listdata4.Visibility = Visibility.Collapsed; loadtext.Visibility = Visibility.Visible; pgbar.Visibility = Visibility.Visible; var item = (PivotItem)title.SelectedItem; string header = (string)item.Header; service = new TwitterService("g8F2KdKH40gGp9BXemw13Q", "OyFRFsI05agcJtURtLv8lpYbYRwZAIL5gr5xQNPW0Q"); service.AuthenticateWith((string)settings["twitter_token"], (string)settings["twitter_tokensecret"]); if (header == "recent") { service.ListTweetsOnFriendsTimeline(0, 40, (tweets, response) => { if (response.StatusCode == HttpStatusCode.OK) { DateTime ti = DateTime.Now; DateTime now = ti.ToUniversalTime(); lists = new List<Tweet>(); foreach (var tweet in tweets) { Tweet tv = new Tweet(); TimeSpan tsp = now - tweet.CreatedDate; tv.id = tweet.Id; tv.name = tweet.User.ScreenName; tv.thumb_img = tweet.User.ProfileImageUrl; tv.text = tweet.Text + "\n"; if (tsp.Days > 0) tv.time = tsp.Days + "일 전"; else if (tsp.Hours > 0) tv.time = tsp.Hours + "시간 전"; else tv.time = tsp.Minutes + "분 전"; lists.Add(tv); } Dispatcher.BeginInvoke(delegate() { if (lists.Count > 0) { loadtext.Visibility = Visibility.Collapsed; pgbar.Visibility = Visibility.Collapsed; listdata.ItemsSource = lists; listdata.Visibility = Visibility.Visible; } else { pgbar.Visibility = Visibility.Collapsed; loadtext.Text = "No items"; } }); } }); } else if (header == "replies") { service.ListTweetsMentioningMe(0, 40, (tweets, response) => { if (response.StatusCode == HttpStatusCode.OK) { DateTime ti = DateTime.Now; DateTime now = ti.ToUniversalTime(); lists = new List<Tweet>(); foreach (var tweet in tweets) { Tweet tv = new Tweet(); TimeSpan tsp = now - tweet.CreatedDate; tv.id = tweet.Id; tv.name = tweet.User.ScreenName; tv.thumb_img = tweet.User.ProfileImageUrl; tv.text = tweet.Text + "\n"; if (tsp.Days > 0) tv.time = tsp.Days + "일 전"; else if (tsp.Hours > 0) tv.time = tsp.Hours + "시간 전"; else tv.time = tsp.Minutes + "분 전"; lists.Add(tv); } Dispatcher.BeginInvoke(delegate() { if (lists.Count > 0) { loadtext.Visibility = Visibility.Collapsed; pgbar.Visibility = Visibility.Collapsed; listdata2.ItemsSource = lists; listdata2.Visibility = Visibility.Visible; } else { pgbar.Visibility = Visibility.Collapsed; loadtext.Text = "No items"; } }); } }); } else if (header == "messages") { service.ListDirectMessagesReceived(40, (tweets, response) => { if (response.StatusCode == HttpStatusCode.OK) { DateTime ti = DateTime.Now; DateTime now = ti.ToUniversalTime(); lists = new List<Tweet>(); foreach (var tweet in tweets) { Tweet tv = new Tweet(); TimeSpan tsp = now - tweet.CreatedDate; tv.id = tweet.Id; tv.name = tweet.Sender.ScreenName; tv.thumb_img = tweet.Sender.ProfileImageUrl; tv.text = tweet.Text + "\n"; if (tsp.Days > 0) tv.time = tsp.Days + "일 전"; else if (tsp.Hours > 0) tv.time = tsp.Hours + "시간 전"; else tv.time = tsp.Minutes + "분 전"; lists.Add(tv); } Dispatcher.BeginInvoke(delegate() { if (lists.Count > 0) { loadtext.Visibility = Visibility.Collapsed; pgbar.Visibility = Visibility.Collapsed; listdata3.ItemsSource = lists; listdata3.Visibility = Visibility.Visible; } else { pgbar.Visibility = Visibility.Collapsed; loadtext.Text = "No items"; } }); } }); } else if (header == "my") { service.ListTweetsOnUserTimeline(0, 40, (tweets, response) => { if (response.StatusCode == HttpStatusCode.OK) { DateTime ti = DateTime.Now; DateTime now = ti.ToUniversalTime(); lists = new List<Tweet>(); foreach (var tweet in tweets) { Tweet tv = new Tweet(); TimeSpan tsp = now - tweet.CreatedDate; tv.id = tweet.Id; tv.name = tweet.User.ScreenName; tv.thumb_img = tweet.User.ProfileImageUrl; tv.text = tweet.Text + "\n"; if (tsp.Days > 0) tv.time = tsp.Days + "일 전"; else if (tsp.Hours > 0) tv.time = tsp.Hours + "시간 전"; else tv.time = tsp.Minutes + "분 전"; lists.Add(tv); } Dispatcher.BeginInvoke(delegate() { if (lists.Count > 0) { loadtext.Visibility = Visibility.Collapsed; pgbar.Visibility = Visibility.Collapsed; listdata4.ItemsSource = lists; listdata4.Visibility = Visibility.Visible; } else { pgbar.Visibility = Visibility.Collapsed; loadtext.Text = "No items"; } }); } }); } }