using System; using Shared.Common; using ZigBee.Device; using Shared.Phone.Device.CommonForm; using Shared.Phone.UserView; using Shared.Phone.Device.DeviceLogic; namespace Shared.Phone.Device.AC { public class ACControl : FrameLayout,ZigBee.Common.IStatus { #region ◆ 变量__________________________ /// /// The action. /// public Action action; /// /// 收藏按钮 /// private Button collectionBtn; /// /// 传过来的设备 /// private DeviceUI device; /// /// 传过来的房间 /// private Shared.Common.Room room; /// /// 房间 /// private Button roomBtn; /// /// 房间名 /// private Button roomName; /// /// 网关 /// private ZbGateway zbGateway = null; /// /// 是否发送控制命令成功了 /// private bool sendedControlCommand = false; /// /// bodyFrameLayout /// private FrameLayout bodyFrameLayout; /// /// 室温 /// private Button indoorTemperatureBtn; /// /// OpenOrUpBtn /// public Button OpenOrUpBtn; /// /// OpenOrUpBtn /// public Button CloseOrDownBtn; /// /// StopBtn /// public Button StopBtn; /// /// 当前模式 /// private Button currentModeBtn; /// /// 添加温度 /// private Button addTemperatureBtn; /// /// 降低温度 /// private Button reduceTemperatureBtn; /// /// 空调模式 /// private Button modeBtn; /// /// 开启或关闭 /// private Button switchBtn; /// /// 风速模式 /// private Button fanModeBtn; /// /// 扫风模式 /// private Button FanSwingModeBtn; /// /// 风速选择视图 /// private Dialog fanModeDialog; /// /// 模式选择视图 /// private Dialog acModeDialog; /// /// 传过来的ac /// private ZigBee.Device.AC ac; /// /// mArcScaleSeekBar /// private ArcScaleSeekBar mArcScaleSeekBar = new ArcScaleSeekBar { }; /// /// 清洁状态 /// private LeftIconButtonRow cleanStatu; /// /// IsDrawerLockMode /// public bool IsDrawerLockMode; #endregion #region ◆ 接口___________________________ /// /// 处理变化事件 --将弃用 改用DeviceInfoChange() /// /// The changed. /// Common. public void Changed(CommonDevice common) { } /// /// 设备状态更新接口 /// type:如果为 DeviceInComingRespon:设备新上报 /// type:如果为 IASInfoReport:RemoveDeviceRespon /// type:如果为 DeviceStatusReport:设备上报 /// type:如果为 IASInfoReport:IAS安防信息上报 /// type:如果为 OnlineStatusChange: 设备在线状态更新 /// /// Common. /// Type tag. public void DeviceInfoChange(CommonDevice common, string typeTag) { if (typeTag == "DeviceStatusReport") { Application.RunOnMainThread(() => { try { var deviceUI = device; if (deviceUI.CommonDevice == null) { return; } if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) { return; } if (common.DeviceStatusReport.CluterID == 513) { var attriButeList = common.DeviceStatusReport.AttriBute; if (attriButeList == null || attriButeList.Count == 0) { return; } deviceUI.CommonDevice.DeviceStatusReport = common.DeviceStatusReport; foreach(var attList in attriButeList) { var curTemp = (attList.AttriButeData / 100 < ACControlBase.Temperature_High && attList.AttriButeData / 100 > ACControlBase.Temperature_Low) ? attList.AttriButeData / 100 : ACControlBase.Temperature_Default; switch (attList.AttributeId) { case 0: ac.currentLocalTemperature = curTemp; ac.LastDateTime = DateTime.Now; indoorTemperatureBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {ac.currentLocalTemperature} ℃"; //currentTemperatureBtn.Text = $"{ac.currentLocalTemperature} ℃"; break; case 17: ac.currentCoolingSetpoint = curTemp; if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8) { mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint; } ac.LastDateTime = DateTime.Now; break; case 18: ac.currentHeatingSetpoint = curTemp; if (ac.currentSystemMode == 4) { mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint; } ac.LastDateTime = DateTime.Now; break; case 4096: ac.currentAutoSetpoint = curTemp; if (ac.currentSystemMode == 1) { mArcScaleSeekBar.Progress = ac.currentAutoSetpoint; } ac.LastDateTime = DateTime.Now; break; case 28: //此属性描述恒温设备正处于哪种模式 //Off = 0 Auto = 1 Cool = 3 Heat = 4 FanOnly = 7 Dry = 8 ac.currentSystemMode = attList.AttriButeData; ac.LastDateTime = DateTime.Now; if (ac.currentSystemMode == 0) { switchBtn.IsSelected = false; modeBtn.IsSelected = false; fanModeBtn.IsSelected = false; FanSwingModeBtn.IsSelected = false; mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } else if (ac.currentSystemMode == 1 || ac.currentSystemMode == 3 || ac.currentSystemMode == 4 || ac.currentSystemMode == 7 || ac.currentSystemMode == 8) { switchBtn.IsSelected = true; modeBtn.IsSelected = true; fanModeBtn.IsSelected = true; FanSwingModeBtn.IsSelected = true; mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor); } modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode); modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode); currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode); mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac); mArcScaleSeekBar.IsClickable = ACControlBase.IsOpen(ac); break; case 4097: //过虑网清洗标志:42 ac.CleanStatu = attList.AttriButeData == 42; cleanStatu.Visible = ac.CleanStatu; break; case 4099: var value = Convert.ToString(attList.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; } } } if (common.DeviceStatusReport.CluterID == 514) { var attriButeList = common.DeviceStatusReport.AttriBute; ac.DeviceStatusReport = common.DeviceStatusReport; foreach(var attList in attriButeList) { switch (attList.AttributeId) { case 0: //风扇当前的工作模式 1=Low 2=Medium 3=High ac.currentFanMode = attList.AttriButeData; ac.LastDateTime = DateTime.Now; fanModeBtn.IsSelected = true; fanModeBtn.SelectedImagePath = ACControlBase.GetFanModeSelectedImagePathByFanModeId(ac.currentFanMode); fanModeBtn.UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanModeId(ac.currentFanMode); break; case 4096: //风扇当前的扫风模式 ac.currentFanSwingMode = attList.AttriButeData; ac.LastDateTime = DateTime.Now; FanSwingModeBtn.IsSelected = true; FanSwingModeBtn.SelectedImagePath = ACControlBase.GetFanSwingModeSelectedImagePathByFanSwingModeId(ac.currentFanSwingMode); FanSwingModeBtn.UnSelectedImagePath = ACControlBase.GetFanSwingModeUnSelectedImagePathByFanSwingModeId(ac.currentFanSwingMode); break; } } } //***新改 * **设备状态上报中,当CluterID = 3,证明设备在线,直接标记 else if (common.DeviceStatusReport.CluterID == 3) { ac.IsOnline = 1; switchBtn.IsSelected = true; ac.LastDateTime = DateTime.Now; } } catch (Exception ex) { System.Console.WriteLine($"Error:{ex.Message}"); } }); } else if (typeTag == "OnlineStatusChange") { Application.RunOnMainThread(() => { try { var deviceUI = device; //设备为空 if (deviceUI.CommonDevice == null) { return; } //是否为当前设备 if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) { return; } if (deviceUI.CommonDevice.Type == DeviceType.Thermostat) { ac.IsOnline = common.IsOnline; ac.LastDateTime = DateTime.Now; } } catch (Exception ex) { System.Console.WriteLine($"Error:{ex.Message}"); } }); } } /// /// Changeds the IL ogic status. /// /// Logic. public void ChangedILogicStatus(ZigBee.Device.Logic logic) { //throw new NotImplementedException(); } /// /// Changeds the IS cene status. /// /// Scene. public void ChangedISceneStatus(Scene scene) { //throw new NotImplementedException(); } #endregion #region ◆ 构造方法________________________ /// /// 构造方法 /// public ACControl() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; ZigBee.Device.ZbGateway.StatusList.Add(this); HomePage.Instance.ScrollEnabled = false; } #endregion #region ◆ 重写移除方法____________________ /// /// Removes from parent. /// public override void RemoveFromParent() { ZigBee.Device.ZbGateway.StatusList.Remove(this); //action(); //action = null; RemoveUpdateControlDeviceStatuAction(); HomePage.Instance.ScrollEnabled = true; if (IsDrawerLockMode) { CommonPage.Instance.IsDrawerLockMode = false; } base.RemoveFromParent(); } #endregion #region ◆ 显示界面________________________ /// /// 显示界面 /// /// Device. /// Room. public void Show(DeviceUI dev, Shared.Common.Room room) { device = dev; zbGateway = this.device.CommonDevice.Gateway; this.room = room; this.ac = device.CommonDevice as ZigBee.Device.AC; AddTop(); AddBodyView(device); if (ac.Gateway == null) { return; } if (ac.Gateway.IsVirtual) { //发送读取状态命令 UserView.UserHomeView.ReadStatus(ac, () => { ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice); }); } else { //防止短时间内多次读取设备状态 if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { ReadDeviceAttributeLogic.Instance.SendACStatuComand(device.CommonDevice); } } var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); if (de == null) { collectionBtn.IsSelected = false; } else { collectionBtn.IsSelected = true; } BindEvent(); } #endregion #region ◆ Add____________________________ /// /// AddTop /// public void AddTop() { var top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.backButton.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; var moreBtn = new Button { X = Application.GetRealWidth(953), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), Gravity = Gravity.CenterVertical, UnSelectedImagePath = "Item/More.png" }; top.topView.AddChidren(moreBtn); moreBtn.MouseUpEventHandler += More; } /// /// AddBodyView /// public void AddBodyView(DeviceUI device) { bodyFrameLayout = new FrameLayout() { Y = Application.GetRealHeight(184), Height = Application.GetRealHeight(1737), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, }; AddChidren(bodyFrameLayout); var itemView = new FrameLayout() { Y = Application.GetRealHeight(115), Width = Application.GetRealWidth(965), Height = Application.GetRealHeight(1457), Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), Gravity = Gravity.CenterHorizontal, 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() { X = Application.GetRealWidth(850), Y = Application.GetRealHeight(46), Width = Application.GetMinReal(69), Height = Application.GetMinReal(69), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png" }; itemView.AddChidren(collectionBtn); var deviceNameBtn = new Button() { Y = Application.GetRealHeight(184), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, Text = device.CommonDevice.DeviceEpointName, TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextSize = 15 }; itemView.AddChidren(deviceNameBtn); indoorTemperatureBtn = new Button { Y = Application.GetRealHeight(256), Width = Application.GetRealWidth(600), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {ac.currentLocalTemperature} ℃" }; itemView.AddChidren(indoorTemperatureBtn); mArcScaleSeekBar = new ArcScaleSeekBar { Y = Application.GetRealHeight(412), Width = Application.GetRealWidth(671), Height = Application.GetRealHeight(671), Gravity = Gravity.CenterHorizontal, MinValue = ACControlBase.Temperature_Low, MaxValue = ACControlBase.Temperature_High, Progress = ACControlBase.GetCurrentModeTemperature(ac), IsClickable = ACControlBase.IsOpen(ac) }; itemView.AddChidren(mArcScaleSeekBar); if(ACControlBase.IsOpen(ac)) { mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor); } else { mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } mArcScaleSeekBar.OnStopTrackingTouchEvent += (sender, e) => { 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); } }; currentModeBtn = new Button() { Y = Application.GetRealHeight(565), Height = Application.GetRealHeight(80), Width = Application.GetRealWidth(200), TextColor = ZigbeeColor.Current.GXCTextBlackColor, Gravity = Gravity.CenterHorizontal, Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode) }; itemView.AddChidren(currentModeBtn); reduceTemperatureBtn = new Button() { X = Application.GetRealWidth(268), Y = Application.GetRealHeight(650), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = "AC/Reduce.png" }; itemView.AddChidren(reduceTemperatureBtn); addTemperatureBtn = new Button() { X = Application.GetRealWidth(610), Y = Application.GetRealHeight(650), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = "AC/Add.png" }; itemView.AddChidren(addTemperatureBtn); FanSwingModeBtn = new Button() { X = Application.GetRealWidth(156), Y = Application.GetRealHeight(1086), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = ACControlBase.GetFanSwingModeUnSelectedImagePathByFanSwingModeId(ac.currentFanSwingMode), SelectedImagePath = ACControlBase.GetFanSwingModeSelectedImagePathByFanSwingModeId(ac.currentFanSwingMode), IsSelected = ACControlBase.IsOpen(ac) }; itemView.AddChidren(FanSwingModeBtn); modeBtn = new Button() { X = Application.GetRealWidth(346), Y = Application.GetRealHeight(1086), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode), SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode), IsSelected = ACControlBase.IsOpen(ac) }; itemView.AddChidren(modeBtn); switchBtn = new Button() { X = Application.GetRealWidth(536), Y = Application.GetRealHeight(1086), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = "AC/OpenOrClose.png", SelectedImagePath = "AC/OpenOrCloseSelected.png", IsSelected = ACControlBase.IsOpen(ac) }; itemView.AddChidren(switchBtn); fanModeBtn = new Button() { X = Application.GetRealWidth(729), Y = Application.GetRealHeight(1086), Width = Application.GetMinRealAverage(80), Height = Application.GetMinRealAverage(80), UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanModeId(ac.currentFanMode), SelectedImagePath = ACControlBase.GetFanModeSelectedImagePathByFanModeId(ac.currentFanMode), IsSelected = ACControlBase.IsOpen(ac) }; itemView.AddChidren(fanModeBtn); var roomBG = new Button { Y = Application.GetRealHeight(1322 - 50), Height = Application.GetRealHeight(138 + 50), BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor, Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius) }; itemView.AddChidren(roomBG); var roomBG2 = new Button { Y = Application.GetRealHeight(1322 - 50), Height = Application.GetRealHeight(50), BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; itemView.AddChidren(roomBG2); roomBtn = new Button() { X = Application.GetRealWidth(CommonFormResouce.X_Left), Y = Application.GetRealHeight(1351), Width = Application.GetMinReal(80), Height = Application.GetMinReal(80), UnSelectedImagePath = "Item/Room.png" }; itemView.AddChidren(roomBtn); roomName = new Button() { X = Application.GetRealWidth(150), Y = Application.GetRealHeight(1368), Width = Application.GetRealWidth(400), Height = Application.GetRealHeight(50), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; itemView.AddChidren(roomName); } #endregion #region ◆ 绑定事件________________________ /// /// 绑定按钮的事件 /// private void BindEvent() { switchBtn.MouseUpEventHandler += Switch_MouseUpEvent; collectionBtn.MouseUpEventHandler += Collection; fanModeBtn.MouseUpEventHandler += ShowChangeFan_MouseUpEvent; modeBtn.MouseUpEventHandler += ShowChangeMode_MouseUpEvent; FanSwingModeBtn.MouseUpEventHandler += ShowChangeFanSwing_MouseUpEvent; reduceTemperatureBtn.MouseUpEventHandler += Reduce_MouseUpEvent; addTemperatureBtn.MouseUpEventHandler += Add_MouseUpEvent; } #endregion #region ◆ 开关__________________________ /// /// 开关 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void Switch_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { switchBtn.IsSelected = !switchBtn.IsSelected; mArcScaleSeekBar.IsClickable = switchBtn.IsSelected; if (switchBtn.IsSelected == true) { ac.Open(); modeBtn.IsSelected = true; fanModeBtn.IsSelected = true; FanSwingModeBtn.IsSelected = true; mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor); } else { ac.Close(); modeBtn.IsSelected = false; fanModeBtn.IsSelected = false; FanSwingModeBtn.IsSelected = false; mArcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } } #endregion #region ◆ 切换风速_______________________ /// /// 切换风速 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void ShowChangeFan_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { int fanItem_X = 80; int fanItem_Height = 150; int fanItem_Width = 449; fanModeDialog = new Dialog(); fanModeDialog.Show(); var closeBGview = new FrameLayout(); fanModeDialog.AddChidren(closeBGview); closeBGview.MouseUpEventHandler += (send1, e1) => { fanModeDialog.Close(); }; var changeFanModeBG = new Button() { X = Application.GetRealWidth(600), Y = Application.GetRealHeight(750), Height = Application.GetRealHeight(625), Width = Application.GetRealWidth(fanItem_Width), UnSelectedImagePath = "AC/SelectedFanModeBG.png" }; closeBGview.AddChidren(changeFanModeBG); var changeFanModeFL = new FrameLayout() { X = Application.GetRealWidth(600), Y = Application.GetRealHeight(750), Height = Application.GetRealHeight(600), Width = Application.GetRealWidth(fanItem_Width), Radius = CommonPage.BigFormRadius, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; closeBGview.AddChidren(changeFanModeFL); var changeFanBtn = new Button() { X = Application.GetRealWidth(fanItem_X), Width = Application.GetRealWidth(fanItem_Width - fanItem_X), Height = Application.GetRealHeight(fanItem_Height), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextID = R.MyInternationalizationString.SelectFanMode, TextAlignment = TextAlignment.CenterLeft }; changeFanModeFL.AddChidren(changeFanBtn); var fan_Low = new CommonForm.ACLeftIconButtonRowLayout() { Y = changeFanBtn.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanMode.Low }; changeFanModeFL.AddChidren(fan_Low); fan_Low.Init("AC/Fan_Low.png", "AC/Fan_LowSelected.png", Language.StringByID(R.MyInternationalizationString.Fan_Low)); var fan_Middle = new CommonForm.ACLeftIconButtonRowLayout() { Y = fan_Low.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanMode.Medium }; changeFanModeFL.AddChidren(fan_Middle); fan_Middle.Init("AC/Fan_Middle.png", "AC/Fan_MiddleSelected.png", Language.StringByID(R.MyInternationalizationString.Fan_Middle)); var fan_Height = new CommonForm.ACLeftIconButtonRowLayout() { Y = fan_Middle.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanMode.High }; changeFanModeFL.AddChidren(fan_Height); fan_Height.Init("AC/Fan_Height.png", "AC/Fan_HeightSelected.png", Language.StringByID(R.MyInternationalizationString.Fan_Height), false); fan_Low.TitleButton.MouseUpEventHandler += ChangeFan_MouseUpEvent; fan_Low.IconButton.MouseUpEventHandler += ChangeFan_MouseUpEvent; fan_Middle.TitleButton.MouseUpEventHandler += ChangeFan_MouseUpEvent; fan_Middle.IconButton.MouseUpEventHandler += ChangeFan_MouseUpEvent; fan_Height.TitleButton.MouseUpEventHandler += ChangeFan_MouseUpEvent; fan_Height.IconButton.MouseUpEventHandler += ChangeFan_MouseUpEvent; if (ACControlBase.IsOpen(ac)) { if (ac.currentFanMode == 1) { fan_Low.SetSelectedStatu(); } else if (ac.currentFanMode == 2) { fan_Middle.SetSelectedStatu(); } else { fan_Height.SetSelectedStatu(); } } } /// /// 切换风速 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void ChangeFan_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { var tag = (sender as Button).Tag.ToString(); ZigBee.Device.AC.FanMode mode = ZigBee.Device.AC.FanMode.Low; if (tag == "Low") { mode = ZigBee.Device.AC.FanMode.Low; } else if (tag == "Medium") { mode = ZigBee.Device.AC.FanMode.Medium; } else if (tag == "High") { mode = ZigBee.Device.AC.FanMode.High; } ChangeFan(mode); } /// /// 切换风速 /// /// Fan mode. private void ChangeFan(ZigBee.Device.AC.FanMode fanMode) { fanModeDialog.Close(); if (ACControlBase.IsOpen(ac) == false) { ACControlBase.ShowACIsCloseTip(); return; } fanModeBtn.IsSelected = true; fanModeBtn.SelectedImagePath = ACControlBase.GetFanModeSelectedImagePathByFanMode(fanMode); fanModeBtn.UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanMode(fanMode); ac.currentFanMode = (int)(fanMode); ac.SetFanModeAsync(fanMode); } #endregion #region ◆ 切换模式_______________________ /// /// 切换模式 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void ShowChangeMode_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { int modeItem_X = 80; int modeItem_Height = 150; int modeItem_Width = 449; acModeDialog = new Dialog(); acModeDialog.Show(); var closeBGview = new FrameLayout(); acModeDialog.AddChidren(closeBGview); closeBGview.MouseUpEventHandler += (send1, e1) => { acModeDialog.Close(); }; var changeModeBG = new Button() { X = Application.GetRealWidth(230), Y = Application.GetRealHeight(450), Height = Application.GetRealHeight(933), Width = Application.GetRealWidth(modeItem_Width), UnSelectedImagePath = "AC/SelectedModeBG.png" }; closeBGview.AddChidren(changeModeBG); var changeModeFL = new VerticalScrolViewLayout() { X = Application.GetRealWidth(230), Y = Application.GetRealHeight(450), Height = Application.GetRealHeight(900), Width = Application.GetRealWidth(modeItem_Width), Radius = CommonFormResouce.BigFormRadius, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, //BackgroundIagePath="AC/SelectedModeBG.png" }; closeBGview.AddChidren(changeModeFL); var changeModeBtn = new Button() { X = Application.GetRealWidth(modeItem_X), Width = Application.GetRealWidth(modeItem_Width - modeItem_X), Height = Application.GetRealHeight(modeItem_Height), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextID = R.MyInternationalizationString.SelectMode, TextAlignment = TextAlignment.CenterLeft }; changeModeFL.AddChidren(changeModeBtn); var mode_Auto = new CommonForm.ACLeftIconButtonRowLayout() { Y = changeModeBtn.Bottom, Width = Application.GetRealWidth(modeItem_Width), Height = Application.GetRealHeight(modeItem_Height), Tag = ZigBee.Device.AC.AcMode.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() { Y = mode_Auto.Bottom, Width = Application.GetRealWidth(modeItem_Width), Height = Application.GetRealHeight(modeItem_Height), Tag = ZigBee.Device.AC.AcMode.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() { Y = mode_Cool.Bottom, Width = Application.GetRealWidth(modeItem_Width), Height = Application.GetRealHeight(modeItem_Height), Tag = ZigBee.Device.AC.AcMode.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() { Y = mode_Heat.Bottom, Width = Application.GetRealWidth(modeItem_Width), Height = Application.GetRealHeight(modeItem_Height), Tag = ZigBee.Device.AC.AcMode.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() { Y = mode_Dry.Bottom, Width = Application.GetRealWidth(modeItem_Width), Height = Application.GetRealHeight(modeItem_Height), Tag = ZigBee.Device.AC.AcMode.FanOnly }; 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; mode_Cool.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Cool.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Heat.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Heat.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Dry.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Dry.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Fan.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; mode_Fan.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent; if (ACControlBase.IsOpen(ac)) { if (ac.currentSystemMode == 1) { mode_Auto.SetSelectedStatu(); } else if (ac.currentSystemMode == 3) { mode_Cool.SetSelectedStatu(); } else if (ac.currentSystemMode == 4) { mode_Heat.SetSelectedStatu(); } else if (ac.currentSystemMode == 8) { mode_Dry.SetSelectedStatu(); } else if (ac.currentSystemMode == 7) { mode_Fan.SetSelectedStatu(); } } } /// /// 切换模式 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void ChangeMode_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { var tag = (sender as Button).Tag.ToString(); ZigBee.Device.AC.AcMode mode = ZigBee.Device.AC.AcMode.Cool; if (tag == "Auto") { mode = ZigBee.Device.AC.AcMode.Auto; } else if (tag == "Cool") { mode = ZigBee.Device.AC.AcMode.Cool; } else if (tag == "Heat") { mode = ZigBee.Device.AC.AcMode.Heat; } else if (tag == "Dry") { mode = ZigBee.Device.AC.AcMode.Dry; } else if (tag == "FanOnly") { mode = ZigBee.Device.AC.AcMode.FanOnly; } ChangeMode(mode); } /// /// 切换模式 /// /// Ac mode. private void ChangeMode(ZigBee.Device.AC.AcMode acMode) { acModeDialog.Close(); if (ACControlBase.IsOpen(ac) == false) { ACControlBase.ShowACIsCloseTip(); return; } modeBtn.IsSelected = true; modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByMode(acMode); modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByMode(acMode); currentModeBtn.Text = ACControlBase.GetModeNameByMode(acMode); ac.currentSystemMode = (int)acMode; mArcScaleSeekBar.Progress = ACControlBase.GetCurrentModeTemperature(ac); ac.SetSystemModeAsync(acMode); } #endregion #region ◆ 切换扫风______________________ /// /// 切换扫风 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void ShowChangeFanSwing_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { int fanItem_X = 80; int fanItem_Height = 150; int fanItem_Width = 449; fanModeDialog = new Dialog(); fanModeDialog.Show(); var closeBGview = new FrameLayout(); fanModeDialog.AddChidren(closeBGview); closeBGview.MouseUpEventHandler += (send1, e1) => { fanModeDialog.Close(); }; var changeFanModeBG = new Button() { X = Application.GetRealWidth(35), Y = Application.GetRealHeight(297), Height = Application.GetRealHeight(1089), Width = Application.GetRealWidth(fanItem_Width), UnSelectedImagePath = "AC/SwingBackground.png" }; closeBGview.AddChidren(changeFanModeBG); var changeFanModeFL = new FrameLayout() { X = Application.GetRealWidth(35), Y = Application.GetRealHeight(297), Height = Application.GetRealHeight(1050), Width = Application.GetRealWidth(fanItem_Width), Radius = CommonPage.BigFormRadius, BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, }; closeBGview.AddChidren(changeFanModeFL); var changeFanBtn = new Button() { X = Application.GetRealWidth(fanItem_X), Width = Application.GetRealWidth(fanItem_Width - fanItem_X), Height = Application.GetRealHeight(fanItem_Height), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextID = R.MyInternationalizationString.SelectSwing, TextAlignment = TextAlignment.CenterLeft }; changeFanModeFL.AddChidren(changeFanBtn); var swing_First = new CommonForm.ACLeftIconButtonRowLayout() { Y = changeFanBtn.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanSwingMode.First }; changeFanModeFL.AddChidren(swing_First); swing_First.Init("AC/Swing_1.png", "AC/Swing_1Selected.png", Language.StringByID(R.MyInternationalizationString.Swing_First)); var swing_Second = new CommonForm.ACLeftIconButtonRowLayout() { Y = swing_First.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanSwingMode.Second }; changeFanModeFL.AddChidren(swing_Second); swing_Second.Init("AC/Swing_2.png", "AC/Swing_2Selected.png", Language.StringByID(R.MyInternationalizationString.Swing_Second)); var swing_Thrid = new CommonForm.ACLeftIconButtonRowLayout() { Y = swing_Second.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanSwingMode.Thrid }; changeFanModeFL.AddChidren(swing_Thrid); swing_Thrid.Init("AC/Swing_3.png", "AC/Swing_3Selected.png", Language.StringByID(R.MyInternationalizationString.Swing_Thrid)); var swing_Fourth = new CommonForm.ACLeftIconButtonRowLayout() { Y = swing_Thrid.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanSwingMode.Fourth }; changeFanModeFL.AddChidren(swing_Fourth); swing_Fourth.Init("AC/Swing_4.png", "AC/Swing_4Selected.png", Language.StringByID(R.MyInternationalizationString.Swing_Fourth)); var swing_Fifth = new CommonForm.ACLeftIconButtonRowLayout() { Y = swing_Fourth.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanSwingMode.Fifth }; changeFanModeFL.AddChidren(swing_Fifth); swing_Fifth.Init("AC/Swing_5.png", "AC/Swing_5Selected.png", Language.StringByID(R.MyInternationalizationString.Swing_Fifth)); var swing_Auto = new CommonForm.ACLeftIconButtonRowLayout() { Y = swing_Fifth.Bottom, Width = Application.GetRealWidth(fanItem_Width), Height = Application.GetRealHeight(fanItem_Height), Tag = ZigBee.Device.AC.FanSwingMode.Auto }; changeFanModeFL.AddChidren(swing_Auto); swing_Auto.Init("AC/Swing_Auto.png", "AC/Swing_AutoSelected.png", Language.StringByID(R.MyInternationalizationString.Swing_Auto),false); swing_First.TitleButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_First.IconButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Second.TitleButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Second.IconButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Thrid.TitleButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Thrid.IconButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Fourth.TitleButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Fourth.IconButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Fifth.TitleButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Fifth.IconButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Auto.TitleButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; swing_Auto.IconButton.MouseUpEventHandler += ChangeFanSwing_MouseUpEvent; if (ACControlBase.IsOpen(ac)) { if (ac.currentFanSwingMode == 0) { swing_First.SetSelectedStatu(); } else if (ac.currentFanSwingMode == 1) { swing_Second.SetSelectedStatu(); } else if (ac.currentFanSwingMode == 2) { swing_Thrid.SetSelectedStatu(); } else if (ac.currentFanSwingMode == 3) { swing_Fourth.SetSelectedStatu(); } else if (ac.currentFanSwingMode == 4) { swing_Fifth.SetSelectedStatu(); } else if (ac.currentFanSwingMode == 7) { swing_Auto.SetSelectedStatu(); } } } /// /// 切换扫风 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void ChangeFanSwing_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { var tag = (sender as Button).Tag.ToString(); ZigBee.Device.AC.FanSwingMode mode = ZigBee.Device.AC.FanSwingMode.Auto; if (tag == "First") { mode = ZigBee.Device.AC.FanSwingMode.First; } else if (tag == "Second") { mode = ZigBee.Device.AC.FanSwingMode.Second; } else if (tag == "Thrid") { mode = ZigBee.Device.AC.FanSwingMode.Thrid; } else if(tag=="Fourth") { mode = ZigBee.Device.AC.FanSwingMode.Fourth; } else if (tag == "Fifth") { mode = ZigBee.Device.AC.FanSwingMode.Fifth; } ChangeFanSwing(mode); } /// /// 切换扫风 /// /// Fan mode. private void ChangeFanSwing(ZigBee.Device.AC.FanSwingMode fanSwingMode) { fanModeDialog.Close(); if (ACControlBase.IsOpen(ac) == false) { ACControlBase.ShowACIsCloseTip(); return; } FanSwingModeBtn.IsSelected = true; FanSwingModeBtn.SelectedImagePath = ACControlBase.GetFanSwingModeSelectedImagePathByFanSwingMode(fanSwingMode); FanSwingModeBtn.UnSelectedImagePath = ACControlBase.GetFanSwingModeUnSelectedImagePathByFanSwingMode(fanSwingMode); ac.currentFanSwingMode = (int)fanSwingMode; ac.SetFanSwingAsyncMode(fanSwingMode); } #endregion #region ◆ 升温__________________________ /// /// 升温 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void Add_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { if (ACControlBase.IsOpen(ac) == false) { ACControlBase.ShowACIsCloseTip(); return; } if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8) { if (ac.currentCoolingSetpoint >= ACControlBase.Temperature_High) { return; } ac.currentCoolingSetpoint += 1; ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100); mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint; } else if (ac.currentSystemMode == 4) { if (ac.currentHeatingSetpoint >= ACControlBase.Temperature_High) { return; } ac.currentHeatingSetpoint += 1; ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100); mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint; } else if (ac.currentSystemMode == 1) { if (ac.currentAutoSetpoint >= ACControlBase.Temperature_High) { return; } ac.currentAutoSetpoint += 1; ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100); mArcScaleSeekBar.Progress = ac.currentAutoSetpoint; } } #endregion #region ◆ 降温__________________________ /// /// 降温 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void Reduce_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { if (ACControlBase.IsOpen(ac) == false) { ACControlBase.ShowACIsCloseTip(); return; } if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8) { if (ac.currentCoolingSetpoint <= ACControlBase.Temperature_Low) { return; } ac.currentCoolingSetpoint -= 1; ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint * 100); mArcScaleSeekBar.Progress = ac.currentCoolingSetpoint; } else if (ac.currentSystemMode == 4) { if (ac.currentHeatingSetpoint <= ACControlBase.Temperature_Low) { return; } ac.currentHeatingSetpoint -= 1; ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint * 100); mArcScaleSeekBar.Progress = ac.currentHeatingSetpoint; } else if (ac.currentSystemMode == 1) { if (ac.currentAutoSetpoint <= ACControlBase.Temperature_Low) { return; } ac.currentAutoSetpoint -= 1; ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint * 100); mArcScaleSeekBar.Progress = ac.currentAutoSetpoint; } } #endregion #region ◆ 控制反馈_________________________ /// /// 显示设备控制状态 /// /// Command. /// Object value. private void UpdateDeviceControllStatu(string command, object objValue) { if (command != "DeviceDefaultAck" || objValue == null) { return; } var tempDevice = (CommonDevice)objValue; if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) { //不是当前设备的推送,则不处理 return; } //标记已经发送控制命令到网关 sendedControlCommand = true; //成功不提示 //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success); } /// /// 移除更新控制设备的action /// private void RemoveUpdateControlDeviceStatuAction() { if (zbGateway != null) { zbGateway.ReportAction -= UpdateDeviceControllStatu; } } #endregion #region ◆ 更多设置________________________ /// /// 更多设置 /// /// Sender. /// E. private void More(object sender, MouseEventArgs e) { var detailInfo = new Device.CommonForm.DeviceDetailInfo { }; UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; detailInfo.Show(device, room); detailInfo.action = () => { Show(device, room); }; } #endregion #region ◆ 收藏到主页_______________________ /// /// 收藏到主页 /// /// Sender. /// E. private void Collection(object sender, MouseEventArgs e) { if (collectionBtn.IsSelected) { Shared.Common.Room.Lists[0].DeleteDevice(device.FileName); collectionBtn.IsSelected = false; } else { Shared.Common.Room.Lists[0].AddDevice(device.FileName); collectionBtn.IsSelected = true; } } #endregion #region ◆ 回到主页________________________ /// /// 回到主页 /// /// Sender. /// The ${ParameterType} instance containing the event data. private void BackToRoomHandler(object sender, MouseEventArgs mouseEventArgs) { //backToRoom } #endregion } }