Ejemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            try
            {
                m_itemViewModel = e.Parameter as ItemViewModel;
            }
            catch (System.Exception ex)
            {

            }
            InitialLoad();
        }
Ejemplo n.º 2
0
        public static ItemViewModel ConvertItemToCommon(Status status)
        {
            try
            {
                FiltPicture(status);
                ItemViewModel model = new ItemViewModel();
                model.IconURL = status.user.profile_image_url;
                model.LargeIconURL = status.user.avatar_large;
                model.Title = status.user.name;
                model.Content = status.text;
                model.ImageURL = MiscTool.MakeFriendlyImageURL(status.thumbnail_pic);
                model.MidImageURL = MiscTool.MakeFriendlyImageURL(status.bmiddle_pic);
                model.FullImageURL = MiscTool.MakeFriendlyImageURL(status.original_pic);
                model.TimeObject = status.CreatedAt;
                model.Type = EntryType.SinaWeibo;
                model.ID = status.id;
                model.SharedCount = status.reposts_count.ToString();
                model.CommentCount = status.comments_count.ToString();
                model.Comments = new ObservableCollection<CommentViewModel>();

                if (status.IsRetweetedStatus == "Visible")
                {
                    model.ForwardItem = new ItemViewModel();
                    if (status.retweeted_status.user != null)
                    {
                        model.ForwardItem.Title = status.retweeted_status.user.name;
                    }
                    model.ForwardItem.Content = status.retweeted_status.text;
                    model.ForwardItem.ImageURL = MiscTool.MakeFriendlyImageURL(status.retweeted_status.thumbnail_pic);
                    model.ForwardItem.MidImageURL = MiscTool.MakeFriendlyImageURL(status.retweeted_status.bmiddle_pic);
                    model.ForwardItem.FullImageURL = MiscTool.MakeFriendlyImageURL(status.retweeted_status.original_pic);
                    model.ForwardItem.TimeObject = status.retweeted_status.CreatedAt;
                    model.ForwardItem.Type = EntryType.SinaWeibo;
                    model.ForwardItem.SharedCount = status.retweeted_status.reposts_count.ToString();
                    model.ForwardItem.CommentCount = status.retweeted_status.comments_count.ToString();
                    model.ForwardItem.ID = status.id;
                    model.ForwardItem.IconURL = status.retweeted_status.user.profile_image_url;
                    model.ForwardItem.LargeIconURL = status.retweeted_status.user.avatar_large;
                }
                return model;
            }
            catch (System.Exception ex)
            {
                return null;
            }
        }
Ejemplo n.º 3
0
        // 跳转到此页有2种情况
        // 1:对状态本身的评论  此时m_itemViewModel有值
        // 2:对评论本身的评论  此时m_itemViewModel和m_commentViewModel都需要有值
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            try
            {
                Dictionary<String, Object> parameters = e.Parameter as Dictionary<String, Object>;
                if (parameters.ContainsKey("ItemViewModel"))
                {
                    m_itemViewModel = parameters["ItemViewModel"] as ItemViewModel;
                    m_type = m_itemViewModel.Type;
                }
                if (parameters.ContainsKey("CommentViewModel"))
                    m_commentViewModel = parameters["CommentViewModel"] as CommentViewModel;
            }
            catch (System.Exception ex)
            {

            }
            ChangeUIByInputType();
        }
Ejemplo n.º 4
0
        public static void RefreshViewItems()
        {
            App.MainViewModel.ListItems.Clear();
            App.MainViewModel.ListItems.AddRange(App.MainViewModel.SinaWeiboItems);
            App.MainViewModel.ListItems.AddRange(App.MainViewModel.RssItems);
            App.MainViewModel.ListItems.AddRange(App.MainViewModel.RenrenItems);
            App.MainViewModel.ListItems.AddRange(App.MainViewModel.DoubanItems);
            App.MainViewModel.ListItems.Sort(
                delegate(ItemViewModel a, ItemViewModel b)
                {
                    return (a.TimeObject < b.TimeObject ? 1 : a.TimeObject == b.TimeObject ? 0 : -1);
                }
                );
            App.MainViewModel.Items.Clear();
            
            if (App.MainViewModel.ListItems.Count == 0)
            {
                ItemViewModel model = new ItemViewModel();
                model.Title = "没有得到任何结果的说~~~";
                model.Content = "请确保网络通畅。如果没有设置关注人,请到帐号设置页中登陆并设置关注人";
                model.Type = EntryType.Nothing;
                model.IconURL = "/Images/Thumb/DefaultAvatar.png";
                model.ID = "nothing";
                App.MainViewModel.ListItems.Add(model);
            }
            foreach (ItemViewModel item in App.MainViewModel.ListItems)
            {
                App.MainViewModel.Items.Add(item);
            }


            // 更新主页上显示的头条,并且在最后加上一个"显示更多..."的条目
            // 由于主页的头条动态最开始可能是从缓存中加载的,如果两次的数据其实一模一样的话,
            // 重加载一次会造成UI没必要的刷新,所以需要先与上次作比较,有区别再刷新
            ObservableCollection<ItemViewModel> tempList = new ObservableCollection<ItemViewModel>();
            //
            int count = App.MainViewModel.Items.Count > MAX_SHOW_IN_HOMEPAGE ? MAX_SHOW_IN_HOMEPAGE : App.MainViewModel.Items.Count;            
            for (int i = 0; i < count; i++)
            {
                tempList.Add(App.MainViewModel.Items[i]);
            }

            if (HaveMeaningfullItem(tempList))
            {
                ItemViewModel showMore = new ItemViewModel();
                showMore.Type = EntryType.ShowMore;
                tempList.Add(showMore);
            }

            if (!IsItemListTheSame(tempList, App.MainViewModel.TopItems))
            {
                App.MainViewModel.TopItems.Clear();
                foreach (ItemViewModel model in tempList)
                {
                    App.MainViewModel.TopItems.Add(model);
                }
                // 离开前,先把当前的TopItem缓存起来,这样下次进来就可以直接看到了
                SaveTopItemToLoaclCache();
            }

            // 开始刷新图片页信息
            RefreshPicturePage();

            // 更新桌面磁贴
            UpdateTile();
        }