Exemplo n.º 1
0
 public DirectMessageViewModel(DirectMessage dm, MainWindowViewModel main)
 {
     Kbtter = Kbtter.Instance;
     this.main = main;
     Source = dm;
     Text = Source.Text;
     CreatedAt = Source.CreatedAt.LocalDateTime.ToString();
     Sender = new UserViewModel(dm.Sender, main);
     IsSentByMe = dm.Sender.Id == Kbtter.Instance.AuthenticatedUser.Id;
     AnalyzeTextElements();
 }
 public DirectMessageTimelineViewModel(MainWindowViewModel main, DirectMessageTimeline dtl)
 {
     DirectMessages = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         dtl.DirectMessages,
         (p) =>
         {
             if (!IsSelected) UnreadCount++;
             return new DirectMessageViewModel(p, main);
         },
         DispatcherHelper.UIDispatcher);
     Party = new UserViewModel(dtl.Party, main);
 }
Exemplo n.º 3
0
 public StatusViewModel(MainWindowViewModel mw, Status st, bool isinc)
 {
     Kbtter = Kbtter.Instance;
     AdditionalMenus = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         Kbtter.StatusMenus,
         p => new StatusAdditionalMenuViewModel(p, st),
         DispatcherHelper.UIDispatcher);
     main = mw;
     SourceStatus = st;
     OnelineText = st.Text;
     User = new UserViewModel(st.User, mw);
 }
Exemplo n.º 4
0
 public NotificationViewModel(Kbtter4Notification nt, MainWindowViewModel mw)
 {
     var ins = Kbtter.Instance;
     switch (nt.Kind)
     {
         case Kbtter4NotificationKind.Favorited:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("ツイートが{0}さんのお気に入りに登録されました", SourceUser.Name);
             IconKind = Kbtter4NotificationIconKind.Favorited;
             Description = nt.SourceEvent.TargetStatus.Text;
             break;
         case Kbtter4NotificationKind.Unfavorited:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("ツイートが{0}さんのお気に入りから削除されました", SourceUser.Name);
             IconKind = Kbtter4NotificationIconKind.Unfavorited;
             Description = nt.SourceEvent.TargetStatus.Text;
             break;
         case Kbtter4NotificationKind.Followed:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("{0}さんにフォローされました", SourceUser.Name);
             IconKind = Kbtter4NotificationIconKind.Followed;
             Description = nt.SourceEvent.Source.Description;
             break;
         case Kbtter4NotificationKind.Unfollowed:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("{0}さんにリムーブされました", SourceUser.Name);
             IconKind = Kbtter4NotificationIconKind.Unfollowed;
             Description = nt.SourceEvent.Source.Description;
             break;
         case Kbtter4NotificationKind.Retweeted:
             SourceUser = new UserViewModel(nt.SourceStatus.Status.User, mw);
             if (nt.SourceStatus.Status.Text.Contains(ins.AuthenticatedUser.ScreenName) &&
                 nt.SourceStatus.Status.RetweetedStatus.User.Id != ins.AuthenticatedUser.Id)
             {
                 Message = string.Format("リツイートが{0}さんにリツイートされました", SourceUser.Name);
             }
             else
             {
                 Message = string.Format("ツイートが{0}さんにリツイートされました", SourceUser.Name);
             }
             IconKind = Kbtter4NotificationIconKind.Retweeted;
             Description = nt.SourceStatus.Status.RetweetedStatus.Text;
             break;
         case Kbtter4NotificationKind.ListAdded:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("{0}さんのリスト {1} に登録されました", SourceUser.Name, nt.SourceEvent.TargetList.Name);
             IconKind = Kbtter4NotificationIconKind.ListAdded;
             Description = nt.SourceEvent.TargetList.Description;
             break;
         case Kbtter4NotificationKind.ListRemoved:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("{0}さんのリスト {1} から外されました", SourceUser.Name, nt.SourceEvent.TargetList.Name);
             IconKind = Kbtter4NotificationIconKind.ListRemoved;
             Description = nt.SourceEvent.TargetList.Description;
             break;
         case Kbtter4NotificationKind.Blocked:
             SourceUser = new UserViewModel(nt.SourceEvent.Source, mw);
             Message = string.Format("{0}さんにブロックされました", SourceUser.Name);
             IconKind = Kbtter4NotificationIconKind.Blocked;
             Description = nt.SourceEvent.Source.Description;
             break;
     }
 }
Exemplo n.º 5
0
        public StatusViewModel(MainWindowViewModel mw, Status st)
        {
            Kbtter = Kbtter.Instance;
            main = mw;
            AdditionalMenus = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.StatusMenus,
                p => new StatusAdditionalMenuViewModel(p, st),
                DispatcherHelper.UIDispatcher);
            RegisterEventListeners();

            SourceStatus = st;
            ReceivedStatus = SourceStatus;
            if (SourceStatus.RetweetedStatus != null)
            {
                SourceStatus = SourceStatus.RetweetedStatus;
                IsRetweet = true;
                RetweetingUser = new UserViewModel(ReceivedStatus.User, main);
            }

            _IsFavorited = Kbtter.CheckFavorited(SourceStatus.Id);
            RaisePropertyChanged(() => IsFavorited);

            _IsRetweeted = Kbtter.CheckRetweeted(SourceStatus.Id);
            RaisePropertyChanged(() => IsRetweeted);

            _CreatedTimeText = SourceStatus.CreatedAt.LocalDateTime;
            RaisePropertyChanged(() => CreatedTimeText);

            User = new UserViewModel(SourceStatus.User, main);

            Text = SourceStatus.Text;

            OnelineText = Text
                .Replace("\r", " ")
                .Replace("\n", " ");

            FavoriteCount = SourceStatus.FavoriteCount ?? 0;
            RetweetCount = SourceStatus.RetweetCount ?? 0;

            IsMyStatus = SourceStatus.User.Id == Kbtter.AuthenticatedUser.Id;
            IsRetweetable = !IsMyStatus && !SourceStatus.User.IsProtected;

            if (SourceStatus.Entities.UserMentions != null)
            {
                IsReplyToMe = SourceStatus.Entities.UserMentions.Any(p => p.Id == Kbtter.AuthenticatedUser.Id);
            }
            ExtractVia();
            AnalyzeTextElements();

            DispatcherHelper.UIDispatcher.BeginInvoke((Action)(() =>
            {
                if (SourceStatus.Entities != null)
                {
                    Medias = new ObservableSynchronizedCollection<StatusMediaViewModel>();
                    if (SourceStatus.Entities.Urls != null)
                    {
                        var r = Kbtter4ExtraMediaUriConverter.TryGetDirectUri(SourceStatus.Entities.Urls.Select(p => p.ExpandedUrl));
                        foreach (var i in r) Medias.Add(new StatusMediaViewModel { Uri = i });
                    }
                    if (SourceStatus.Entities.Media != null)
                    {
                        foreach (var i in SourceStatus.Entities.Media)
                        {
                            Medias.Add(new StatusMediaViewModel { Uri = i.MediaUrlHttps });
                        }
                    }

                    HasMedia = Medias.Count != 0;

                }
            }));
        }