From b7b3e92bed9c4553e30e2901a1877f088a5f8823 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期一, 04 十一月 2019 17:20:52 +0800
Subject: [PATCH] 2019.11.4

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |  607 +++++++++++++++++++++++++------------------------------
 1 files changed, 275 insertions(+), 332 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
old mode 100755
new mode 100644
index 9ed8a71..716fece
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -166,45 +166,25 @@
                                     {
                                         var light = deviceUI.CommonDevice as ToggleLight;
                                         light.DeviceStatusReport = common.DeviceStatusReport;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
+                                        //璁板綍銆佹洿鏂扮姸鎬�
+                                        if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0)
                                         {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
-                                            {
-                                                //璁板綍銆佹洿鏂扮姸鎬�
-                                                if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0)
-                                                {
-                                                    continue;
-                                                }
-                                                light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                                (tempView as Button).IsSelected = light.OnOffStatus == 1;
-                                                //璁板綍鍥炲鏃堕棿
-                                                light.LastDateTime = DateTime.Now;
-                                            }
+                                            continue;
                                         }
+                                        light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+
+                                        row.SetStatu(light.OnOffStatus == 1);
+                                        row.SetStatuText(deviceUI.GetDeviceStatu());
+                                        //璁板綍鍥炲鏃堕棿
+                                        light.LastDateTime = DateTime.Now;
                                     }
                                     if (common.DeviceStatusReport.CluterID == 3)
                                     {
-                                        var light = deviceUI.CommonDevice as ToggleLight;
-                                        light.IsOnline = 1;
-                                        //璁板綍鍥炲鏃堕棿
-                                        light.LastDateTime = DateTime.Now;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                        {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_Online)
-                                            {
-                                                (tempView as Button).IsSelected = light.IsOnline == 1;
-                                            }
-                                        }
+                                        deviceUI.CommonDevice.IsOnline = 1;
+                                        deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                        row.SetStatu(true);
                                     }
                                     break;
 
@@ -214,80 +194,69 @@
                                     {
                                         var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch;
                                         airSwitch.DeviceStatusReport = common.DeviceStatusReport;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
+                                        //璁板綍銆佹洿鏂扮姸鎬�
+                                        if (airSwitch.DeviceStatusReport.AttriBute == null || airSwitch.DeviceStatusReport.AttriBute.Count == 0)
                                         {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
-                                            {
-                                                //璁板綍銆佹洿鏂扮姸鎬�
-                                                if (airSwitch.DeviceStatusReport.AttriBute == null || airSwitch.DeviceStatusReport.AttriBute.Count == 0)
-                                                {
-                                                    return;
-                                                }
-                                                airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                                (tempView as Button).IsSelected = airSwitch.OnOffStatus == 1;
-                                                //璁板綍鍥炲鏃堕棿
-                                                airSwitch.LastDateTime = DateTime.Now;
-                                            }
+                                            return;
                                         }
+                                        airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                        row.SetStatu(airSwitch.OnOffStatus == 1);
+                                        row.SetStatuText(deviceUI.GetDeviceStatu());
+                                        //璁板綍鍥炲鏃堕棿
+                                        airSwitch.LastDateTime = DateTime.Now;
                                     }
                                     if (common.DeviceStatusReport.CluterID == 3)
                                     {
-                                        var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch;
-                                        airSwitch.IsOnline = 1;
-                                        //璁板綍鍥炲鏃堕棿
-                                        airSwitch.LastDateTime = DateTime.Now;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                        {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_Online)
-                                            {
-                                                (tempView as Button).IsSelected = airSwitch.IsOnline == 1;
-                                            }
-                                        }
+                                        deviceUI.CommonDevice.IsOnline = 1;
+                                        deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                        row.SetStatu(true);
                                     }
                                     break;
                                 case DeviceType.WindowCoveringDevice:
+
+                                    if (common.DeviceStatusReport.CluterID == 258)
+                                    {
+                                        if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0)
+                                        {
+                                            //绐楀笜绫诲瀷
+                                            var rollerShade = deviceUI.CommonDevice as Rollershade;
+                                            rollerShade.DeviceStatusReport = common.DeviceStatusReport;
+                                            rollerShade.WcdType = common.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                            rollerShade.LastDateTime = DateTime.Now;
+                                        }
+                                        if (common.DeviceStatusReport.AttriBute[0].AttributeId == 8)
+                                        {
+                                            var row = rowLayout.GetChildren(0) as CategoryFunctionForWinRow;
+                                            //绐楀笜鐧惧垎姣�
+                                            var rollerShade = deviceUI.CommonDevice as Rollershade;
+                                            rollerShade.DeviceStatusReport = common.DeviceStatusReport;
+                                            rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                            row.SetStatuText($"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}");
+                                            rollerShade.LastDateTime = DateTime.Now;
+                                        }
+                                    }
                                     if (common.DeviceStatusReport.CluterID == 3)
                                     {
-                                        var rollerShape = deviceUI.CommonDevice as Rollershade;
-                                        //璁板綍鍥炲鏃堕棿
-                                        rollerShape.LastDateTime = DateTime.Now;
-                                        rollerShape.IsOnline = 1;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                        {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_Online)
-                                            {
-                                                (tempView as Button).IsSelected = rollerShape.IsOnline == 1;
-                                            }
-                                        }
+                                        deviceUI.CommonDevice.IsOnline = 1;
+                                        deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionForWinRow;
+                                        row.SetStatu(true);
                                     }
                                     break;
 
                                 case DeviceType.Thermostat:
                                     //AC鍔熻兘
-                                    if (common.DeviceStatusReport.CluterID == 513)
+                                    if ((common as ZigBee.Device.AC).DeviceStatusReport.CluterID == 513)
                                     {
-                                        var attriButeList = common.DeviceStatusReport.AttriBute;
+                                        var attriButeList = (common as ZigBee.Device.AC).DeviceStatusReport.AttriBute;
                                         if (attriButeList == null || attriButeList.Count == 0)
                                         {
                                             return;
                                         }
                                         var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
-                                        ac.DeviceStatusReport = common.DeviceStatusReport;
+                                        ac.DeviceStatusReport = (common as ZigBee.Device.AC).DeviceStatusReport;
                                         switch (attriButeList[0].AttributeId)
                                         {
                                             case 0:
@@ -336,7 +305,7 @@
                                         }
 
                                     }
-                                    if (common.DeviceStatusReport.CluterID == 3)
+                                    if ((common as ZigBee.Device.AC).DeviceStatusReport.CluterID == 3)
                                     {
                                         var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
                                         ac.IsOnline = 1;
@@ -360,47 +329,27 @@
                                     //璋冨厜鐏姛鑳�
                                     if (common.DeviceStatusReport.CluterID == 6)
                                     {
-                                        var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight;
+                                        var dimmableLight = deviceUI.CommonDevice as DimmableLight;
                                         dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
+                                        //璁板綍銆佹洿鏂扮姸鎬�
+                                        if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
                                         {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_OnOffStatus)
-                                            {
-                                                //璁板綍銆佹洿鏂扮姸鎬�
-                                                if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
-                                                {
-                                                    return;
-                                                }
-                                                dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                                (tempView as Button).IsSelected = dimmableLight.OnOffStatus == 1;
-                                                //璁板綍鍥炲鏃堕棿
-                                                dimmableLight.LastDateTime = DateTime.Now;
-                                            }
+                                            continue;
                                         }
+                                        dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+
+                                        row.SetStatu(dimmableLight.OnOffStatus == 1);
+                                        row.SetStatuText(deviceUI.GetDeviceStatu());
+                                        //璁板綍鍥炲鏃堕棿
+                                        dimmableLight.LastDateTime = DateTime.Now;
                                     }
                                     if (common.DeviceStatusReport.CluterID == 3)
                                     {
-                                        var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight;
-                                        dimmableLight.IsOnline = 1;
-                                        //璁板綍鍥炲鏃堕棿
-                                        dimmableLight.LastDateTime = DateTime.Now;
-                                        for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                        {
-                                            var tempView = rowLayout.GetChildren(j);
-                                            if (tempView.Tag == null)
-                                            {
-                                                continue;
-                                            }
-                                            if (tempView.Tag.ToString() == deviceStatus_Online)
-                                            {
-                                                (tempView as Button).IsSelected = dimmableLight.IsOnline == 1;
-                                            }
-                                        }
+                                        deviceUI.CommonDevice.IsOnline = 1;
+                                        deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                        var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                        row.SetStatu(true);
                                     }
                                     break;
                             }
@@ -433,77 +382,35 @@
                             switch (deviceUI.CommonDevice.Type)
                             {
                                 case DeviceType.OnOffOutput:
-                                    var light = deviceUI.CommonDevice as ToggleLight;
-                                    light.IsOnline = (common as ToggleLight).IsOnline;
-                                    //璁板綍鍥炲鏃堕棿
-                                    light.LastDateTime = DateTime.Now;
-                                    for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                    {
-                                        var tempView = rowLayout.GetChildren(j);
-                                        if (tempView.Tag == null)
-                                        {
-                                            continue;
-                                        }
-                                        if (tempView.Tag.ToString() == deviceStatus_Online)
-                                        {
-                                            (tempView as Button).IsSelected = light.IsOnline == 1;
-                                        }
-                                    }
+                                    deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                                    var row = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                    row.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
+                                    deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     break;
                                 case DeviceType.AirSwitch:
-                                    var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch;
-                                    airSwitch.IsOnline = (common as ZigBee.Device.AirSwitch).IsOnline;
-                                    //璁板綍鍥炲鏃堕棿
-                                    airSwitch.LastDateTime = DateTime.Now;
-                                    for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                    {
-                                        var tempView = rowLayout.GetChildren(j);
-                                        if (tempView.Tag == null)
-                                        {
-                                            continue;
-                                        }
-                                        if (tempView.Tag.ToString() == deviceStatus_Online)
-                                        {
-                                            (tempView as Button).IsSelected = airSwitch.IsOnline == 1;
-                                        }
-                                    }
+                                    deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                                    var row1 = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                    row1.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
+                                    deviceUI.CommonDevice.LastDateTime = DateTime.Now;
                                     break;
                                 case DeviceType.WindowCoveringDevice:
-                                    var rollerShape = deviceUI.CommonDevice as Rollershade;
-                                    //璁板綍鍥炲鏃堕棿
-                                    rollerShape.LastDateTime = DateTime.Now;
-                                    rollerShape.IsOnline = (common as Rollershade).IsOnline;
-                                    for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                    {
-                                        var tempView = rowLayout.GetChildren(j);
-                                        if (tempView.Tag == null)
-                                        {
-                                            continue;
-                                        }
-                                        if (tempView.Tag.ToString() == deviceStatus_Online)
-                                        {
-                                            (tempView as Button).IsSelected = rollerShape.IsOnline == 1;
-                                        }
-                                    }
+                                    deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                    deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                                    var row2 = rowLayout.GetChildren(0) as CategoryFunctionForWinRow;
+                                    row2.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
                                     break;
 
+                                case DeviceType.DimmableLight:
+                                    deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                    deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                                    var row3 = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                    row3.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
+                                    break;
                                 case DeviceType.Thermostat:
-                                    var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
-                                    //璁板綍鍥炲鏃堕棿
-                                    ac.LastDateTime = DateTime.Now;
-                                    ac.IsOnline = (common as ZigBee.Device.AC).IsOnline;
-                                    for (int j = 0; j < rowLayout.ChildrenCount; j++)
-                                    {
-                                        var tempView = rowLayout.GetChildren(j);
-                                        if (tempView.Tag == null)
-                                        {
-                                            continue;
-                                        }
-                                        if (tempView.Tag.ToString() == deviceStatus_Online)
-                                        {
-                                            (tempView as Button).IsSelected = ac.IsOnline == 1;
-                                        }
-                                    }
+                                    deviceUI.CommonDevice.LastDateTime = DateTime.Now;
+                                    deviceUI.CommonDevice.IsOnline = common.IsOnline;
+                                    //var row4 = rowLayout.GetChildren(0) as CategoryFunctionRow;
+                                    //row4.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
                                     break;
                             }
                         }
@@ -543,7 +450,7 @@
         /// <param name="selectedBtn">閫変腑閭d釜鐣岄潰 0--鍔熻兘 1--鍦烘櫙 2--鑷姩鍖� </param>
         public void Show(int selectedBtn = 1)
         {
-            
+
             ZbGateway.StatusList.Add(this);
             RemoveAll();
 
@@ -585,7 +492,7 @@
             var midFL = new FrameLayout
             {
                 Y = topView.Bottom,
-                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.TabbarHeight) - topView.Bottom,
+                Height = Application.GetRealHeight(1549),
                 BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
             };
             AddChidren(midFL);
@@ -596,18 +503,17 @@
                 BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
             };
             midFL.AddChidren(functionSceneAutoBG);
-            //鍔熻兘
-            functionBtn = new ButtonLineForm(CommonFormResouce.X_Left, 34, 150, 68);
-            functionSceneAutoBG.AddChidren(functionBtn);
-            functionBtn.Init();
-            functionBtn.SetTitle(R.MyInternationalizationString.Function);
 
             //鍦烘櫙
-            sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 34, 150, 68);
+            sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left, 34, 150, 68);
             functionSceneAutoBG.AddChidren(sceneBtn);
             sceneBtn.Init();
             sceneBtn.SetTitle(R.MyInternationalizationString.Scence);
-
+            //鍔熻兘
+            functionBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 34, 150, 68);
+            functionSceneAutoBG.AddChidren(functionBtn);
+            functionBtn.Init();
+            functionBtn.SetTitle(R.MyInternationalizationString.Function);
             //鑷姩鍖�
             automationBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 * 2 + 20, 34, 150, 68);
             automationBtn.Init();
@@ -895,11 +801,10 @@
                 deviceListScrolView = new VerticalScrolViewLayout
                 {
                     X = Application.GetRealWidth(CommonFormResouce.X_Left),
-                    Y = functionTypeScrowView.Bottom + Application.GetRealHeight(50),
+                    Y = Application.GetRealHeight(35+275),
                     Width = Application.GetRealWidth(1028),
-                    Height = functionSceneBodyView.Height - Application.GetRealHeight(279 + 50) - 1,
+                    Height = Application.GetRealHeight(938) - 1,
                     BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
-
                 };
                 functionSceneBodyView.AddChidren(deviceListScrolView);
                 tempFunctionTypeBtn = new FunctionButton();
@@ -987,18 +892,19 @@
 
                             var deviceTypeRowLayout = new RowLayout()
                             {
-                                Height = Application.GetRealHeight(127 + 35),
+                                Height = Application.GetRealHeight(129 + 35),
                                 LineColor = ZigbeeColor.Current.GXCBackgroundColor,
                                 Tag = deviceUI
                             };
                             deviceListScrolView.AddChidren(deviceTypeRowLayout);
 
-                            var deviceRow = new FunctionRow(0, 35);
+                            var deviceRow = new CategoryFunctionRow(0, 35);
                             deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                             deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                            deviceRow.SetStatu(light.IsOnline == 1);
+                            deviceRow.SetOnLineStatu(light.IsOnline == 1);
+                            deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
+                            deviceRow.SetStatu(light.OnOffStatus == 1);
                             deviceTypeRowLayout.AddChidren(deviceRow);
-
 
                             deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
                             {
@@ -1007,6 +913,7 @@
                                 zbGateway.ReportAction += UpdateDeviceControllStatu;
                                 AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
                                 (send2 as Button).IsSelected = !(send2 as Button).IsSelected;
+                                deviceRow.IsSelected = (send2 as Button).IsSelected;
                                 if ((send2 as Button).IsSelected)
                                 {
                                     light.SwitchControl(1);
@@ -1015,6 +922,7 @@
                                 {
                                     light.SwitchControl(0);
                                 }
+                                deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                 //鎺у埗寤舵椂鍥炶皟
                                 DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () =>
                                 {
@@ -1028,6 +936,15 @@
                                         DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
                                     }
                                 });
+                            };
+
+                            deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
+                            {
+                                var lightControl = new Phone.Device.Light.LightControl();
+                                UserView.HomePage.Instance.AddChidren(lightControl);
+                                UserView.HomePage.Instance.PageIndex += 1;
+                                //lightControl.action = RefreshBodyView;
+                                lightControl.Show(deviceUI, room);
                             };
 
                             var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1074,16 +991,18 @@
 
                             var deviceTypeRowLayout = new RowLayout()
                             {
-                                Height = Application.GetRealHeight(127 + 35),
+                                Height = Application.GetRealHeight(129 + 35),
                                 LineColor = ZigbeeColor.Current.GXCBackgroundColor,
                                 Tag = deviceUI
                             };
                             deviceListScrolView.AddChidren(deviceTypeRowLayout);
 
-                            var deviceRow = new FunctionRow(0, 35);
+                            var deviceRow = new CategoryFunctionRow(0, 35);
                             deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                             deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                            deviceRow.SetStatu(airSwitch.IsOnline == 1);
+                            deviceRow.SetOnLineStatu(airSwitch.IsOnline == 1);
+                            deviceRow.SetStatu(airSwitch.OnOffStatus == 1);
+                            deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                             deviceTypeRowLayout.AddChidren(deviceRow);
 
                             deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
@@ -1093,8 +1012,8 @@
                                 zbGateway.ReportAction += UpdateDeviceControllStatu;
                                 AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
 
-                                (send2 as CommonForm.SelectedStatuButton).IsSelected = !(send2 as CommonForm.SelectedStatuButton).IsSelected;
-                                if ((send2 as CommonForm.SelectedStatuButton).IsSelected)
+                                (send2 as Button).IsSelected = !(send2 as Button).IsSelected;
+                                if ((send2 as Button).IsSelected)
                                 {
                                     airSwitch.SwitchControl(1);
                                 }
@@ -1102,6 +1021,7 @@
                                 {
                                     airSwitch.SwitchControl(0);
                                 }
+                                deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                 //鎺у埗寤舵椂鍥炶皟
                                 DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () =>
                                 {
@@ -1115,6 +1035,15 @@
                                         DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
                                     }
                                 });
+                            };
+
+                            deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
+                            {
+                                var lightControl = new Phone.Device.Light.AirSwitchControl();
+                                UserView.HomePage.Instance.AddChidren(lightControl);
+                                UserView.HomePage.Instance.PageIndex += 1;
+                                //lightControl.action = RefreshBodyView;
+                                lightControl.Show(deviceUI, room);
                             };
 
                             var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1163,16 +1092,18 @@
 
                             var deviceTypeRowLayout = new RowLayout()
                             {
-                                Height = Application.GetRealHeight(127 + 35),
+                                Height = Application.GetRealHeight(129 + 35),
                                 LineColor = ZigbeeColor.Current.GXCBackgroundColor,
                                 Tag = deviceUI
                             };
                             deviceListScrolView.AddChidren(deviceTypeRowLayout);
 
-                            var deviceRow = new FunctionRow(0, 35);
+                            var deviceRow = new CategoryFunctionRow(0, 35);
                             deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                             deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                            deviceRow.SetStatu(dimmableLight.IsOnline == 1);
+                            deviceRow.SetOnLineStatu(dimmableLight.IsOnline == 1);
+                            deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
+                            deviceRow.SetStatu(dimmableLight.OnOffStatus == 1);
                             deviceTypeRowLayout.AddChidren(deviceRow);
 
                             deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
@@ -1182,8 +1113,8 @@
                                 zbGateway.ReportAction += UpdateDeviceControllStatu;
                                 AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
 
-                                (send2 as CommonForm.SelectedStatuButton).IsSelected = !(send2 as CommonForm.SelectedStatuButton).IsSelected;
-                                if ((send2 as CommonForm.SelectedStatuButton).IsSelected)
+                                (send2 as Button).IsSelected = !(send2 as Button).IsSelected;
+                                if ((send2 as Button).IsSelected)
                                 {
                                     dimmableLight.SwitchControl(1);
                                 }
@@ -1191,6 +1122,7 @@
                                 {
                                     dimmableLight.SwitchControl(0);
                                 }
+                                deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                 //鎺у埗寤舵椂鍥炶皟
                                 DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () =>
                                 {
@@ -1204,6 +1136,16 @@
                                         DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
                                     }
                                 });
+                            };
+
+                            deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
+                            {
+                                var dimmableLightControl = new Phone.Device.Light.DimmableLightControl();
+                                UserView.HomePage.Instance.AddChidren(dimmableLightControl);
+                                UserView.HomePage.Instance.PageIndex += 1;
+                                UserView.HomePage.Instance.ScrollEnabled = false;
+                                //dimmableLightControl.action = RefreshBodyView;
+                                dimmableLightControl.Show(deviceUI, room);
                             };
 
                             var editBtn = new CommonForm.RowLayoutEditButton()
@@ -1267,10 +1209,12 @@
                             };
                             deviceListScrolView.AddChidren(deviceTypeRowLayout);
 
-                            var deviceRow = new FunctionRow(0, 35);
+                            var deviceRow = new CategoryFunctionRow(0, 35);
                             deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                             deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                            deviceRow.SetStatu(ac.IsOnline == 1);
+                            deviceRow.SetOnLineStatu(ac.IsOnline == 1);
+                            deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
+                            deviceRow.SetStatu(ac.currentSystemMode != 1);
                             deviceTypeRowLayout.AddChidren(deviceRow);
 
                             deviceRow.SwitchBtn.MouseUpEventHandler += (send2, e2) =>
@@ -1289,6 +1233,7 @@
                                 {
                                     ac.Close();
                                 }
+                                deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
                                 //鎺у埗寤舵椂鍥炶皟
                                 DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () =>
                                 {
@@ -1348,17 +1293,37 @@
 
                             var deviceTypeRowLayout = new RowLayout()
                             {
-                                Height = Application.GetRealHeight(127 + 35),
-                                LineColor = ZigbeeColor.Current.GXCLineColor,
+                                Height = Application.GetRealHeight(129 + 35),
+                                LineColor = ZigbeeColor.Current.GXCBackgroundColor,
                                 Tag = deviceUI
                             };
                             deviceListScrolView.AddChidren(deviceTypeRowLayout);
 
-                            var deviceRow = new FunctionRow(0, 35);
-                            deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
+                            var deviceRow = new CategoryFunctionForWinRow(0, 35);
+                            deviceRow.Init(deviceUI);
                             deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
-                            deviceRow.SetStatu(rollerShade.IsOnline == 1);
+                            deviceRow.SetOnLineStatu(rollerShade.IsOnline == 1);
+                            deviceRow.SetStatuText(deviceUI.GetDeviceStatu());
+                            deviceRow.SetStatu(rollerShade.WcdCurrentPositionLiftPercentage != 0);
+                            deviceRow.SetRollerShadeIcon(rollerShade.WcdType);
                             deviceTypeRowLayout.AddChidren(deviceRow);
+
+                            if (rollerShade.WcdType == -1)
+                            {
+                                CommonPage.Loading.Start();
+                                new System.Threading.Thread(() =>
+                                {
+                                    Rollershade.ReadWcdTypeAction(rollerShade, () =>
+                                    {
+                                        Application.RunOnMainThread(() =>
+                                        {
+                                            deviceRow.SetRollerShadeIcon(rollerShade.WcdType);
+                                            CommonPage.Loading.Hide();
+                                        });
+                                    });
+                                })
+                                { IsBackground = true }.Start();
+                            }
 
                             var editBtn = new CommonForm.RowLayoutEditButton()
                             {
@@ -1376,37 +1341,14 @@
                             deviceTypeRowLayout.AddRightView(delBtn);
                             delBtn.MouseUpEventHandler += delEvent;
 
-
-                            deviceRow.SwitchBtn.MouseUpEventHandler += (sender, e) =>
+                            deviceRow.ClickBtn.MouseUpEventHandler += (send2, e2) =>
                             {
-                                zbGateway = deviceUI.CommonDevice.Gateway;
-                                sendedControlCommand = false;
-                                zbGateway.ReportAction += UpdateDeviceControllStatu;
-                                AddZbGateway(zbGatewayList, zbGateway, commonDeviceList, deviceUI.CommonDevice);
-
-                                (sender as CommonForm.SelectedStatuButton).IsSelected = !(sender as CommonForm.SelectedStatuButton).IsSelected;
-                                if ((sender as CommonForm.SelectedStatuButton).IsSelected)
-                                {
-                                    rollerShade.CurtainUpDownStopControl(0);
-                                }
-                                else
-                                {
-                                    rollerShade.CurtainUpDownStopControl(1);
-                                }
-
-                                //鎺у埗寤舵椂鍥炶皟
-                                DeviceUI.SendCommandDelayAction(deviceUI.CommonDevice, () =>
-                                {
-                                    if (Parent == null)
-                                    {
-                                        return;
-                                    }
-                                    RemoveUpdateControlDeviceStatuAction(zbGateway);
-                                    if (sendedControlCommand == false)
-                                    {
-                                        DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
-                                    }
-                                });
+                                var rollerShadeControl = new Phone.Device.Curtain.RollerShadeControl();
+                                UserView.HomePage.Instance.AddChidren(rollerShadeControl);
+                                UserView.HomePage.Instance.PageIndex += 1;
+                                UserView.HomePage.Instance.ScrollEnabled = false;
+                                //rollerShadeControl.action = RefreshBodyView;
+                                rollerShadeControl.Show(deviceUI, room);
                             };
                         }
                         else
@@ -1434,7 +1376,7 @@
                     typeRowLayout.AddChidren(functionTypeIMG);
 
                     functionTypeIMG.ClickBtn.MouseUpEventHandler += ShowSameTypeFunction;
-                   
+
 
                     if (deviceType == room.DeviceUIList[0].CommonDevice.Type)
                     {
@@ -1452,7 +1394,7 @@
             var roomFL = new HorizontalScrolViewLayout()
             {
                 X = Application.GetRealWidth(CommonFormResouce.X_Left),
-                Height = Application.GetRealHeight(167),
+                Height = Application.GetRealHeight(170),
                 Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonFormResouce.X_Left),
                 BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
             };
@@ -1462,7 +1404,7 @@
             functionSceneBodyView = new FrameLayout()
             {
                 Y = roomFL.Bottom,
-                Height = Application.GetRealHeight(1316),
+                Height = Application.GetRealHeight(973+279),
                 BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
             };
             functionSceneAutoBodyView.AddChidren(functionSceneBodyView);
@@ -1505,7 +1447,7 @@
                     {
                         RefreshFunction(room);
                     }
-                   
+
                 }
                 roomBtn.MouseUpEventHandler += (sender, e) =>
                 {
@@ -1526,7 +1468,7 @@
                     }
                 };
             }
-            
+
         }
 
         #endregion
@@ -1556,7 +1498,7 @@
             {
                 var sceneScrolView = new VerticalScrolViewLayout
                 {
-                    Y = Application.GetRealHeight(58)
+                    //Y = Application.GetRealHeight(58)
                 };
                 functionSceneBodyView.AddChidren(sceneScrolView);
                 foreach (var scene in sceneList)
@@ -1611,7 +1553,7 @@
                         Tag = scene
                     };
                     leftFL.AddChidren(collectionBtn);
-                    
+
                     var sceneNameBtn = new Button()
                     {
                         Width = Application.GetRealWidth(176),
@@ -1760,7 +1702,7 @@
                                 }
                             };
                         }
-                        
+
                     };
                     deleteBtn.MouseUpEventHandler += delEvent;
                     //缂栬緫鍦烘櫙
@@ -1816,6 +1758,7 @@
 
         #endregion
 
+
         #region 鈼� 鑷姩鍖朹_________________________
 
         /// <summary>
@@ -1825,7 +1768,7 @@
         {
 
             functionSceneAutoBodyView.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
-            
+
             var bjFrameLayout = new FrameLayout
             {
                 Width = Application.GetRealWidth(1080 - 58),
@@ -1992,7 +1935,7 @@
                 var Idlist = await Logic.Send.GetLogicId(0);
                 if (Idlist.Count != 0)
                 {
-                    var listlogic = await Logic.Send.ReadList(Idlist.Count,0);
+                    var listlogic = await Logic.Send.ReadList(Idlist.Count, 0);
                     //foreach鍙兘闆嗗悎宸茶淇敼,鏋氫妇鎿嶄綔鍙兘涓嶄細鎵ц,鍙兘鍑虹幇宕╂簝(寤鸿for)銆�
                     for (int j = 0; j < listlogic.Count; j++)
                     {
@@ -2145,78 +2088,6 @@
 
 
         }
-
-        #region 鈼� 鎺у埗鐘舵�乢________________________
-
-        /// <summary>
-        /// 鏄剧ず璁惧鎺у埗鐘舵��
-        /// </summary>
-        /// <param name="command">Command.</param>
-        /// <param name="objValue">Object value.</param>
-        private void UpdateDeviceControllStatu(string command, object objValue)
-        {
-            if (command != "DeviceDefaultAck" || objValue == null)
-            {
-                return;
-            }
-            var tempDevice = (CommonDevice)objValue;
-            if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == tempDevice.DeviceEpoint && obj.DeviceAddr == tempDevice.DeviceAddr))
-            {
-                return;
-            }
-            //鏍囪宸茬粡鍙戦�佹帶鍒跺懡浠ゅ埌缃戝叧
-            sendedControlCommand = true;
-            //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success);
-        }
-
-        /// <summary>
-        /// 绉婚櫎鍏ㄩ儴鏇存柊鎺у埗璁惧鐨刟ction
-        /// </summary>
-        private void RemoveAllUpdateControlDeviceStatuAction()
-        {
-            foreach (var gateway in zbGatewayList)
-            {
-                //绉婚櫎action
-                if (gateway != null)
-                {
-                    gateway.ReportAction -= UpdateDeviceControllStatu;
-                }
-            }
-        }
-
-        /// <summary>
-        /// 绉婚櫎鍗曚釜鎺у埗璁惧鐨勬洿鏂扮姸鎬乤ction
-        /// </summary>
-        /// <param name="gateway">Gateway.</param>
-        private void RemoveUpdateControlDeviceStatuAction(ZbGateway gateway)
-        {
-            //绉婚櫎action
-            if (gateway != null)
-            {
-                gateway.ReportAction -= UpdateDeviceControllStatu;
-            }
-        }
-
-        /// <summary>
-        /// 娣诲姞闇�瑕佺洃鎺у洖璋冪姸鎬佺殑缃戝叧鍜岃澶�
-        /// </summary>
-        /// <param name="gatewayList">Gateway list.</param>
-        /// <param name="gateway">Gateway.</param>
-        /// <param name="deviceList">Device list.</param>
-        /// <param name="common">Common.</param>
-        private void AddZbGateway(List<ZbGateway> gatewayList, ZbGateway gateway, List<CommonDevice> deviceList, CommonDevice common)
-        {
-            if (null == gatewayList.Find((obj) => obj.getGatewayBaseInfo.gwID == gateway.getGatewayBaseInfo.gwID))
-            {
-                gatewayList.Add(gateway);
-            }
-            if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == common.DeviceEpoint && obj.DeviceAddr == common.DeviceAddr))
-            {
-                commonDeviceList.Add(common);
-            }
-        }
-
-        #endregion
 
         private void StatusColor(Common.Logic logic, RowLayout logicRowlayout, int intvalue)
         {
@@ -2612,5 +2483,77 @@
             }
         }
         #endregion
+
+        #region 鈼� 鎺у埗鐘舵�乢________________________
+
+        /// <summary>
+        /// 鏄剧ず璁惧鎺у埗鐘舵��
+        /// </summary>
+        /// <param name="command">Command.</param>
+        /// <param name="objValue">Object value.</param>
+        private void UpdateDeviceControllStatu(string command, object objValue)
+        {
+            if (command != "DeviceDefaultAck" || objValue == null)
+            {
+                return;
+            }
+            var tempDevice = (CommonDevice)objValue;
+            if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == tempDevice.DeviceEpoint && obj.DeviceAddr == tempDevice.DeviceAddr))
+            {
+                return;
+            }
+            //鏍囪宸茬粡鍙戦�佹帶鍒跺懡浠ゅ埌缃戝叧
+            sendedControlCommand = true;
+            //DeviceUI.ShowStatuTip(R.MyInternationalizationString.Success);
+        }
+
+        /// <summary>
+        /// 绉婚櫎鍏ㄩ儴鏇存柊鎺у埗璁惧鐨刟ction
+        /// </summary>
+        private void RemoveAllUpdateControlDeviceStatuAction()
+        {
+            foreach (var gateway in zbGatewayList)
+            {
+                //绉婚櫎action
+                if (gateway != null)
+                {
+                    gateway.ReportAction -= UpdateDeviceControllStatu;
+                }
+            }
+        }
+
+        /// <summary>
+        /// 绉婚櫎鍗曚釜鎺у埗璁惧鐨勬洿鏂扮姸鎬乤ction
+        /// </summary>
+        /// <param name="gateway">Gateway.</param>
+        private void RemoveUpdateControlDeviceStatuAction(ZbGateway gateway)
+        {
+            //绉婚櫎action
+            if (gateway != null)
+            {
+                gateway.ReportAction -= UpdateDeviceControllStatu;
+            }
+        }
+
+        /// <summary>
+        /// 娣诲姞闇�瑕佺洃鎺у洖璋冪姸鎬佺殑缃戝叧鍜岃澶�
+        /// </summary>
+        /// <param name="gatewayList">Gateway list.</param>
+        /// <param name="gateway">Gateway.</param>
+        /// <param name="deviceList">Device list.</param>
+        /// <param name="common">Common.</param>
+        private void AddZbGateway(List<ZbGateway> gatewayList, ZbGateway gateway, List<CommonDevice> deviceList, CommonDevice common)
+        {
+            if (null == gatewayList.Find((obj) => obj.getGatewayBaseInfo.gwID == gateway.getGatewayBaseInfo.gwID))
+            {
+                gatewayList.Add(gateway);
+            }
+            if (null == commonDeviceList.Find((obj) => obj.DeviceEpoint == common.DeviceEpoint && obj.DeviceAddr == common.DeviceAddr))
+            {
+                commonDeviceList.Add(common);
+            }
+        }
+
+        #endregion
     }
 }

--
Gitblit v1.8.0