wjc
2023-08-28 2c1411a48874e4033a538a9725f09c8465536fa8
HDL_ON/UI/UI2/FuntionControlView/HisenseTV /HisenseTvPage.cs
@@ -15,7 +15,7 @@
    {
        #region ■ 变量声明___________________________
        #region   -------变量声明---------
        /// <summary>
        /// 设备
        /// </summary>
@@ -28,6 +28,11 @@
        /// 上一级界面的房间名字控件
        /// </summary>
        private Button btnRoomName;
        /// <summary>
        /// 上一级界面的收藏控件
        /// </summary>
        private Button btnCollectionIcon;
        /// <summary>
        /// 头部布局
        /// </summary>
@@ -83,12 +88,14 @@
        /// </summary>
        /// <param name="function">设备</param>
        /// <param name="btnDeviceName">上一级界面的设备名字控件(注:不能传null,没有可以传new Button())</param>
        /// <param name="btnRoomName">上一级界面的房间名字控件(注:不能传null,没有可以传new Button())</param>
        public HisenseTvPage(Function function, Button btnDeviceName, Button btnRoomName, CommonMethod.Comerom comerom, Action action)
        /// <param name="btnRoomName">上一级界面的房间名字控件(注:不能传null,没有可以传new Button())</param>
        /// <param name="btnCollectionIcon">上一级界面的房间名字控件(注:不能传null,没有可以传new Button())</param>
        public HisenseTvPage(Function function, Button btnDeviceName, Button btnRoomName, Button btnCollectionIcon, CommonMethod.Comerom comerom, Action action)
        {
            this.device = function;
            this.btnDeviceName = btnDeviceName;
            this.btnRoomName = btnRoomName;
            this.btnCollectionIcon = btnCollectionIcon;
            this.comerom = comerom;
            this.action = action;
@@ -159,48 +166,132 @@
            {
                btnOpenCollectIcon.IsSelected = this.device.collect = !btnOpenCollectIcon.IsSelected;
                this.device.CollectFunction();
                btnCloseCollectIcon.IsSelected = btnOpenCollectIcon.IsSelected;
                this.btnCollectionIcon.IsSelected = btnOpenCollectIcon.IsSelected;
            };
            //首页
            shouyeFL.SetClickListener((fl, btnImage, btnText) => { });
            shouyeFL.SetClickListener((fl, btnImage, btnText) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.home_page, "");
            });
            //关机
            kaiguanFL.SetClickListener((fl, btnImage, btnText) =>
            {
                vv.Visible = false;
                baseCloseFFL.Visible = true;
                ControlCommand(HisenseTVFunctionalAttributeConstant.on_off, "off", (isBool) =>
                {
                    if (isBool)
                    {
                        CommonMethod.Current.MainThread(() =>
                        {
                            vv.Visible = false;
                            baseCloseFFL.Visible = true;
                        });
                    }
                    else
                    {
                        //提示:关机失败;
                    }
                });
            });
            //菜单
            caidanFL.SetClickListener((fl, btnImage, btnText) => { });
            caidanFL.SetClickListener((fl, btnImage, btnText) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "11");
            });
            //音量+
            btn_jia.MouseDownEventHandler += (sender, e) => { };
            btn_jia.MouseDownEventHandler += (sender, e) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.volume_add, "");
            };
            //音量-
            btn_jian.MouseDownEventHandler += (sender, e) => { };
            btn_jian.MouseDownEventHandler += (sender, e) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.volume_subtract, "");
            };
            //播放
            bofangBtn.SetClickListener((btn) => { });
            bofangBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.media_play, "");
            });
            //暂停
            zantingBtn.SetClickListener((btn) => { });
            zantingBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.media_pause, "");
            });
            //快进
            kuaijinBtn.SetClickListener((btn) => { });
            kuaijinBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.fast_forward, "");
            });
            //快退
            kauituiBtn.SetClickListener((btn) => { });
            kauituiBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.fast_back, "");
            });
            //静音
            jingyinBtn.SetClickListener((btn) => { });
            jingyinBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.mute, "1");
            });
            //设置
            shezhiBtn.SetClickListener((btn) => { });
            shezhiBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.system_setting, "");
            });
            //解除静音
            jiechujingyinBtn.SetClickListener((btn) => { });
            jiechujingyinBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.mute, "0");
            });
            //返回
            fanhuiBtn.SetClickListener((btn) => { });
            //控制菜单
            fanhuiBtn.SetClickListener((btn) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "5");
            });
            //上
            muenFrameLayout.SetTopClickListener((muen) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "0");
            });
            //下
            muenFrameLayout.SetBottomClickListener((muen) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "1");
            });
            //左
            muenFrameLayout.SetLeftClickListener((muen) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "2");
            });
            //右
            muenFrameLayout.SetRightClickListener((muen) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "3");
            });
            //OK
            muenFrameLayout.SetOkClickListener((muen) =>
            {
                ControlCommand(HisenseTVFunctionalAttributeConstant.operation, "4");
            });
            //信号源
            sourceFrameLayout.selectAction += (text) =>
            {
                string value = text.Replace(" ", "_");
                ControlCommand(HisenseTVFunctionalAttributeConstant.signal, value);
            };
@@ -209,17 +300,49 @@
            {
                btnCloseCollectIcon.IsSelected = this.device.collect = !btnCloseCollectIcon.IsSelected;
                this.device.CollectFunction();
                btnOpenCollectIcon.IsSelected = btnCloseCollectIcon.IsSelected;
                this.btnCollectionIcon.IsSelected = btnCloseCollectIcon.IsSelected;
            };
            //开机
            clickBtn.MouseDownEventHandler += (sen, e) =>
            {
                vv.Visible = true;
                baseCloseFFL.Visible = false;
                ControlCommand(HisenseTVFunctionalAttributeConstant.on_off, "on", (isBool) =>
                {
                    if (isBool)
                    {
                        CommonMethod.Current.MainThread(() =>
                        {
                            vv.Visible = true;
                            baseCloseFFL.Visible = false;
                        });
                    }
                    else
                    {
                        //提示:开机失败;
                    }
                });
            };
        }
        /// <summary>
        /// 初始数据
        /// 发送控制属性指令
        /// </summary>
        /// <param name="key">功能属性(语雀上定义的)</param>
        /// <param name="value">值</param>
        /// <param name="action">结果回调(默认不回调)</param>
        private void ControlCommand(string key, string value, Action<bool> action = null)
        {
            try
            {
                Dictionary<string, string> dic = new Dictionary<string, string>();
                dic.Add(key, value);
                Send.Current.SendControlCommand(this.device, dic, action);
            }
            catch { }
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void ReadData()
        {
@@ -242,6 +365,8 @@
                }
            });
        }
        #region   -------界面布局---------
        /// <summary>
        /// 初始化【开机】界面
        /// </summary>
@@ -316,7 +441,7 @@
            shouyeFL.AddImageView();
            shouyeFL.AddTextButtonView();
            shouyeFL.GetImageButton().UnSelectedImagePath = "HisenseTv/shouye.png";
            shouyeFL.GetTextButton().Text = "首页";
            shouyeFL.GetTextButton().TextID = StringId.shouye;
            kaiguanFL = new CustomFrameLayout();
@@ -326,7 +451,7 @@
            kaiguanFL.AddImageView();
            kaiguanFL.AddTextButtonView();
            kaiguanFL.GetImageButton().UnSelectedImagePath = "HisenseTv/kaiguan.png";
            kaiguanFL.GetTextButton().Text = "关机";
            kaiguanFL.GetTextButton().TextID = StringId.guanji;
            caidanFL = new CustomFrameLayout();
            backgroundOpenFl.AddChidren(caidanFL);
@@ -335,7 +460,7 @@
            caidanFL.AddImageView();
            caidanFL.AddTextButtonView();
            caidanFL.GetImageButton().UnSelectedImagePath = "HisenseTv/caidan.png";
            caidanFL.GetTextButton().Text = "菜单";
            caidanFL.GetTextButton().TextID = StringId.caidan;
            var yinliangFL = new FrameLayout();
            backgroundOpenFl.AddChidren(yinliangFL);
@@ -360,7 +485,8 @@
            {
                Y = Application.GetRealHeight(90),
                Height = Application.GetRealHeight(20),
                Text = "音量",
                //Text = "音量",
                TextID = StringId.yinliang,
                TextColor = MusicColor.TextColor,
                TextSize = TextSize.Text14,
                Gravity = Gravity.CenterHorizontal,
@@ -389,28 +515,28 @@
            };
            bofangBtn = new CustomButton();
            bofangBtn.Text = "播放";
            bofangBtn.TextID = StringId.bofang;
            bofangBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(24);
            bofangBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(bofangBtn);
            zantingBtn = new CustomButton();
            zantingBtn.Text = "暂停";
            zantingBtn.TextID = StringId.zanting;
            zantingBtn.Y = shouyeFL.Bottom + Application.GetRealHeight(24);
            zantingBtn.X = bofangBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(zantingBtn);
            kuaijinBtn = new CustomButton();
            kuaijinBtn.Text = "快进";
            kuaijinBtn.TextID = StringId.kuaijin;
            kuaijinBtn.Y = bofangBtn.Bottom + Application.GetRealHeight(16);
            kuaijinBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(kuaijinBtn);
            kauituiBtn = new CustomButton();
            kauituiBtn.Text = "快退";
            kauituiBtn.TextID = StringId.kuaitui;
            kauituiBtn.Y = bofangBtn.Bottom + Application.GetRealHeight(16);
            kauituiBtn.X = kuaijinBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(kauituiBtn);
@@ -419,14 +545,14 @@
            jingyinBtn = new CustomButton();
            jingyinBtn.Text = "静音";
            jingyinBtn.TextID = StringId.jingyin;
            jingyinBtn.Y = kuaijinBtn.Bottom + Application.GetRealHeight(16);
            jingyinBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(jingyinBtn);
            shezhiBtn = new CustomButton();
            shezhiBtn.Text = "设置";
            shezhiBtn.TextID = StringId.shezhi;
            shezhiBtn.Y = kuaijinBtn.Bottom + Application.GetRealHeight(16);
            shezhiBtn.X = jingyinBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(shezhiBtn);
@@ -434,14 +560,14 @@
            jiechujingyinBtn = new CustomButton();
            jiechujingyinBtn.Text = "解除静音";
            jiechujingyinBtn.TextID = StringId.jiechujingyin;
            jiechujingyinBtn.Y = jingyinBtn.Bottom + Application.GetRealHeight(16);
            jiechujingyinBtn.X = yinliangFL.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(jiechujingyinBtn);
            fanhuiBtn = new CustomButton();
            fanhuiBtn.Text = "返回";
            fanhuiBtn.TextID = StringId.fanhui;
            fanhuiBtn.Y = jingyinBtn.Bottom + Application.GetRealHeight(16);
            fanhuiBtn.X = jiechujingyinBtn.Right + Application.GetRealWidth(37);
            backgroundOpenFl.AddChidren(fanhuiBtn);
@@ -566,7 +692,8 @@
                Height = Application.GetRealHeight(22),
                TextSize = TextSize.Text16,
                TextColor = MusicColor.TextColor,
                Text = "已关机",
                //Text = "已关机",
                TextID = StringId.yiguanji,
                TextAlignment = TextAlignment.Center,
                Gravity = Gravity.CenterHorizontal,
                Padding = new Padding(0, 16, 0, 16),
@@ -599,7 +726,7 @@
                Height = Application.GetRealHeight(16),
                TextSize = TextSize.Text12,
                TextColor = MusicColor.TextCancelColor,
                Text = "开机",
                TextID = StringId.kaiji,
                TextAlignment = TextAlignment.Center,
                Gravity = Gravity.CenterHorizontal,
                Padding = new Padding(0, 2, 0, 2),
@@ -618,7 +745,7 @@
        /// <summary>
        /// 初始化头部
        /// </summary>
        private void InitTopUI()
        private void InitTopUI()
        {
            this.BackgroundColor = MusicColor.ViewColor;
            this.topView = new TopView();
@@ -627,29 +754,32 @@
            this.AddChidren(topView.TopFLayoutView());
        }
        /// <summary>
        /// 根据设备开关状态显示指定显示界面
        /// 根据设备开关状态显示指定界面
        /// (进来的时候用到)
        /// </summary>
        /// <returns></returns>
        private void CurrentAssignPage()
        {
            CommonMethod.Current.MainThread(() =>
            {
            if (this.device == null)
            {
                vv.Visible = false;
                baseCloseFFL.Visible = true;
                return;
            }
            if (this.device.GetAttrState("on_off") == "on")
            {
                vv.Visible = true;
                baseCloseFFL.Visible = false;
            }
            else
            {
                vv.Visible = false;
                baseCloseFFL.Visible = true;
            }
                if (this.device == null)
                {
                    vv.Visible = false;
                    baseCloseFFL.Visible = true;
                    return;
                }
                if (this.device.GetAttrState("on_off") == "on" || this.device.GetAttrState("on_off") == "1")
                {
                    vv.Visible = true;
                    baseCloseFFL.Visible = false;
                }
                else
                {
                    vv.Visible = false;
                    baseCloseFFL.Visible = true;
                }
            });
        }
@@ -692,9 +822,11 @@
            }
            //this.cellFrame.X = this.btnCurrDeviceRoom.Right + Application.GetRealWidth(20);
        }
    }
        #endregion
    }
    #region   -------自定义当前界面的容器---------
    /// <summary>
    /// 自定义(首页,关机,菜单)容器
    /// </summary>
@@ -757,7 +889,7 @@
        {
            EventHandler<MouseEventArgs> DownClick = (sender, e) =>
            {
                this.BackgroundColor = 0xFFF2F3F7;
                //this.BackgroundColor = 0xFFF2F3F7;
                action?.Invoke(this, btnImage, btnText);
            };
            this.MouseDownEventHandler += DownClick;
@@ -767,7 +899,7 @@
            EventHandler<MouseEventArgs> UpClick = (sender, e) =>
             {
                 this.BackgroundColor = 0x00000000;
                 //this.BackgroundColor = 0x00000000;
             };
            this.MouseUpEventHandler += UpClick;
            btnImage.MouseUpEventHandler += UpClick;
@@ -1052,6 +1184,7 @@
                button.SetClickListener((btn) =>
                {
                    // MovieLibrary movieLibrary = new MovieLibrary();
                    selectAction?.Invoke(button.Text);
                });
                //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i)
@@ -1065,7 +1198,7 @@
        {
            return new List<string>
            {
                "HDML 1",
                "HDML 1",//" "
                "HDML 2",
                "HDML 3",
                "HDML 4",
@@ -1078,6 +1211,6 @@
    }
    #endregion
}