예제 #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);
 }
예제 #2
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();
 }
예제 #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);
 }
예제 #4
0
        public void Initialize()
        {
            Kbtter = Kbtter.Instance;
            Kbtter.Initialize();

            View.SettingInstance = Kbtter.Setting;
            View.HomeTimeline = new StatusTimelineViewModel(this, Kbtter.HomeStatusTimeline);
            View.HomeNotification = new NotificationTimelineViewModel(this, Kbtter.HomeNotificationTimeline);
            View.LoginUser = new UserViewModel(Kbtter.AuthenticatedUser, this);
            View.Accounts = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.Accounts,
                p => new AccountViewModel(p),
                DispatcherHelper.UIDispatcher);
            View.DirectMessageTimelines = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.DirectMessageTimelines,
                p => new DirectMessageTimelineViewModel(this, p),
                DispatcherHelper.UIDispatcher);
            View.Users = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.Users,
                p => new UserViewModel(p, this, true),
                DispatcherHelper.UIDispatcher);
            View.Plugins = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.GlobalPlugins,
                p => new PluginViewModel(p),
                DispatcherHelper.UIDispatcher);

            View.SearchResultStatuses = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.SearchResultStatuses,
                p => new StatusViewModel(this, p),
                DispatcherHelper.UIDispatcher);
            View.SearchResultUsers = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.SearchResultUsers,
                p => new UserViewModel(p, this),
                DispatcherHelper.UIDispatcher);

            View.UserDefinitionTimelines = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Kbtter.StatusTimelines,
                p => new StatusTimelineViewModel(this, p),
                DispatcherHelper.UIDispatcher);

            InitializeEventListeners();
            View.ChangeToHomeStatusTimeline();
            View.IsAccountPanelVisible = true;
        }
예제 #5
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();
        }
예제 #6
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;

                }
            }));
        }