Exemplo n.º 1
0
        public void OnDirectMessageUpdate(object sender, PropertyChangedEventArgs e)
        {
            var dm  = kbtter.LatestDirectMessage.DirectMessage;
            var dml = DirectMessages.FirstOrDefault(p => p.CheckUserPair(dm.Recipient.ScreenName, dm.Sender.ScreenName));

            if (dml == null)
            {
                var  nd = new DirectMessageViewModel(this, kbtter.AuthenticatedUser.ScreenName);
                User tus;
                if (dm.Recipient.Id == kbtter.AuthenticatedUser.Id)
                {
                    tus = dm.Sender;
                }
                else
                {
                    tus = dm.Recipient;
                }
                nd.TargetUserName       = tus.Name;
                nd.TargetUserScreenName = tus.ScreenName;
                nd.TargetUserImageUri   = tus.ProfileImageUrlHttps;
                DirectMessages.Add(nd);
                dml = nd;
            }
            dml.AddMessage(dm);
            RaisePropertyChanged("DirectMessage");
        }
Exemplo n.º 2
0
        public async void AddDirectMessageTarget()
        {
            try
            {
                var fs = await kbtter.Token.Friendships.ShowAsync(source_id => kbtter.AuthenticatedUser.ScreenName, target_screen_name => NewDirectMessageTargetScreenName);

                if (!fs.Target.CanDM ?? false)
                {
                    NotifyInformation("そのユーザーにはダイレクトメッセージを送れません");
                    return;
                }
                else
                {
                    var user = await kbtter.Token.Users.ShowAsync(screen_name => NewDirectMessageTargetScreenName);

                    var dmvm = new DirectMessageViewModel(this, kbtter.AuthenticatedUser.ScreenName);
                    dmvm.TargetUserName       = user.Name;
                    dmvm.TargetUserScreenName = user.ScreenName;
                    dmvm.TargetUserImageUri   = user.ProfileImageUrlHttps;
                    DirectMessages.Add(dmvm);
                }
            }
            catch (TwitterException e)
            {
                NotifyInformation(string.Format("ユーザー情報の取得に失敗しました : {0}", e.Message));
            }
            catch
            { }
        }
Exemplo n.º 3
0
 /// <summary>
 /// ダイレクトメッセージをスタックに積む
 /// </summary>
 /// <param name="user">送ってきたユーザー</param>
 /// <param name="message">送られてきたダイレクトメッセージ</param>
 public static void StackMention(User user, CoreTweet.DirectMessage message)
 {
     if (DirectMessages == null)
     {
         DirectMessages = new ObservableCollection <DirectMessage>();
         BindingOperations.EnableCollectionSynchronization(DirectMessages, new object());
     }
     DirectMessages.Add(new DirectMessage()
     {
         User    = new UserOverviewProperties(user),
         Message = message
     });
 }