Пример #1
0
        private async void SetContext()
        {
            await AuthData.Authenticate();

            CurrentUser = await TwitterService.Instance.GetUserAsync();

            TagsAvailable.Add(new NameValue <bool>("wenku10", true));

            if (!string.IsNullOrEmpty(ThisBook.Title))
            {
                TagsAvailable.AddRange(ThisBook.Title.ToHashTags().Remap(x => new NameValue <bool>(x, false)));
            }

            if (!string.IsNullOrEmpty(ThisBook.Info.Press))
            {
                TagsAvailable.AddRange(ThisBook.Info.Press.ToHashTags().Remap(x => new NameValue <bool>(x, false)));
            }

            if (!string.IsNullOrEmpty(ThisBook.Info.Author))
            {
                TagsAvailable.AddRange(ThisBook.Info.Author.ToHashTags().Remap(x => new NameValue <bool>(x, false)));
            }

            Keywords.Text        = ThisBook.Title.TrimForSearch();
            HashTags.ItemsSource = TagsAvailable;

            ReloadTweets();
        }
Пример #2
0
        private async void ReloadTweets()
        {
            await AuthData.Authenticate();

            TwitterLoader Loader = new TwitterLoader();

            Loader.Keyword = ThisBook.Title.TrimForSearch();
            Loader.Tags    = TagsAvailable;

            LoadingRing.IsActive = true;

            Observables <Tweet, Tweet> Tweets = new Observables <Tweet, Tweet>(await Loader.NextPage(20));

            Tweets.ConnectLoader(Loader);

            Tweets.LoadStart += (s, e) => { LoadingRing.IsActive = true; };
            Tweets.LoadEnd   += (s, e) => { LoadingRing.IsActive = false; };

            LoadingRing.IsActive = false;

            TweetsView.ItemsSource = Tweets;
        }
Пример #3
0
        private async void AddTweet_Click(object sender, RoutedEventArgs e)
        {
            Button Btn = ( Button )sender;

            Btn.IsEnabled = false;

            if (!await AuthData.Authenticate())
            {
                goto TweetEnd;
            }

            string          TweetText = "";
            StringResources stx       = StringResources.Load("Error", "AppResources");

TweetStart:

            ValueHelpInput TweetInput = new ValueHelpInput("", "wenku10 ♥", stx.Text("Tweetwenku10", "AppResources"));

            TweetInput.Value = TweetText;

            await Popups.ShowDialog(TweetInput);

            if (TweetInput.Canceled)
            {
                goto TweetEnd;
            }

            TweetText = TweetInput.Value.Trim();
            if (string.IsNullOrEmpty(TweetText))
            {
                goto TweetEnd;
            }

            if (131 < TweetText.Length)
            {
                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            stx.Str("TweetTooLong") + string.Format(" ( {0} < {1} )", 131, TweetText.Length)
                                            ));

                goto TweetStart;
            }

            if (await TwitterService.Instance.TweetStatusAsync(TweetText + " #wenku10"))
            {
                Observables <Tweet, Tweet> Tweets = (Observables <Tweet, Tweet>)TweetsView.ItemsSource;
                Tweets.Insert(0, new Tweet()
                {
                    Text        = TweetText
                    , User      = await TwitterService.Instance.GetUserAsync()
                    , CreatedAt = DateTime.Now.ToString("ddd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture)
                });
            }
            else
            {
                await Popups.ShowDialog(UIAliases.CreateDialog(stx.Str("SubmitError")));

                goto TweetStart;
            }

TweetEnd:
            Btn.IsEnabled = true;
        }