gxc
2019-12-13 eb424d24e39bab4a245725f35deab3f234ea0f13
ZigbeeApp/Shared/Phone/Device/AC/ACControl.cs
old mode 100755 new mode 100644
@@ -3,6 +3,7 @@
using ZigBee.Device;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.UserView;
using Shared.Phone.Device.DeviceLogic;
namespace Shared.Phone.Device.AC
{
@@ -72,10 +73,6 @@
        /// </summary>
        private Button currentModeBtn;
        /// <summary>
        /// 当前温度
        /// </summary>
        private Button currentTemperatureBtn;
        /// <summary>
        /// 添加温度
        /// </summary>
        private Button addTemperatureBtn;
@@ -112,6 +109,19 @@
        /// 传过来的ac
        /// </summary>
        private ZigBee.Device.AC ac;
        /// <summary>
        /// mArcScaleSeekBar
        /// </summary>
        private ArcScaleSeekBar mArcScaleSeekBar = new ArcScaleSeekBar { };
        /// <summary>
        /// 清洁状态
        /// </summary>
        private LeftIconButtonRow cleanStatu;
        /// <summary>
        /// IsDrawerLockMode
        /// </summary>
        public bool IsDrawerLockMode;
        #endregion
        #region ◆ 接口___________________________
@@ -174,7 +184,7 @@
                                    ac.currentCoolingSetpoint = curTemp;
                                    if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
                                    {
                                        currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} ℃";
                                        mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint;
                                    }
                                    ac.LastDateTime = DateTime.Now;
@@ -184,7 +194,7 @@
                                    ac.currentHeatingSetpoint = curTemp;
                                    if (ac.currentSystemMode == 4)
                                    {
                                        currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} ℃";
                                        mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint;
                                    }
                                    ac.LastDateTime = DateTime.Now;
                                    break;
@@ -193,7 +203,7 @@
                                    ac.currentAutoSetpoint = curTemp;
                                    if (ac.currentSystemMode == 1)
                                    {
                                        currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} ℃";
                                        mArcScaleSeekBar.Progress = ac.currentAutoSetpoint;
                                    }
                                    ac.LastDateTime = DateTime.Now;
                                    break;
@@ -210,7 +220,8 @@
                                        modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode);
                                        modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode);
                                        currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode);
                                        currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} ℃";
                                        mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac);
                                        fanModeBtn.IsSelected = false;
                                        FanSwingModeBtn.IsSelected = false;
@@ -222,12 +233,28 @@
                                        modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode);
                                        modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode);
                                        currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode);
                                        currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} ℃";
                                        mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac);
                                        fanModeBtn.IsSelected = true;
                                        FanSwingModeBtn.IsSelected = true;
                                    }
                                    break;
                                case 4097:
                                    //过虑网清洗标志:42
                                    ac.CleanStatu = attriButeList[0].AttriButeData == 42;
                                    cleanStatu.Visible = ac.CleanStatu;
                                    break;
                                case 4099:
                                    var value = Convert.ToString(attriButeList[0].AttriButeData, 2).PadLeft(16, '0');
                                    var modeStr = value.Substring(value.Length - 5, 5);
                                    for (int j = 0; j < modeStr.Length; j++)
                                    {
                                        ac.listSupportMode[j] = Convert.ToInt32(modeStr[j]) == 49 ? 1 : 0;
                                    }
                                    break;
                            }
                        }
@@ -250,7 +277,7 @@
                                    fanModeBtn.UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanModeId(ac.currentFanMode);
                                    break;
                                case 4096:
                                    //风扇当前的扫风模式
                                    //风扇当前的扫风模式
                                    ac.currentFanSwingMode = attriButeList[0].AttriButeData;
                                    ac.LastDateTime = DateTime.Now;
                                    FanSwingModeBtn.IsSelected = true;
@@ -331,6 +358,8 @@
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
            HomePage.Instance.ScrollEnabled = false;
        }
        #endregion
@@ -346,6 +375,11 @@
            //action();
            //action = null;
            RemoveUpdateControlDeviceStatuAction();
            HomePage.Instance.ScrollEnabled = true;
            if (IsDrawerLockMode)
            {
                CommonPage.Instance.IsDrawerLockMode = false;
            }
            base.RemoveFromParent();
        }
@@ -377,14 +411,7 @@
                //发送读取状态命令
                UserView.UserHomeView.ReadStatus(ac, () =>
                {
                    ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                    ac.ReadLocalTemperature();
                    ac.ReadCoolingSetpoint();
                    ac.ReadHeatingSetpoint();
                    ac.ReadAutoSetpoint();
                    ac.ReadFanMode();
                    ac.ReadSystemMode();
                    ac.ReadSystemFansSwingMode();
                    ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice);
                });
            }
            else
@@ -392,14 +419,7 @@
                //防止短时间内多次读取设备状态
                if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                {
                    ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
                    ac.ReadLocalTemperature();
                    ac.ReadCoolingSetpoint();
                    ac.ReadHeatingSetpoint();
                    ac.ReadAutoSetpoint();
                    ac.ReadFanMode();
                    ac.ReadSystemMode();
                    ac.ReadSystemFansSwingMode();
                    ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice);
                }
            }
@@ -413,9 +433,7 @@
                collectionBtn.IsSelected = true;
            }
            BindEvent();
        }
        #endregion
@@ -435,16 +453,6 @@
                RemoveFromParent();
            };
            var sharedBtn = new Button
            {
                X = Application.GetRealWidth(850),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/Shared.png"
            };
            top.topView.AddChidren(sharedBtn);
            var moreBtn = new Button
            {
                X = Application.GetRealWidth(953),
@@ -456,7 +464,6 @@
            top.topView.AddChidren(moreBtn);
            moreBtn.MouseUpEventHandler += More;
        }
        /// <summary>
        /// AddBodyView
@@ -481,6 +488,11 @@
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
            };
            bodyFrameLayout.AddChidren(itemView);
            cleanStatu = new LeftIconButtonRow(400, 80, 0, 20);
            itemView.AddChidren(cleanStatu);
            cleanStatu.Init("AC/AC_TIP.png", "AC/AC_TIP.png", Language.StringByID(R.MyInternationalizationString.NeedCleanAC), false);
            cleanStatu.Visible = false;
            collectionBtn = new Button()
            {
@@ -516,74 +528,67 @@
            };
            itemView.AddChidren(indoorTemperatureBtn);
            var controlBG = new FrameLayout()
            mArcScaleSeekBar = new ArcScaleSeekBar
            {
                Y = Application.GetRealHeight(412),
                Height = Application.GetMinRealAverage(547),
                Width = Application.GetMinRealAverage(671),
                Width = Application.GetRealWidth(671),
                Height = Application.GetRealHeight(671),
                Gravity = Gravity.CenterHorizontal,
                BackgroundImagePath = "AC/Group.png"
                MinValue=ACControlBase.Temperature_Low,
                MaxValue=ACControlBase.Temperature_High,
                Progress=ACControlBase.GetCurrentModeTemperature(ac)
            };
            itemView.AddChidren(controlBG);
            var controlBG2 = new Button()
            itemView.AddChidren(mArcScaleSeekBar);
            mArcScaleSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
            {
                Y = Application.GetRealHeight(873),
                Height = Application.GetMinRealAverage(121),
                Width = Application.GetMinRealAverage(351),
                UnSelectedImagePath = "AC/Path.png",
                Gravity = Gravity.CenterHorizontal
                if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
                {
                    ac.currentCoolingSetpoint = e;
                    ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100);
                }
                else if (ac.currentSystemMode == 4)
                {
                    ac.currentHeatingSetpoint = e;
                    ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100);
                }
                else if (ac.currentSystemMode == 1)
                {
                    ac.currentAutoSetpoint = e;
                    ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100);
                }
            };
            itemView.AddChidren(controlBG2);
            //当前模式
            currentModeBtn = new Button()
            {
                Y = Application.GetRealHeight(187),
                Y = Application.GetRealHeight(599),
                Height = Application.GetRealHeight(80),
                Width = Application.GetRealWidth(200),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                Gravity = Gravity.CenterHorizontal,
                Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode)
            };
            controlBG.AddChidren(currentModeBtn);
            //降低温度
            itemView.AddChidren(currentModeBtn);
            reduceTemperatureBtn = new Button()
            {
                X = Application.GetRealWidth(112),
                Y = Application.GetRealHeight(268),
                X = Application.GetRealWidth(268),
                Y = Application.GetRealHeight(680),
                Width = Application.GetMinRealAverage(80),
                Height = Application.GetMinRealAverage(80),
                UnSelectedImagePath = "AC/Reduce.png"
            };
            controlBG.AddChidren(reduceTemperatureBtn);
            itemView.AddChidren(reduceTemperatureBtn);
            //温度
            currentTemperatureBtn = new Button()
            {
                //X = Application.GetRealWidth(239),
                Y = Application.GetRealHeight(248),
                Width = Application.GetRealWidth(180),
                Height = Application.GetRealHeight(100),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize = 15,
                Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} °C",
                Gravity = Gravity.CenterHorizontal
            };
            controlBG.AddChidren(currentTemperatureBtn);
            //添加温度
            addTemperatureBtn = new Button()
            {
                X = Application.GetRealWidth(472),
                Y = Application.GetRealHeight(268),
                X = Application.GetRealWidth(628),
                Y = Application.GetRealHeight(680),
                Width = Application.GetMinRealAverage(80),
                Height = Application.GetMinRealAverage(80),
                UnSelectedImagePath = "AC/Add.png"
            };
            controlBG.AddChidren(addTemperatureBtn);
            itemView.AddChidren(addTemperatureBtn);
            //扫风
            FanSwingModeBtn = new Button()
            {
                X = Application.GetRealWidth(156),
@@ -595,8 +600,7 @@
                IsSelected = ACControlBase.IsOpen(ac)
            };
            itemView.AddChidren(FanSwingModeBtn);
            //模式
            modeBtn = new Button()
            {
                X = Application.GetRealWidth(346),
@@ -609,7 +613,6 @@
            };
            itemView.AddChidren(modeBtn);
            //开关
            switchBtn = new Button()
            {
                X = Application.GetRealWidth(536),
@@ -622,7 +625,6 @@
            };
            itemView.AddChidren(switchBtn);
            //风速
            fanModeBtn = new Button()
            {
                X = Application.GetRealWidth(729),
@@ -911,13 +913,13 @@
            };
            closeBGview.AddChidren(changeModeBG);
            var changeModeFL = new FrameLayout()
            var changeModeFL = new VerticalScrolViewLayout()
            {
                X = Application.GetRealWidth(230),
                Y = Application.GetRealHeight(450),
                Height = Application.GetRealHeight(900),
                Width = Application.GetRealWidth(modeItem_Width),
                Radius = CommonPage.BigFormRadius,
                Radius = CommonFormResouce.BigFormRadius,
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                //BackgroundIagePath="AC/SelectedModeBG.png"
            };
@@ -929,7 +931,7 @@
                Width = Application.GetRealWidth(modeItem_Width - modeItem_X),
                Height = Application.GetRealHeight(modeItem_Height),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextID = R.MyInternationalizationString.SelectFanMode,
                TextID = R.MyInternationalizationString.SelectMode,
                TextAlignment = TextAlignment.CenterLeft
            };
            changeModeFL.AddChidren(changeModeBtn);
@@ -941,7 +943,10 @@
                Height = Application.GetRealHeight(modeItem_Height),
                Tag = ZigBee.Device.AC.AcMode.Auto
            };
            changeModeFL.AddChidren(mode_Auto);
            if (ac.listSupportMode[4] == 1)
            {
                changeModeFL.AddChidren(mode_Auto);
            }
            mode_Auto.Init("AC/Mode_Auto.png", "AC/Mode_AutoSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Auto));
            var mode_Cool = new CommonForm.ACLeftIconButtonRowLayout()
@@ -951,7 +956,10 @@
                Height = Application.GetRealHeight(modeItem_Height),
                Tag = ZigBee.Device.AC.AcMode.Cool
            };
            changeModeFL.AddChidren(mode_Cool);
            if (ac.listSupportMode[0] == 1)
            {
                changeModeFL.AddChidren(mode_Cool);
            }
            mode_Cool.Init("AC/Mode_Cool.png", "AC/Mode_CoolSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Cool));
            var mode_Heat = new CommonForm.ACLeftIconButtonRowLayout()
@@ -961,7 +969,10 @@
                Height = Application.GetRealHeight(modeItem_Height),
                Tag = ZigBee.Device.AC.AcMode.Heat
            };
            changeModeFL.AddChidren(mode_Heat);
            if (ac.listSupportMode[1] == 1)
            {
                changeModeFL.AddChidren(mode_Heat);
            }
            mode_Heat.Init("AC/Mode_Heat.png", "AC/Mode_HeatSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Heat));
            var mode_Dry = new CommonForm.ACLeftIconButtonRowLayout()
@@ -971,7 +982,10 @@
                Height = Application.GetRealHeight(modeItem_Height),
                Tag = ZigBee.Device.AC.AcMode.Dry
            };
            changeModeFL.AddChidren(mode_Dry);
            if (ac.listSupportMode[3] == 1)
            {
                changeModeFL.AddChidren(mode_Dry);
            }
            mode_Dry.Init("AC/Mode_Dry.png", "AC/Mode_DrySelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Dry));
            var mode_Fan = new CommonForm.ACLeftIconButtonRowLayout()
@@ -981,8 +995,12 @@
                Height = Application.GetRealHeight(modeItem_Height),
                Tag = ZigBee.Device.AC.AcMode.FanOnly
            };
            changeModeFL.AddChidren(mode_Fan);
            if (ac.listSupportMode[2] == 1)
            {
                changeModeFL.AddChidren(mode_Fan);
            }
            mode_Fan.Init("AC/Mode_Fan.png", "AC/Mode_FanSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_FanOnly), false);
            mode_Auto.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
            mode_Auto.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
@@ -1075,15 +1093,13 @@
            modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByMode(acMode);
            currentModeBtn.Text = ACControlBase.GetModeNameByMode(acMode);
            ac.currentSystemMode = (int)acMode;
            currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} °C";
            mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac);
            ac.SetSystemModeAsync(acMode);
        }
        #endregion
        #region ◆ 切换扫风___________________________
        #region ◆ 切换扫风______________________
        /// <summary>
@@ -1276,7 +1292,6 @@
                mode = ZigBee.Device.AC.FanSwingMode.Fifth;
            }
            ChangeFanSwing(mode);
        }
@@ -1316,7 +1331,6 @@
                ACControlBase.ShowACIsCloseTip();
                return;
            }
            //cool  //dry
            if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
            {
                if (ac.currentCoolingSetpoint >= ACControlBase.Temperature_High)
@@ -1325,9 +1339,8 @@
                }
                ac.currentCoolingSetpoint += 1;
                ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint;
            }
            //heat
            else if (ac.currentSystemMode == 4)
            {
                if (ac.currentHeatingSetpoint >= ACControlBase.Temperature_High)
@@ -1336,9 +1349,8 @@
                }
                ac.currentHeatingSetpoint += 1;
                ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint;
            }
            //auto
            else if (ac.currentSystemMode == 1)
            {
                if (ac.currentAutoSetpoint >= ACControlBase.Temperature_High)
@@ -1347,10 +1359,8 @@
                }
                ac.currentAutoSetpoint += 1;
                ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentAutoSetpoint;
            }
        }
        #endregion
@@ -1369,7 +1379,6 @@
                ACControlBase.ShowACIsCloseTip();
                return;
            }
            //cool //dry
            if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
            {
                if (ac.currentCoolingSetpoint <= ACControlBase.Temperature_Low)
@@ -1378,10 +1387,8 @@
                }
                ac.currentCoolingSetpoint -= 1;
                ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint;
            }
            //heat
            else if (ac.currentSystemMode == 4)
            {
                if (ac.currentHeatingSetpoint <= ACControlBase.Temperature_Low)
@@ -1390,10 +1397,8 @@
                }
                ac.currentHeatingSetpoint -= 1;
                ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint;
            }
            //auto
            else if (ac.currentSystemMode == 1)
            {
                if (ac.currentAutoSetpoint <= ACControlBase.Temperature_Low)
@@ -1402,15 +1407,13 @@
                }
                ac.currentAutoSetpoint -= 1;
                ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100);
                currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
                mArcScaleSeekBar.Progress = ac.currentAutoSetpoint;
            }
        }
        #endregion
        #region ◆ 控制反馈_________________________
@@ -1442,7 +1445,6 @@
        /// </summary>
        private void RemoveUpdateControlDeviceStatuAction()
        {
            //移除action
            if (zbGateway != null)
            {
                zbGateway.ReportAction -= UpdateDeviceControllStatu;
@@ -1481,7 +1483,6 @@
        /// <param name="e">E.</param>
        private void Collection(object sender, MouseEventArgs e)
        {
            //collection
            if (collectionBtn.IsSelected)
            {
                Shared.Common.Room.Lists[0].DeleteDevice(device.FileName);
@@ -1506,7 +1507,6 @@
        private void BackToRoomHandler(object sender, MouseEventArgs mouseEventArgs)
        {
            //backToRoom
        }
        #endregion