예제 #1
0
 public void ResetNewTweet(bool bNotify = true)
 {
     this.imageUploadsFailed = false;
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)true), (object)ViewModelMessages.EnableReplyOptions);
     this.StatusLabelVisibility = Visibility.Collapsed;
     this.StatusText = "";
     this.ReplyToID = new Decimal(0);
     this.UserName = "";
     if (bNotify)
         this.ActualTweetText = "";
     this.newTweetType = TwitViewModel.NewTweetType.Normal;
     this.StatusType = -1;
     this.Status = (MetroTwitStatusBase)null;
     if (!bNotify)
         return;
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText));
 }
예제 #2
0
 private void TweetTextCounter()
 {
     int count = 0;
     int num1 = 0;
     int num2 = this.actualtweetText.EndsWith(Environment.NewLine) ? Environment.NewLine.Length : 0;
     Match match1 = TwitViewModel.DM_EXPRESSION.Match(this.actualtweetText);
     if (match1.Success)
     {
         if (this.newTweetType != TwitViewModel.NewTweetType.DirectMessage)
         {
             System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => this.ResetNewTweet(false)));
             this.newTweetType = TwitViewModel.NewTweetType.DirectMessage;
             this.DMCheckUserFollow(this.actualtweetText.Split(new char[1]
   {
     ' '
   })[1]);
             count = this.actualtweetText.Replace(match1.Groups[0].Value, "").TrimStart(new char[0]).Length;
         }
         else
         {
             MatchCollection matchCollection = RegularExpressions.VALID_URL.Matches(this.actualtweetText);
             if (matchCollection.Count > 0)
             {
                 foreach (Match match2 in matchCollection)
                 {
                     num2 += match2.Groups[3].Length;
                     num1 += match2.Groups[4].Value == "https://" ? SettingsData.Instance.TwitterShortEncryptedUrlLength : SettingsData.Instance.TwitterShortUrlLength;
                 }
             }
             count = Enumerable.Count<char>((IEnumerable<char>)this.actualtweetText) - match1.Groups[0].Length - num2 + num1;
         }
     }
     else
     {
         if (this.newTweetType == TwitViewModel.NewTweetType.DirectMessage)
         {
             System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => this.ResetNewTweet(false)));
         }
         else
         {
             MatchCollection matchCollection = RegularExpressions.VALID_URL.Matches(this.actualtweetText);
             if (matchCollection.Count > 0)
             {
                 foreach (Match match2 in matchCollection)
                 {
                     num2 += match2.Groups[3].Length;
                     num1 += match2.Groups[4].Value == "https://" ? SettingsData.Instance.TwitterShortEncryptedUrlLength : SettingsData.Instance.TwitterShortUrlLength;
                 }
             }
         }
         count = Enumerable.Count<char>((IEnumerable<char>)this.actualtweetText) - num2 + num1;
     }
     if (this.CurrentlySelectedImage != null)
         count += SettingsData.Instance.TwitterShortUrlLength;
     string countText = (SettingsData.Instance.TweetCharLimit - count).ToString();
     bool postEnabled = (count <= SettingsData.Instance.TweetCharLimit || Enumerable.Count<ITweetService>(Enumerable.Where<ITweetService>((IEnumerable<ITweetService>)CoreServices.Instance.TweetServices, (Func<ITweetService, bool>)(x => x.OverrideTweetCharLimit))) != 0) && (count != 0 && this.StatusType != 0);
     Visibility countVisible = count == 0 ? Visibility.Collapsed : Visibility.Visible;
     bool countOver = count > SettingsData.Instance.TweetCharLimit;
     System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
     {
         this.CharCount = count;
         this.CharCountText = countText;
         this.PostTweetEnabled = postEnabled;
         this.CharCountVisibility = countVisible;
         this.CharCountOver = countOver;
     }));
     if (this.newTweetType != TwitViewModel.NewTweetType.Reply || (this.Status == null || this.ActualTweetText.IndexOf("@" + this.Status.User.ScreenName) >= 0))
         return;
     this.ReplyToID = new Decimal(0);
     this.newTweetType = TwitViewModel.NewTweetType.Normal;
     this.Status = (MetroTwitStatusBase)null;
 }
예제 #3
0
 public void UndoTweet(UndoTweetState state, bool undoLastTweetTriggered = false)
 {
     ProgressPromptViewModel progressPromptViewModel = new ProgressPromptViewModel
     {
         ErrorMessage = "The DeLorean is not working! Please try again.",
         ProgressText = "back to the future!...",
         Title = "undoing the tweet"
     };
     string errorTitle = "tweet could not be undone";
     Action<RequestResult> UndoCallback = result => System.Windows.Application.Current.Dispatcher.Invoke(delegate
     {
         if (result == RequestResult.Success)
         {
             this.ActualTweetText = state.LastTweetText;
             this.UserName = state.UserName;
             this.newTweetType = state.TweetType;
             this.ReplyToID = state.ReplyToID;
             Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>(string.Empty), this.MultiAccountifyToken(ViewModelMessages.NewTweetEditUpdateText));
             Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>(null), ViewModelMessages.UndoTweetClose);
         }
         else
         {
             progressPromptViewModel.Title = errorTitle;
             progressPromptViewModel.ShowAnimation = false;
             progressPromptViewModel.ShowErrorMessage = true;
             if (undoLastTweetTriggered)
             {
                 this.lastTweet = null;
             }
         }
     });
     Messenger.Default.Send<DialogMessage>(new DialogMessage(string.Empty, delegate(MessageBoxResult answer)
     {
         if (answer == MessageBoxResult.Yes)
         {
             Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>(progressPromptViewModel), DialogType.UndoTweet);
             if ((state.TweetType == NewTweetType.Normal) || (state.TweetType == NewTweetType.Reply))
             {
                 CommonCommands.DeleteTweet(state.Id, this.TwitterAccountID, UndoCallback, true);
             }
             else if (state.TweetType == NewTweetType.DirectMessage)
             {
                 CommonCommands.DeleteDirectMessage(state.Id, this.TwitterAccountID, UndoCallback, true);
             }
         }
     }), DialogType.UndoTweetConfirmation);
 }
예제 #4
0
 private void DirectMessage(GenericMessage<object> o)
 {
     if (this.sendingTweetInProgress)
         return;
     string str = string.Empty;
     string screenName = !(o.Content is string) ? (o.Content as MetroTwitStatusBase).User.ScreenName : o.Content.ToString();
     this.ResetNewTweet(true);
     this.UserName = screenName;
     this.newTweetType = TwitViewModel.NewTweetType.DirectMessage;
     this.ActualTweetText = "d " + this.UserName + " ";
     App.AppState.SwitchToAccount(this.TwitterAccountID);
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText));
     this.DMCheckUserFollow(screenName);
     this.StatusLabelVisibility = Visibility.Visible;
     base.RaisePropertyChanged("SingleImageTypeEnabled");
 }
예제 #5
0
 private void ReplyAll(GenericMessage<object> o)
 {
     if (this.sendingTweetInProgress)
         return;
     if (this.Status == null)
     {
         this.Status = o.Content as MetroTwitStatusBase;
         this.ReplyToID = this.Status.ID;
         this.UserName = this.Status.User.ScreenName;
         this.newTweetType = TwitViewModel.NewTweetType.Reply;
     }
     string str = o.Content as MetroTwitStatusBase == this.Status ? this.SetupReplyAll(this.Status, this.UserName, this.Status.IsRetweet ? this.Status.RetweetUser.ScreenName : string.Empty) : this.SetupReplyAll(o.Content as MetroTwitStatusBase, (o.Content as MetroTwitStatusBase).User.ScreenName, (o.Content as MetroTwitStatusBase).IsRetweet ? (o.Content as MetroTwitStatusBase).RetweetUser.ScreenName : string.Empty);
     App.AppState.SwitchToAccount(this.TwitterAccountID);
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText));
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)str), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.SelectTweetText));
 }
예제 #6
0
 private void Reply(GenericMessage<object> o)
 {
     if (this.sendingTweetInProgress)
         return;
     if (this.Status == null)
     {
         this.Status = o.Content as MetroTwitStatusBase;
         this.ReplyToID = this.Status.ID;
         this.UserName = this.Status.User.ScreenName;
         this.newTweetType = TwitViewModel.NewTweetType.Reply;
     }
     App.AppState.SwitchToAccount(this.TwitterAccountID);
     if (this.ActualTweetText.IndexOf("@" + this.UserName) < 0)
     {
         this.ActualTweetText = string.Format("{0}{1}@{2} ", (object)this.ActualTweetText.Trim(), this.ActualTweetText == string.Empty ? (object)"" : (object)" ", (object)this.UserName);
         Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText));
     }
     else
         Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)null), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditFocus));
 }
예제 #7
0
 private void Retweet(GenericMessage<object> o)
 {
     if (this.sendingTweetInProgress)
         return;
     this.ResetNewTweet(true);
     this.newTweetType = TwitViewModel.NewTweetType.Retweet;
     this.Status = o.Content as MetroTwitStatusBase;
     this.ActualTweetText = "RT @{1} {2}".Replace("{1}", (o.Content as MetroTwitStatusBase).User.ScreenName).Replace("{2}", WebUtility.HtmlDecode((o.Content as MetroTwitStatusBase).Text));
     Messenger.Default.Send<GenericMessage<object>>(new GenericMessage<object>((object)string.Empty), (object)this.MultiAccountifyToken((System.Enum)ViewModelMessages.NewTweetEditUpdateText));
     App.AppState.SwitchToAccount(this.TwitterAccountID);
 }