Example #1
0
        public void ShowGetTweetDialog()
        {
            int    count;
            string screenName;

            var settings = new MetroDialogSettings()
            {
                AnimateHide = true,
                AnimateShow = true
            };

            var dlg = new GetTweetDialog();

            dlg.OKButton.Click += async(s, e) =>
            {
                count      = Convert.ToInt32(dlg.CountBox.Value);
                screenName = dlg.ScreenNameBox.Text;

                if (!string.IsNullOrWhiteSpace(screenName))
                {
                    dynamic json = await twitterAuth.GetJson($"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name={screenName}&count={count}", "GET");

                    if (json == null)
                    {
                        return;
                    }

                    collection.Clear();
                    RetweetCountBlock.Text     = "Unselected";
                    TweetListView.SelectedItem = null;
                    foreach (var obj in json)
                    {
                        Tweet t = new Tweet(obj);
                        collection.Add(t);
                    }
                    if (TweetListView.Items.Count > 0)
                    {
                        TweetListView.ScrollIntoView(TweetListView.Items[0]);
                    }
                }

                await this.HideMetroDialogAsync(dlg, settings);
            };
            dlg.CancelButton.Click += (s, e) =>
            {
                this.HideMetroDialogAsync(dlg, settings);
            };

            DialogManager.ShowMetroDialogAsync(this, dlg, settings);
        }
 public void EmptyData()
 {
     Cursor = null;
     TweetCollection.Clear();
 }