黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBrightnessAdjustForm.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DevicePanel
{
    public class PanelBrightnessAdjustForm : EditorCommonForm
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DevicePanel
{
    public class PanelBrightnessAdjustForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
        /// <summary>
@@ -14,7 +14,7 @@
        /// <summary>
        /// 面板的回路
        /// </summary>
        private Panel panelDevice;
        private Panel panelDevice;
        /// <summary>
        /// 设备的某一回路
        /// </summary>
@@ -34,7 +34,7 @@
        /// <summary>
        /// 按键的颜色数据
        /// </summary>
        private Panel.KeyColorData keyColorData = null;
        private Panel.KeyColorData keyColorData = null;
        /// <summary>
        /// 选择睡眠时间的事件 value:索引(从0开始)  文本信息请用Text获取
        /// </summary>
@@ -56,11 +56,11 @@
        /// <summary>
        ///睡眠时间 
        /// </summary>
        public NormalViewControl btnSleepTime = null;
        public NormalViewControl btnSleepTime = null;
        #endregion
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
@@ -68,14 +68,14 @@
        public void ShowForm(CommonDevice device)
        {
            //左滑使能不可
            this.ScrollEnabled = false;
            this.deviceObj = device;
            this.panelDevice = new Panel();
            this.panelDevice.DeviceAddr = this.deviceObj.DeviceAddr;
            this.panelDevice.DeviceEpoint = 200;
            this.panelDevice.CurrentGateWayId = this.deviceObj.CurrentGateWayId;
            //设置头部信息
            this.ScrollEnabled = false;
            this.deviceObj = device;
            this.panelDevice = new Panel();
            this.panelDevice.DeviceAddr = this.deviceObj.DeviceAddr;
            this.panelDevice.DeviceEpoint = 200;
            this.panelDevice.CurrentGateWayId = this.deviceObj.CurrentGateWayId;
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uLightRegulation));
            //初始化中部信息
@@ -99,24 +99,24 @@
            listview = new VerticalScrolViewLayout();
            listview.Height = Application.GetRealHeight(1981 - 184);
            bodyFrameLayout.AddChidren(listview);
            bodyFrameLayout.AddChidren(listview);
            HdlThreadLogic.Current.RunMain(() =>
            {
                //添加节能模式控件
                this.AddEnergyConservationRow();
                //添加屏幕亮度级别控件
                this.AddScreenBrightnesLevelControl();
                //获取设备类型的
                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { deviceObj });
                if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleEnvironment)
                {
                    //添加面板的颜色
                    this.AddColorControl();
                }
                this.AddScreenBrightnesLevelControl();
                //获取设备类型的
                var deviceEnumInfo = HdlDeviceCommonLogic.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { deviceObj });
                if (deviceEnumInfo.ConcreteType != DeviceConcreteType.ButtonPanel_SimpleEnvironment)
                {
                    //添加面板的颜色
                    this.AddColorControl();
                }
                this.FinishInitControl(listview, energyModeInfo.enable);
                //保存
@@ -140,7 +140,7 @@
        private void AddScreenBrightnesLevelControl()
        {
            var btnEspace = new NormalViewControl(600, 58, true);
            btnEspace.X = ControlCommonResourse.XXLeft;
            btnEspace.X = HdlControlResourse.XXLeft;
            listview.AddChidren(btnEspace);
            var frameBack = new FrameLayout();
@@ -151,7 +151,7 @@
            //屏幕亮度级别
            var btnLevelView = new NormalViewControl(400, 60, true);
            btnLevelView.X = ControlCommonResourse.XXLeft;
            btnLevelView.X = HdlControlResourse.XXLeft;
            btnLevelView.Y = Application.GetRealHeight(54);
            btnLevelView.TextID = R.MyInternationalizationString.uScreenBrightnesLevel;
            frameBack.AddChidren(btnLevelView);
@@ -167,7 +167,7 @@
            //当前亮度
            var btnProgressView1 = new NormalViewControl(200, 50, true);
            btnProgressView1.X = ControlCommonResourse.XXLeft;
            btnProgressView1.X = HdlControlResourse.XXLeft;
            btnProgressView1.Y = Application.GetRealHeight(157);
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
@@ -279,7 +279,7 @@
            }
            var btnTemp1 = new NormalViewControl(200, 50, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
            btnTemp1.X = HdlControlResourse.XXLeft;
            btnTemp1.Y = Application.GetRealHeight(322);
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
@@ -287,7 +287,7 @@
            frameBack.AddChidren(btnTemp1);
            var btnTemp2 = new NormalViewControl(100, 50, true);
            btnTemp2.X = frameBack.Width - ControlCommonResourse.XXLeft - Application.GetRealWidth(100);
            btnTemp2.X = frameBack.Width - HdlControlResourse.XXLeft - Application.GetRealWidth(100);
            btnTemp2.Y = Application.GetRealHeight(322);
            btnTemp2.TextAlignment = TextAlignment.CenterRight;
            btnTemp2.TextSize = 12;
@@ -305,7 +305,7 @@
        private void AddColorControl()
        {
            var btnEspace = new NormalViewControl(600, 58, true);
            btnEspace.X = ControlCommonResourse.XXLeft;
            btnEspace.X = HdlControlResourse.XXLeft;
            listview.AddChidren(btnEspace);
            //背景
@@ -317,7 +317,7 @@
            //背光灯颜色
            var btnLevelView = new NormalViewControl(400, 60, true);
            btnLevelView.X = ControlCommonResourse.XXLeft;
            btnLevelView.X = HdlControlResourse.XXLeft;
            btnLevelView.Y = Application.GetRealHeight(54);
            btnLevelView.Gravity = Gravity.CenterVertical;
            btnLevelView.TextID = R.MyInternationalizationString.BackgroundLightColor;
@@ -327,8 +327,8 @@
            frameColor.UseClickStatu = false;
            frameColor.Width = Application.GetRealHeight(262);
            frameColor.Height = this.GetPictrueRealSize(79);
            frameColor.Gravity = Gravity.CenterVertical;
            frameColor.X = frameBack.Width - ControlCommonResourse.XXLeft - Application.GetRealHeight(262);
            frameColor.Y = Application.GetRealHeight(26);
            frameColor.X = listview.Width - HdlControlResourse.XXLeft - Application.GetRealHeight(262);
            frameBack.AddChidren(frameColor);
            //颜色
@@ -346,21 +346,25 @@
            int B1 = Convert.ToInt32(this.keyColorData.OpenColorB, 16);
            uint backColor = this.GetColorByRGB((byte)R1, (byte)G1, (byte)B1);
            //颜色外框
            var btnColorLine = new FrameLayoutStatuControl();
            btnColorLine.Width = Application.GetRealHeight(79);
            btnColorLine.Height = this.GetPictrueRealSize(79);
            btnColorLine.X = btnColorView.Right + Application.GetRealHeight(18);
            btnColorLine.Radius = (uint)this.GetPictrueRealSize(79) / 2;
            btnColorLine.BorderWidth = 1;
            btnColorLine.BorderColor = 0xffcccccc;
            frameColor.AddChidren(btnColorLine, ChidrenBindMode.BindEvent);
            //颜色外框
            var frameColorLine = new FrameLayoutStatuControl();
            frameColorLine.UseClickStatu = false;
            frameColorLine.Height = this.GetPictrueRealSize(79);
            frameColorLine.Width = this.GetPictrueRealSize(79);
            frameColorLine.X = btnColorView.Right + Application.GetRealHeight(18);
            frameColorLine.Radius = (uint)this.GetPictrueRealSize(79) / 2;
            frameColorLine.BorderWidth = 1;
            frameColorLine.BorderColor = 0xffcccccc;
            frameColor.AddChidren(frameColorLine, ChidrenBindMode.NotBind);
            var btnColor = new NormalViewControl(this.GetPictrueRealSize(69), this.GetPictrueRealSize(69), false);
            //分两步计算,不然有可能它得出的结果有误差导致不居中
            int btnColorWidth = frameColorLine.Height - this.GetPictrueRealSize(7) - this.GetPictrueRealSize(7);
            var btnColor = new NormalViewControl(btnColorWidth, btnColorWidth, false);
            btnColor.Gravity = Gravity.Center;
            btnColor.Radius = (uint)this.GetPictrueRealSize(69) / 2;
            btnColor.Radius = (uint)btnColorWidth / 2;
            btnColor.BackgroundColor = backColor;
            btnColorLine.AddChidren(btnColor, ChidrenBindMode.BindEvent);
            frameColorLine.AddChidren(btnColor, ChidrenBindMode.NotBind);
            frameColor.ChangedChidrenBindMode(frameColorLine, ChidrenBindMode.BindEvent);
            var btnRight = new NormalViewControl(this.GetPictrueRealSize(58), this.GetPictrueRealSize(58), false);
            btnRight.UnSelectedImagePath = "Item/RightNext.png";
@@ -371,47 +375,22 @@
            frameColor.ButtonClickEvent += (sender, e) =>
            {
                PanelColor(btnColor, R1, G1, B1);
            };
            btnColorView.ButtonClickEvent += (sender, e) =>
            {
                PanelColor(btnColor, R1, G1, B1);
            };
            btnColor.ButtonClickEvent += (sender, e) =>
            {
                PanelColor(btnColor, R1, G1, B1);
            };
            btnColorLine.ButtonClickEvent += (sender, e) =>
            {
                PanelColor(btnColor, R1, G1, B1);
            };
            btnRight.ButtonClickEvent += (sender, e) =>
            {
                PanelColor(btnColor, R1, G1, B1);
                var form = new PanelColorSelectForm();
                form.AddForm(R1, G1, B1);
                form.FinishSelectColorEvent += (Rcolor, Gcolor, Bcolor) =>
                {
                    R1 = Rcolor;
                    G1 = Gcolor;
                    B1 = Bcolor;
                    this.keyColorData.OpenColorR = Convert.ToString(Rcolor, 16);
                    this.keyColorData.OpenColorG = Convert.ToString(Gcolor, 16);
                    this.keyColorData.OpenColorB = Convert.ToString(Bcolor, 16);
                    btnColor.BackgroundColor = this.GetColorByRGB((byte)Rcolor, (byte)Gcolor, (byte)Bcolor);
                };
            };
        }
        /// <summary>
        /// PanelColorSelectForm
        /// </summary>
        private void PanelColor(NormalViewControl btnColor, int R1, int G1, int B1)
        {
            var form = new PanelColorSelectForm();
            form.AddForm(R1, G1, B1);
            form.FinishSelectColorEvent += (Rcolor, Gcolor, Bcolor) =>
            {
                R1 = Rcolor;
                G1 = Gcolor;
                B1 = Bcolor;
                this.keyColorData.OpenColorR = Convert.ToString(Rcolor, 16);
                this.keyColorData.OpenColorG = Convert.ToString(Gcolor, 16);
                this.keyColorData.OpenColorB = Convert.ToString(Bcolor, 16);
                btnColor.BackgroundColor = this.GetColorByRGB((byte)Rcolor, (byte)Gcolor, (byte)Bcolor);
            };
        }
        #endregion
        #region ■ 节能模式行_________________________ 
@@ -455,7 +434,7 @@
            //当前亮度
            var btnProgressView1 = new NormalViewControl(200, 49, true);
            btnProgressView1.X = ControlCommonResourse.XXLeft;
            btnProgressView1.X = HdlControlResourse.XXLeft;
            btnProgressView1.Y = Application.GetRealHeight(164);
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
@@ -489,7 +468,7 @@
            seekBar1.Progress = energyModeInfo.level;
            var btnTemp1 = new NormalViewControl(200, 49, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
            btnTemp1.X = HdlControlResourse.XXLeft;
            btnTemp1.Y = Application.GetRealHeight(325);
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
@@ -540,9 +519,9 @@
            frameBack.UseClickStatu = false;
            frameBack.Y = Application.GetRealHeight(443);
            frameBack.Height = Application.GetRealHeight(170);
            frameRowControl.AddChidren(frameBack);
            //接近感应
            frameRowControl.AddChidren(frameBack);
            //接近感应
            frameBack.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.ProximitySensors), 400);
            //开关控件
            var btnSwitch = frameBack.AddMostRightSwitchIcon();
@@ -571,13 +550,13 @@
            frameBack.BackgroundColor = UserCenterColor.Current.White;
            frameBack.UseClickStatu = false;
            frameBack.Y = Application.GetRealHeight(784 - 170);
            frameBack.Height = Application.GetRealHeight(170);
            frameBack.Height = Application.GetRealHeight(170);
            frameRowControl.AddChidren(frameBack);
            //睡眠时间
            frameBack.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.SleepTime), 400);
            //右箭头
            frameBack.AddRightArrow();
            frameBack.AddRightArrow();
            btnSleepTime = new NormalViewControl(700, true);
            switch (energyModeInfo.time)
            {
@@ -593,28 +572,28 @@
                    btnSleepTime.Text = "5min";
                    nowSelectNo = 2;
                    break;
            }
            }
            frameBack.AddMostRightView(this.sleepTimeText, 700);
            timeAction = null;
            timeAction += (nowSelectNo) =>
            {
                switch (nowSelectNo)
                {
                    case 0:
                        energyModeInfo.time = 15;
                        break;
                    case 1:
                        energyModeInfo.time = 60;
                        break;
                    case 2:
                        energyModeInfo.time = 300;
                        break;
                }
            timeAction += (nowSelectNo) =>
            {
                switch (nowSelectNo)
                {
                    case 0:
                        energyModeInfo.time = 15;
                        break;
                    case 1:
                        energyModeInfo.time = 60;
                        break;
                    case 2:
                        energyModeInfo.time = 300;
                        break;
                }
                AddSleepTimeRow(frameRowControl);
            };
            frameBack.ButtonClickEvent += (sender, e) =>
            {
            {
                this.ShowSelectDeviceSleepTimeListForm();
            };
        }
@@ -635,7 +614,7 @@
            var form = new BottomItemSelectForm();
            form.CancelCallEvent = false;//允许取消
            form.AddForm(title, listText, nowSelectNo);
            form.AddForm(title, listText, null, nowSelectNo);
            form.FinishSelectEvent += (selectNo) =>
            {
                if (selectNo == nowSelectNo)
@@ -645,8 +624,8 @@
                }
                //-1:选择取消
                this.sleepTimeText = selectNo == -1 ? string.Empty : listText[selectNo];
                nowSelectNo = selectNo;
                //调用回调函数
                nowSelectNo = selectNo;
                //调用回调函数
                this.timeAction?.Invoke(nowSelectNo);
            };
        }
@@ -709,10 +688,10 @@
        /// </summary>
        private async void SavePanelData()
        {
            this.ShowProgressBar();
            //节能模式修改(他们说随便一个回路就行)
            this.ShowProgressBar();
            //节能模式修改(他们说随便一个回路就行)
            var result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
            if (result == false)
            {
@@ -784,8 +763,8 @@
        private uint GetColorByRGB(byte R, byte G, byte B)
        {
            return (uint)(0xFF000000 + R * 256 * 256 + G * 256 + B);
        }
        }
        #endregion
    }
}
    }
}