CrabtreeOn,印度客户定制APP,迁移2.0平台版本
陈嘉乐
2021-03-02 c404f2f369710fe72bbcc4cff2b7b8a2c11b5ff1
Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs
@@ -74,7 +74,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 +102,7 @@
            };
            topUserMsgView.AddChidren (btnTopUserMsgRight);
            EventHandler<MouseEventArgs> accountEventHandler = (sender, e) => {
                new AccountLogin ().Show ();
            };
@@ -117,7 +117,7 @@
            UserMiddle.SettingView.AddChidren (btTopNull);
            #endregion
            #region ---进入后台---DeviceManagementView---
            if (true) {//调试账号
                       //if (MainPage.LoginUser.AccountType == 0) {//调试账号
@@ -246,56 +246,56 @@
                };
                UserMiddle.SettingView.AddChidren (btnNull3);
            }
        #endregion
            #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);
            #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 ();
        //};
            //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
            //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,7 +329,7 @@
                Height = Application.GetRealHeight (5),
                BackgroundColor = SkinStyle.Current.MainColor
            };
            //UserMiddle.SettingView.AddChidren (btnNullSchedule);
            #endregion
@@ -344,7 +344,7 @@
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth (75),
                Height = Application.GetRealWidth (75),
                UnSelectedImagePath = "CrabtreeAdd/Alexa.png",
                UnSelectedImagePath = "CrabtreeAdd/Alexa.png",
            };
            AlexaView.AddChidren (btnAlexaIcon);
@@ -356,7 +356,7 @@
            };
            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,80 +368,80 @@
                Height = Application.GetRealHeight (5),
                BackgroundColor = SkinStyle.Current.MainColor
            };
            //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
                };
            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) {
                //主账号开放该功能;
@@ -453,8 +453,6 @@
                UserMiddle.SettingView.AddChidren (btnNullSubaccount);
            }
            //主账号开放该功能;
            #region ---help---
            var helpView = new FrameLayout () {
                Width = Application.GetRealWidth (640),
@@ -502,7 +500,7 @@
            #endregion
            Button btnNullSkin = new Button () {
                Height = Application.GetRealHeight (5),
@@ -606,7 +604,7 @@
        static void ShowGetSubAccountByDistributedMarkErrorInfo (string stateCodeStr)
        {
            string mes = "";
            if (stateCodeStr == ErrorCode.NetworkError) {
                mes = ErrorCode.NetworkError;
            } else {