Пример #1
0
 private static void Data_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null && e.NewValue is Reply data)
     {
         var instance = d as ReplyMainBlock;
         instance.UserAvatar.Source        = new BitmapImage(new Uri(data.member.avatar + "@50w.jpg"));
         instance.UserNameBlock.Text       = data.member.uname;
         instance.LevelImage.Source        = new BitmapImage(new Uri($"ms-appx:///Assets/Level/level_{data.member.level_info.current_level}.png"));
         instance.TimeBlock.Text           = AppTool.GetReadDateString(data.ctime);
         instance.ContentBlock.EmoteSource = data.content.emote;
         instance.ContentBlock.Text        = data.content.message;
         instance.LikeBlock.Text           = AppTool.GetNumberAbbreviation(data.like);
         instance.LikeIcon.Foreground      = data.action == 1 ? UIHelper.GetThemeBrush(Models.Enums.ColorType.PrimaryColor) : UIHelper.GetThemeBrush(Models.Enums.ColorType.TipTextColor);
         if (data.rcount > 0 && instance.SubReplyVisibility == Visibility.Visible)
         {
             instance.SubReplyContainer.Visibility     = Visibility.Visible;
             instance.SubReplyItemsControl.ItemsSource = data.replies;
             instance.TotalReplyCount.Text             = $"共{AppTool.GetNumberAbbreviation(data.rcount)}条回复";
             instance.MoreReplyButton.Visibility       = data.rcount > 3 ? Visibility.Visible : Visibility.Collapsed;
         }
         else
         {
             instance.SubReplyContainer.Visibility = Visibility.Collapsed;
         }
     }
 }
 private static void Data_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null && e.NewValue is FeedAtDetail data)
     {
         var instance = d as MessageAtBlock;
         instance.UserAvatar.ProfilePicture = new BitmapImage(new Uri(data.user.avatar + "@40w.jpg"))
         {
             DecodePixelWidth = 40
         };
         instance.ShowUserBlock.Text = data.user.nickname;
         instance.TimeBlock.Text     = AppTool.GetReadDateString(data.at_time);
         instance.TypeBlock.Text     = $"在{data.item.business}中@了我";
         instance.DetailBlock.Text   = data.item.source_content;
         instance.TitleBlock.Text    = string.IsNullOrEmpty(data.item.title) ? "数据蜜汁消失了" : data.item.title;
     }
 }
Пример #3
0
 private static void Data_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null && e.NewValue is FeedReplyDetail data)
     {
         var instance = d as MessageReplyBlock;
         instance.UserAvatar.ProfilePicture = new BitmapImage(new Uri(data.user.avatar + "@40w.jpg"))
         {
             DecodePixelWidth = 40
         };
         instance.ShowUserBlock.Text     = data.user.nickname;
         instance.TimeBlock.Text         = AppTool.GetReadDateString(data.reply_time);
         instance.MultipleUserBlock.Text = data.is_multi == 1 ? "等人" : "";
         instance.TypeBlock.Text         = $"对我的{data.item.business}发表了{data.counts}条评论";
         instance.DetailBlock.Text       = data.item.source_content;
         instance.TitleBlock.Text        = string.IsNullOrEmpty(data.item.title) ? data.item.desc : data.item.title;
     }
 }
Пример #4
0
        private void HeaderInit(Topic data)
        {
            if (data.desc.user_profile != null)
            {
                HeaderContainer.Visibility = Visibility.Visible;
                UserAvatar.ProfilePicture  = new BitmapImage(new Uri(data.desc.user_profile.info.face))
                {
                    DecodePixelWidth = 40
                };
                UserNameBlock.Text = data.desc.user_profile.info.uname;
                string tip = AppTool.GetReadDateString(data.desc.timestamp);
                if (data.display != null && !string.IsNullOrEmpty(data.display.usr_action_txt))
                {
                    tip += " · " + data.display.usr_action_txt;
                }
                if (data.desc.view != 0)
                {
                    tip += " · " + AppTool.GetNumberAbbreviation(data.desc.view) + "次查看";
                }
                TipBlock.Text = tip;
            }
            else
            {
                HeaderContainer.Visibility = Visibility.Collapsed;
            }
            var me = App.BiliViewModel._client.Account.Me;

            if (data.desc.type == 512 || data.desc.type == 4101 || data.display == null)
            {
                FollowButton.Visibility = Visibility.Collapsed;
            }
            else if ((me != null && me.mid == data.desc.uid) || data.display.relation.is_follow == 1)
            {
                FollowButton.Visibility = Visibility.Collapsed;
            }
            else
            {
                FollowButton.Visibility = Visibility.Visible;
            }
        }
Пример #5
0
 private static void Data_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null && e.NewValue is FeedLikeDetail data)
     {
         var instance = d as MessageLikeBlock;
         instance.UserAvatarItemsControl.ItemsSource = data.users.Take(5);
         bool isMany = data.users.Count > 1;
         instance.LatestContainer.Visibility = data.is_latest ? Visibility.Visible : Visibility.Collapsed;
         string detail = string.Empty;
         if (isMany)
         {
             string first  = data.users.First().nickname;
             string second = data.users[1].nickname;
             detail = $"**{first}**、**{second}**等{data.counts}人赞了我的{data.item.business}";
         }
         else
         {
             detail = $"**{data.users.First().nickname}**赞了我的{data.item.business}";
         }
         instance.DetailBlock.Text = detail;
         instance.TimeBlock.Text   = AppTool.GetReadDateString(data.like_time);
         instance.TitleBlock.Text  = string.IsNullOrEmpty(data.item.title) ? data.item.desc : data.item.title;
     }
 }
Пример #6
0
 private void BodyInit(Topic data)
 {
     MainDisplay.Visibility = Visibility.Visible;
     MoreButton.Visibility  = Visibility.Collapsed;
     if (data.display != null && data.display.emoji_info != null && data.display.emoji_info.emoji_details.Count > 0)
     {
         var dict = new Dictionary <string, Emote>();
         foreach (var item in data.display.emoji_info.emoji_details)
         {
             dict.Add(item.text, item);
         }
         DescriptionBlock.EmoteSource = dict;
     }
     if (data.desc.type == 8)
     {
         //视频
         var info = JsonConvert.DeserializeObject <VideoDynamic>(data.card);
         info.dynamic = Uri.UnescapeDataString(info.dynamic);
         if (!string.IsNullOrEmpty(info.dynamic))
         {
             DescriptionBlock.Text = Regex.Replace(info.dynamic, @"#(.*?)#", "").Trim();
         }
         DescriptionBlock.Visibility = string.IsNullOrEmpty(DescriptionBlock.Text) ? Visibility.Collapsed : Visibility.Visible;
         CommentBlock.Text           = AppTool.GetNumberAbbreviation(info.stat.reply);
         MoreButton.Visibility       = Visibility.Visible;
         MainDisplay.Data            = info;
     }
     else if (data.desc.type == 1)
     {
         //转发
         var info = JsonConvert.DeserializeObject <RepostDynamic>(data.card);
         DescriptionBlock.Visibility = Visibility.Collapsed;
         CommentBlock.Text           = AppTool.GetNumberAbbreviation(info.item.reply);
         MainDisplay.Data            = info;
     }
     else if (data.desc.type == 2)
     {
         //图片
         var temp = JObject.Parse(data.card);
         var info = JsonConvert.DeserializeObject <ImageDynamic>(temp["item"].ToString());
         info.description      = Uri.UnescapeDataString(info.description);
         DescriptionBlock.Text = Regex.Replace(info.description, @"#(.*?)#", "").Trim();
         CommentBlock.Text     = AppTool.GetNumberAbbreviation(info.reply);
         MainDisplay.Data      = info;
     }
     else if (data.desc.type == 4)
     {
         //纯文本
         var temp = JObject.Parse(data.card);
         var info = JsonConvert.DeserializeObject <TextDynamic>(temp["item"].ToString());
         if (!string.IsNullOrEmpty(info.content))
         {
             DescriptionBlock.Text = Regex.Replace(info.content, @"#(.*?)#", "").Trim();
         }
         CommentBlock.Text      = AppTool.GetNumberAbbreviation(info.reply);
         MainDisplay.Visibility = Visibility.Collapsed;
     }
     else if (data.desc.type == 64)
     {
         //专栏
         var info = JsonConvert.DeserializeObject <DocumentDynamic>(data.card);
         if (!string.IsNullOrEmpty(info.dynamic))
         {
             DescriptionBlock.Text = Regex.Replace(info.dynamic, @"#(.*?)#", "").Trim();
         }
         CommentBlock.Text = AppTool.GetNumberAbbreviation(info.stats.reply);
         MainDisplay.Data  = info;
     }
     else if (data.desc.type == 512 || data.desc.type == 4101)
     {
         //动漫
         var info = JsonConvert.DeserializeObject <AnimeDynamic>(data.card);
         HeaderContainer.Visibility = Visibility.Visible;
         UserAvatar.ProfilePicture  = new BitmapImage(new Uri(info.season.square_cover))
         {
             DecodePixelWidth = 40
         };
         UserNameBlock.Text = info.season.title;
         string tip = AppTool.GetReadDateString(data.desc.timestamp);
         tip          += " · " + "更新了";
         TipBlock.Text = tip;
         DescriptionBlock.Visibility = Visibility.Collapsed;
         FollowButton.Visibility     = Visibility.Collapsed;
         CommentBlock.Text           = AppTool.GetNumberAbbreviation(info.stat.reply);
         MainDisplay.Data            = info;
     }
     else if (data.desc.type == 16)
     {
         //小视频
         var info = JsonConvert.DeserializeObject <ShortVideoDynamic>(data.card);
         if (!string.IsNullOrEmpty(info.item.description))
         {
             DescriptionBlock.Text = Regex.Replace(info.item.description, @"#(.*?)#", "").Trim();
         }
         CommentBlock.Text = AppTool.GetNumberAbbreviation(info.item.reply);
         MainDisplay.Data  = info;
     }
     else if (data.desc.type == 2048)
     {
         //网页
         var info = JsonConvert.DeserializeObject <WebDynamic>(data.card);
         if (!string.IsNullOrEmpty(info.vest.content))
         {
             DescriptionBlock.Text = Regex.Replace(info.vest.content, @"#(.*?)#", "").Trim();
         }
         CommentBlock.Text = AppTool.GetNumberAbbreviation(data.desc.comment);
         MainDisplay.Data  = info;
     }
     else if (data.desc.type == 4303)
     {
         //视频单
         var info = JsonConvert.DeserializeObject <CourseDynamic>(data.card);
         if (!string.IsNullOrEmpty(info.new_ep.title))
         {
             DescriptionBlock.Text = Regex.Replace(info.new_ep.title, @"#(.*?)#", "").Trim();
         }
         CommentBlock.Text = data.desc.comment == 0 ? "" : AppTool.GetNumberAbbreviation(data.desc.comment);
         MainDisplay.Data  = info;
     }
     else if (data.desc.type == 256)
     {
         //音频
         var info = JsonConvert.DeserializeObject <MusicDynamic>(data.card);
         if (!string.IsNullOrEmpty(info.intro))
         {
             DescriptionBlock.Text = Regex.Replace(info.intro, @"#(.*?)#", "").Trim();
         }
         CommentBlock.Text = AppTool.GetNumberAbbreviation(info.replyCnt);
         MainDisplay.Data  = info;
     }
     else if (data.desc.type == 4200)
     {
         //直播
         var info = JsonConvert.DeserializeObject <LiveDynamic>(data.card);
         DescriptionBlock.Visibility = Visibility.Collapsed;
         CommentBlock.Text           = "";
         MainDisplay.Data            = info;
     }
     else
     {
         string yo = "";
     }
 }
Пример #7
0
        public async Task Init(VideoDetail detail, int partId = 0)
        {
            Reset();
            App.AppViewModel.CurrentPlayerType  = Models.Enums.PlayerType.Video;
            App.AppViewModel.CurrentVideoPlayer = VideoPlayer;
            _detail        = detail;
            _currentPartId = partId;
            TabletMainPage.Current.SetBackgroundImage(_detail.pic);
            if (!string.IsNullOrEmpty(_detail.redirect_url))
            {
                var result = BiliTool.GetResultFromUri(_detail.redirect_url);
                videoId        = 0;
                _currentPartId = 0;
                if (result.Type == UriType.Bangumi)
                {
                    throw new InvalidDataException(result.Param);
                }
            }
            TitleBlock.Text = detail.title;
            ToolTipService.SetToolTip(TitleBlock, _detail.title);
            videoId                = _detail.aid;
            bvId                   = _detail.bvid;
            PlayCountBlock.Text    = AppTool.GetNumberAbbreviation(_detail.stat.view);
            DanmakuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmaku);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);
            BVBlock.Text           = _detail.bvid;
            AVBlock.Text           = _detail.aid.ToString();

            DescriptionBlock.Text = _detail.desc;

            LikeButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.like);
            CoinButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.coin);
            FavoriteButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.favorite);

            PublishBlock.Text = AppTool.GetReadDateString(_detail.pubdate);

            UPAvatar.ProfilePicture = string.IsNullOrEmpty(_detail.owner.face) ? null : new BitmapImage(new Uri(_detail.owner.face + "@50w.jpg"))
            {
                DecodePixelWidth = 40
            };
            UPNameBlock.Text = _detail.owner.name;

            if (_detail.pages != null)
            {
                _detail.pages.ForEach(p => VideoPartCollection.Add(p));
                PartGridView.SelectedIndex = 0;
            }
            PartContainer.Visibility = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed;
            if (_detail.tag != null && _detail.tag.Count > 0)
            {
                TagGridView.Visibility = Visibility.Visible;
                _detail.tag.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagGridView.Visibility = Visibility.Collapsed;
            }

            if (_detail.staff != null && _detail.staff.Count > 0)
            {
                _detail.staff.ForEach(p => StaffCollection.Add(p));
                SingleUserContainer.Visibility = Visibility.Collapsed;
                StaffContainer.Visibility      = Visibility.Visible;
            }
            else
            {
                StaffContainer.Visibility      = Visibility.Collapsed;
                SingleUserContainer.Visibility = Visibility.Visible;
            }

            if (_detail.req_user != null)
            {
                LikeButton.IsCheck     = _detail.req_user.like != 0;
                CoinButton.IsCheck     = _detail.req_user.coin != 0;
                FavoriteButton.IsCheck = _detail.req_user.favorite != 0;
            }

            await MyVideoPlayer.Init(_detail, _currentPartId);

            CheckLikeHoldState();
        }
Пример #8
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var num = System.Convert.ToInt32(value);

            return(AppTool.GetReadDateString(num));
        }
Пример #9
0
        private bool InitDetail()
        {
            if (!string.IsNullOrEmpty(_detail.redirect_url))
            {
                var result = BiliTool.GetResultFromUri(_detail.redirect_url);
                videoId        = 0;
                _currentPartId = 0;
                App.AppViewModel.CurrentPagePanel.RemoveMainHistory(Models.Enums.AppMenuItemType.VideoPlayer);
                if (result.Type == UriType.Bangumi)
                {
                    new TipPopup("正在转到专题...").ShowMessage();
                    App.AppViewModel.PlayBangumi(Convert.ToInt32(result.Param), null, true);
                }
                return(false);
            }
            if (_isPlayList)
            {
                VideoPlayer.IsAutoReturnWhenEnd = false;
            }
            else
            {
                VideoPlayer.IsAutoReturnWhenEnd = _detail.pages.Count <= 1;
            }
            TitleBlock.Text = _detail.title;
            ToolTipService.SetToolTip(TitleBlock, _detail.title);
            videoId                = _detail.aid;
            bvId                   = _detail.bvid;
            PlayCountBlock.Text    = AppTool.GetNumberAbbreviation(_detail.stat.view);
            DanmukuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmaku);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);
            BVBlock.Text           = _detail.bvid;
            AVBlock.Text           = _detail.aid.ToString();

            DescriptionBlock.Text = _detail.desc;

            LikeButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.like);
            CoinButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.coin);
            FavoriteButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.favorite);

            DateBlock.Text = AppTool.GetReadDateString(_detail.pubdate);

            UPAvatar.ProfilePicture = string.IsNullOrEmpty(_detail.owner.face) ? null : new BitmapImage(new Uri(_detail.owner.face + "@50w.jpg"))
            {
                DecodePixelWidth = 40
            };
            UPNameBlock.Text = _detail.owner.name;

            _detail.pages.ForEach(p => VideoPartCollection.Add(p));
            PartListView.SelectedIndex = PartGridView.SelectedIndex = 0;
            PartContainer.Visibility   = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed;

            if (_detail.tag != null && _detail.tag.Count > 0)
            {
                TagListView.Visibility = Visibility.Visible;
                _detail.tag.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagListView.Visibility = Visibility.Collapsed;
            }

            if (_detail.staff != null && _detail.staff.Count > 0)
            {
                _detail.staff.ForEach(p => StaffCollection.Add(p));
                SingleUserContainer.Visibility = Visibility.Collapsed;
                StaffContainer.Visibility      = Visibility.Visible;
            }
            else
            {
                StaffContainer.Visibility      = Visibility.Collapsed;
                SingleUserContainer.Visibility = Visibility.Visible;
            }

            if (_detail.req_user != null)
            {
                LikeButton.IsCheck     = _detail.req_user.like != 0;
                CoinButton.IsCheck     = _detail.req_user.coin != 0;
                FavoriteButton.IsCheck = _detail.req_user.favorite != 0;
                FollowButton.Style     = _detail.req_user.attention == 1 ? UIHelper.GetStyle("DefaultAsyncButtonStyle") : UIHelper.GetStyle("PrimaryAsyncButtonStyle");
                FollowButton.Text      = _detail.req_user.attention == 1 ? "已关注" : "关注";
            }

            if (_detail.relates != null && _detail.relates.Count > 0)
            {
                _detail.relates.Where(p => p.@goto == "av").Take(10).ToList().ForEach(p => RelatedCollection.Add(p));
            }
            CheckLikeHoldState();
            return(true);
        }