gxc
2019-12-25 944b87b6bcccb095cd73f13f4410fb20faf48f74
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs
@@ -36,6 +36,11 @@
        /// 设备的某一回路
        /// </summary>
        private CommonDevice deviceObj = null;
        Action action;
        Action actionNone;
        string modifyDeviceName = "";
        bool IsModifyName = true;
        public Action<string> devicNameAction;
        #endregion
        /// <summary>
@@ -59,7 +64,6 @@
        public void MidFrameLayoutContent()
        {
            var MidTopFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(449),
@@ -94,7 +98,7 @@
            var bottomFrameLayout2 = new FrameLayout()
            {
                Height = Application.GetRealHeight(1054),
                Height = Application.GetRealHeight(1000),
                Y = Application.GetRealHeight(418),
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout2);
@@ -159,14 +163,57 @@
                if (i == 0)
                {
                    bottomRowLayout.Y = Application.GetRealHeight(220);
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm) + ":";
                    btnName.Text = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm);
                    btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58);
                    btnNextFrameLayout.X = Application.GetRealWidth(233);
                    btnNext.TextAlignment = TextAlignment.CenterLeft;
                    btnNext.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                    btnNext.Text = doorLock.DeviceName;
                    var btnDeviceNameEditText = new EditText()
                    {
                        X = Application.GetRealWidth(46),
                        Width = Application.GetRealWidth(731),
                        Height = Application.GetRealHeight(58),
                        TextColor = ZigbeeColor.Current.XMGray3,
                        PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor2,
                        TextAlignment = TextAlignment.CenterLeft,
                        Text = string.IsNullOrEmpty(doorLock.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : doorLock.DeviceName,
                    };
                    btnNextFrameLayout.AddChidren(btnDeviceNameEditText);
                    btnDeviceNameEditText.TextChangeEventHandler += (sender, e) =>
                    {
                        modifyDeviceName = btnDeviceNameEditText.Text;
                    };
                    Action<Shared.View> actionEdit = async (obj) =>
                     {
                         try
                         {
                             Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
                             var doorLockDeviceList = new List<CommonDevice> { };
                             doorLockDeviceList.Add(doorLock);
                             var result = await Common.LocalDevice.Current.ReMacName(doorLockDeviceList, btnDeviceNameEditText.Text);
                             if (result)
                             {
                                 IsModifyName = false;
                             }
                             else
                             {
                                 IsModifyName = true;
                             }
                         }
                         catch { }
                         finally
                         {
                             Application.RunOnMainThread(() =>
                             {
                                 CommonPage.Loading.Hide();
                             });
                         }
                     };
                    btnDeviceNameEditText.EditorEnterAction += actionEdit;
                    btnLine.Visible = true;
                    btnLine.Y = Application.GetRealHeight(303);
                }
                else if (i == 1)
                {
@@ -242,46 +289,23 @@
                    btnLine.Visible = false;
                    btnLine.Y = Application.GetRealHeight(992);
                }
                //else if (i == 6)
                //{
                //    bottomRowLayout.Y = Application.GetRealHeight(999 + 35);
                //    btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockShare);
                //    btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png";
                //    btnLine.Visible = true;
                //    btnLine.Y = Application.GetRealHeight(1131);
                //}
                int currentIndex = i;
                EventHandler<MouseEventArgs> eHandler = async (sender, e) =>
                 {
                     if (currentIndex == 1)
                     if (currentIndex == 3)
                     {
                         //获取设备所属房间
                         var aa = Common.Room.CurrentRoom.GetRoomByDevice(doorLock);
                         //获取设备所在楼层
                         var bb = aa.FloorId;
                         //获取设备所在楼层
                         var cc = aa.FloorId;
                         //获取楼层的名字
                         var dd = Common.Config.Instance.Home.GetFloorNameById(cc);
                         //if (Common.Config.Instance.Home.FloorDics.Count == 0)//这个是无楼层模式
                         var listCheck = new List<string>();
                     }
                     else if (currentIndex == 3)
                     {
                         var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result == false)
                         action = async () =>
                         {
                             var temporaryPassword = new Shared.Phone.UserCenter.DoorLock.TemporaryPassword(doorLock);
                             Shared.Phone.UserView.HomePage.Instance.AddChidren(temporaryPassword);
                             Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                             temporaryPassword.Show();
                         }
                         else
                         };
                         actionNone = async () =>
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                         }
                             Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                         };
                         HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
                     }
                     else if (currentIndex == 4)
                     {
@@ -308,12 +332,12 @@
                                 }
                                 else
                                 {
                                     new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                                     new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                                 }
                             }
                             else
                             {
                                 new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                                 new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                             }
                         }
                         else
@@ -344,7 +368,7 @@
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip);
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                         }
                     }
                 };
@@ -356,51 +380,53 @@
            }
            //保存
            //var btnFinifh = new Button()
            //{
            //    Width = Application.GetRealWidth(907),
            //    Height = Application.GetRealHeight(127),
            //    Y = Application.GetRealHeight(1472),
            //    Gravity = Gravity.CenterHorizontal,
            //    Radius = (uint)Application.GetRealHeight(127) / 2,
            //    TextID = R.MyInternationalizationString.Save,
            //    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
            //    TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
            //    TextSize = 16,
            //};
            //this.midFrameLayout.AddChidren(btnFinifh);
            //btnFinish.MouseUpEventHandler += async (sender, e) =>
            //{
            //    //记录起当前正在操作的回路名字
            //    dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
            //    //开启进度条
            //    this.ShowProgressBar();
            //    foreach (var epoint in dicDeviceSaveName.Keys)
            //    {
            //        var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
            //        if (device == null || dicDeviceSaveName[epoint] == string.Empty)
            //        {
            //            //不能允许空白名字
            //            continue;
            //        }
            //        string newName = dicDeviceSaveName[epoint];
            //        string oldName = Common.LocalDevice.Current.GetDeviceEpointName(device);
            //        if (oldName != newName)
            //        {
            //            //设备名称修改
            //            var result = await Common.LocalDevice.Current.ReName(device, newName);
            //            if (result == false)
            //            {
            //                //关闭
            //                this.CloseProgressBar();
            //                return;
            //            }
            //        }
            //    }
            //    this.CloseProgressBar();
            //    //关闭自身
            //    this.CloseForm();
            //};
            var btnFinifh = new Button()
            {
                Width = Application.GetRealWidth(907),
                Height = Application.GetRealHeight(127),
                Y = Application.GetRealHeight(1472),
                Gravity = Gravity.CenterHorizontal,
                Radius = (uint)Application.GetRealHeight(127) / 2,
                TextID = R.MyInternationalizationString.Save,
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                TextSize = 16,
            };
            this.midFrameLayout.AddChidren(btnFinifh);
            btnFinifh.MouseUpEventHandler += (sender, e) =>
            {
                System.Threading.Tasks.Task.Run(async () =>
                {
                    Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); });
                    try
                    {
                        if (IsModifyName)
                        {
                            var doorLockDeviceList = new List<CommonDevice> { };
                            doorLockDeviceList.Add(doorLock);
                            var result = await Common.LocalDevice.Current.ReMacName(doorLockDeviceList, modifyDeviceName);
                            if (result)
                            {
                                if (devicNameAction != null)
                                {
                                    devicNameAction(modifyDeviceName);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var mess = ex.Message;
                    }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            CommonPage.Loading.Hide();
                        });
                    }
                });
            };
        }
        #region ◆ 接口实现__________________________