From a5b3c4bae726ef6770d4bfcbf2f4b50a37ed4a15 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 06 三月 2020 15:31:36 +0800
Subject: [PATCH] 删除了郭雪城的 DeviceUi 这个类

---
 ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs |  109 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 59 insertions(+), 50 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs
index bbc4894..9baac28 100755
--- a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs
@@ -20,7 +20,7 @@
         /// <summary>
         /// The action.
         /// </summary>
-        public Action<DeviceUI, Common.Room> action;
+        public Action<CommonDevice, Common.Room> action;
 
         /// <summary>
         /// The light image.
@@ -33,7 +33,7 @@
         /// <summary>
         /// 浼犺繃鏉ョ殑璁惧
         /// </summary>
-        private DeviceUI device;
+        private CommonDevice device;
         /// <summary>
         /// 浼犺繃鏉ョ殑鎴块棿
         /// </summary>
@@ -123,20 +123,20 @@
                     {
                         var deviceUI = device;
                         //璁惧涓虹┖
-                        if (deviceUI.CommonDevice == null)
+                        if (deviceUI == null)
                         {
                             return;
                         }
                         //鏄惁涓哄綋鍓嶈澶�
-                        if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
+                        if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr)
                         {
                             return;
                         }
-                        if (deviceUI.CommonDevice.Type == DeviceType.OnOffOutput)
+                        if (deviceUI.Type == DeviceType.OnOffOutput)
                         {
                             if (common.DeviceStatusReport.CluterID == 6)
                             {
-                                var light = deviceUI.CommonDevice as ToggleLight;
+                                var light = deviceUI as ToggleLight;
                                 light.DeviceStatusReport = common.DeviceStatusReport;
                                 //璁板綍銆佹洿鏂扮姸鎬�
                                 if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0)
@@ -144,13 +144,13 @@
                                     return;
                                 }
                                 light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}";
+                                StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + "   " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device);
 
-                                if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
                                 {
                                     SetONOFFStatu(light.OnOffStatus == 1);
                                 }
-                                else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
                                 {
                                     deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1;
                                 }
@@ -178,18 +178,18 @@
                     {
                         var deviceUI = device;
                         //璁惧涓虹┖
-                        if (deviceUI.CommonDevice == null)
+                        if (deviceUI == null)
                         {
                             return;
                         }
                         //鏄惁涓哄綋鍓嶈澶�
-                        if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
+                        if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr)
                         {
                             return;
                         }
-                        deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                        deviceUI.IsOnline = common.IsOnline;
                         //OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1;
-                        deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                        deviceUI.LastDateTime = DateTime.Now;
                     }
                     catch (Exception ex)
                     {
@@ -230,10 +230,10 @@
         /// </summary>
         /// <param name="dev">Device.</param>
         /// <param name="room">Room.</param>
-        public void Show(DeviceUI dev, Shared.Common.Room room)
+        public void Show(CommonDevice dev, Shared.Common.Room room)
         {
             device = dev;
-            zbGateway = this.device.CommonDevice.Gateway;
+            zbGateway = this.device.Gateway;
             this.room = room;
 
             AddTop();
@@ -241,7 +241,7 @@
             AddBodyView(device);
 
 
-            var light = dev.CommonDevice as ToggleLight;
+            var light = dev as ToggleLight;
             //琛ヤ笂闈炶繙绋�
             if (light.Gateway == null)
             {
@@ -251,7 +251,7 @@
             {
                 UserHomeView.ReadStatus(light, () =>
                 {
-                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
+                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device);
                 });
             }
             else
@@ -259,11 +259,11 @@
                 //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵��
                 if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds)
                 {
-                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice);
+                    ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device);
                 }
             }
 
-            if(Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false)
+            if(UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false)
             {
                 collectionBtn.IsSelected = false;
             }
@@ -310,7 +310,7 @@
         /// <summary>
         /// AddBodyView
         /// </summary>
-        public void AddBodyView(DeviceUI device)
+        public void AddBodyView(CommonDevice device)
         {
             bodyFrameLayout = new FrameLayout()
             {
@@ -348,7 +348,7 @@
                 Width = Application.GetRealWidth(500),
                 Height = Application.GetRealHeight(60),
                 Gravity = Gravity.CenterHorizontal,
-                Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice),
+                Text = Common.LocalDevice.Current.GetDeviceEpointName(device),
                 TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                 TextSize = 15,
                 IsBold=true
@@ -362,7 +362,7 @@
                 Height = Application.GetRealHeight(60),
                 Gravity = Gravity.CenterHorizontal,
                 TextColor = ZigbeeColor.Current.GXCTextGrayColor,
-                Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}",
+                Text = Language.StringByID(R.MyInternationalizationString.Current) + "   " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device),
                 TextSize = 10
             };
             itemView.AddChidren(StatuBtn);
@@ -415,11 +415,11 @@
         /// </summary>
         private void AddByFunctionType(FrameLayout itemView)
         {
-            if(device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�)
+            if(device.DfunctionType == DeviceFunctionType.A寮�鍏�)
             {
                 AddOnOff(itemView);
             }
-            else if(device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇)
+            else if(device.DfunctionType == DeviceFunctionType.A鎻掑骇)
             {
                 AddPlug(itemView);
             }
@@ -452,7 +452,7 @@
                 Height = Application.GetMinRealAverage(81),
                 UnSelectedImagePath = "Light/OFF.png",
                 SelectedImagePath = "Light/OFFSelected.png",
-                IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 0
+                IsSelected = (device as ToggleLight).OnOffStatus == 0
             };
             itemView.AddChidren(OffBtn);
 
@@ -464,7 +464,7 @@
                 Height = Application.GetMinRealAverage(81),
                 UnSelectedImagePath = "Light/ON.png",
                 SelectedImagePath = "Light/ONSelected.png",
-                IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+                IsSelected = (device as ToggleLight).OnOffStatus == 1
             };
             itemView.AddChidren(OnBtn);
 
@@ -486,7 +486,7 @@
                 Gravity = Gravity.CenterHorizontal,
                 UnSelectedImagePath = "Light/DeskLamp.png",
                 SelectedImagePath = "Light/DeskLampSelected.png",
-                IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+                IsSelected = (device as ToggleLight).OnOffStatus == 1
             };
             itemView.AddChidren(deviceIMG);
 
@@ -498,7 +498,7 @@
                 Gravity = Gravity.CenterHorizontal,
                 UnSelectedImagePath = "Item/Switch.png",
                 SelectedImagePath = "Item/SwitchSelected.png",
-                IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+                IsSelected = (device as ToggleLight).OnOffStatus == 1
             };
             itemView.AddChidren(switchBtn);
 
@@ -520,7 +520,7 @@
                 Gravity = Gravity.CenterHorizontal,
                 UnSelectedImagePath = "Light/Plug.png",
                 SelectedImagePath = "Light/PlugSelected.png",
-                IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+                IsSelected = (device as ToggleLight).OnOffStatus == 1
             };
             itemView.AddChidren(deviceIMG);
 
@@ -532,7 +532,7 @@
                 Gravity = Gravity.CenterHorizontal,
                 UnSelectedImagePath = "Item/Switch.png",
                 SelectedImagePath = "Item/SwitchSelected.png",
-                IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1
+                IsSelected = (device as ToggleLight).OnOffStatus == 1
             };
             itemView.AddChidren(switchBtn);
 
@@ -565,19 +565,26 @@
             sendedControlCommand = false;
             zbGateway.ReportAction += UpdateDeviceControllStatu;
             switchBtn.IsSelected = !switchBtn.IsSelected;
-            deviceIMG.IsSelected = !deviceIMG.IsSelected;
-            StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}";
-
-            if (switchBtn.IsSelected == true)
+            deviceIMG.IsSelected = !deviceIMG.IsSelected;
+            StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + "   ";
+            if (deviceIMG.IsSelected == true)
             {
-                (device.CommonDevice as ToggleLight).SwitchControl(1);
+                StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1);
             }
             else
             {
-                (device.CommonDevice as ToggleLight).SwitchControl(0);
+                StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close);
+            }
+            if (switchBtn.IsSelected == true)
+            {
+                (device as ToggleLight).SwitchControl(1);
+            }
+            else
+            {
+                (device as ToggleLight).SwitchControl(0);
             }
             //鎺у埗寤舵椂鍥炶皟
-            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+            UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () =>
             {
                 if (Parent == null)
                 {
@@ -586,7 +593,7 @@
                 RemoveUpdateControlDeviceStatuAction();
                 if (sendedControlCommand == false)
                 {
-                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+                    UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL);
                 }
             });
         }
@@ -599,10 +606,10 @@
         private void ON(object sender, MouseEventArgs eventArgs)
         {
             SetONOFFStatu(true);
-            (device.CommonDevice as ToggleLight).SwitchControl(1);
+            (device as ToggleLight).SwitchControl(1);
             //鎺у埗寤舵椂鍥炶皟
             zbGateway.ReportAction += UpdateDeviceControllStatu;
-            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+            UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () =>
             {
                 if (Parent == null)
                 {
@@ -611,7 +618,7 @@
                 RemoveUpdateControlDeviceStatuAction();
                 if (sendedControlCommand == false)
                 {
-                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+                    UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL);
                 }
             });
         }
@@ -623,10 +630,10 @@
         private void OFF(object sender, MouseEventArgs eventArgs)
         {
             SetONOFFStatu(false);
-            (device.CommonDevice as ToggleLight).SwitchControl(0);
+            (device as ToggleLight).SwitchControl(0);
             //鎺у埗寤舵椂鍥炶皟
             zbGateway.ReportAction += UpdateDeviceControllStatu;
-            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+            UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () =>
             {
                 if (Parent == null)
                 {
@@ -635,7 +642,7 @@
                 RemoveUpdateControlDeviceStatuAction();
                 if (sendedControlCommand == false)
                 {
-                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+                    UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL);
                 }
             });
         }
@@ -645,18 +652,20 @@
         /// </summary>
         /// <param name="statu"></param>
         private void SetONOFFStatu(bool statu)
-        {
+        {
+            StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + "   ";
             if (statu)
             {
                 OnBtn.IsSelected = true;
                 OffBtn.IsSelected = false;
+                StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1);
             }
             else
             {
                 OnBtn.IsSelected = false;
-                OffBtn.IsSelected = true;
+                OffBtn.IsSelected = true;
+                StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close);
             }
-            StatuBtn.Text = statu ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}";
         }
 
 
@@ -693,12 +702,12 @@
             //collection
             if ((sender as Button).IsSelected)
             {
-                Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName);
+                UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device);
                 (sender as Button).IsSelected = false;
             }
             else
             {
-                Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName);
+                UserCenter.HdlRoomLogic.Current.AddLoveDevice(device);
                 (sender as Button).IsSelected = true;
             }
         }
@@ -723,7 +732,7 @@
                 return;
             }
             var tempDevice = (CommonDevice)objValue;
-            if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr)
+            if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr)
             {
                 //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊
                 return;

--
Gitblit v1.8.0