示例#1
0
        private void OpenInputBox(object sender, RoutedEventArgs e)
        {
            TransitionDisplay.SetState(TweetBox, TransitionState.Active);

            if (InReplyTo != null)
            {
                ReplyToName.Text = InReplyTo.User.ScreenName;
            }

            TweetInput.Text           = " " + Keywords.Text + " #wenku10";
            TweetInput.SelectionStart = 0;
            TweetInput.Focus(FocusState.Keyboard);

            UpdateCharLeft();

            MajorControls = InputControls;
            ControlChanged?.Invoke(this);
        }
示例#2
0
        private async void Submit()
        {
            string TweetContent = TweetInput.Text.Replace("\r\n", "\n").Trim();

            if (TweetLimit < TweetContent.Length)
            {
                return;
            }

            if (!SubmitBtn.IsEnabled)
            {
                return;
            }
            SubmitBtn.IsEnabled = false;

            if (!(TweetContent.Contains("#wenku10") && TweetContent.Contains(Keywords.Text)))
            {
                bool            Continue = false;
                StringResources stx      = StringResources.Load("Message");
                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            string.Format(stx.Str("Desc_OSTweet"), Keywords.Text, "#wenku10")
                                            , stx.Str("OSTweet")
                                            , () => Continue = true
                                            , stx.Str("Yes"), stx.Str("No")
                                            ));

                if (!Continue)
                {
                    string ScopeText = "";

                    if (!TweetContent.Contains(Keywords.Text))
                    {
                        ScopeText += Keywords.Text + " ";
                    }
                    if (!TweetContent.Contains("#wenku10"))
                    {
                        ScopeText += "#wenku10 ";
                    }

                    TweetInput.Text            = TweetContent + " " + ScopeText;
                    TweetInput.SelectionStart  = TweetContent.Length;
                    TweetInput.SelectionLength = ScopeText.Length;

                    TweetInput.Focus(FocusState.Keyboard);

                    UpdateCharLeft();

                    SubmitBtn.IsEnabled = true;
                    return;
                }
            }

            try
            {
                TweetInput.IsEnabled = false;
                if (InReplyTo == null)
                {
                    await TwitterService.Instance.TweetStatusAsync(TweetContent);
                }
                else
                {
                    await TSExtended.Instance.ReplyStatusAsync(TweetContent, InReplyTo.Id);
                }

                InsertFakeTweet(TweetContent);

                TweetInput.Text     = "";
                SubmitBtn.IsEnabled = true;

                CloseInputBox();
            }
            catch (TwitterException ex)
            {
                var j = Popups.ShowDialog(UIAliases.CreateDialog(ex.Message));
            }

            TweetInput.IsEnabled = true;
        }