黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/Relay/RelayThreeLoadBackLightSettionForm.cs
@@ -14,10 +14,6 @@
        #region ■ 变量声明___________________________
        /// <summary>
        /// 设备Mac地址
        /// </summary>
        private string deviceMac = string.Empty;
        /// <summary>
        /// 亮度调节的信息
        /// </summary>
        private Panel.PanelSwitchLevelInfo linghtLevelInfo = null;
@@ -38,51 +34,50 @@
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm(string i_deviceMac)
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm(string i_deviceMac)
        {
            UserView.HomePage.Instance.ScrollEnabled = false;
            this.ScrollEnabled = false;
            this.deviceMac = i_deviceMac;
            this.listDevice = Common.LocalDevice.Current.GetDevicesByMac(i_deviceMac);
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBackLight));
            //初始化中部信息
            this.InitMiddleFrame();
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private async void InitMiddleFrame()
            this.listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(i_deviceMac);
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBackLight));
            //初始化中部信息
            this.InitMiddleFrame();
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //获取设备初始数据
            var result = await this.GetDeviceDefultData();
            var result = this.GetDeviceDefultData();
            if (result == false)
            {
                return;
            }
            //清空bodyFrame
            this.ClearBodyFrame();
            //点击状态
            var btnClickStatu = new NormalViewControl(600, 49, true);
            btnClickStatu.X = ControlCommonResourse.XXLeft;
            btnClickStatu.Y = Application.GetRealHeight(207);
            btnClickStatu.TextSize = 12;
            btnClickStatu.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnClickStatu.TextID = R.MyInternationalizationString.uClickStatu;
            bodyFrameLayout.AddChidren(btnClickStatu);
            this.ClearBodyFrame();
            //点击状态
            var btnClickStatu = new NormalViewControl(600, 49, true);
            btnClickStatu.X = HdlControlResourse.XXLeft;
            btnClickStatu.Y = Application.GetRealHeight(207);
            btnClickStatu.TextSize = 12;
            btnClickStatu.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnClickStatu.TextID = R.MyInternationalizationString.uClickStatu;
            bodyFrameLayout.AddChidren(btnClickStatu);
            //各种背光灯的容器
            var frameLinght = new FrameLayout();
            frameLinght.Height = Application.GetRealHeight(818);
            frameLinght.Y = Application.GetRealHeight(279);
            frameLinght.BackgroundColor = UserCenterColor.Current.White;
            var frameLinght = new FrameLayout();
            frameLinght.Height = Application.GetRealHeight(818);
            frameLinght.Y = Application.GetRealHeight(279);
            frameLinght.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(frameLinght);
            //添加1-6干接点的背光灯进度条
@@ -96,20 +91,20 @@
            var btnSave = new BottomClickButton();
            btnSave.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnSave);
            btnSave.ButtonClickEvent += async (sender, e) =>
            btnSave.ButtonClickEvent += (sender, e) =>
            {
                if (valueChanged == true)
                {
                    this.ShowProgressBar();
                    //亮度调节更改(他们说随便一个回路就行)
                    result = await HdlPanelLogic.Current.SetDeviceLightSettion(listDevice[0], linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel);
                    result = HdlDevicePanelLogic.Current.SetDeviceLightSettion(listDevice[0], linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel);
                    if (result == false)
                    {
                        this.CloseProgressBar();
                        return;
                    }
                    //节能模式修改(他们说随便一个回路就行)
                    result = await HdlPanelLogic.Current.SetDeviceEnergyConservationMode(listDevice[0], energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
                    result = HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode(listDevice[0], energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
                    this.CloseProgressBar();
                    if (result == false)
                    {
@@ -139,6 +134,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);
            //开关控件
@@ -154,12 +153,16 @@
                    frameBack.Height += value;
                    btnClickStatu.Y += value;
                    frameLinght.Y += value;
                    btnProgressView1.Visible = true;
                    btnProgress1.Visible = true;
                }
                else
                {
                    frameBack.Height -= value;
                    btnClickStatu.Y -= value;
                    frameLinght.Y -= value;
                    btnProgressView1.Visible = false;
                    btnProgress1.Visible = false;
                }
                //数据变更
                valueChanged = true;
@@ -170,56 +173,50 @@
            }
            //当前亮度
            var btnProgressView1 = new NormalViewControl(200, 49, true);
            btnProgressView1.X = ControlCommonResourse.XXLeft;
            btnProgressView1.X = HdlControlResourse.XXLeft;
            btnProgressView1.Y = Application.GetRealHeight(161);
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.TextID = R.MyInternationalizationString.uNowLuminance;
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.TextID = R.MyInternationalizationString.uNowLuminance;
            frameBack.AddChidren(btnProgressView1);
            var btnProgress1 = new NormalViewControl(200, 49, true);
            btnProgress1.X = Application.GetRealWidth(222);
            btnProgressView1.Visible = false;
            btnProgress1.X = Application.GetRealWidth(222);
            btnProgress1.Y = Application.GetRealHeight(158);
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = energyModeInfo.level + "%";
            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;
                valueChanged = true;
            };
            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;
            btnTemp1.Text = "0%";
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp1.Text = "0%";
            frameBack.AddChidren(btnTemp1);
            var btnTemp2 = new NormalViewControl(200, 49, true);
            btnTemp2.X = frameLinght.Width - Application.GetRealWidth(200 + 49);
            btnTemp2.X = frameLinght.Width - Application.GetRealWidth(200 + 49);
            btnTemp2.Y = Application.GetRealHeight(325);
            btnTemp2.TextAlignment = TextAlignment.CenterRight;
            btnTemp2.TextSize = 12;
            btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp2.Text = "100%";
            btnTemp2.TextSize = 12;
            btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp2.Text = "100%";
            frameBack.AddChidren(btnTemp2);
            if (energyModeInfo.enable == true)
@@ -229,6 +226,15 @@
                frameBack.Height += value;
                btnClickStatu.Y += value;
                frameLinght.Y += value;
                btnProgressView1.Visible = true;
                btnProgress1.Visible = true;
            }
            //如果当前是展示模板
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                seekBar1.Enable = false;
                btnSwitch.CanClick = false;
            }
        }
@@ -243,63 +249,63 @@
        private void AddSixDryContactProgress(FrameLayout frameLinght)
        {
            var btnProgressView1 = new NormalViewControl(200, 49, true);
            btnProgressView1.X = ControlCommonResourse.XXLeft;
            btnProgressView1.X = HdlControlResourse.XXLeft;
            btnProgressView1.Y = Application.GetRealHeight(29);
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.Text = "Dry1-6";
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.Text = "Dry1-6";
            frameLinght.AddChidren(btnProgressView1);
            var btnProgress1 = new NormalViewControl(200, 49, true);
            btnProgress1.X = Application.GetRealWidth(204);
            btnProgress1.X = Application.GetRealWidth(204);
            btnProgress1.Y = Application.GetRealHeight(29);
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = linghtLevelInfo.panelDirectionsLevel + "%";
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = linghtLevelInfo.panelDirectionsLevel + "%";
            frameLinght.AddChidren(btnProgress1);
            //进度条
            var seekBar1 = new HorizontalSeekBar();
            var seekBar1 = new SeekBarControl();
            seekBar1.Y = Application.GetRealHeight(124);
            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;
            seekBar1.ProgressBarColor = 0xfffdb500;
            frameLinght.AddChidren(seekBar1);
            seekBar1.ProgressChanged += (sender, value) =>
            seekBar1.ProgressChangedEvent += (div, value) =>
            {
                btnProgress1.Text = value + "%";
                //数据变更
                linghtLevelInfo.panelDirectionsLevel = value;
                valueChanged = true;
            };
            seekBar1.Progress = linghtLevelInfo.panelDirectionsLevel;
            var btnTemp1 = new NormalViewControl(200, 49, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
            btnTemp1.X = HdlControlResourse.XXLeft;
            btnTemp1.Y = Application.GetRealHeight(193);
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp1.Text = "0%";
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp1.Text = "0%";
            frameLinght.AddChidren(btnTemp1);
            var btnTemp2 = new NormalViewControl(200, 49, true);
            btnTemp2.X = frameLinght.Width - Application.GetRealWidth(200 + 49);
            btnTemp2.X = frameLinght.Width - Application.GetRealWidth(200 + 49);
            btnTemp2.Y = Application.GetRealHeight(193);
            btnTemp2.TextAlignment = TextAlignment.CenterRight;
            btnTemp2.TextSize = 12;
            btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp2.Text = "100%";
            btnTemp2.TextSize = 12;
            btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp2.Text = "100%";
            frameLinght.AddChidren(btnTemp2);
            //线
            var btnLine = new NormalViewControl(Application.GetRealWidth(965), ControlCommonResourse.BottomLineHeight, false);
            var btnLine = new NormalViewControl(Application.GetRealWidth(965), HdlControlResourse.BottomLineHeight, false);
            btnLine.Y = Application.GetRealHeight(311);
            btnLine.Gravity = Gravity.CenterHorizontal;
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            frameLinght.AddChidren(btnLine);
            //如果当前是展示模板
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                seekBar1.Enable = false;
            }
        }
        #endregion
@@ -313,63 +319,63 @@
        private void AddSevenDryContactProgress(FrameLayout frameLinght)
        {
            var btnProgressView1 = new NormalViewControl(200, 49, true);
            btnProgressView1.X = ControlCommonResourse.XXLeft;
            btnProgressView1.X = HdlControlResourse.XXLeft;
            btnProgressView1.Y = Application.GetRealHeight(369);
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.Text = "Dry7";
            btnProgressView1.TextSize = 12;
            btnProgressView1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgressView1.Text = "Dry7";
            frameLinght.AddChidren(btnProgressView1);
            var btnProgress1 = new NormalViewControl(200, 49, true);
            btnProgress1.X = Application.GetRealWidth(161);
            btnProgress1.X = Application.GetRealWidth(161);
            btnProgress1.Y = Application.GetRealHeight(369);
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = linghtLevelInfo.panelBacklightLevel + "%";
            btnProgress1.TextSize = 12;
            btnProgress1.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnProgress1.Text = linghtLevelInfo.panelBacklightLevel + "%";
            frameLinght.AddChidren(btnProgress1);
            //进度条
            var seekBar1 = new HorizontalSeekBar();
            var seekBar1 = new SeekBarControl();
            seekBar1.Y = Application.GetRealHeight(464);
            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.panelBacklightLevel;
            seekBar1.ProgressBarColor = 0xfffdb500;
            frameLinght.AddChidren(seekBar1);
            seekBar1.ProgressChanged += (sender, value) =>
            seekBar1.ProgressChangedEvent += (div, value) =>
            {
                btnProgress1.Text = value + "%";
                //数据变更
                linghtLevelInfo.panelBacklightLevel = value;
                valueChanged = true;
            };
            seekBar1.Progress = linghtLevelInfo.panelBacklightLevel;
            var btnTemp1 = new NormalViewControl(200, 49, true);
            btnTemp1.X = ControlCommonResourse.XXLeft;
            btnTemp1.X = HdlControlResourse.XXLeft;
            btnTemp1.Y = Application.GetRealHeight(533);
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp1.Text = "0%";
            btnTemp1.TextSize = 12;
            btnTemp1.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp1.Text = "0%";
            frameLinght.AddChidren(btnTemp1);
            var btnTemp2 = new NormalViewControl(200, 49, true);
            btnTemp2.X = frameLinght.Width - Application.GetRealWidth(200 + 49);
            btnTemp2.X = frameLinght.Width - Application.GetRealWidth(200 + 49);
            btnTemp2.Y = Application.GetRealHeight(533);
            btnTemp2.TextAlignment = TextAlignment.CenterRight;
            btnTemp2.TextSize = 12;
            btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp2.Text = "100%";
            btnTemp2.TextSize = 12;
            btnTemp2.TextColor = UserCenterColor.Current.TextGrayColor3;
            btnTemp2.Text = "100%";
            frameLinght.AddChidren(btnTemp2);
            //线
            var btnLine = new NormalViewControl(Application.GetRealWidth(965), ControlCommonResourse.BottomLineHeight, false);
            var btnLine = new NormalViewControl(Application.GetRealWidth(965), HdlControlResourse.BottomLineHeight, false);
            btnLine.Gravity = Gravity.CenterHorizontal;
            btnLine.Y = Application.GetRealHeight(651);
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
            frameLinght.AddChidren(btnLine);
            //如果当前是展示模板
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                seekBar1.Enable = false;
            }
        }
        #endregion
@@ -380,12 +386,12 @@
        /// 获取设备初始数据
        /// </summary>
        /// <returns></returns>
        private async Task<bool> GetDeviceDefultData()
        private bool GetDeviceDefultData()
        {
            //开启进度条
            this.ShowProgressBar();
            //亮度调节(他们说随便拿一路回路就行了)
            linghtLevelInfo = await HdlPanelLogic.Current.GetDeviceLightSettion(listDevice[0]);
            linghtLevelInfo = HdlDevicePanelLogic.Current.GetDeviceLightSettion(listDevice[0]);
            if (linghtLevelInfo == null)
            {
                //关闭进度条
@@ -393,7 +399,7 @@
                return false;
            }
            //节能模式(他们说随便拿一路回路就行了)
            energyModeInfo = await HdlPanelLogic.Current.GetDeviceEnergyConservationMode(listDevice[0]);
            energyModeInfo = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationMode(listDevice[0]);
            if (energyModeInfo == null)
            {
                //关闭进度条
@@ -404,20 +410,6 @@
            this.CloseProgressBar();
            return true;
        }
        #endregion
        #region ■ 界面关闭___________________________
        /// <summary>
        /// 界面关闭
        /// </summary>
        public override void CloseForm()
        {
            UserView.HomePage.Instance.ScrollEnabled = true;
            base.CloseForm();
        }
        #endregion