JLChen
2020-07-10 7b43f0f5c5dca88576efc0bb51bf95b523de90c9
Crabtree/SmartHome/UI/SimpleControl/Phone/User/UserSettingView.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace Shared.SimpleControl.Phone
@@ -40,11 +41,11 @@
            };
            topView.AddChidren (NameButton);
            //try {
            //    Console.WriteLine ("3");
            //    Utlis.WriteLine ("3");
            //    UserMiddle.SettingBodyView.AddChidren (topView);
            //    Console.WriteLine ("3");
            //    Utlis.WriteLine ("3");
            //} catch(Exception ex) {
            //    Console.WriteLine (ex.ToString ());
            //    Utlis.WriteLine (ex.ToString ());
            //}
            FrameLayout topUserMsgView = new FrameLayout () {
@@ -57,7 +58,7 @@
            Button btnUserIcon = new Button () {
                X = Application.GetRealWidth (27),
                Width = Application.GetRealWidth (96),
                Height = Application.GetRealHeight (96),
                Height = Application.GetRealWidth (96),
                Gravity = Gravity.CenterVertical,
                Radius = 5,
                BorderColor = SkinStyle.Current.Transparent,
@@ -94,7 +95,7 @@
            Button btnTopUserMsgRight = new Button () {
                X = Application.GetRealWidth (570),
                Width = Application.GetRealWidth (28),
                Height = Application.GetRealHeight (40),
                Height = Application.GetRealWidth (40),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "Item/Right.png",
                SelectedImagePath = "Item/RightSelected.png",
@@ -118,8 +119,8 @@
            #region ---进入后台---DeviceManagementView---
            //if (true) {//调试账号
            if (MainPage.LoginUser.AccountType == 0) {//调试账号
            if (true) {//调试账号
                       //if (MainPage.LoginUser.AccountType == 0) {//调试账号
                FrameLayout DeviceManagementView = new FrameLayout () {
                    Width = Application.GetRealWidth (640),
                    Height = Application.GetRealHeight (100),
@@ -131,7 +132,7 @@
                    X = Application.GetRealWidth (30),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth (75),
                    Height = Application.GetRealHeight (75),
                    Height = Application.GetRealWidth (75),
                    UnSelectedImagePath = "AccountSettings/DeviceManagement.png",
                    IsSelected = false
                };
@@ -148,7 +149,7 @@
                EventHandler<MouseEventArgs> SystemEventHandler = (sender, e) => {
                    var hl = new GuideAddResidence ();
                    UserMiddle.SettingPageView.AddChidren (hl);
                    hl.ShowHomeList ();
                    hl.ShowHomeView ();
                    UserMiddle.SettingPageView.PageIndex = UserMiddle.SettingPageView.ChildrenCount - 1;
                    //HomeListView hl = new HomeListView ();
@@ -179,7 +180,7 @@
                X = Application.GetRealWidth (30),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth (75),
                Height = Application.GetRealHeight (75),
                Height = Application.GetRealWidth (75),
                UnSelectedImagePath = "AccountSettings/Backup.png"
            };
            BackupView.AddChidren (btnBackupIcon);
@@ -210,89 +211,91 @@
            #region ---数据接收---
            //if (MainPage.LoginUser.AccountType == 2 || MainPage.LoginUser.AccountString == @"464027401@qq.com") {
            //    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
            if (true) {
                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);
        #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
@@ -302,7 +305,7 @@
                X = Application.GetRealWidth (30),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth (75),
                Height = Application.GetRealHeight (75),
                Height = Application.GetRealWidth (75),
                UnSelectedImagePath = "CrabtreeAdd/Schedule.png",
            };
            ScheduleView.AddChidren (btnScheduleIcon);
@@ -342,7 +345,7 @@
                X = Application.GetRealWidth (30),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth (75),
                Height = Application.GetRealHeight (75),
                Height = Application.GetRealWidth (75),
                UnSelectedImagePath = "CrabtreeAdd/Alexa.png", 
            };
            AlexaView.AddChidren (btnAlexaIcon);
@@ -371,7 +374,7 @@
            #endregion
            #region subaccount
            if (MainPage.LoginUser.AccountType == 0) {
            //if (MainPage.LoginUser.AccountType == 0) {
                FrameLayout subaccountView = new FrameLayout () {
                    Width = Application.GetRealWidth (640),
                    Height = Application.GetRealHeight (100),
@@ -382,7 +385,7 @@
                    X = Application.GetRealWidth (30),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetRealWidth (75),
                    Height = Application.GetRealHeight (75),
                    Height = Application.GetRealWidth (75),
                    UnSelectedImagePath = "CrabtreeAdd/SubaccountIcon.png",
                };
                subaccountView.AddChidren (btnSubaccountIcon);
@@ -401,6 +404,12 @@
                UserMiddle.SettingView.AddChidren (btnNullSubaccount);
                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;
@@ -408,12 +417,15 @@
                    MainPage.Loading.Start ("Please wait...");
                    System.Threading.Tasks.Task.Run (() => {
                        try {
                            var requestObj = new GetSubAccountListObj ();
                            var requestObj = new GetSubAccountByDistributedMarkObj () {
                                DistributedMark = UserConfig.Instance.CurrentRegion.Id,
                            };
                            //var requestObj = new GetSubAccountListObj ();
                            var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
                            var revertObj = MainPage.RequestHttps ("GetSubAccountList", requestJson);
                            if (revertObj.StateCode == "SUCCESS") {
                            var revertObj = MainPage.RequestHttps (API.GetSubAccountByDistributedMark, requestJson);
                            if (revertObj.StateCode.ToUpper() == "SUCCESS") {
                                Application.RunOnMainThread (() => {
                                    var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Collections.Generic.List<SubAccountRes>> (revertObj.ResponseData.ToString ());
                                    var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SubAccountRes>> (revertObj.ResponseData.ToString ());
                                    SubaccountListView subView = new SubaccountListView (responseDataObj);
                                    UserMiddle.SettingPageView.AddChidren (subView);
                                    subView.ShowSubaccountListView ();
@@ -422,7 +434,7 @@
                            }
                        } catch (Exception ex) {
                            MainPage.FailureToServer ();
                            Console.WriteLine (ex.Message);
                            Utlis.WriteLine (ex.Message);
                        } finally {
                            Application.RunOnMainThread (() => {
                                MainPage.Loading.Hide ();
@@ -433,7 +445,7 @@
                subaccountView.MouseUpEventHandler += SubaccountEventHandler;
                btnSubaccountIcon.MouseUpEventHandler += SubaccountEventHandler;
                btnSubaccountTitle.MouseUpEventHandler += SubaccountEventHandler;
            }
            //}
            #endregion
@@ -449,7 +461,7 @@
                X = Application.GetRealWidth (30),
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth (75),
                Height = Application.GetRealHeight (75),
                Height = Application.GetRealWidth (75),
                UnSelectedImagePath = "CrabtreeAdd/Help.png",
                SelectedImagePath = "CrabtreeAdd/HelpOn.png"
            };
@@ -465,6 +477,7 @@
            btnhelpTitle.MouseLongEventHandler += (sd, ds) => {
                //var uc = UserConfig.Instance.RometoUserInfoKeys.Find ((obj) => obj.Contains ("HiddenJson"));
                //new Alert ("", uc, "close").Show ();
            };
            EventHandler<MouseEventArgs> helpEventHandler = (sender, e) => {