| | |
| | | VerticalScrolViewLayout contentView; |
| | | FrameLayout userPermissionsView; |
| | | |
| | | Button btnUserName; |
| | | //Button btnUserName; |
| | | |
| | | Function device; |
| | | VideoDoorlockUser doorlockUser; |
| | |
| | | }; |
| | | userNameView.AddChidren(btnEditUserNameIcon); |
| | | |
| | | btnUserName = new Button() |
| | | var btnUserName = new Button() |
| | | { |
| | | X = Application.GetRealWidth(100), |
| | | Width = Application.GetRealWidth(230), |
| | |
| | | contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8) }); |
| | | |
| | | initOptionView(false); |
| | | |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | Action<string> callBack = (str) => |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.UesrNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | if (str == UserInfo.Current.userName) |
| | | { |
| | | return; |
| | | } |
| | | if (System.Text.Encoding.Default.GetBytes(str).Length > 20) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.LengthOutOfRange), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var resultObj = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId, str); |
| | | if (resultObj.Code == StateCode.SUCCESS) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnUserName.Text = str; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | //失败提示 |
| | | IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"update user name error : {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | var pa = new PublicAssmebly(); |
| | | pa.entryMaxLength = 20; |
| | | pa.LoadDialog_EditParater(StringId.ChangeName, doorlockUser.lockUserName, callBack, StringId.UesrNameCannotBeEmpty, 0, new List<string>()); |
| | | }; |
| | | btnUserName.MouseUpEventHandler = eventHandler; |
| | | btnEditUserNameIcon.MouseUpEventHandler = eventHandler; |
| | | userNameView.MouseUpEventHandler = eventHandler; |
| | | |
| | | } |
| | | |
| | | void initOptionView(bool isEdit) |
| | |
| | | /// </summary> |
| | | void LoadEvent_EditUserName() |
| | | { |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | Action<string> callBack = (str) => |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | new Tip() |
| | | { |
| | | CloseTime = 1, |
| | | Text = Language.StringByID(StringId.UesrNameCannotBeEmpty), |
| | | Direction = AMPopTipDirection.None, |
| | | }.Show(bodyView); |
| | | return; |
| | | } |
| | | if (str == UserInfo.Current.userName) |
| | | { |
| | | return; |
| | | } |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | var resultObj = ApiUtlis.Ins.HttpRequest.EditDoorlockUserName(device.deviceId, doorlockUser.extUserId,str); |
| | | if (resultObj.Code == StateCode.SUCCESS) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnUserName.Text = str; |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | //失败提示 |
| | | IMessageCommon.Current.ShowErrorInfoAlter(resultObj.Code); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"update user name error : {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | waitPage.Hide(); |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }; |
| | | new PublicAssmebly().LoadDialog_EditParater(StringId.ChangeName, doorlockUser.lockUserName, callBack, StringId.UesrNameCannotBeEmpty, 0, new System.Collections.Generic.List<string>()); |
| | | }; |
| | | btnUserName.MouseUpEventHandler = eventHandler; |
| | | //btnUserName.MouseUpEventHandler = eventHandler; |
| | | } |
| | | |
| | | |