Beispiel #1
0
        public static StatusViewModel CreateStatusViewModel(this MainWindowViewModel vm, Status st)
        {
            var ret = new StatusViewModel();

            ret.status = st;
            if (st.RetweetedStatus != null)
            {
                ret.RetweetUserName = st.User.Name;
                st            = st.RetweetedStatus;
                ret.IsRetweet = true;
            }
            else
            {
                ret.IsRetweet       = false;
                ret.RetweetUserName = "";
            }
            ret.origin              = st;
            ret.UserName            = st.User.Name;
            ret.ScreenName          = st.User.ScreenName;
            ret.Text                = st.Text;
            ret.UserProfileImageUri = st.User.ProfileImageUrlHttps;
            ret.RetweetCount        = st.RetweetCount ?? 0;
            ret._IsFavorited        = (st.IsFavorited ?? false) || Kbtter.Instance.IsFavoritedInCache(st);
            ret._IsRetweeted        = (st.IsRetweeted ?? false) || (ret.status.RetweetedStatus != null && Kbtter.Instance.IsRetweetedInCache(ret.status));
            ret.FavoriteCount       = st.FavoriteCount ?? 0;
            ret.IsMyStatus          = (Kbtter.Instance.AuthenticatedUser != null && Kbtter.Instance.AuthenticatedUser.Id == st.User.Id);
            ret.IsOthersStatus      = !ret.IsMyStatus;
            ret.IsOthersStatus      = !ret.IsMyStatus;
            ret._CreatedTimeText    = st.CreatedAt.DateTime.ToLocalTime();
            ret.IsReplyToMe         = st.Entities != null && st.Entities.UserMentions.Any(p => p.ScreenName == Kbtter.Instance.AuthenticatedUser.ScreenName);
            ret.AnalyzeText();
            ret.TryGetReply();

            var m = reg.Match(st.Source);

            ret.Via = m.Groups["client"].Value;
            if (m.Groups["url"].Value != "")
            {
                ret.ViaUri = new Uri(m.Groups["url"].Value);
            }

            ret.main = vm;

            ret.listener = new PropertyChangedEventListener(Kbtter.Instance);
            ret.listener.Add("Status", ret.UpdateTime);
            ret.CompositeDisposable.Add(ret.listener);

            return(ret);
        }
Beispiel #2
0
        public StatusPage(StatusViewModel vm)
        {
            statvm = vm;
            DataContext = vm;
            InitializeComponent();
            elm = vm.TextElements;
            stsn = vm.ScreenName;

            if (vm.Via == "") StackPanelBlockVia.Visibility = Visibility.Collapsed;
            SetMainText();

            composite = new LivetCompositeDisposable();
            ctxlistener = new PropertyChangedWeakEventListener((INotifyPropertyChanged)DataContext);
            ctxlistener.Add("Delete", DeleteContent);
        }
Beispiel #3
0
        public static StatusViewModel CreateStatusViewModel(this MainWindowViewModel vm, Status st)
        {
            var ret = new StatusViewModel();
            ret.status = st;
            if (st.RetweetedStatus != null)
            {
                ret.RetweetUserName = st.User.Name;
                st = st.RetweetedStatus;
                ret.IsRetweet = true;
            }
            else
            {
                ret.IsRetweet = false;
                ret.RetweetUserName = "";
            }
            ret.origin = st;
            ret.UserName = st.User.Name;
            ret.ScreenName = st.User.ScreenName;
            ret.Text = st.Text;
            ret.UserProfileImageUri = st.User.ProfileImageUrlHttps;
            ret.RetweetCount = st.RetweetCount ?? 0;
            ret._IsFavorited = (st.IsFavorited ?? false) || Kbtter.Instance.IsFavoritedInCache(st);
            ret._IsRetweeted = (st.IsRetweeted ?? false) || (ret.status.RetweetedStatus != null && Kbtter.Instance.IsRetweetedInCache(ret.status));
            ret.FavoriteCount = st.FavoriteCount ?? 0;
            ret.IsMyStatus = (Kbtter.Instance.AuthenticatedUser != null && Kbtter.Instance.AuthenticatedUser.Id == st.User.Id);
            ret.IsOthersStatus = !ret.IsMyStatus;
            ret.IsOthersStatus = !ret.IsMyStatus;
            ret._CreatedTimeText = st.CreatedAt.DateTime.ToLocalTime();
            ret.IsReplyToMe = st.Entities != null && st.Entities.UserMentions.Any(p => p.ScreenName == Kbtter.Instance.AuthenticatedUser.ScreenName);
            ret.AnalyzeText();
            ret.TryGetReply();

            var m = reg.Match(st.Source);
            ret.Via = m.Groups["client"].Value;
            if (m.Groups["url"].Value != "") ret.ViaUri = new Uri(m.Groups["url"].Value);

            ret.main = vm;

            ret.listener = new PropertyChangedEventListener(Kbtter.Instance);
            ret.listener.Add("Status", ret.UpdateTime);
            ret.CompositeDisposable.Add(ret.listener);

            return ret;
        }