陈嘉乐
2020-07-10 48ba446936b51fffafa7c3600c0dadc6ac0e8c20
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelBackLightSettionForm.cs
old mode 100644 new mode 100755
@@ -40,7 +40,7 @@
        /// <param name="i_listdevice">面板设备的全部回路</param>
        public void ShowForm(Panel i_panel)
        {
            UserView.HomePage.Instance.ScrollEnabled = false;
            this.ScrollEnabled = false;
            this.panelDevice = i_panel;
@@ -57,10 +57,10 @@
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private async void InitMiddleFrame()
        private void InitMiddleFrame()
        {
            //获取设备初始数据
            var result = await this.GetDeviceDefultData();
            var result = this.GetDeviceDefultData();
            if (result == false)
            {
                return;
@@ -112,6 +112,10 @@
            frameBack.Height = Application.GetRealHeight(170);
            bodyFrameLayout.AddChidren(frameBack);
            //当前亮度(先声明,为了对应IOS的折叠后,没有完全遮挡的问题)
            var btnProgressView1 = new NormalViewControl(200, 49, true);
            var btnProgress1 = new NormalViewControl(200, 49, true);
            //节能模式
            frameBack.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uEnergyConservationMode), 400);
            //开关控件
@@ -126,11 +130,15 @@
                {
                    frameBack.Height += value;
                    frameLinght.Y += value;
                    btnProgressView1.Visible = true;
                    btnProgress1.Visible = true;
                }
                else
                {
                    frameBack.Height -= value;
                    frameLinght.Y -= value;
                    btnProgressView1.Visible = false;
                    btnProgress1.Visible = false;
                }
            };
            if (energyModeInfo.enable == true)
@@ -139,39 +147,33 @@
            }
            //当前亮度
            var btnProgressView1 = new NormalViewControl(200, 49, true);
            btnProgressView1.X = ControlCommonResourse.XXLeft;
            btnProgressView1.Y = Application.GetRealHeight(164);
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.TextID = R.MyInternationalizationString.uNowLuminance;
            frameBack.AddChidren(btnProgressView1);
            var btnProgress1 = new NormalViewControl(200, 49, true);
            btnProgressView1.Visible = false;
            btnProgress1.X = Application.GetRealWidth(222);
            btnProgress1.Y = Application.GetRealHeight(164);
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = energyModeInfo.level + "%";
            frameBack.AddChidren(btnProgress1);
            btnProgress1.Visible = false;
            //进度条
            var seekBar1 = new HorizontalSeekBar();
            var seekBar1 = new SeekBarControl();
            seekBar1.Y = Application.GetRealHeight(253);
            seekBar1.Gravity = Gravity.CenterHorizontal;
            seekBar1.Width = Application.GetRealWidth(962);
            seekBar1.Height = Application.GetRealHeight(81);
            seekBar1.Max = 100;
            seekBar1.BackgroundColor = 0xfff5f5f5;
            seekBar1.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
            seekBar1.ProgressColor = 0xff3e99f4;
            seekBar1.Progress = energyModeInfo.level;
            seekBar1.ProgressBarColor = 0xff3e99f4;
            frameBack.AddChidren(seekBar1);
            seekBar1.ProgressChanged += (sender, value) =>
            seekBar1.ProgressChangedEvent += (div, value) =>
            {
                btnProgress1.Text = value + "%";
                //数据变更
                energyModeInfo.level = value;
            };
            seekBar1.Progress = energyModeInfo.level;
            var btnTemp1 = new NormalViewControl(200, 49, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
@@ -196,6 +198,9 @@
                var value = Application.GetRealHeight(259);
                frameBack.Height += value;
                frameLinght.Y += value;
                btnProgressView1.Visible = true;
                btnProgress1.Visible = true;
            }
        }
@@ -236,27 +241,20 @@
            btnProgress1.Y = Application.GetRealHeight(52);
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = linghtLevelInfo.panelDirectionsLevel + "%";
            btnProgress1.Text = linghtLevelInfo.panelBacklightLevel + "%";
            frameBack.AddChidren(btnProgress1);
            //进度条
            var seekBar1 = new HorizontalSeekBar();
            var seekBar1 = new SeekBarControl();
            seekBar1.Y = Application.GetRealHeight(147);
            seekBar1.Gravity = Gravity.CenterHorizontal;
            seekBar1.Width = Application.GetRealWidth(962);
            seekBar1.Height = Application.GetRealHeight(81);
            seekBar1.Max = 100;
            seekBar1.BackgroundColor = 0xfff5f5f5;
            seekBar1.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
            seekBar1.ProgressColor = 0xfffdb500;
            seekBar1.Progress = linghtLevelInfo.panelDirectionsLevel;
            frameBack.AddChidren(seekBar1);
            seekBar1.ProgressChanged += (sender, value) =>
            seekBar1.ProgressChangedEvent += (div, value) =>
            {
                btnProgress1.Text = value + "%";
                //数据变更
                linghtLevelInfo.panelDirectionsLevel = value;
                linghtLevelInfo.panelBacklightLevel = value;
            };
            seekBar1.Progress = linghtLevelInfo.panelBacklightLevel;
            var btnTemp1 = new NormalViewControl(200, 49, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
@@ -275,37 +273,57 @@
            btnTemp2.Text = "100%";
            frameBack.AddChidren(btnTemp2);
            var frameColor = new FrameLayoutControl();
            var frameColor = new FrameLayoutStatuControl();
            frameColor.UseClickStatu = false;
            frameColor.Width = Application.GetRealHeight(262);
            frameColor.Height = Application.GetMinRealAverage(69);
            frameColor.Y = Application.GetRealHeight(41);
            frameColor.Height = this.GetPictrueRealSize(79);
            frameColor.Y = Application.GetRealHeight(26);
            frameColor.X = frameLinght.Width - ControlCommonResourse.XXLeft - Application.GetRealHeight(262);
            frameBack.AddChidren(frameColor);
            //颜色
            var btnColorView = new NormalViewControl(Application.GetRealHeight(110), Application.GetMinRealAverage(49), false);
            var btnColorView = new NormalViewControl(Application.GetRealHeight(110), this.GetPictrueRealSize(49), false);
            btnColorView.Gravity = Gravity.CenterVertical;
            btnColorView.TextAlignment = TextAlignment.CenterRight;
            btnColorView.TextSize = 12;
            btnColorView.Y = Application.GetRealHeight(5);
            btnColorView.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnColorView.TextID = R.MyInternationalizationString.uColor;
            frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEventOnly);
            frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEvent);
            int R1 = Convert.ToInt32(this.keyColorData.CloseColorR, 16);
            int G1 = Convert.ToInt32(this.keyColorData.CloseColorG, 16);
            int B1 = Convert.ToInt32(this.keyColorData.CloseColorB, 16);
            uint backColor = this.GetColorByRGB((byte)R1, (byte)G1, (byte)B1);
            var btnColor = new NormalViewControl(Application.GetMinRealAverage(69), Application.GetMinRealAverage(69), false);
            btnColor.X = btnColorView.Right + Application.GetRealHeight(23);
            btnColor.Radius = (uint)Application.GetMinRealAverage(69) / 2;
            btnColor.BackgroundColor = backColor;
            frameColor.AddChidren(btnColor, ChidrenBindMode.BindEventOnly);
            var btnRight = new NormalViewControl(Application.GetMinRealAverage(58), Application.GetMinRealAverage(58), false);
            btnRight.UnSelectedImagePath = "Item/Next.png";
            btnRight.X = frameColor.Width - Application.GetMinRealAverage(58);
            frameColor.AddChidren(btnRight, ChidrenBindMode.BindEventOnly);
            btnRight.Y += Application.GetMinRealAverage(8);
            //颜色外框
            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);
            //分两步计算,不然有可能它得出的结果有误差导致不居中
            int btnColorWidth = frameColorLine.Height - this.GetPictrueRealSize(7) - this.GetPictrueRealSize(7);
            var btnColor = new NormalViewControl(btnColorWidth, btnColorWidth, false);
            btnColor.Gravity = Gravity.Center;
            btnColor.Radius = (uint)btnColorWidth / 2;
            btnColor.BackgroundColor = backColor;
            frameColorLine.AddChidren(btnColor, ChidrenBindMode.NotBind);
            frameColor.ChangedChidrenBindMode(frameColorLine, ChidrenBindMode.BindEvent);
            //变更滑动条的颜色
            seekBar1.ProgressBarColor = backColor;
            var btnRight = new NormalViewControl(this.GetPictrueRealSize(58), this.GetPictrueRealSize(58), false);
            btnRight.UnSelectedImagePath = "Item/RightNext.png";
            btnRight.Y = Application.GetRealHeight(5);
            btnRight.X = frameColor.Width - this.GetPictrueRealSize(58);
            frameColor.AddChidren(btnRight, ChidrenBindMode.BindEvent);
            btnRight.Y += this.GetPictrueRealSize(8);
            frameColor.ButtonClickEvent += (sender, e) =>
            {
@@ -322,6 +340,8 @@
                    this.keyColorData.CloseColorB = Convert.ToString(Bcolor, 16);
                    btnColor.BackgroundColor = this.GetColorByRGB((byte)Rcolor, (byte)Gcolor, (byte)Bcolor);
                    //变更滑动条的颜色
                    seekBar1.ProgressBarColor = btnColor.BackgroundColor;
                };
            };
        }
@@ -363,27 +383,20 @@
            btnProgress1.Y = Application.GetRealHeight(52);
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = linghtLevelInfo.panelBacklightLevel + "%";
            btnProgress1.Text = linghtLevelInfo.panelDirectionsLevel + "%";
            frameBack.AddChidren(btnProgress1);
            //进度条
            var seekBar1 = new HorizontalSeekBar();
            var seekBar1 = new SeekBarControl();
            seekBar1.Y = Application.GetRealHeight(147);
            seekBar1.Gravity = Gravity.CenterHorizontal;
            seekBar1.Width = Application.GetRealWidth(962);
            seekBar1.Height = Application.GetRealHeight(81);
            seekBar1.Max = 100;
            seekBar1.BackgroundColor = 0xfff5f5f5;
            seekBar1.ThumbColor = Common.ZigbeeColor.Current.GXCButtonBlueColor;
            seekBar1.ProgressColor = 0xff2b62fd;
            seekBar1.Progress = linghtLevelInfo.panelBacklightLevel;
            frameBack.AddChidren(seekBar1);
            seekBar1.ProgressChanged += (sender, value) =>
            seekBar1.ProgressChangedEvent += (div, value) =>
            {
                btnProgress1.Text = value + "%";
                //数据变更
                linghtLevelInfo.panelBacklightLevel = value;
                linghtLevelInfo.panelDirectionsLevel = value;
            };
            seekBar1.Progress = linghtLevelInfo.panelDirectionsLevel;
            var btnTemp1 = new NormalViewControl(200, 49, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
@@ -402,37 +415,57 @@
            btnTemp2.Text = "100%";
            frameBack.AddChidren(btnTemp2);
            var frameColor = new FrameLayoutControl();
            var frameColor = new FrameLayoutStatuControl();
            frameColor.UseClickStatu = false;
            frameColor.Width = Application.GetRealHeight(262);
            frameColor.Height = Application.GetMinRealAverage(69);
            frameColor.Y = Application.GetRealHeight(41);
            frameColor.Height = this.GetPictrueRealSize(79);
            frameColor.Y = Application.GetRealHeight(26);
            frameColor.X = frameLinght.Width - ControlCommonResourse.XXLeft - Application.GetRealHeight(262);
            frameBack.AddChidren(frameColor);
            //颜色
            var btnColorView = new NormalViewControl(Application.GetRealHeight(110), Application.GetMinRealAverage(49), false);
            var btnColorView = new NormalViewControl(Application.GetRealHeight(110), this.GetPictrueRealSize(49), false);
            btnColorView.Gravity = Gravity.CenterVertical;
            btnColorView.TextAlignment = TextAlignment.CenterRight;
            btnColorView.TextSize = 12;
            btnColorView.Y = Application.GetRealHeight(5);
            btnColorView.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnColorView.TextID = R.MyInternationalizationString.uColor;
            frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEventOnly);
            frameColor.AddChidren(btnColorView, ChidrenBindMode.BindEvent);
            int R1 = Convert.ToInt32(this.keyColorData.OpenColorR, 16);
            int G1 = Convert.ToInt32(this.keyColorData.OpenColorG, 16);
            int B1 = Convert.ToInt32(this.keyColorData.OpenColorB, 16);
            uint backColor = this.GetColorByRGB((byte)R1, (byte)G1, (byte)B1);
            var btnColor = new NormalViewControl(Application.GetMinRealAverage(69), Application.GetMinRealAverage(69), false);
            btnColor.X = btnColorView.Right + Application.GetRealHeight(23);
            btnColor.Radius = (uint)Application.GetMinRealAverage(69) / 2;
            btnColor.BackgroundColor = backColor;
            frameColor.AddChidren(btnColor, ChidrenBindMode.BindEventOnly);
            var btnRight = new NormalViewControl(Application.GetMinRealAverage(58), Application.GetMinRealAverage(58), false);
            btnRight.UnSelectedImagePath = "Item/Next.png";
            btnRight.X = frameColor.Width - Application.GetMinRealAverage(58);
            frameColor.AddChidren(btnRight, ChidrenBindMode.BindEventOnly);
            btnRight.Y += Application.GetMinRealAverage(8);
            //颜色外框
            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);
            //分两步计算,不然有可能它得出的结果有误差导致不居中
            int btnColorWidth = frameColorLine.Height - this.GetPictrueRealSize(7) - this.GetPictrueRealSize(7);
            var btnColor = new NormalViewControl(btnColorWidth, btnColorWidth, false);
            btnColor.Gravity = Gravity.Center;
            btnColor.Radius = (uint)btnColorWidth / 2;
            btnColor.BackgroundColor = backColor;
            frameColorLine.AddChidren(btnColor, ChidrenBindMode.NotBind);
            frameColor.ChangedChidrenBindMode(frameColorLine, ChidrenBindMode.BindEvent);
            //变更滑动条的颜色
            seekBar1.ProgressBarColor = backColor;
            var btnRight = new NormalViewControl(this.GetPictrueRealSize(58), this.GetPictrueRealSize(58), false);
            btnRight.UnSelectedImagePath = "Item/RightNext.png";
            btnRight.Y = Application.GetRealHeight(5);
            btnRight.X = frameColor.Width - this.GetPictrueRealSize(58);
            frameColor.AddChidren(btnRight, ChidrenBindMode.BindEvent);
            btnRight.Y += this.GetPictrueRealSize(8);
            frameColor.ButtonClickEvent += (sender, e) =>
            {
@@ -448,7 +481,9 @@
                    this.keyColorData.OpenColorG = Convert.ToString(Gcolor, 16);
                    this.keyColorData.OpenColorB = Convert.ToString(Bcolor, 16);
                    btnColor.BackgroundColor= this.GetColorByRGB((byte)Rcolor, (byte)Gcolor, (byte)Bcolor);
                    btnColor.BackgroundColor = this.GetColorByRGB((byte)Rcolor, (byte)Gcolor, (byte)Bcolor);
                    //变更滑动条的颜色
                    seekBar1.ProgressBarColor = btnColor.BackgroundColor;
                };
            };
        }
@@ -461,12 +496,12 @@
        /// 获取设备初始数据
        /// </summary>
        /// <returns></returns>
        private async Task<bool> GetDeviceDefultData()
        private bool GetDeviceDefultData()
        {
            //开启进度条
            this.ShowProgressBar();
            //亮度调节(他们说随便拿一路回路就行了)
            linghtLevelInfo = await HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice);
            linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(panelDevice);
            if (linghtLevelInfo == null)
            {
                //关闭进度条
@@ -474,14 +509,14 @@
                return false;
            }
            //节能模式(他们说随便拿一路回路就行了)
            energyModeInfo = await HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice);
            energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(panelDevice);
            if (energyModeInfo == null)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return false;
            }
            keyColorData = await HdlDevicePanelLogic.Current.GetPanelEpointColorInfo(panelDevice);
            keyColorData = HdlDevicePanelLogic.Current.GetPanelEpointColorInfo(panelDevice);
            if (this.keyColorData == null)
            {
                //关闭进度条
@@ -501,25 +536,23 @@
        /// <summary>
        /// 保存面板数据
        /// </summary>
        private async void SavePanelData()
        private void SavePanelData()
        {
            this.ShowProgressBar();
            //亮度调节更改(他们说随便一个回路就行)
            var result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel);
            var result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(panelDevice, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel);
            if (result == false)
            {
                this.CloseProgressBar();
                return;
            }
            //节能模式修改(他们说随便一个回路就行)
            result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
            this.CloseProgressBar();
            result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(panelDevice, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
            if (result == false)
            {
                return;
            }
            //设置按键面板指定端点的【指示灯开关颜色】的信息
            result = await HdlDevicePanelLogic.Current.SetPanelEpointColorInfo(panelDevice, this.keyColorData);
            result = HdlDevicePanelLogic.Current.SetPanelEpointColorInfo(panelDevice, this.keyColorData);
            if (result == false)
            {
                return;
@@ -542,20 +575,6 @@
        private uint GetColorByRGB(byte R, byte G, byte B)
        {
            return (uint)(0xFF000000 + R * 256 * 256 + G * 256 + B);
        }
        #endregion
        #region ■ 界面关闭___________________________
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseFormBefore()
        {
            UserView.HomePage.Instance.ScrollEnabled = true;
            base.CloseFormBefore();
        }
        #endregion