From 3272ca5b51e19f7f8a827b0f68400570a547fe60 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 28 四月 2020 15:02:44 +0800
Subject: [PATCH] 2020-04-28-1

---
 ZigbeeApp/Shared/Phone/UserView/UserPage.cs |  431 ++++++++++-------------------------------------------
 1 files changed, 83 insertions(+), 348 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
index 13ca839..8df13b5 100755
--- a/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
+++ b/ZigbeeApp/Shared/Phone/UserView/UserPage.cs
@@ -1,15 +1,14 @@
 锘縰sing System;
 using System.Collections.Generic;
 using Shared.Common;
-using ZigBee.Device;
-using Shared.Phone.Device.AC;
-
+using System.Text;
+
 namespace Shared.Phone.UserView
 {
     /// <summary>
     /// User page.
     /// </summary>
-    public class UserPage : FrameLayout,ZigBee.Common.IStatus
+    public class UserPage : FrameLayout
     {
         #region 鈼� 鍙橀噺_______________________
         /// <summary>
@@ -39,318 +38,7 @@
         /// <summary>
         /// 搴曢儴鎸夐挳鏂囧瓧鐨刌鍊�
         /// </summary>
-        private static readonly int tabBarEnumName_Y = 104;
-        #endregion
-
-        #region 鈼� 鎺ュ彛____________________________
-
-        /// <summary>
-        /// 璇ユ帴鍙e皢寮冪敤 !!!!!!
-        /// 鏀圭敤DeviceInfoChange()
-        /// </summary>
-        /// <returns>The changed.</returns>
-        /// <param name="common">Common.</param>
-        public void Changed(CommonDevice common)
-        {
-
-        }
-
-        /// <summary>
-        /// 璁惧鐘舵�佹洿鏂版帴鍙�
-        /// <para>type锛氬鏋滀负 DeviceInComingRespon:璁惧鏂颁笂鎶�</para>
-        /// <para>type锛氬鏋滀负 IASInfoReport:RemoveDeviceRespon</para>
-        /// <para>type锛氬鏋滀负 DeviceStatusReport:璁惧涓婃姤</para>
-        /// <para>type锛氬鏋滀负 IASInfoReport:IAS瀹夐槻淇℃伅涓婃姤</para>
-        /// <para>type锛氬鏋滀负 OnlineStatusChange: 璁惧鍦ㄧ嚎鐘舵�佹洿鏂�</para>
-        /// </summary>
-        /// <param name="common">Common.</param>
-        /// <param name="typeTag">Type tag.</param>
-        public void DeviceInfoChange(CommonDevice common, string typeTag)
-        {
-            ///
-            //璁惧涓婃姤鐘舵�佷腑 褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
-            if (typeTag == "DeviceStatusReport")
-            {
-                try
-                {
-                    for (int i = 0; i < Room.AllRoomDeviceUIList.Count; i++)
-                    {
-                        var deviceUI = Room.AllRoomDeviceUIList[i];
-                        if (deviceUI.CommonDevice == null)
-                        {
-                            //璁惧涓虹┖
-                            continue;
-                        }
-                        if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint)
-                        {
-                            //鍒ゆ柇鏄惁涓哄綋鍓嶈澶�
-                            continue;
-                        }
-                        switch (deviceUI.CommonDevice.Type)
-                        {
-                            case DeviceType.OnOffOutput:
-                                //寮�鍏冲姛鑳�
-                                if (common.DeviceStatusReport.CluterID == 6)
-                                {
-                                    var onOffOutputLight = deviceUI.CommonDevice as ZigBee.Device.ToggleLight;
-                                    onOffOutputLight.DeviceStatusReport = common.DeviceStatusReport;
-                                    //璁板綍銆佹洿鏂扮姸鎬�
-                                    if (onOffOutputLight.DeviceStatusReport.AttriBute == null || onOffOutputLight.DeviceStatusReport.AttriBute.Count == 0)
-                                    {
-                                        continue;
-                                    }
-                                    onOffOutputLight.OnOffStatus = onOffOutputLight.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                    //璁板綍鍥炲鏃堕棿
-                                    onOffOutputLight.LastDateTime = DateTime.Now;
-                                }
-                                //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
-                                if (common.DeviceStatusReport.CluterID == 3)
-                                {
-                                    var onOffOutputLight = deviceUI.CommonDevice as ToggleLight;
-                                    onOffOutputLight.IsOnline = 1;
-                                    //璁板綍鍥炲鏃堕棿
-                                    onOffOutputLight.LastDateTime = DateTime.Now;
-                                }
-                                break;
-
-                            case DeviceType.AirSwitch:
-                                //寮�鍏冲姛鑳�
-                                if (common.DeviceStatusReport.CluterID == 6)
-                                {
-                                    var airSwitch = deviceUI.CommonDevice as ZigBee.Device.AirSwitch;
-                                    airSwitch.DeviceStatusReport = common.DeviceStatusReport;
-                                    //璁板綍銆佹洿鏂扮姸鎬�
-                                    if (airSwitch.DeviceStatusReport.AttriBute == null || airSwitch.DeviceStatusReport.AttriBute.Count == 0)
-                                    {
-                                        return;
-                                    }
-                                    airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                    //璁板綍鍥炲鏃堕棿
-                                    airSwitch.LastDateTime = DateTime.Now;
-
-                                }
-                                //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
-                                if (common.DeviceStatusReport.CluterID == 3)
-                                {
-                                    var airSwitch = deviceUI.CommonDevice as AirSwitch;
-                                    airSwitch.IsOnline = 1;
-                                    //璁板綍鍥炲鏃堕棿
-                                    airSwitch.LastDateTime = DateTime.Now;
-                                }
-                                break;
-
-                            case DeviceType.WindowCoveringDevice:
-                                if (common.DeviceStatusReport.CluterID == 258)
-                                {
-                                    var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
-                                    rollershade.DeviceStatusReport = common.DeviceStatusReport;
-                                    var attriButeList = rollershade.DeviceStatusReport.AttriBute;
-                                    if (attriButeList == null || attriButeList.Count == 0)
-                                    {
-                                        continue;
-                                    }
-                                    switch (attriButeList[0].AttributeId)
-                                    {
-                                        case 0:
-                                            rollershade.WcdType = attriButeList[0].AttriButeData;
-                                            rollershade.LastDateTime = DateTime.Now;
-                                            break;
-                                    }
-                                }
-                                if (common.DeviceStatusReport.CluterID == 3)
-                                {
-                                    var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
-                                    rollershade.IsOnline = 1;
-                                    //璁板綍鍥炲鏃堕棿
-                                    rollershade.LastDateTime = DateTime.Now;
-                                }
-                                break;
-
-                            case DeviceType.Thermostat:
-                                //AC鍔熻兘
-                                if (common.DeviceStatusReport.CluterID == 513)
-                                {
-                                    var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
-                                    ac.DeviceStatusReport = common.DeviceStatusReport;
-                                    var attriButeList = ac.DeviceStatusReport.AttriBute;
-                                    if (attriButeList == null || attriButeList.Count == 0)
-                                    {
-                                        continue;
-                                    }
-                                    switch (attriButeList[0].AttributeId)
-                                    {
-                                        case 0:
-                                            //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝
-                                            ac.currentLocalTemperature = attriButeList[0].AttriButeData / 100;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-
-                                        case 17:
-                                            //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鍐锋俯搴︼紝瀹為檯娓╁害涓衡�淐oolingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆�
-                                            ac.currentCoolingSetpoint = attriButeList[0].AttriButeData / 100;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-
-                                        case 18:
-                                            //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鐑俯搴︼紝瀹為檯娓╁害涓衡�淗eatingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆�
-                                            ac.currentHeatingSetpoint = attriButeList[0].AttriButeData / 100;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-
-                                        case 4096:
-                                            //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勮嚜鍔ㄦ俯搴︼紝瀹為檯娓╁害涓衡�淎utoSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆�
-                                            ac.currentAutoSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-
-                                        case 28:
-                                            //姝ゅ睘鎬ф弿杩版亽娓╄澶囨澶勪簬鍝妯″紡
-                                            //Off = 0  Auto = 1 Cool = 3 Heat = 4 FanOnly = 7  Dry = 8
-                                            ac.currentSystemMode = attriButeList[0].AttriButeData;
-                                            ac.LastDateTime = DateTime.Now;
-                                            break;
-
-                                    }
-
-                                }
-                                //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
-                                if (common.DeviceStatusReport.CluterID == 3)
-                                {
-                                    var ac = deviceUI.CommonDevice as AC;
-                                    ac.IsOnline = 1;
-                                    //璁板綍鍥炲鏃堕棿
-                                    ac.LastDateTime = DateTime.Now;
-
-                                }
-                                break;
-
-                            case DeviceType.DimmableLight:
-                                //璋冨厜鐏姛鑳�
-                                //寮�鍏冲姛鑳�
-                                if (common.DeviceStatusReport.CluterID == 6)
-                                {
-                                    var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight;
-                                    dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
-                                    //璁板綍銆佹洿鏂扮姸鎬�
-                                    if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0)
-                                    {
-                                        return;
-                                    }
-                                    dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                    //璁板綍鍥炲鏃堕棿
-                                    dimmableLight.LastDateTime = DateTime.Now;
-                                }
-                                //浜害
-                                if (common.DeviceStatusReport.CluterID == 8)
-                                {
-                                    var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight;
-                                    dimmableLight.DeviceStatusReport = common.DeviceStatusReport;
-                                    var attriButeList = dimmableLight.DeviceStatusReport.AttriBute;
-                                    if (attriButeList == null || attriButeList.Count == 0)
-                                    {
-                                        continue;
-                                    }
-                                    switch (attriButeList[0].AttributeId)
-                                    {
-                                        case 0:
-                                            //姝ゅ睘鎬ц〃鏄庡綋鍓嶄寒搴︾▼搴�
-                                            dimmableLight.Level = attriButeList[0].AttriButeData;
-                                            dimmableLight.LastDateTime = DateTime.Now;
-                                            break;
-                                    }
-                                }
-                                //褰揅luterID=3,灏辫瘉鏄庤璁惧鍦ㄧ嚎锛岀洿鎺ユ爣璁�
-                                if (common.DeviceStatusReport.CluterID == 3)
-                                {
-                                    var dimmableLight = deviceUI.CommonDevice as DimmableLight;
-                                    dimmableLight.IsOnline = 1;
-                                    //璁板綍鍥炲鏃堕棿
-                                    dimmableLight.LastDateTime = DateTime.Now;
-                                }
-                                break;
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    System.Console.WriteLine($"Error:{ex.Message}");
-                }
-            }
-            //璁惧鍦ㄧ嚎鐘舵�佷笂鎶�
-            else if (typeTag == "OnlineStatusChange")
-            {
-                try
-                {
-                    for (int i = 0; i < Room.AllRoomDeviceUIList.Count; i++)
-                    {
-                        var deviceUI = Room.AllRoomDeviceUIList[i];
-                        if (deviceUI.CommonDevice == null)
-                        {
-                            //璁惧涓虹┖鎴栬�呮帶浠朵负绌�
-                            continue;
-                        }
-                        if (common.DeviceAddr != deviceUI.CommonDevice.DeviceAddr || common.DeviceEpoint != deviceUI.CommonDevice.DeviceEpoint)
-                        {
-                            //鍒ゆ柇鏄惁涓哄綋鍓嶈澶�
-                            continue;
-                        }
-                        switch (deviceUI.CommonDevice.Type)
-                        {
-                            case DeviceType.OnOffOutput:
-                                var onOffOutputLight = deviceUI.CommonDevice as ToggleLight;
-                                onOffOutputLight.IsOnline = common.IsOnline;
-                                //璁板綍鍥炲鏃堕棿
-                                onOffOutputLight.LastDateTime = DateTime.Now;
-                                break;
-                            case DeviceType.AirSwitch:
-                                var airSwitch = deviceUI.CommonDevice as AirSwitch;
-                                airSwitch.IsOnline = common.IsOnline;
-                                //璁板綍鍥炲鏃堕棿
-                                airSwitch.LastDateTime = DateTime.Now;
-                                break;
-                            case DeviceType.WindowCoveringDevice:
-                                var rollershade = deviceUI.CommonDevice as ZigBee.Device.Rollershade;
-                                rollershade.IsOnline = common.IsOnline;
-                                //璁板綍鍥炲鏃堕棿
-                                rollershade.LastDateTime = DateTime.Now;
-                                break;
-                            case DeviceType.Thermostat:
-                                var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
-                                ac.IsOnline = common.IsOnline;
-                                //璁板綍鍥炲鏃堕棿
-                                ac.LastDateTime = DateTime.Now;
-                                break;
-                            case DeviceType.DimmableLight:
-                                var dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight;
-                                dimmableLight.IsOnline = common.IsOnline;
-                                //璁板綍鍥炲鏃堕棿
-                                dimmableLight.LastDateTime = DateTime.Now;
-                                break;
-                        }
-                    }
-                }
-                catch (Exception ex)
-                {
-                    System.Console.WriteLine($"userpage鍔熻兘鍒锋柊-Error:{ex.Message}");
-                }
-            }
-        }
-        /// <summary>
-        /// Changeds the IL ogic status.
-        /// </summary>
-        /// <param name="logic">Logic.</param>
-        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
-        {
-            //throw new NotImplementedException();
-        }
-        /// <summary>
-        /// Changeds the IS cene status.
-        /// </summary>
-        /// <param name="scene">Scene.</param>
-        public void ChangedISceneStatus(Scene scene)
-        {
-            //throw new NotImplementedException();
-        }
+        private static readonly int tabBarEnumName_Y = 98;
         #endregion
 
         /// <summary>
@@ -375,7 +63,10 @@
         public UserPage()
         {
             BackgroundColor = Shared.Common.ZigbeeColor.Current.MainColor;
-            ZbGateway.StatusList.Add(this);
+            Shared.Application.LocationAction += (lon, lat) =>
+            {
+                Login.AccountLogic.Instance.ReceiveAppLatAndLon(lon.ToString(), lat.ToString());
+            };
         }
 
         /// <summary>
@@ -426,7 +117,6 @@
             Width = Application.GetMinRealAverage(tabBarEnumIMG_Width),
             UnSelectedImagePath = "Navigation/Home.png",
             SelectedImagePath = "Navigation/HomeSelected.png",
-            IsSelected = true,
             Gravity = Gravity.CenterHorizontal
         };
         /// <summary>
@@ -439,7 +129,6 @@
             TextID = R.MyInternationalizationString.HomePage,
             TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBottomUnSelectedColor,
             SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2,
-            IsSelected = true,
             Gravity = Gravity.CenterHorizontal,
             TextSize = 10
         };
@@ -451,7 +140,7 @@
         /// </summary>
         public FrameLayout categoryFL = new FrameLayout
         {
-            X=Application.GetRealWidth(tabBarEnum_Width),
+            X = Application.GetRealWidth(tabBarEnum_Width),
             Width = Application.GetRealWidth(tabBarEnum_Width),
             Height = Application.GetRealHeight(CommonPage.TabbarHeight)
         };
@@ -477,9 +166,8 @@
             TextID = R.MyInternationalizationString.Category,
             TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBottomUnSelectedColor,
             SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2,
-            IsSelected = false,
             Gravity = Gravity.CenterHorizontal,
-            TextSize=10
+            TextSize = 10
         };
         #endregion
 
@@ -489,7 +177,7 @@
         /// </summary>
         public FrameLayout settingFL = new FrameLayout
         {
-            X = Application.GetRealWidth(tabBarEnum_Width*2),
+            X = Application.GetRealWidth(tabBarEnum_Width * 2),
             Width = Application.GetRealWidth(tabBarEnum_Width),
             Height = Application.GetRealHeight(CommonPage.TabbarHeight)
         };
@@ -515,48 +203,95 @@
             TextID = R.MyInternationalizationString.Me,
             TextColor = Shared.Common.ZigbeeColor.Current.GXCTextBottomUnSelectedColor,
             SelectedTextColor = Shared.Common.ZigbeeColor.Current.GXCTextBlackColor2,
-            IsSelected = false,
             Gravity = Gravity.CenterHorizontal,
             TextSize = 10
-        };
+        };
         #endregion
+
+        #region 寮哄埗鏄剧ず鑷姩鍖栫晫闈�
 
+        /// <summary>
+        /// 寮哄埗鏄剧ず鑷姩鍖栧垪琛ㄧ晫闈�
+        /// </summary>
+        public void ShowCategoryAutoListForm()
+        {
+            //鍏抽棴鍏ㄩ儴鐣岄潰,鐩村埌涓婚〉涓烘
+            UserCenter.UserCenterLogic.CloseAllOpenForm();
+            //寮哄埗鏄剧ず鑷姩鍖栧垪琛ㄧ晫闈�
+            UserCenter.UserCenterResourse.ResidenceOption.CategoryPageSwitchIndex = 2;
+            BottomEventHandler(Instance.categoryIMG, null);
+        }
 
+        #endregion
+
         EventHandler<MouseEventArgs> BottomEventHandler = (sender, e) =>
         {
-            Instance.homePageName.IsSelected = false;
-            Instance.homePageIMG.IsSelected = false;
-
-            Instance.categoryName.IsSelected = false;
-            Instance.categoryIMG.IsSelected = false;
-
-            Instance.settingName.IsSelected = false;
-            Instance.settingIMG.IsSelected = false;
-
-            Instance.BodyView.RemoveAll();
             if (sender == Instance.homePageIMG || sender == Instance.homePageName)
-            {
+            {
+                if (Instance.homePageName.IsSelected == true && e != null)
+                {
+                    //鍙湁鏄墜鍔ㄧ偣鍑荤殑鏃跺�欐墠澶勭悊
+                    return;
+                }
+                Instance.BodyView.RemoveAll();
                 //涓婚〉
+                CommonPage.Instance.IsDrawerLockMode = false;
                 Instance.homePageName.IsSelected = true;
-                Instance.homePageIMG.IsSelected = true;
-                var home = new UserHomeView { };
+                Instance.homePageIMG.IsSelected = true;
+
+                Instance.categoryName.IsSelected = false;
+                Instance.categoryIMG.IsSelected = false;
+
+                Instance.settingName.IsSelected = false;
+                Instance.settingIMG.IsSelected = false;
+
+                var home = new MainPage.HomeMainPageForm();
                 Instance.BodyView.AddChidren(home);
-                home.Show();
+                home.ShowForm();
+
             }
-            else if (sender == Instance.categoryIMG || sender==Instance.categoryName)
-            {
+            else if (sender == Instance.categoryIMG || sender == Instance.categoryName)
+            {
+                if (Instance.categoryName.IsSelected == true && e != null)
+                {
+                    //鍙湁鏄墜鍔ㄧ偣鍑荤殑鏃跺�欐墠澶勭悊
+                    return;
+                }
+
+                Instance.BodyView.RemoveAll();
                 //鍒嗙被
+                CommonPage.Instance.IsDrawerLockMode = true;
                 Instance.categoryName.IsSelected = true;
-                Instance.categoryIMG.IsSelected = true;
-                var category = new Phone.Device.Category.Category { };
+                Instance.categoryIMG.IsSelected = true;
+
+                Instance.homePageName.IsSelected = false;
+                Instance.homePageIMG.IsSelected = false;
+
+                Instance.settingName.IsSelected = false;
+                Instance.settingIMG.IsSelected = false;
+
+                var category = new Category.CategoryMainForm { };
                 Instance.BodyView.AddChidren(category);
-                category.Show();
+                category.ShowForm();
             }
-            else if (sender == Instance.settingIMG || sender==Instance.settingName)
-            {
-                 //涓汉涓績
+            else if (sender == Instance.settingIMG || sender == Instance.settingName)
+            {
+                if (Instance.settingName.IsSelected == true && e != null)
+                {
+                    return;
+                }
+                Instance.BodyView.RemoveAll();
+                //涓汉涓績
+                CommonPage.Instance.IsDrawerLockMode = true;
                 Instance.settingName.IsSelected = true;
-                Instance.settingIMG.IsSelected = true;
+                Instance.settingIMG.IsSelected = true;
+
+                Instance.homePageName.IsSelected = false;
+                Instance.homePageIMG.IsSelected = false;
+
+                Instance.categoryName.IsSelected = false;
+                Instance.categoryIMG.IsSelected = false;
+
                 var form = new UserCenter.UserMain.UserMainForm();
                 Instance.BodyView.AddChidren(form);
                 form.ShowForm();

--
Gitblit v1.8.0