陈嘉乐
2021-03-30 003abaf86b766eb40ef62300ab0c707774c36ba9
HDL_ON/UI/UI2/FuntionControlView/Electrical/TVPage.cs
@@ -2,12 +2,15 @@
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
namespace HDL_ON.UI
{
    public partial class TVPage : FrameLayout
    {
        #region 控件集合
        static TVPage bodyView;
        TVPage bodyView;
        /// <summary>
        /// 功能名称按钮
        /// </summary>
@@ -20,16 +23,31 @@
        /// 收藏按钮
        /// </summary>
        Button btnCollection;
        /// <summary>
        /// 图标按钮
        /// </summary>
        Button btnSwitchIcon;
        Button btnSwitch;
        Button btnChangeTVAV;
        FrameLayout topMenuView;
        Button btnTopMenuUp;
        Button btnTopMenuLeft;
        Button btnTopMenuRight;
        Button btnTopMenuDown;
        Button btnOk;
        FrameLayout channleView;
        Button btnChlReduce;
        Button btnChlPlus;
        FrameLayout volView;
        Button btnVolReduce;
        Button btnVolPlus;
        Button btnBack;
        Button btnMenu;
        Button btn123;
        Button btnMute;
        Button btnPower;
        #endregion
        #region 区域变量
        TV tv;
        TV tvTemp = new TV();
        Function function;
        Button btnCollection_Out;
        Button btnFunctionName_Out;
        Button btnFromFloor_Out;
@@ -42,7 +60,7 @@
        public TVPage(Function func)
        {
            bodyView = this;
            tv = func as TV;
            function = func;
        }
@@ -72,7 +90,7 @@
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel,
                Text = tv.name,
                Text = function.name,
            };
            controlView.AddChidren(btnFunctionName);
@@ -85,7 +103,7 @@
                TextColor = CSS_Color.PromptingColor1,
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                Text = tv.GetRoomListName()
                Text = function.GetRoomListName()
            };
            controlView.AddChidren(btnFromFoorAndRoom);
@@ -97,16 +115,334 @@
                Height = Application.GetMinRealAverage(40),
                SelectedImagePath = "Collection/CollectionIcon.png",
                UnSelectedImagePath = "Collection/CollectionGrayIcon.png",
                IsSelected = tv.collection
                IsSelected = function.collect
            };
            controlView.AddChidren(btnCollection);
            //controlView.AddChidren(btnCollection);
            //2020-12-16 如果是成员隐藏收藏功能
            if (!DB_ResidenceData.Instance.CurrentRegion.IsOthreShare)
            {
                controlView.AddChidren(btnCollection);
            }
            #region 轮盘控制区域
            topMenuView = new FrameLayout()
            {
                Y = Application.GetRealHeight(88),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(199),
                Height = Application.GetRealWidth(199),
                BackgroundImagePath = "FunctionIcon/Electrical/TV/TVOkIcon.png",
            };
            controlView.AddChidren(topMenuView);
            btnTopMenuUp = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealWidth(50),
            };
            topMenuView.AddChidren(btnTopMenuUp);
            btnTopMenuLeft = new Button()
            {
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(50),
                Height = Application.GetRealWidth(80),
            };
            topMenuView.AddChidren(btnTopMenuLeft);
            btnTopMenuRight = new Button()
            {
                X = Application.GetRealWidth(150),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(50),
                Height = Application.GetRealWidth(80),
            };
            topMenuView.AddChidren(btnTopMenuRight);
            btnTopMenuDown = new Button()
            {
                Y = Application.GetRealWidth(150),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(80),
                Height = Application.GetRealWidth(50),
            };
            topMenuView.AddChidren(btnTopMenuDown);
            btnOk = new Button()
            {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealWidth(100),
            };
            topMenuView.AddChidren(btnOk);
            #endregion
            #region 频道音量调节
            channleView = new FrameLayout()
            {
                X = Application.GetRealWidth(26),
                Y = Application.GetRealHeight(246),
                Width = Application.GetRealWidth(44),
                Height = Application.GetRealWidth(102),
                BackgroundImagePath = "FunctionIcon/Electrical/TV/MenuBgIcon.png",
            };
            controlView.AddChidren(channleView);
            btnChlPlus = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(10),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/PlusIcon.png"
            };
            channleView.AddChidren(btnChlPlus);
            Button btnChlText;
            btnChlText = new Button()
            {
                Gravity = Gravity.CenterVertical,
                Height = Application.GetRealWidth(23),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.Chl,
            };
            channleView.AddChidren(btnChlText);
            btnChlReduce = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(66),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/ReduceIcon.png"
            };
            channleView.AddChidren(btnChlReduce);
            volView = new FrameLayout()
            {
                X = Application.GetRealWidth(257),
                Y = Application.GetRealHeight(246),
                Width = Application.GetRealWidth(44),
                Height = Application.GetRealWidth(102),
                BackgroundImagePath = "FunctionIcon/Electrical/TV/MenuBgIcon.png",
            };
            controlView.AddChidren(volView);
            btnVolPlus = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(10),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/PlusIcon.png"
            };
            volView.AddChidren(btnVolPlus);
            Button btnVolText;
            btnVolText = new Button()
            {
                Gravity = Gravity.CenterVertical,
                Height = Application.GetRealWidth(23),
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextID = StringId.Vol,
            };
            volView.AddChidren(btnVolText);
            btnVolReduce = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(66),
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/ReduceIcon.png"
            };
            volView.AddChidren(btnVolReduce);
            #endregion
            #region 底部控制区域
            btnBack = new Button()
            {
                X = Application.GetRealWidth(52),
                Y = Application.GetRealHeight(402),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVBackIcon.png",
            };
            controlView.AddChidren(btnBack);
            btnChangeTVAV = new Button()
            {
                X = Application.GetRealWidth(116),
                Y = Application.GetRealHeight(402),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVAV.png",
            };
            controlView.AddChidren(btnChangeTVAV);
            btn123 = new Button()
            {
                X = Application.GetRealWidth(180),
                Y = Application.GetRealHeight(402),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TV123Icon.png",
            };
            controlView.AddChidren(btn123);
            btnMute = new Button()
            {
                X = Application.GetRealWidth(244),
                Y = Application.GetRealHeight(402),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVMuteIcon.png",
            };
            controlView.AddChidren(btnMute);
            btnMenu = new Button()
            {
                X = Application.GetRealWidth(116),
                Y = Application.GetRealHeight(466),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVMenuIcon.png",
            };
            controlView.AddChidren(btnMenu);
            btnPower = new Button()
            {
                X = Application.GetRealWidth(180),
                Y = Application.GetRealHeight(466),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "FunctionIcon/Electrical/TV/TVPowerIcon.png",
            };
            controlView.AddChidren(btnPower);
            #endregion
            LoadEventList();
            new TopViewDiv(bodyView, Language.StringByID(StringId.Fan)).LoadTopView(tv, actionRefresh);
            new TopViewDiv(bodyView, Language.StringByID(StringId.TV)).LoadTopView_FunctionTop(function, actionRefresh);
            DriverLayer.Control.Ins.SendReadCommand(function);
        }
        void ShowNumberView()
        {
            Dialog dialog = new Dialog();
            FrameLayout dialogView = new FrameLayout()
            {
                AnimateSpeed = 0.3f,
                Animate = Animate.DownToUp,
            };
            dialog.AddChidren(dialogView);
            dialogView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            FrameLayout numberView = new FrameLayout()
            {
                Y = Application.GetRealHeight(403),
                Height = Application.GetRealHeight(264),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            dialogView.AddChidren(numberView);
            for (int i = 0; i < 10; i++)
            {
                Button btn = new Button()
                {
                    Width = Application.GetRealWidth(98),
                    Height = Application.GetRealHeight(44),
                    Radius = (uint)Application.GetRealWidth(8),
                    BorderWidth = (uint)Application.GetRealWidth(1),
                    BorderColor = CSS_Color.PromptingColor1,
                    BackgroundColor  = CSS_Color.MainBackgroundColor,
                    SelectedBackgroundColor = CSS_Color.MainColor,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    SelectedTextColor = CSS_Color.MainBackgroundColor,
                    IsBold = true,
                    Text = i.ToString(),
                    TextAlignment = TextAlignment.Center,
                };
                if (i == 1 || i == 4 || i == 7)
                {
                    btn.X = Application.GetRealWidth(24);
                }
                else if (i == 2 || i == 5 || i == 8)
                {
                    btn.X = Application.GetRealWidth(138);
                }
                else if (i == 3 || i == 6 || i == 9)
                {
                    btn.X = Application.GetRealWidth(252);
                }
                else
                {
                    btn.X = Application.GetRealWidth(138);
                }
                if (i == 0)
                {
                    btn.Y = Application.GetRealHeight(204);
                }
                else if (i < 4)
                {
                    btn.Y = Application.GetRealHeight(24);
                }
                else if (i<7)
                {
                    btn.Y = Application.GetRealHeight(84);
                }
                else
                {
                    btn.Y = Application.GetRealHeight(144);
                }
                numberView.AddChidren(btn);
                btn.MouseUpEventHandler = (sender, e) => {
                    string index = (sender as  Button ).Text;
                    btn.IsSelected = false;
                    if (DB_ResidenceData.Instance.GatewayType == 1)
                    {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add($"number_{index}", "");
                        Control.Ins.SendWriteCommand(function, d);
                    }
                    else
                    {
                        tvTemp.ControlTV(i, function);
                    }
                };
                btn.MouseDownEventHandler = (sender, e) => {
                    btn.IsSelected = true;
                };
            }
            dialog.Show();
        }
    }
}