Beispiel #1
0
 public DraftWindowViewModel(MainWindowViewModel mw)
 {
     Kbtter = Kbtter.Instance;
     main = mw;
     Drafts = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         Kbtter.AuthenticatedUserDrafts,
         p => new DraftViewModel(p),
         DispatcherHelper.UIDispatcher);
     CompositeDisposable.Add(Drafts);
 }
 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 NotificationTimelineViewModel(MainWindowViewModel main, NotificationTimeline tl)
 {
     Source = tl;
     Notificaitons = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         tl.Notifications,
         (p) =>
         {
             if (!IsSelected) UnreadCount++;
             return new NotificationViewModel(p, main);
         },
         DispatcherHelper.UIDispatcher);
 }
 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);
 }
Beispiel #5
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);
 }
 public StatusTimelineViewModel(MainWindowViewModel main, StatusTimeline tl)
 {
     Source = tl;
     Statuses = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         tl.Statuses,
         (p) =>
         {
             if (!IsSelected) UnreadCount++;
             return new StatusViewModel(main, p);
         },
         DispatcherHelper.UIDispatcher);
     Name = Source.Name;
     QueryText = Source.Query.QueryText;
 }
Beispiel #7
0
        //PropertyChangedEventListener listener;

        public UserViewModel(User user, MainWindowViewModel mw)
        {
            Kbtter = Kbtter.Instance;
            main = mw;
            src = user;
            Name = src.Name;
            ScreenName = src.ScreenName;
            IdString = src.Id.ToString();
            ProfileImageUri = src.ProfileImageUrlHttps;
            IsProtected = src.IsProtected;
            Location = src.Location;
            UriString = src.Url != null ? src.Url.ToString() : "";
            Description = src.Description;
            Statuses = src.StatusesCount;
            Favorites = src.FavouritesCount;
            Friends = src.FriendsCount;
            Followers = src.FollowersCount;
            //if (Description != null) AnalyzeDescription();
        }
Beispiel #8
0
        /*
        //UserStreamのStatus.UserにEntityがろくに含まれてないので凍結
        public void AnalyzeDescription()
        {
            var l = new List<Tuple<int[], StatusTextElement>>();

            if (src.Entities != null && src.Entities.Url != null)
            {
                if (src.Entities.Url.Urls != null)
                    foreach (var i in src.Entities.Url.Urls)
                    {
                        //Text = Text.Replace(i.Url.ToString(), i.DisplayUrl.ToString());
                        var e = new StatusTextElement();
                        e.Original = i.Url.ToString();
                        e.Action = main.View.OpenInDefault;
                        e.Type = StatusTextElementType.Uri;
                        e.Link = i.ExpandedUrl;
                        e.Surface = i.DisplayUrl;
                        l.Add(new Tuple<int[], StatusTextElement>(i.Indices, e));
                    }

                if (src.Entities.Url.Media != null)
                    foreach (var i in src.Entities.Url.Media)
                    {
                        //Text = Text.Replace(i.Url.ToString(), i.DisplayUrl.ToString());
                        var e = new StatusTextElement();
                        e.Original = i.Url.ToString();
                        e.Action = main.View.OpenInDefault;
                        e.Type = StatusTextElementType.Media;
                        e.Link = i.ExpandedUrl;
                        e.Surface = i.DisplayUrl;
                        l.Add(new Tuple<int[], StatusTextElement>(i.Indices, e));
                    }

                if (src.Entities.Url.UserMentions != null)
                    foreach (var i in src.Entities.Url.UserMentions)
                    {
                        var e = new StatusTextElement();
                        e.Action = async (p) =>
                        {
                            var user = await Kbtter.Token.Users.ShowAsync(id => i.Id);
                            Kbtter.AddUserToUsersList(user);
                            main.View.Notify(user.Name + "さんの情報");
                            main.View.ChangeToUser();
                        };
                        e.Type = StatusTextElementType.User;
                        e.Link = new Uri("https://twitter.com/" + i.ScreenName);
                        e.Surface = "@" + i.ScreenName;
                        e.Original = e.Surface;
                        l.Add(new Tuple<int[], StatusTextElement>(i.Indices, e));
                    }

                if (src.Entities.Url.HashTags != null)
                    foreach (var i in src.Entities.Url.HashTags)
                    {
                        var e = new StatusTextElement();
                        e.Action = (p) =>
                        {
                            main.View.ChangeToSearch();
                            main.View.SearchText = "#" + i.Text;
                            Kbtter.Search("#" + i.Text);
                        };
                        e.Type = StatusTextElementType.Hashtag;
                        e.Link = new Uri("https://twitter.com/search?q=%23" + i.Text);
                        e.Surface = "#" + i.Text;
                        e.Original = e.Surface;
                        l.Add(new Tuple<int[], StatusTextElement>(i.Indices, e));
                    }

                l.Sort((x, y) => x.Item1[0].CompareTo(y.Item1[0]));
            }

            int le = 0;
            foreach (var i in l)
            {
                var el = i.Item1[1] - i.Item1[0];
                var ntl = i.Item1[0] - le;
                if (ntl != 0)
                {
                    var nt = Description.Substring(le, ntl);
                    nt = nt
                        .Replace("&lt;", "<")
                        .Replace("&gt;", ">")
                        .Replace("&amp;", "&");
                    DescriptionElements.Add(new StatusTextElement { Surface = nt, Type = StatusTextElementType.None });
                }
                DescriptionElements.Add(i.Item2);
                le = i.Item1[1];
            }
            //foreach (var i in l) Text = Text.Replace(i.Item2.Original, i.Item2.Surface);
            if (Description.Length > le - 1)
            {
                var ls = Description.Substring(le);
                ls = ls
                        .Replace("&lt;", "<")
                        .Replace("&gt;", ">")
                        .Replace("&amp;", "&");
                DescriptionElements.Add(new StatusTextElement { Surface = ls, Type = StatusTextElementType.None });
            }
        }
        */
        public UserViewModel(User user, MainWindowViewModel mw, bool gfs)
            : this(user, mw)
        {

        }
 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;
     }
 }
Beispiel #10
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;

                }
            }));
        }
Beispiel #11
0
 public TegakiWindowViewModel(MainWindowViewModel mw)
 {
     main = mw;
     PenThickness = main.View.SettingInstance.Miscellaneous.TegakiPenThickness;
 }
Beispiel #12
0
 public StatusViewModel CreateVirtualStatusViewModel(MainWindowViewModel mw)
 {
     return new StatusViewModel(mw, Source.CreateVirtualStatus(), true);
 }