using System; using System.Collections.Generic; using Shared.SimpleControl.Phone.Music; namespace Shared.SimpleControl.Phone { public static class UserMiddle { public static int userMenuItemHeight { get { //if (Application.PixelScale > 1) { // return Convert.ToInt32 (90 * Application.PixelScale + 20); //} else { return Convert.ToInt32 (90 * MainPage.PixelScale); //} } } public static FrameLayout UserPageView = new FrameLayout (); public static Button LinkStatusTip = new Button () { Height = Application.GetRealHeight (Convert.ToInt32 (36 * MainPage.PixelScale)), BackgroundColor = SkinStyle.Current.LinkStatusTipColor }; public static PageLayout FavoritePageView = new PageLayout () { IsShowPoint = false, }; public static FrameLayout FavoriteBodyView = new FrameLayout () { //BackgroundColor = 0xFF00FF00, //Width = Application.GetRealWidth (640), //Height = Application.GetRealHeight (Application.DesignHeight) }; public static UserRoom FavoriteRoom = new UserRoom () { //BackgroundColor = 0xFF0000ff, Height = Application.GetRealHeight (Application.DesignHeight - userMenuItemHeight) }; public static PageLayout DevicePageView = new PageLayout () { IsShowPoint = false, }; public static FrameLayout DeviceBodyView = new FrameLayout () { Height = Application.GetRealHeight (Application.DesignHeight) }; public static VerticalScrolViewLayout DeviceView = new VerticalScrolViewLayout () { Y = Application.GetRealHeight (126), Height = Application.GetRealHeight (Application.DesignHeight - 126 - userMenuItemHeight), }; public static PageLayout RoomPageView = new PageLayout () { IsShowPoint = false, }; public static FrameLayout RoomBodyView = new FrameLayout () { Width = Application.GetRealWidth (640), Height = Application.GetRealHeight (Application.DesignHeight) }; public static PageLayout SettingPageView = new PageLayout () { IsShowPoint = false, }; public static FrameLayout SettingBodyView = new FrameLayout () { BackgroundColor = SkinStyle.Current.MainColor, Height = Application.GetRealHeight (Application.DesignHeight) }; public static VerticalScrolViewLayout SettingView = new VerticalScrolViewLayout () { Y = Application.GetRealHeight (126), Width = Application.GetRealWidth (640), Height = Application.GetRealHeight (Application.DesignHeight - 126 - userMenuItemHeight), BackgroundColor = SkinStyle.Current.ViewColor, ScrollEnabled = false }; //public static Button btnVersion = new Button () { // Y = Application.GetRealHeight (Application.DesignHeight - userMenuItemHeight - 90), // Width = Application.GetRealWidth (640), // Height = Application.GetRealHeight (90), // Text = Language.StringByID (R.MyInternationalizationString.Version) + " : " + MainPage.CodeIDString, // TextColor = SkinStyle.Current.TextColor1, // BackgroundColor = SkinStyle.Current.ViewColor, // Enable = false //}; public static FrameLayout UserMenuItem = new FrameLayout () { Y = Application.GetRealHeight (Application.DesignHeight - userMenuItemHeight), Height = Application.GetRealHeight (userMenuItemHeight+5), BackgroundColor = SkinStyle.Current.MainColor }; static int curPageView = 0; public static List updateSensorhreadList = new List (); #region ---Bottom Button---- public static Button btnFavorite = new Button () { Width = Application.GetRealWidth (160), Height = MainPage.GetDesignHeight (90), TextID = R.MyInternationalizationString.Favorite, TextColor = SkinStyle.Current.TextColor1, SelectedTextColor = SkinStyle.Current.SelectedColor, BackgroundColor = SkinStyle.Current.MainColor, SelectedBackgroundColor = SkinStyle.Current.UserMenuItemButton, UnSelectedImagePath = "Navigation/MenuFavorite.png", SelectedImagePath = "Navigation/MenuFavoriteOn.png", TextSize = 10, Padding = new Padding (Application.GetRealHeight (50), 0, 0, 0), IsSelected = true }; public static Button btnDevice = new Button () { X = Application.GetRealWidth (160), Width = Application.GetRealWidth (160), Height = MainPage.GetDesignHeight (90), TextID = R.MyInternationalizationString.Category, SelectedTextColor = SkinStyle.Current.SelectedColor, TextColor = SkinStyle.Current.TextColor1, BackgroundColor = SkinStyle.Current.MainColor, SelectedBackgroundColor = SkinStyle.Current.UserMenuItemButton, UnSelectedImagePath = "Navigation/MenuCategory.png", SelectedImagePath = "Navigation/MenuCategoryOn.png", TextSize = 10, Padding = new Padding (Application.GetRealHeight (50), 0, 0, 0), }; public static Button btnRoom = new Button () { X = Application.GetRealWidth (160 * 2), Width = Application.GetRealWidth (160), Height = MainPage.GetDesignHeight (90), TextID = R.MyInternationalizationString.Rooms, SelectedTextColor = SkinStyle.Current.SelectedColor, TextColor = SkinStyle.Current.TextColor1, BackgroundColor = SkinStyle.Current.MainColor, SelectedBackgroundColor = SkinStyle.Current.UserMenuItemButton, UnSelectedImagePath = "Navigation/MenuRoom.png", SelectedImagePath = "Navigation/MenuRoomOn.png", TextSize = 10, Padding = new Padding (Application.GetRealHeight (50), 0, 0, 0), }; public static Button btnSetting = new Button () { X = Application.GetRealWidth (160 * 3), Width = Application.GetRealWidth (160), Height = MainPage.GetDesignHeight (90), TextID = R.MyInternationalizationString.Setting, SelectedTextColor = SkinStyle.Current.SelectedColor, TextColor = SkinStyle.Current.TextColor1, BackgroundColor = SkinStyle.Current.MainColor, SelectedBackgroundColor = SkinStyle.Current.UserMenuItemButton, UnSelectedImagePath = "Navigation/MenuSettings.png", SelectedImagePath = "Navigation/MenuSettingsOn.png", TextSize = 10, Padding = new Padding (Application.GetRealHeight (50), 0, 0, 0), }; public static void SelectedBottomButton (Button btn) { btnFavorite.IsSelected = false; btnDevice.IsSelected = false; btnRoom.IsSelected = false; btnSetting.IsSelected = false; btn.IsSelected = true; } #endregion static void CleanPageView (FrameLayout BodyView) { UserMenuItem.RemoveAll (); FavoriteRoom.RemoveAll (); FavoriteBodyView.RemoveAll (); FavoritePageView.RemoveAll (); DeviceView.RemoveAll (); DeviceBodyView.RemoveAll (); DevicePageView.RemoveAll (); RoomBodyView.RemoveAll (); RoomPageView.RemoveAll (); SettingView.RemoveAll (); SettingBodyView.RemoveAll (); SettingPageView.RemoveAll (); UserPageView.RemoveAll (); BodyView.AddChidren (UserMenuItem); UserMenuItem.AddChidren (btnFavorite); UserMenuItem.AddChidren (btnDevice); UserMenuItem.AddChidren (btnRoom); UserMenuItem.AddChidren (btnSetting); foreach (var thread in UserMiddle.updateSensorhreadList) { thread.Abort (); //Console.WriteLine ("abortThread"); } UserMiddle.updateSensorhreadList.Clear (); } public static void Init () { #if wallon InitHomePageView (); return; #else if (MainPage.LoginUser == null) MainPage.LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject (System.Text.Encoding.UTF8.GetString (Shared.IO.FileUtils.ReadFile (UserInfo.GlobalRegisterFile))); //判断需不需要登录,有没有登录,或者登录是否过期, if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin) { if (MainPage.LoginUser != null) new AccountLogin (MainPage.LoginUser.AccountString, "").Show (); else new AccountLogin ().Show (); UserConfig.Instance.SaveUserConfig (); } else { InitHomePageView (); //Console.WriteLine ("TokenID : " + MainPage.LoginUser.LoginTokenString); //后台验证账号 new System.Threading.Thread (() => { try { var requestObj = new LoginObj () { Account = MainPage.LoginUser.AccountString, Password = MainPage.LoginUser.Password }; var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); var revertObj = MainPage.RequestHttps ("Login", requestJson, false); if (revertObj != null) { Application.RunOnMainThread (() => { if (revertObj.StateCode == "SUCCESS") { var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject (revertObj.ResponseData.ToString ()); MainPage.LoginUser.AllVisionRegisterDevUserNameGuid = revertData.AllVisionRegisterDevUserNameGuid; MainPage.LoginUser.LastTime = DateTime.Now; MainPage.LoginUser.SaveUserInfo (); string DeviceType = "android"; #if __IOS__ DeviceType = "iphone"; #endif var mAddRegIDObj = new AddRegIDObj () { RegID = UserConfig.Instance.tokenID, Alias = UserConfig.Instance.phoneName, Account = MainPage.LoginUser.AccountString, UserMode = 2, }; var mAddRegIDObjJson = Newtonsoft.Json.JsonConvert.SerializeObject (mAddRegIDObj); MainPage.RequestHttps (@"AddRegID", mAddRegIDObjJson, true, false); //string jsonString = "{" + // "\"RegID\":" + "\"" + UserConfig.Instance.tokenID + "\"" + "," + // "\"Alias\":" + "\"" + UserConfig.Instance.phoneName + "\"" + "," + // "\"Account\":" + "\"" + MainPage.LoginUser.AccountString + "\"" + // "}"; //MainPage.RequestHttps (@"AddRegID", jsonString, true); if (!string.IsNullOrEmpty (MainPage.LoginUser.AllVisionRegisterDevUserNameGuid)) { //可视对讲 Application.RunOnMainThread (() => { #if Android (Application.Activity as BaseActivity).ReadWriteContact ((b) => { if (b) { com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid); } }); #else com.freeview.global.Video.Init (MainPage.LoginUser.LoginTokenString, MainPage.LoginUser.AllVisionRegisterDevUserNameGuid); #endif }); } } else if (revertObj.StateCode != "Net_Error") { MainPage.LoginUser.LastTime = DateTime.Now.AddDays (-30); MainPage.LoginUser.SaveUserInfo (); new AccountLogin ().Show (); } }); } #if Android if (UserConfig.Instance.UpdateVersionType == 0) UserSettingView.CheckVersionInfo (); #endif } catch { } finally { UserConfig.Instance.SaveUserConfig (); } }) { IsBackground = true}.Start(); } #endif } /// /// 加载用户界面 /// static void InitHomePageView () { #if DEBUG //var tv = new InfraredMode () { SubnetID = 42, DeviceID = 1, LoopID = 1, InfraredType = InfraredType.TV, Name = "TV" }; //IO.FileUtils.SaveEquipmentMessage (tv, "1"); //var tv1 = new InfraredMode () { SubnetID = 42, DeviceID = 1, LoopID = 11, InfraredType = InfraredType.STB, Name = "stb" }; //IO.FileUtils.SaveEquipmentMessage (tv1, "11"); //var ac = new ACInfrared () { SubnetID = 42, DeviceID = 1, LoopID = 111, Name = "ac" }; //IO.FileUtils.SaveEquipmentMessage (ac, "111"); var mHVAC = new HVAC () { SubnetID = 42, DeviceID = 12, LoopID = 11, Name = "ac" }; IO.FileUtils.SaveEquipmentMessage (mHVAC, "11"); var mThermostat = new Thermostat () { SubnetID = 42, DeviceID = 221, LoopID = 1, Name = "空调系统" }; IO.FileUtils.SaveEquipmentMessage (mThermostat, "111"); var mACMerrill = new ACMerrill () { SubnetID = 80, DeviceID = 0, LoopID = 1, Name = "美林空调系统", LoopCount = 17 }; var mACMerrillLoopList = new List (); for (int i = 0; i < mACMerrill.LoopCount; i++) { var id = i + 1; var ac = new ACMerrillLoop () { SubnetID = 42, DeviceID = 0, LoopID = (byte)id, Name = "空调" + id, }; if (i > 10) { ac.Power = 1; ac.IndoorTemperature = (byte)i; ac.IndoorHumidity = (byte)(30 + i); } mACMerrillLoopList.Add (ac); } mACMerrill.mACMerrillLoopList = mACMerrillLoopList; //IO.FileUtils.SaveEquipmentMessage (mACMerrill, mACMerrill.LoopID.ToString ()); //var mLightDoorLock = new LightDoorLock () { SubnetID = 42, DeviceID = 7, LoopID = 1, Name = "Door Lock", ReadStatusSubnetID = 42, ReadStatusDeviceID = 5, ReadStatusLoopID = 3 }; //IO.FileUtils.SaveEquipmentMessage (mLightDoorLock, "1"); //var mCurtainModel = new CurtainModel () { SubnetID = 111, DeviceID = 8, LoopID = 1, Name = "Curtain" }; //IO.FileUtils.SaveEquipmentMessage (mCurtainModel, "1"); //var s1 = new LightMixDimming () { SubnetID = 42,DeviceID = 2,LoopID = 1,Name = "Dimming 1",CurrentBrightness = 88}; //IO.FileUtils.SaveEquipmentMessage (s1, "1"); //var s2 = new LightMixDimming () { SubnetID = 42, DeviceID = 2, LoopID = 2, Name = "Dimming 2", CurrentBrightness = 100 }; //IO.FileUtils.SaveEquipmentMessage (s1, "2"); //var s3 = new LightMixDimming () { SubnetID = 42, DeviceID = 2, LoopID = 3, Name = "Dimming 3", CurrentBrightness = 0 }; //IO.FileUtils.SaveEquipmentMessage (s1, "3"); //var s4 = new LightMixDimming () { SubnetID = 42, DeviceID = 2, LoopID = 4, Name = "Dimming 4", CurrentBrightness = 88 }; //IO.FileUtils.SaveEquipmentMessage (s1, "4"); //var lii = new LightLogic () { Type = DeviceType.LightRGB, LoopID = 1, DeviceID = 4, SubnetID = 42, Name = "RGB" }; //IO.FileUtils.SaveEquipmentMessage (lii, lii.LoopID.ToString ()); var daliLoop = new LightDALI { Type = DeviceType.LightDALI, LoopID = 1, Name = "LightDALI1", CoolTones_High = 100, CoolTones_Low = 100, CoolTones_High_Modular = 100, CoolTones_Low_Modular = 100, WarmTones_High = 10, WarmTones_Low = 10, WarmTones_Low_Modular = 10, WarmTones_High_Modular = 10, CurrentBrightness = 0, CurTones_High = 20, CurTones_Low = 20, SubnetID = 205, DeviceID = 222 }; IO.FileUtils.SaveEquipmentMessage (daliLoop, daliLoop.LoopID.ToString ()); var daliLoop2 = new LightDALI { Type = DeviceType.LightDALI, LoopID = 2, Name = "LightDALI2", CoolTones_High = 100, CoolTones_Low = 100, CoolTones_High_Modular = 100, CoolTones_Low_Modular = 100, WarmTones_High = 10, WarmTones_Low = 10, WarmTones_Low_Modular = 10, WarmTones_High_Modular = 10, CurrentBrightness = 0, CurTones_High = 20, CurTones_Low = 20, SubnetID = 205, DeviceID = 222 }; IO.FileUtils.SaveEquipmentMessage (daliLoop2, daliLoop2.LoopID.ToString ()); //var tt = new CurtainTrietex () { LoopID = 1, DeviceID = 1, SubnetID = 42, Name = "开合帘" }; //IO.FileUtils.SaveEquipmentMessage (tt, "1"); //var fa = new FreshAir () { LoopID = 1, DeviceID = 112, SubnetID = 42, Name = "Fresh Air" }; //IO.FileUtils.SaveEquipmentMessage (fa, fa.LoopID.ToString ()); var se = new SensorPM25 () { LoopID = 1, DeviceID = 1, SubnetID = 11, Name = "PM2.5", CurrentPM25 = 22 }; IO.FileUtils.SaveEquipmentMessage (se, "1"); var se1 = new SensorCO2 () { LoopID = 1, DeviceID = 2, SubnetID = 11, Name = "CO2", CurrentCO2 = 338 }; IO.FileUtils.SaveEquipmentMessage (se1, "2"); var se2 = new SensorTVOC () { LoopID = 1, DeviceID = 3, SubnetID = 11, Name = "TVOC", CurrentTVOC = 197 }; IO.FileUtils.SaveEquipmentMessage (se2, "3"); var se3 = new SensorTemperature () { LoopID = 1, DeviceID = 4, SubnetID = 11, Name = "Temp.", CurrentTemperature = 19 }; IO.FileUtils.SaveEquipmentMessage (se3, "4"); var se4 = new SensorHumidity () { LoopID = 1, DeviceID = 5, SubnetID = 11, Name = "Humidity", CurrentHumidity = 43 }; IO.FileUtils.SaveEquipmentMessage (se4, "5"); var se5 = new SensorHumidity () { LoopID = 1, DeviceID = 6, SubnetID = 11, Name = "Humidity1", CurrentHumidity = 43 }; IO.FileUtils.SaveEquipmentMessage (se5, "6"); var se6 = new SensorHumidity () { LoopID = 1, DeviceID = 7, SubnetID = 11, Name = "Humidity2", CurrentHumidity = 43 }; IO.FileUtils.SaveEquipmentMessage (se6, "7"); //var infraredMode1 = new ACInfrared () { LoopID = 1, SubnetID = 42, DeviceID = 12, Name = "AC",SetTemperature = 26,IndoorTemperature =28 }; //IO.FileUtils.SaveEquipmentMessage (infraredMode1, "1"); //var udo = new UniversalDevice () { LoopID = 1, SubnetID = 1, DeviceID = 6, ActionType = 2, Name = "Universal-1", obj1 = 1, TargetType = 0 }; //udo.SendBytes = new List () { 1, 0 }; //IO.FileUtils.SaveEquipmentMessage (udo, "1"); //var ud12 = new UniversalDevice () { LoopID = 2, SubnetID = 1, DeviceID = 6, ActionType = 0, Name = "Universal-2", obj1 = 1, TargetType = 1 }; //ud12.SendBytes = new List () { 2, 0 }; //IO.FileUtils.SaveEquipmentMessage (ud12, "2"); //var ud13 = new UniversalDevice () { ON_Text = "DAKAI", OFF_Text = "GUAN", LoopID = 3, SubnetID = 1, DeviceID = 6, ActionType = 1, Name = "Universal-3", obj1 = 1, TargetType = 2 }; //ud13.SendBytes = new List () { 3, 0 }; //IO.FileUtils.SaveEquipmentMessage (ud13, "3"); //var ud8 = new UniversalDevice () { LoopID = 1, SubnetID = 42, DeviceID = 90, ActionType = 2, Name = "Universal-1", obj1 = 1, TargetType = 0, UniversalType = 0xE01C }; //ud8.SendBytes = new List () { 1, 100 }; //IO.FileUtils.SaveEquipmentMessage (ud8, "1"); //var ud82 = new UniversalDevice () { LoopID = 1, SubnetID = 42, DeviceID = 90, ActionType = 2, Name = "Universal-2", obj1 = 1, TargetType = 0, UniversalType = 0xE01C }; //ud82.SendBytes = new List () { 2, 100 }; //IO.FileUtils.SaveEquipmentMessage (ud82, "2"); //var ud83 = new UniversalDevice () { ON_Text = "DAKAI", OFF_Text = "GUAN", LoopID = 3, SubnetID = 2, DeviceID = 6, ActionType = 1, Name = "Universal-3", obj1 = 1, TargetType = 2 }; //ud83.SendBytes = new List () { 3, 0 }; //IO.FileUtils.SaveEquipmentMessage (ud83, "3"); //SecurityModul sm0 = new SecurityModul () { Name = "SecurityModul-1", SubnetID = 42, DeviceID = 11, LoopID = 1, obj1 = 1 }; //SecurityModul sm1 = new SecurityModul () { Name = "SecurityArea-1", SubnetID = 42, DeviceID = 11, LoopID = 1, obj1 = 1, AreaNumber = 1 }; //SecurityModul sm2 = new SecurityModul () { Name = "SecurityArea-2", SubnetID = 42, DeviceID = 11, LoopID = 2, obj1 = 1, AreaNumber = 2 }; //SecurityModul sm3 = new SecurityModul () { Name = "SecurityArea-3", SubnetID = 42, DeviceID = 11, LoopID = 3, obj1 = 1, AreaNumber = 3 }; //SecurityModul sm4 = new SecurityModul () { Name = "SecurityArea-4", SubnetID = 42, DeviceID = 11, LoopID = 4, obj1 = 1, AreaNumber = 4 }; //SecurityModul sm5 = new SecurityModul () { Name = "SecurityArea-5", SubnetID = 42, DeviceID = 11, LoopID = 5, obj1 = 1, AreaNumber = 5 }; //SecurityModul sm6 = new SecurityModul () { Name = "SecurityArea-6", SubnetID = 42, DeviceID = 11, LoopID = 6, obj1 = 1, AreaNumber = 6 }; //ScurityDryContact sdc = new ScurityDryContact () { Name = "window", SubnetID = 42, DeviceID = 10, LoopID = 1, obj1 = 1, AreaNumber = 1 }; //ScurityDryContact sdc2 = new ScurityDryContact () { Name = "door", SubnetID = 42, DeviceID = 10, LoopID = 2, obj1 = 1, SensorType = 1, AreaNumber = 1 }; //ScurityDryContact sdc3 = new ScurityDryContact () { Name = "door2", SubnetID = 42, DeviceID = 10, LoopID = 3, obj1 = 1, SensorType = 1, AreaNumber = 1 }; //sm1.SensorList.Add (sdc); //sm1.SensorList.Add (sdc2); //sm2.SensorList.Add (sdc3); //IO.FileUtils.SaveEquipmentMessage (sm1, "1"); //IO.FileUtils.SaveEquipmentMessage (sm2, "2"); //IO.FileUtils.SaveEquipmentMessage (sm3, "3"); //IO.FileUtils.SaveEquipmentMessage (sm4, "4"); //IO.FileUtils.SaveEquipmentMessage (sm5, "5"); //IO.FileUtils.SaveEquipmentMessage (sm6, "6"); #endif #if wallon MainPage.LoginUser = new UserInfo (); #endif if (null != UserPageView.Parent) { CleanPageView (FavoriteBodyView); UserPageView.AddChidren (FavoritePageView); FavoritePageView.AddChidren (FavoriteBodyView); FavoriteBodyView.AddChidren (FavoriteRoom); FavoriteRoom.InitRoomView (Room.FavoriteRoom); SelectedBottomButton (btnFavorite); curPageView = 0; btnFavorite.TextID = R.MyInternationalizationString.Favorite; btnDevice.TextID = R.MyInternationalizationString.Category; btnRoom.TextID = R.MyInternationalizationString.Rooms; btnSetting.TextID = R.MyInternationalizationString.Setting; FavoritePageView.PageIndex = 0; return; } UserHomePage.FrameLayoutMain.AddChidren (UserPageView); UserHomePage.FrameLayoutMain.AddChidren (LinkStatusTip); UserPageView.AddChidren (FavoritePageView); FavoritePageView.AddChidren (FavoriteBodyView); FavoriteBodyView.AddChidren (UserMenuItem); FavoriteBodyView.AddChidren (FavoriteRoom); FavoriteRoom.InitRoomView (Room.FavoriteRoom); #region 底部导航栏 UserMenuItem.AddChidren (btnFavorite); UserMenuItem.AddChidren (btnDevice); UserMenuItem.AddChidren (btnRoom); UserMenuItem.AddChidren (btnSetting); SelectedBottomButton (btnFavorite); #if wallon btnFavorite.Height = Application.GetRealHeight (85); btnDevice.Height = Application.GetRealHeight (85); btnRoom.Height = Application.GetRealHeight (85); btnSetting.Height = Application.GetRealHeight (85); btnFavorite.Y = Application.GetRealHeight (5); btnDevice.Y = Application.GetRealHeight (5); btnRoom.Y = Application.GetRealHeight (5); btnSetting.Y = Application.GetRealHeight (5); #endif btnFavorite.MouseUpEventHandler += (sender, e) => { CleanPageView (FavoriteBodyView); UserPageView.AddChidren (FavoritePageView); FavoritePageView.AddChidren (FavoriteBodyView); FavoriteBodyView.AddChidren (FavoriteRoom); FavoriteRoom.InitRoomView (Room.FavoriteRoom); curPageView = 0; SharedMethod.SharedMethod.CurPageLayout = FavoritePageView; SelectedBottomButton (btnFavorite); }; btnDevice.MouseUpEventHandler += (sender, e) => { try { CleanPageView (DeviceBodyView); UserPageView.AddChidren (DevicePageView); DevicePageView.AddChidren (DeviceBodyView); DeviceBodyView.AddChidren (DeviceView); UserDeviceView.DeviceMode (); curPageView = 1; SharedMethod.SharedMethod.CurPageLayout = DevicePageView; DevicePageView.PageIndex = 0; SelectedBottomButton (btnDevice); } catch (Exception ex) { Console.WriteLine (ex.Message); } finally { } }; btnRoom.MouseUpEventHandler += (sender, e) => { CleanPageView (RoomBodyView); UserPageView.AddChidren (RoomPageView); RoomPageView.AddChidren (RoomBodyView); UserRooms.ShowRoomList (); curPageView = 2; SharedMethod.SharedMethod.CurPageLayout = RoomPageView; RoomPageView.PageIndex = 0; SelectedBottomButton (btnRoom); }; btnSetting.MouseUpEventHandler += (sender, e) => { CleanPageView (SettingBodyView); UserPageView.AddChidren (SettingPageView); SettingPageView.AddChidren (SettingBodyView); SettingBodyView.AddChidren (SettingView); //SettingBodyView.AddChidren (btnVersion); UserSettingView.InitUserSettingView (); curPageView = 3; SharedMethod.SharedMethod.CurPageLayout = SettingPageView; SettingPageView.PageIndex = 0; SelectedBottomButton (btnSetting); }; FavoritePageView.PageChange += (sender, e) => { if (e < FavoritePageView.ChildrenCount - 1) { FavoritePageView.GetChildren (FavoritePageView.ChildrenCount - 1).RemoveFromParent (); } }; SettingPageView.PageChange += (sender, e) => { if (e < SettingPageView.ChildrenCount - 1) { SettingPageView.GetChildren (SettingPageView.ChildrenCount - 1).RemoveFromParent (); } }; RoomPageView.PageChange += (sender, e) => { if (e < RoomPageView.ChildrenCount - 1) { RoomPageView.GetChildren (RoomPageView.ChildrenCount - 1).RemoveFromParent (); } }; DevicePageView.PageChange += (sender, e) => { while (e < DevicePageView.ChildrenCount - 1) { DevicePageView.GetChildren (DevicePageView.ChildrenCount - 1).RemoveFromParent (); } if (e == 0) { DevicePageView.ScrollEnabled = true; } }; #endregion } public static void ShowSettingView () { CleanPageView (SettingBodyView); UserPageView.AddChidren (SettingPageView); SettingPageView.AddChidren (SettingBodyView); SettingBodyView.AddChidren (SettingView); //SettingBodyView.AddChidren (btnVersion); UserSettingView.InitUserSettingView (); SettingPageView.PageIndex = 0; curPageView = 3; SharedMethod.SharedMethod.CurPageLayout = SettingPageView; Console.WriteLine (SharedMethod.SharedMethod.CurPageLayout); SelectedBottomButton (btnSetting); } public static void ShowRoomsView () { CleanPageView (RoomBodyView); UserPageView.AddChidren (RoomPageView); RoomPageView.AddChidren (RoomBodyView); //UserMiddle.RoomBodyView.RemoveAll (); UserRooms.ShowRoomList (); curPageView = 2; SelectedBottomButton (btnRoom); } public static void ReadAllDeviceStatus () { if (MainPage.LoginUser == null || !MainPage.LoginUser.IsLogin) { return; } UserDeviceToCurtains.readAllStatus (true); UserDeviceToLight.readAllStatus (true); UserDeviceToSocket.readAllStatus (true); UserDeviceToAC.readAllStatus (true); UserDeviceToFH.readAllStatus (true); UserFresAirList.readAllStatus (true); } } }