using Shared; using System; using HDL_ON.UI.Music; using HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView; using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock; using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity; namespace HDL_ON.UI.UI2.FuntionControlView.Aks { /// /// 影片详情界面 /// public class DetailPage : FrameLayout { /// /// /// /// 遥控器对象 /// 影片对象 public DetailPage(RemoteControlEntity remoteControlEntity, MovieLibrary movieLibrary) { this.remoteControl = remoteControlEntity; this.movieLibrary = movieLibrary; //从缓存获取 this.movieLibraryInfo = AksCommonMethod.Current.GetMovieLibraryInfo(remoteControl.rcId + "_" + movieLibrary.movieId); } /// /// 当前的遥控器对象 /// RemoteControlEntity remoteControl; /// /// 影片详情 /// MovieLibraryInfoEntity movieLibraryInfo; /// /// 头部布局 /// private TopView topView; /// /// 立即播放 /// Button btnPaly; /// /// 影片 /// MovieLibrary movieLibrary; /// /// 年份 /// Button btnYear; /// /// 地区 /// Button btnRegion; /// /// 收藏 /// Button btnCollectImage; Button btnCollectText; /// /// 电影简介内容 /// Button btnIntroduceContent; /// /// 演员图片列表容器 /// HorizontalScrolViewLayout horizontalFram; public Action action; private bool isOldState; public void Show() { //初始化UI this.InitTop(); this.InitMiddle(); //初始化事件 this.EventListener(); //读取数据 ReadData(); } /// /// 初始化头部界面 /// private void InitTop() { this.BackgroundColor = MusicColor.ViewColor; this.topView = new TopView(); this.topView.setBtn.Visible = false; this.topView.topNameBtn.TextID = StringId.yingpianjieshao; this.AddChidren(topView.TopFLayoutView()); } /// /// 初始化中部界面 /// private void InitMiddle() { var vv = new VerticalRefreshLayout { Y = topView.fLayout.Bottom, Height = Application.GetRealHeight(H_W.H - H_W.T_Height), BackgroundColor = MusicColor.WhiteColor, }; this.AddChidren(vv); vv.BeginHeaderRefreshingAction += () => { vv.EndHeaderRefreshing(); movieLibraryInfo = null; ReadData(); }; BaseFramLayout baseFramLayout = new BaseFramLayout(); vv.AddChidren(baseFramLayout); ImageView btnImage = new ImageView { X = Application.GetRealWidth(16), Y = Application.GetRealHeight(16), Width = Application.GetRealWidth(140), Height = Application.GetRealHeight(180), Radius = (uint)Application.GetRealHeight(12), ImageBytes = movieLibrary.imageBytes, }; baseFramLayout.AddChidren(btnImage); //电影名称 Button btnName = new Button { X = btnImage.Right + Application.GetRealWidth(16), Y = Application.GetRealHeight(36), Width = Application.GetRealWidth(178), Height = Application.GetRealHeight(45), Text = movieLibrary.name, TextColor = MusicColor.TextColor, TextSize = TextSize.Text16, TextAlignment = TextAlignment.CenterLeft, IsBold = true, IsMoreLines = true, }; baseFramLayout.AddChidren(btnName); this.AdjustRealWidth(btnName, 178); //年份 btnYear = new Button { X = btnImage.Right + Application.GetRealWidth(16), Y = btnName.Bottom + Application.GetRealHeight(12), Width = Application.GetRealWidth(34), Height = Application.GetRealHeight(20), TextColor = MusicColor.TextColor, TextSize = TextSize.Text14, TextAlignment = TextAlignment.CenterLeft, Text = movieLibraryInfo == null ? "" : movieLibraryInfo.releaseDate, }; baseFramLayout.AddChidren(btnYear); this.AdjustRealWidth(btnYear, 34); //"/" Button btnSlope = new Button { X = btnYear.Right + Application.GetRealWidth(8), Y = btnName.Bottom + Application.GetRealHeight(12), Width = Application.GetRealWidth(34), Height = Application.GetRealHeight(20), Text = "/", TextColor = MusicColor.LineColor, TextSize = TextSize.Text14, }; baseFramLayout.AddChidren(btnSlope); //地区 btnRegion = new Button { X = btnSlope.Right + Application.GetRealWidth(8), Y = btnName.Bottom + Application.GetRealHeight(12), Width = Application.GetRealWidth(140), Height = Application.GetRealHeight(20), TextColor = MusicColor.TextColor, TextSize = TextSize.Text14, TextAlignment = TextAlignment.CenterLeft, Text = movieLibraryInfo == null ? "" : movieLibraryInfo.area, }; baseFramLayout.AddChidren(btnRegion); this.AdjustRealWidth(btnRegion, 140); //电影分数 Button btnGrade = new Button { X = btnImage.Right + Application.GetRealWidth(16), Y = btnYear.Bottom + Application.GetRealHeight(20), Width = Application.GetRealWidth(45), Height = Application.GetRealHeight(43), Text = movieLibraryInfo == null ? "" : movieLibraryInfo.rating, TextSize = 32, TextColor = MusicColor.TextColor, TextAlignment = TextAlignment.CenterLeft, IsBold = true, }; baseFramLayout.AddChidren(btnGrade); this.AdjustRealWidth(btnGrade, 45); // Button btnScore = new Button { X = btnGrade.Right + Application.GetRealWidth(8), Y = btnYear.Bottom + Application.GetRealHeight(46), Width = Application.GetRealWidth(26), Height = Application.GetRealHeight(17), TextID = StringId.pingfen, TextColor = 0xffA5AEBC, TextSize = TextSize.Text12, TextAlignment = TextAlignment.CenterLeft, }; baseFramLayout.AddChidren(btnScore); btnCollectImage = new Button { X = btnImage.Right + Application.GetRealWidth(167), Y = btnRegion.Bottom + Application.GetRealHeight(12), Width = Application.GetRealWidth(32), Height = Application.GetRealWidth(32), UnSelectedImagePath = "MusicIcon/collect.png", SelectedImagePath = "MusicIcon/collectSelected.png", IsSelected = movieLibraryInfo == null ? false : movieLibraryInfo.collect, }; baseFramLayout.AddChidren(btnCollectImage); btnCollectText = new Button { X = btnImage.Right + Application.GetRealWidth(169), Y = btnCollectImage.Bottom + Application.GetRealHeight(2), Width = Application.GetRealWidth(36), Height = Application.GetRealHeight(17), TextID = StringId.weishoucang, TextColor = 0xffA5AEBC, TextSize = TextSize.Text12, TextAlignment = TextAlignment.CenterLeft, }; baseFramLayout.AddChidren(btnCollectText); if (btnCollectImage.IsSelected) { btnCollectText.TextID = StringId.yishoucang; } else { btnCollectText.TextID = StringId.weishoucang; } isOldState = btnCollectImage.IsSelected; //电影简介 Button btnIntroduceTitle = new Button { X = Application.GetRealWidth(16), Y = btnImage.Bottom + Application.GetRealHeight(28), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(23), //TextID = StringId., Text = "电影简介", TextColor = MusicColor.TextColor, TextSize = TextSize.Text16, TextAlignment = TextAlignment.CenterLeft, IsBold = true, }; baseFramLayout.AddChidren(btnIntroduceTitle); //电影简介内容 btnIntroduceContent = new Button { X = Application.GetRealWidth(16), Y = btnIntroduceTitle.Bottom + Application.GetRealHeight(12), Width = Application.GetRealWidth(343), Height = Application.GetRealHeight(140), //TextID = StringId., TextColor = MusicColor.TextCancelColor, TextSize = TextSize.Text14, TextAlignment = TextAlignment.TopLeft, IsBold = true, IsMoreLines = true, Text = movieLibraryInfo == null ? "" : movieLibraryInfo.introduction, }; baseFramLayout.AddChidren(btnIntroduceContent); #region -----演员照片 名称------ //演员 Button btnActor = new Button { X = Application.GetRealWidth(16), Y = btnIntroduceContent.Bottom + Application.GetRealHeight(28), Width = Application.GetRealWidth(300), Height = Application.GetRealHeight(23), //TextID = StringId.yan, Text = "演员", TextColor = MusicColor.TextColor, TextSize = TextSize.Text16, TextAlignment = TextAlignment.CenterLeft, IsBold = true, }; baseFramLayout.AddChidren(btnActor); horizontalFram = new HorizontalScrolViewLayout { Y = btnActor.Bottom + Application.GetRealHeight(12), X = Application.GetRealWidth(16), Height = Application.GetRealHeight(112), Width = Application.GetRealWidth(375 - 16), }; baseFramLayout.AddChidren(horizontalFram); LoadActorPage(); #endregion //立即播放 btnPaly = new Button { Y = horizontalFram.Bottom + Application.GetRealHeight(70), Width = Application.GetRealWidth(220), Height = Application.GetRealHeight(44), TextID = StringId.lijibofang, TextColor = MusicColor.WhiteColor, TextSize = TextSize.Text16, TextAlignment = TextAlignment.Center, Gravity = Gravity.CenterHorizontal, BackgroundColor = MusicColor.SelectedColor, Radius = (uint)Application.GetRealHeight(22), }; baseFramLayout.AddChidren(btnPaly); baseFramLayout.AdjustRealHeight(37); } /// /// 加载演员图片列表 /// private void LoadActorPage() { if (this.movieLibraryInfo == null || this.movieLibraryInfo.actors.Count == 0) { return; } for (int i = 0; i < this.movieLibraryInfo.actors.Count; i++) { var actors = this.movieLibraryInfo.actors[i]; FrameLayout actorFrame = new FrameLayout { Height = Application.GetRealHeight(112), Width = Application.GetRealWidth(72), }; horizontalFram.AddChidren(actorFrame); ImageView btnActorImage = new ImageView { Width = Application.GetRealWidth(72), Height = Application.GetRealHeight(84), Radius = (uint)Application.GetRealHeight(8), ImageBytes = actors.imageBytes, }; actorFrame.AddChidren(btnActorImage); Button btnActorName = new Button { Y = btnActorImage.Bottom + Application.GetRealHeight(8), Width = Application.GetRealWidth(72), Height = Application.GetRealHeight(20), TextSize = TextSize.Text14, TextColor = MusicColor.TextColor, TextAlignment = TextAlignment.Center, IsMoreLines = true, Text = actors.actorName, }; actorFrame.AddChidren(btnActorName); //间隔,弄个空的进去占位置 Button btnSpacing = new Button { Width = Application.GetRealWidth(8), }; horizontalFram.AddChidren(btnSpacing); } } /// /// 注册事件 /// private void EventListener() { //返回 this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { action?.Invoke(isOldState != btnCollectImage.IsSelected); this.RemoveFromParent(); }; //立即播放 this.btnPaly.MouseUpEventHandler += (sender, e) => { CommonMethod.Current.Loading.Start(); CommonMethod.Current.SunThread(() => { try { SendMethod.Current.MovieLibraryPlay(remoteControl.deviceId, remoteControl.rcId, movieLibrary.movieId); } catch { } finally { CommonMethod.Current.MainThread(() => { CommonMethod.Current.Loading.Hide(); }); } }); }; //收藏 EventHandler CollectClick = (sender, e) => { btnCollectImage.IsSelected = !btnCollectImage.IsSelected; if (btnCollectImage.IsSelected) { btnCollectText.TextID = StringId.yishoucang; } else { btnCollectText.TextID = StringId.weishoucang; } CommonMethod.Current.Loading.Start(); CommonMethod.Current.SunThread(() => { try { var isBool = SendMethod.Current.IsCollect(remoteControl.deviceId, remoteControl.rcId, movieLibrary.movieId, btnCollectImage.IsSelected); if (isBool) { //更新缓存数据 movieLibraryInfo.collect = btnCollectImage.IsSelected; //成功后才更新缓存数据 if (btnCollectImage.IsSelected) { AksCommonMethod.Current.AddCollectMovie(movieLibrary); } else { AksCommonMethod.Current.DelCollectMovie(movieLibrary); } } } catch { } finally { CommonMethod.Current.MainThread(() => { CommonMethod.Current.Loading.Hide(); }); } }); }; btnCollectImage.MouseUpEventHandler += CollectClick; btnCollectText.MouseUpEventHandler += CollectClick; } /// /// 初始数据 /// private void ReadData() { if (this.movieLibraryInfo != null) { return; } CommonMethod.Current.Loading.Start(); CommonMethod.Current.SunThread(() => { try { this.movieLibraryInfo = SendMethod.Current.GetMovieLibraryInfo(remoteControl.deviceId, remoteControl.rcId, movieLibrary.movieId); if (movieLibraryInfo.actors.Count == 0) { return; } for (int i = 0; i < movieLibraryInfo.actors.Count; i++) { movieLibraryInfo.actors[i].imageBytes = SendMethod.Current.GetImage(movieLibraryInfo.actors[i].actorUrl); } } catch { } finally { CommonMethod.Current.MainThread(() => { CommonMethod.Current.Loading.Hide(); btnYear.Text = movieLibraryInfo.releaseDate; btnRegion.Text = movieLibraryInfo.area; btnCollectImage.IsSelected = movieLibraryInfo.collect; btnIntroduceContent.Text = movieLibraryInfo.introduction; LoadActorPage(); AksCommonMethod.Current.AddMovieLibraryInfo(movieLibraryInfo); }); } }); } /// /// 重新计算button宽度 /// /// 控件 /// 宽度最大最 /// 内边距 private void AdjustRealWidth(Button button, int widthMax = 0, int padding = 0) { if (button == null) { return; } int width; if (widthMax == 0) { //内边距 width = button.GetTextWidth() + Application.GetRealWidth(padding * 2); } else { if (button.GetTextWidth() > Application.GetRealWidth(widthMax)) { width = Application.GetRealWidth(widthMax); } else { width = button.GetTextWidth(); } } button.Width = width; } } }