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/Logic/DeviceStateCondition.cs |  219 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 122 insertions(+), 97 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
index e2355c2..f0fe357 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
@@ -105,12 +105,13 @@
                 Y = Application.GetRealHeight(92),
                 UnSelectedImagePath = "ZigeeLogic/drop-down.png",
             };
-            topRowLayout.AddChidren(dropdown);
-
+            topRowLayout.AddChidren(dropdown);
+
             #endregion
-
+
             ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
-            if (Common.Room.Lists.Count == 0)
+            var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms();
+            if (listAllRoom.Count == 0)
             {
                 return;
             }
@@ -264,7 +265,7 @@
                 dropdown.Visible = false;
                 if (Config.Instance.Home.FloorDics.Count == 0)
                 {
-                    roomlists.AddRange(Common.Room.Lists);
+                    roomlists.AddRange(listAllRoom);
                 }
                 else
                 {
@@ -330,14 +331,15 @@
                     roomTextButton = roomnameBtn;
                     roomnameBtn.IsSelected = true;
 
-                    var list = new List<DeviceUI>();
-                    foreach (var device in room.DeviceUIList)
+                    var list = new List<CommonDevice>();
+                    foreach (var deviceKeys in room.ListDevice)
                     {
-                        if (device.CommonDevice == null)
+                        var device = LocalDevice.Current.GetDevice(deviceKeys);
+                        if (device == null)
                         {
                             continue;
                         }
-                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
+                        if (!deviceTypeList.Contains(device.Type))
                         {
                             continue;
                         }
@@ -371,14 +373,15 @@
                     roomTextButton = roomnameBtn;
                     roomnameBtn.IsSelected = true;
 
-                    var list = new List<DeviceUI>();
-                    foreach (var device in room.DeviceUIList)
-                    {
-                        if (device.CommonDevice == null)
+                    var list = new List<CommonDevice>();
+                    foreach (var deviceKeys in room.ListDevice)
+                    {
+                        var device = LocalDevice.Current.GetDevice(deviceKeys);
+                        if (device == null)
                         {
                             continue;
                         }
-                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
+                        if (!deviceTypeList.Contains(device.Type))
                         {
                             continue;
                         }
@@ -409,34 +412,34 @@
         /// 鍔犺浇璇ュ尯鍩熸墍鏈夎澶囪鍥炬柟娉�
         /// </summary>0
         /// <param name="devicelist">Devicelist.</param>
-        void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol)
+        void AllDeviceTypeView(List<CommonDevice> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol)
         {
             List<string> devicetypelist = new List<string>();
             devicetypelist.Clear();
             #region  ------鎺掑垪璁惧绫诲瀷------
             ///鏆傛椂闅愯棌鐏厜鍜岀獥甯樿澶�
-            var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.ColorDimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput);
+            var lightjosn = devicelist.Find((device) => device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.OnOffOutput);
             if (lightjosn != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights));
             }
-            var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice);
+            var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice);
             if (curtainjosn != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
             }
 
-            var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone || device.CommonDevice.Type == DeviceType.TemperatureSensor);
+            var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor);
             if (iASZonejosn != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor));
             }
-            var onOffSwitchjson = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.OnOffSwitch);
+            var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch);
             if (onOffSwitchjson != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch));
             }
-            var doorLock = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DoorLock);
+            var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock);
             if (doorLock != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock));
@@ -571,14 +574,14 @@
         /// </summary>
         /// <param name="deviceTypelist">Device typelist.</param>
         /// <param name="devicelist">璁惧鍒楄〃</param>
-        void ConditionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist)
+        void ConditionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist)
         {
             middle.RemoveAll();
 
             foreach (var common in devicelist)
             {
 
-                if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type))
+                if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type))
                 {
                     continue;
                 }
@@ -623,14 +626,14 @@
 
                 var devicename = new Button
                 {
-                    Text = common.CommonDevice.DeviceEpointName,
+                    Text = common.DeviceEpointName,
                     TextAlignment = TextAlignment.CenterLeft,
                     TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                     SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
                     TextSize = 14,
                 };
                 deviceRow.AddChidren(devicename);
-                switch (common.CommonDevice.Type)
+                switch (common.Type)
                 {
                     case DeviceType.OnOffOutput:
                         {
@@ -640,7 +643,7 @@
                         break;
                     case DeviceType.IASZone:
                         {
-                            var iASZonedevice = common.CommonDevice as IASZone;
+                            var iASZonedevice = common as IASZone;
                             if (iASZonedevice.DeviceID != 1026)
                             {
                                 break;
@@ -653,7 +656,7 @@
                         break;
                     case DeviceType.TemperatureSensor:
                         {
-                            var temperatureSensor = common.CommonDevice as TemperatureSensor;
+                            var temperatureSensor = common as TemperatureSensor;
                             if (temperatureSensor.SensorDiv == 1)
                             {
                                 deviceIconBtn.UnSelectedImagePath = $"ZigeeLogic/temperature.png";
@@ -693,7 +696,7 @@
                     devicename.IsSelected = true;
                     var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                     this.AddChidren(flMain);
-                    CurrentDeviceView(flMain, common.CommonDevice, false);
+                    CurrentDeviceView(flMain, common, false);
                 };
                 deviceFramelayout.MouseUpEventHandler += devicclick;
                 bjFramelayout.MouseUpEventHandler += devicclick;
@@ -1440,94 +1443,116 @@
                 case DeviceType.TemperatureSensor:
                     {
                         string current = Language.StringByID(MyInternationalizationString.current);
-                        devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 * 2 - 20 - 50);
-                        devicefra.Height = Application.GetRealHeight(140 + 160 * 2 + 20 + 50);
+                        devicefra.Y = Application.GetRealHeight(1920 - 140 - 600);
+                        devicefra.Height = Application.GetRealHeight(140 + 600);
                         var temperatureSensor = common as TemperatureSensor;
-                        var Btntemperaturevalue = new Button
+                        SelectedDeviceStatuscondition = "TemperatureSensor";
+                        #region  甯冨眬View
+                        var PickerViewfra = new FrameLayout
                         {
-                            TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
-                            Height = Application.GetRealHeight(60),
-                            Width = Application.GetRealWidth(400),
-                            TextAlignment = TextAlignment.CenterLeft,
-                            X = Application.GetRealWidth(80),
-                            Y = timetype.Bottom + Application.GetRealHeight(70),
-                            TextSize = 14,
+                            Y = Application.GetRealHeight(140),
+                            Height = Application.GetRealHeight(600),
                         };
-                        devicefra.AddChidren(Btntemperaturevalue);
+                        devicefra.AddChidren(PickerViewfra);
 
-                        var horizontalSeekBarVol = new DiyImageSeekBar
+
+                        var mUIPickerView = new UIPickerView
                         {
-                            Y = timetype.Bottom + Application.GetRealHeight(70 + 60 + 70),
-                            X = Application.GetRealWidth(80),
-                            Width = Application.GetRealWidth(920),
-                            Height = Application.GetRealHeight(160),
-                            IsProgressTextShow = false,//鏄剧ず鐧惧垎姣�
-                            IsClickable = true,//杩涘害鏉℃槸鍚︽粦鍔�
-                            ProgressBarColor = ZigbeeColor.Current.LogicProgressColorSelected,//閫変腑杩涘害鏉¢鑹�
-                            ThumbImagePath = "ZigeeLogic/progressbtn_2.png",//杩涘害鏉℃寜閽浘鏍�
-                            ThumbImageHeight = Application.GetRealHeight(56),//杩涘害鏉℃寜閽浘鏍囩殑楂樺害锛堥粯璁ゆ鏂瑰舰锛氬鍜岄珮涓�鏍凤級
-                            ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor,//杩涘害鏉″師棰滆壊
-                            //ProgressTextSize = 13,//鏄剧ず鐧惧垎姣斿瓧浣撳ぇ灏� 
-                            SeekBarViewHeight = Application.GetRealHeight(10),//杩涘害鏉$殑楂樺害
+                            Height = Application.GetRealHeight(600 - 5),
                         };
-                        devicefra.AddChidren(horizontalSeekBarVol);
+                        PickerViewfra.AddChidren(mUIPickerView);
 
-                        EventHandler<int> progressclick = (sender, e) =>
+                        var mList1 = new List<string> { ">", "<", "=", "鈮�", "鈮�" };
+                        var mList2 = new List<string>();
+                        var mList3 = new List<string>();
+                        for (int i = 1; i <=100; i++)
                         {
-
-                            SelectedDeviceStatuscondition = "TemperatureSensor";
-                            if (temperatureSensor.SensorDiv == 1)
-                            {
-                                dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());
-
-                                Btntemperaturevalue.Text = current + ">" + horizontalSeekBarVol.Progress.ToString() + "鈩�";
-
-                            }
-                            else
-                            {
-                                Btntemperaturevalue.Text = current + "<" + horizontalSeekBarVol.Progress.ToString() + "%";
-                                dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());//娓╁害鍊�
-                            }
-
-                        };
-                        horizontalSeekBarVol.OnProgressChangedEvent += progressclick;
-                        horizontalSeekBarVol.OnStopTrackingTouchEvent += progressclick;
-
-
-                        if (temperatureSensor.SensorDiv == 1)
-                        {
+                            mList2.Add(i.ToString());
+                        }
+                        if (temperatureSensor.SensorDiv == 1) {
+                            mList3.Add("鈩�");
                             dictionary(deviceConditionsInfo, "Cluster_ID", "1026");
                             dictionary(deviceConditionsInfo, "AttriButeId", "0");
-                            dictionary(deviceConditionsInfo, "Range", "0");//0澶т簬AttriButeData1鏃惰Е鍙戝姩浣�
-                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");
+                            dictionary(deviceConditionsInfo, "Range", "1");//1:绛変簬AttriButeData1鏃惰Е鍙戝姩浣�
+                            dictionary(deviceConditionsInfo, "AttriButeData1", "50");//榛樿娓╁害鍊�50鈩�
                             dictionary(deviceConditionsInfo, "AttriButeData2", "0");
-                            Btntemperaturevalue.Text = current + ">0鈩�";
-
-                        }
-                        else
-                        {
-                            Btntemperaturevalue.Text = current + "<0%";
+                        } else {
+                            mList3.Add("%");
                             dictionary(deviceConditionsInfo, "Cluster_ID", "1029");
                             dictionary(deviceConditionsInfo, "AttriButeId", "0");
-                            dictionary(deviceConditionsInfo, "Range", "2");//2灏忎簬AttriButeData1鏃惰Е鍙戝姩浣�
-                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");//娓╁害鍊�
+                            dictionary(deviceConditionsInfo, "Range", "1");//1:绛変簬AttriButeData1鏃惰Е鍙戝姩浣�
+                            dictionary(deviceConditionsInfo, "AttriButeData1", "50");//榛樿婀垮害鍊�50%
                             dictionary(deviceConditionsInfo, "AttriButeData2", "0");
                         }
+                        mUIPickerView.setNPicker(mList1, mList2, mList3);
 
+                        #endregion
+
+                        mUIPickerView.OnSelectChangeEvent += (s1, s2, s3) =>
+                        {
+                            SelectedDeviceStatuscondition = "TemperatureSensor";
+                            dictionary(deviceConditionsInfo, "AttriButeData1", mList2[s2]);
+                            switch (mList1[s1])
+                            {
+                                case ">": {
+                                        dictionary(deviceConditionsInfo, "Range", "0");
+                                    } break;
+                                case "<": {
+                                        dictionary(deviceConditionsInfo, "Range", "2");
+                                    } break;
+                                case "=": {
+                                        dictionary(deviceConditionsInfo, "Range", "1");
+                                    } break;
+                                case "鈮�": {
+                                        dictionary(deviceConditionsInfo, "Range", "6");
+                                    } break;
+                                case "鈮�": {
+                                        dictionary(deviceConditionsInfo, "Range", "7");
+                                    } break;
+                            }
+                        };
+
+                        //榛樿=,50
+                        int index1 = 2, index2 = 49;
                         if (edit && devices != null)
                         {
-                            horizontalSeekBarVol.Progress = int.Parse(devices["AttriButeData1"]);
-                            if (temperatureSensor.SensorDiv == 1)
+                            SelectedDeviceStatuscondition = "";
+                            string s = "";
+                            switch (devices["Range"])
                             {
-
-                                Btntemperaturevalue.Text = current + ">" + devices["AttriButeData1"] + "鈩�";
-
+                                case "0":
+                                    {
+                                        s = ">";
+                                    }
+                                    break;
+                                case "1":
+                                    {
+                                        s = "=";
+                                    }
+                                    break;
+                                case "2":
+                                    {
+                                        s = "<";
+                                    }
+                                    break;
+                                case "6":
+                                    {
+                                        s = "鈮�";
+                                    }
+                                    break;
+                                case "7":
+                                    {
+                                        s = "鈮�";
+                                    }
+                                    break;
                             }
-                            else
-                            {
-                                Btntemperaturevalue.Text = current + "<" + devices["AttriButeData1"] + "%";
-                            }
+                            //鏌ユ壘绱㈠紩
+                            index1 = mList1.IndexOf(s);
+                            index2 = mList2.IndexOf(devices["AttriButeData1"]);
+
                         }
+                        ///鏇存柊鏈�鏂扮姸鎬侊紱
+                        mUIPickerView.setCurrentItems(index1, index2, 0);
 
                     }
                     break;
@@ -1544,9 +1569,9 @@
                 {
                     if (!edit)
                     {
-                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
-                                               Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
-                                               Language.StringByID(MyInternationalizationString.confrim));
+                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                    Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
+                                   Language.StringByID(MyInternationalizationString.confrim));
                         alert.Show();
                         return;
                     }

--
Gitblit v1.8.0