From d53e6af2c5f17838fa79659614b15a2a1f383399 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期五, 31 三月 2023 10:04:58 +0800 Subject: [PATCH] 1 --- Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs | 429 ++++++++++++++++++++++++++++++----------------------- 1 files changed, 243 insertions(+), 186 deletions(-) diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs index 3deb6ed..6046a51 100644 --- a/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs +++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs @@ -48,6 +48,39 @@ // Utlis.WriteLine (ex.ToString ()); //} + ShowBodyView (); + + } + + /// <summary> + /// 褰撳墠setting椤甸潰 鍔犺浇鏄惁鍒嗕韩浣忓畢瑙掕壊,鍐冲畾鏄惁闅愯棌鐩稿簲鐨勮彍鍗曟寜閽� + /// </summary> + static bool IsOthreShare = false; + /// <summary> + /// 浣忓畢鍒楄〃椤甸潰 + /// 鍒囨崲浣忓畢鍚庨渶瑕佸垽鏂槸鍚﹂渶瑕侀殣钘忔垨鑰呮樉绀哄姛鑳借彍鍗曟寜閽埛鏂板竷灞� + /// 褰撳墠浣忓畢鑷繁鐨勶細鏄剧ず鏁版嵁鎺ユ敹銆佸悓姝ユ暟鎹�佸畾鏃跺櫒銆乤lexa銆佸瓙璐﹀彿绠$悊 5涓姛鑳借彍鍗曟寜閽� + /// 瀛愯处鍙峰綋鍓嶄綇瀹呬笉鏄嚜宸辩殑锛氶殣钘忎笂闈�5涓寜閽� + /// </summary> + public static void CheckIfRefreshView () + { + if(UserConfig.Instance.CurrentRegion.IsOthreShare != IsOthreShare) { + ShowBodyView (); + //Utlis.WriteLine ("闇�瑕佸埛鏂�"); + } + } + + /// <summary> + /// 鍔犺浇BodyView + /// </summary> + public static void ShowBodyView () + { + if (UserMiddle.SettingView == null) return; + + UserMiddle.SettingView.RemoveAll (); + + IsOthreShare = UserConfig.Instance.CurrentRegion.IsOthreShare; + FrameLayout topUserMsgView = new FrameLayout () { Y = Application.GetRealHeight (126), Height = Application.GetRealHeight (175), @@ -74,7 +107,7 @@ Height = Application.GetRealHeight (50), TextAlignment = TextAlignment.CenterLeft, TextColor = SkinStyle.Current.TextColor1, - Text = MainPage.LoginUser.Name == "" ? Language.StringByID(R.MyInternationalizationString.Account) : MainPage.LoginUser.Name, + Text = MainPage.LoginUser.Name == "" ? Language.StringByID (R.MyInternationalizationString.Account) : MainPage.LoginUser.Name, //TextID = R.MyInternationalizationString.Account }; topUserMsgView.AddChidren (btnUserName); @@ -102,7 +135,7 @@ }; topUserMsgView.AddChidren (btnTopUserMsgRight); - + EventHandler<MouseEventArgs> accountEventHandler = (sender, e) => { new AccountLogin ().Show (); }; @@ -117,7 +150,7 @@ UserMiddle.SettingView.AddChidren (btTopNull); #endregion - + #region ---杩涘叆鍚庡彴---DeviceManagementView--- if (true) {//璋冭瘯璐﹀彿 //if (MainPage.LoginUser.AccountType == 0) {//璋冭瘯璐﹀彿 @@ -211,91 +244,136 @@ #region ---鏁版嵁鎺ユ敹--- //if (MainPage.LoginUser.AccountType == 2 || MainPage.LoginUser.AccountString == @"464027401@qq.com") { - if (true) { - var DataReceptionView = new FrameLayout () { - Width = Application.GetRealWidth (640), - Height = Application.GetRealHeight (100), - BackgroundColor = SkinStyle.Current.ViewColor + var DataReceptionView = new FrameLayout () { + Width = Application.GetRealWidth (640), + Height = Application.GetRealHeight (100), + BackgroundColor = SkinStyle.Current.ViewColor + }; + //UserMiddle.SettingView.AddChidren (DataReceptionView); + var btnDataReceptionIcon = new Button () { + X = Application.GetRealWidth (30), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth (75), + Height = Application.GetRealHeight (75), + UnSelectedImagePath = "AccountSettings/DataShared.png" + }; + DataReceptionView.AddChidren (btnDataReceptionIcon); + var btnDataReceptionTitle = new Button () { + X = Application.GetRealWidth (125), + TextAlignment = TextAlignment.CenterLeft, + TextID = R.MyInternationalizationString.DataReception, + TextColor = SkinStyle.Current.TextColor1, + }; + DataReceptionView.AddChidren (btnDataReceptionTitle); + EventHandler<MouseEventArgs> DataReceptionEventHandler = (sender, e) => { + + GoData (); + }; + DataReceptionView.MouseUpEventHandler += DataReceptionEventHandler; + btnDataReceptionIcon.MouseUpEventHandler += DataReceptionEventHandler; + btnDataReceptionTitle.MouseUpEventHandler += DataReceptionEventHandler; + Button btnNull3 = new Button () { + BackgroundColor = SkinStyle.Current.MainColor, + Height = Application.GetRealHeight (5) + }; + //UserMiddle.SettingView.AddChidren (btnNull3); + #endregion + + #region ---msg--- + //FrameLayout WarningMsgView = new FrameLayout () { + // Width = Application.GetRealWidth (640), + // Height = Application.GetRealHeight (100), + // BackgroundColor = SkinStyle.Current.ViewColor + //}; + //UserMiddle.SettingView.AddChidren (WarningMsgView); + //Button btnWarningMsgIcon = new Button () { + // X = Application.GetRealWidth (30), + // Gravity = Gravity.CenterVertical, + // Width = Application.GetRealWidth (75), + // Height = Application.GetRealHeight (75), + // UnSelectedImagePath = "RemoteMsg/RemoteIcon.png", + // SelectedImagePath = "RemoteMsg/RemoteIconOn.png" + //}; + //WarningMsgView.AddChidren (btnWarningMsgIcon); + + //Button btnWarningMsgTitle = new Button () { + // X = btnWarningMsgIcon.Right + Application.GetRealWidth (20), + // TextAlignment = TextAlignment.CenterLeft, + // TextID = R.MyInternationalizationString.MessageAlert, + // TextColor = SkinStyle.Current.TextColor1, + //}; + //WarningMsgView.AddChidren (btnWarningMsgTitle); + //btnWarningMsgTitle.MouseLongEventHandler += (sd, ds) => { + // //var uc = UserConfig.Instance.RometoUserInfoKeys.Find ((obj) => obj.Contains ("HiddenJson")); + // //new Alert ("", uc, "close").Show (); + //}; + + //EventHandler<MouseEventArgs> WarningMsgEventHandler = (sender, e) => { + // var msgView = new WarningList (); + // UserMiddle.SettingPageView.AddChidren (msgView); + // msgView.ShowWarningListPage (); + // UserMiddle.SettingPageView.PageIndex = 1; + //}; + //WarningMsgView.MouseUpEventHandler += WarningMsgEventHandler; + //btnWarningMsgIcon.MouseUpEventHandler += WarningMsgEventHandler; + //btnWarningMsgTitle.MouseUpEventHandler += WarningMsgEventHandler; + //Button btnNullWarningMsg = new Button () { + // Height = Application.GetRealHeight (5), + // BackgroundColor = SkinStyle.Current.MainColor + //}; + //UserMiddle.SettingView.AddChidren (btnNullWarningMsg); + #endregion + + #region ---鍚屾璁惧--- + FrameLayout SyncDeviceView = new FrameLayout () { + Width = Application.GetRealWidth (640), + Height = Application.GetRealHeight (100), + BackgroundColor = SkinStyle.Current.ViewColor + }; + Button btnSyncDeviceIcon = new Button () { + X = Application.GetRealWidth (30), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth (75), + Height = Application.GetRealWidth (75), + UnSelectedImagePath = "CrabtreeAdd/Alexa.png", + }; + SyncDeviceView.AddChidren (btnSyncDeviceIcon); + + Button btnSyncDeviceTitle = new Button () { + X = Application.GetRealWidth (125), + TextAlignment = TextAlignment.CenterLeft, + TextID = R.MyInternationalizationString.SyncToTheCloud, + //Text = "涓婁紶璁惧", + TextColor = SkinStyle.Current.TextColor1, + }; + SyncDeviceView.AddChidren (btnSyncDeviceTitle); + EventHandler<MouseEventArgs> SyncDeviceEventHandler = (sender, e) => { + //娌$粦瀹氬繕璁版彁绀哄厛缁戝畾缃戝叧锛岀姝㈣烦杞� + if (!UserConfig.Instance.CheckWhetherGatewayIdNotNull ()) { + Utlis.ShowAlertOnMainThread (Language.StringByID (R.MyInternationalizationString.PleaseBindTheGatewayFirst)); + return; + } + + //ok浜嬩欢 + Action okAction = () => { + HDLLinkUtlis.Current.OneclickUpload (); }; - UserMiddle.SettingView.AddChidren (DataReceptionView); - var btnDataReceptionIcon = new Button () { - X = Application.GetRealWidth (30), - Gravity = Gravity.CenterVertical, - Width = Application.GetRealWidth (75), - Height = Application.GetRealHeight (75), - UnSelectedImagePath = "AccountSettings/DataShared.png" - }; - DataReceptionView.AddChidren (btnDataReceptionIcon); - var btnDataReceptionTitle = new Button () { - X = Application.GetRealWidth (125), - TextAlignment = TextAlignment.CenterLeft, - TextID = R.MyInternationalizationString.DataReception, - TextColor = SkinStyle.Current.TextColor1, - }; - DataReceptionView.AddChidren (btnDataReceptionTitle); - EventHandler<MouseEventArgs> DataReceptionEventHandler = (sender, e) => { - GoData (); - }; - DataReceptionView.MouseUpEventHandler += DataReceptionEventHandler; - btnDataReceptionIcon.MouseUpEventHandler += DataReceptionEventHandler; - btnDataReceptionTitle.MouseUpEventHandler += DataReceptionEventHandler; - Button btnNull3 = new Button () { - BackgroundColor = SkinStyle.Current.MainColor, - Height = Application.GetRealHeight (5) - }; - UserMiddle.SettingView.AddChidren (btnNull3); - } - #endregion + CommonUtlis.Current.ShowActionAlert (Language.StringByID (R.MyInternationalizationString.DoYouWantToSynchronizeToTheCloud), okAction); + }; + SyncDeviceView.MouseUpEventHandler += SyncDeviceEventHandler; + btnSyncDeviceIcon.MouseUpEventHandler += SyncDeviceEventHandler; + btnSyncDeviceTitle.MouseUpEventHandler += SyncDeviceEventHandler; + Button btnNullSyncDevice = new Button () { + Height = Application.GetRealHeight (5), + BackgroundColor = SkinStyle.Current.MainColor + }; + //UserMiddle.SettingView.AddChidren (btnNullSchedule); + #endregion - #region ---msg--- - //FrameLayout WarningMsgView = new FrameLayout () { - // Width = Application.GetRealWidth (640), - // Height = Application.GetRealHeight (100), - // BackgroundColor = SkinStyle.Current.ViewColor - //}; - //UserMiddle.SettingView.AddChidren (WarningMsgView); - //Button btnWarningMsgIcon = new Button () { - // X = Application.GetRealWidth (30), - // Gravity = Gravity.CenterVertical, - // Width = Application.GetRealWidth (75), - // Height = Application.GetRealHeight (75), - // UnSelectedImagePath = "RemoteMsg/RemoteIcon.png", - // SelectedImagePath = "RemoteMsg/RemoteIconOn.png" - //}; - //WarningMsgView.AddChidren (btnWarningMsgIcon); - - //Button btnWarningMsgTitle = new Button () { - // X = btnWarningMsgIcon.Right + Application.GetRealWidth (20), - // TextAlignment = TextAlignment.CenterLeft, - // TextID = R.MyInternationalizationString.MessageAlert, - // TextColor = SkinStyle.Current.TextColor1, - //}; - //WarningMsgView.AddChidren (btnWarningMsgTitle); - //btnWarningMsgTitle.MouseLongEventHandler += (sd, ds) => { - // //var uc = UserConfig.Instance.RometoUserInfoKeys.Find ((obj) => obj.Contains ("HiddenJson")); - // //new Alert ("", uc, "close").Show (); - //}; - - //EventHandler<MouseEventArgs> WarningMsgEventHandler = (sender, e) => { - // var msgView = new WarningList (); - // UserMiddle.SettingPageView.AddChidren (msgView); - // msgView.ShowWarningListPage (); - // UserMiddle.SettingPageView.PageIndex = 1; - //}; - //WarningMsgView.MouseUpEventHandler += WarningMsgEventHandler; - //btnWarningMsgIcon.MouseUpEventHandler += WarningMsgEventHandler; - //btnWarningMsgTitle.MouseUpEventHandler += WarningMsgEventHandler; - //Button btnNullWarningMsg = new Button () { - // Height = Application.GetRealHeight (5), - // BackgroundColor = SkinStyle.Current.MainColor - //}; - //UserMiddle.SettingView.AddChidren (btnNullWarningMsg); - #endregion - - #region ---Schedule--- - FrameLayout ScheduleView = new FrameLayout () { + #region ---Schedule--- + FrameLayout ScheduleView = new FrameLayout () { Width = Application.GetRealWidth (640), Height = Application.GetRealHeight (100), BackgroundColor = SkinStyle.Current.ViewColor @@ -329,9 +407,8 @@ Height = Application.GetRealHeight (5), BackgroundColor = SkinStyle.Current.MainColor }; - UserMiddle.SettingView.AddChidren (btnNullSchedule); + //UserMiddle.SettingView.AddChidren (btnNullSchedule); #endregion - #region ---Alexa--- FrameLayout AlexaView = new FrameLayout () { @@ -344,19 +421,20 @@ Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth (75), Height = Application.GetRealWidth (75), - UnSelectedImagePath = "CrabtreeAdd/Alexa.png", + UnSelectedImagePath = "CrabtreeAdd/Speaker.png", }; AlexaView.AddChidren (btnAlexaIcon); + //鏅鸿兘闊崇 Button btnAlexaTitle = new Button () { X = Application.GetRealWidth (125), TextAlignment = TextAlignment.CenterLeft, - Text = "Alexa Integration", + Text = "Smart speaker", TextColor = SkinStyle.Current.TextColor1, }; AlexaView.AddChidren (btnAlexaTitle); EventHandler<MouseEventArgs> AlexaEventHandler = (sender, e) => { - var alexaPage = new AlexaDeviceListPage (); + var alexaPage = new SmartSpeakertListPage (); UserMiddle.SettingPageView.AddChidren (alexaPage); alexaPage.ShowPage (); UserMiddle.SettingPageView.PageIndex = 1; @@ -368,93 +446,97 @@ Height = Application.GetRealHeight (5), BackgroundColor = SkinStyle.Current.MainColor }; - UserMiddle.SettingView.AddChidren (btnNullAlexa); + //UserMiddle.SettingView.AddChidren (btnNullAlexa); #endregion #region subaccount //if (MainPage.LoginUser.AccountType == 0) { - FrameLayout subaccountView = new FrameLayout () { - Width = Application.GetRealWidth (640), - Height = Application.GetRealHeight (100), - BackgroundColor = SkinStyle.Current.ViewColor - }; - Button btnSubaccountIcon = new Button () { - X = Application.GetRealWidth (30), - Gravity = Gravity.CenterVertical, - Width = Application.GetRealWidth (75), - Height = Application.GetRealWidth (75), - UnSelectedImagePath = "CrabtreeAdd/SubaccountIcon.png", - }; - subaccountView.AddChidren (btnSubaccountIcon); + FrameLayout subaccountView = new FrameLayout () { + Width = Application.GetRealWidth (640), + Height = Application.GetRealHeight (100), + BackgroundColor = SkinStyle.Current.ViewColor + }; + Button btnSubaccountIcon = new Button () { + X = Application.GetRealWidth (30), + Gravity = Gravity.CenterVertical, + Width = Application.GetRealWidth (75), + Height = Application.GetRealWidth (75), + UnSelectedImagePath = "CrabtreeAdd/SubaccountIcon.png", + }; + subaccountView.AddChidren (btnSubaccountIcon); - Button btnSubaccountTitle = new Button () { - X = Application.GetRealWidth (125), - TextAlignment = TextAlignment.CenterLeft, - Text= "User Management", - TextColor = SkinStyle.Current.TextColor1, - }; - subaccountView.AddChidren (btnSubaccountTitle); + Button btnSubaccountTitle = new Button () { + X = Application.GetRealWidth (125), + TextAlignment = TextAlignment.CenterLeft, + Text = "User Management", + TextColor = SkinStyle.Current.TextColor1, + }; + subaccountView.AddChidren (btnSubaccountTitle); - Button btnNullSubaccount = new Button () { - Height = Application.GetRealHeight (5), - BackgroundColor = SkinStyle.Current.MainColor - }; - UserMiddle.SettingView.AddChidren (btnNullSubaccount); + Button btnNullSubaccount = new Button () { + Height = Application.GetRealHeight (5), + BackgroundColor = SkinStyle.Current.MainColor + }; + //UserMiddle.SettingView.AddChidren (btnNullSubaccount); - EventHandler<MouseEventArgs> SubaccountEventHandler = (sender, e) => { - if (UserConfig.Instance.CurrentRegion.IsOthreShare) { - //鎻愮ず娌℃湁鍒嗕韩浣忓畢鐨勬潈闄� - new Alert ("", ErrorCode.InsufficientAuthority, "Close").Show (); - return; - } + EventHandler<MouseEventArgs> SubaccountEventHandler = (sender, e) => { + if (UserConfig.Instance.CurrentRegion.IsOthreShare) { + //鎻愮ず娌℃湁鍒嗕韩浣忓畢鐨勬潈闄� + new Alert ("", ErrorCode.InsufficientAuthority, "Close").Show (); + return; + } - if (UserConfig.Instance.internetStatus == 0) { - new Alert ("", "Unable to save data, please check the network.", "Close").Show (); - return; - } - MainPage.Loading.Start ("Please wait..."); - System.Threading.Tasks.Task.Run (() => { - try { - var revertObj = HttpServerRequest.Current.GetResidenceMemberAccount (); - if (revertObj.Code == StateCode.SUCCESS) { - Application.RunOnMainThread (() => { - var responeObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>> (revertObj.Data.ToString ()); - SubaccountListView subView = new SubaccountListView (responeObj); - UserMiddle.SettingPageView.AddChidren (subView); - subView.ShowSubaccountListView (); - UserMiddle.SettingPageView.PageIndex += 1; - }); - } else { - IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); - } - } catch (Exception ex) { - MainPage.FailureToServer (); - Utlis.WriteLine (ex.Message); - } finally { + if (UserConfig.Instance.internetStatus == 0) { + new Alert ("", "Unable to save data, please check the network.", "Close").Show (); + return; + } + MainPage.Loading.Start ("Please wait..."); + System.Threading.Tasks.Task.Run (() => { + try { + var revertObj = HttpServerRequest.Current.GetResidenceMemberAccount (); + if (revertObj.Code == StateCode.SUCCESS) { Application.RunOnMainThread (() => { - MainPage.Loading.Hide (); + var responeObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>> (revertObj.Data.ToString ()); + SubaccountListView subView = new SubaccountListView (responeObj); + UserMiddle.SettingPageView.AddChidren (subView); + subView.ShowSubaccountListView (); + UserMiddle.SettingPageView.PageIndex += 1; }); + } else { + IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); } - }); - }; - subaccountView.MouseUpEventHandler += SubaccountEventHandler; - btnSubaccountIcon.MouseUpEventHandler += SubaccountEventHandler; - btnSubaccountTitle.MouseUpEventHandler += SubaccountEventHandler; + } catch (Exception ex) { + MainPage.FailureToServer (); + Utlis.WriteLine (ex.Message); + } finally { + Application.RunOnMainThread (() => { + MainPage.Loading.Hide (); + }); + } + }); + }; + subaccountView.MouseUpEventHandler += SubaccountEventHandler; + btnSubaccountIcon.MouseUpEventHandler += SubaccountEventHandler; + btnSubaccountTitle.MouseUpEventHandler += SubaccountEventHandler; //} #endregion + if (!UserConfig.Instance.CurrentRegion.IsOthreShare) { + //涓昏处鍙峰紑鏀捐鍔熻兘; + UserMiddle.SettingView.AddChidren (DataReceptionView); + UserMiddle.SettingView.AddChidren (btnNull3); - //if (!UserConfig.Instance.CurrentRegion.IsOthreShare) { - // //涓昏处鍙峰紑鏀捐鍔熻兘; - // UserMiddle.SettingView.AddChidren (ScheduleView); - // UserMiddle.SettingView.AddChidren (AlexaView); - // UserMiddle.SettingView.AddChidren (subaccountView); - //} + UserMiddle.SettingView.AddChidren (SyncDeviceView); + UserMiddle.SettingView.AddChidren (btnNullSyncDevice); - //涓昏处鍙峰紑鏀捐鍔熻兘; - UserMiddle.SettingView.AddChidren (ScheduleView); - UserMiddle.SettingView.AddChidren (AlexaView); - UserMiddle.SettingView.AddChidren (subaccountView); + UserMiddle.SettingView.AddChidren (ScheduleView); + UserMiddle.SettingView.AddChidren (btnNullSchedule); + UserMiddle.SettingView.AddChidren (AlexaView); + UserMiddle.SettingView.AddChidren (btnNullAlexa); + UserMiddle.SettingView.AddChidren (subaccountView); + UserMiddle.SettingView.AddChidren (btnNullSubaccount); + } + #region ---help--- var helpView = new FrameLayout () { Width = Application.GetRealWidth (640), @@ -502,14 +584,13 @@ #endregion - + Button btnNullSkin = new Button () { Height = Application.GetRealHeight (5), BackgroundColor = SkinStyle.Current.MainColor }; UserMiddle.SettingView.AddChidren (btnNullSkin); - } static void GoData () @@ -595,30 +676,6 @@ dialog.Close (); }; dialog.Show (); - } - - - - /// <summary> - /// - /// </summary> - /// <param name="stateCodeStr"></param> - static void ShowGetSubAccountByDistributedMarkErrorInfo (string stateCodeStr) - { - string mes = ""; - - if (stateCodeStr == ErrorCode.NetworkError) { - mes = ErrorCode.NetworkError; - } else { - mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; - } - if (!string.IsNullOrEmpty (mes)) { - Application.RunOnMainThread (() => { - new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); - }); - } - - } } -- Gitblit v1.8.0