From d6b4e510f1430d19bc48da6894cf707bbe3c226d Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期二, 29 十月 2019 14:25:15 +0800 Subject: [PATCH] 2019.10.29-2 --- ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/GatewayInfoAddForm.cs | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 225 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/GatewayInfoAddForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/GatewayInfoAddForm.cs new file mode 100755 index 0000000..b43ab8a --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/GatewayInfoAddForm.cs @@ -0,0 +1,225 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone.UserCenter.GatewayAdd +{ + /// <summary> + /// 缂栬緫鏂版坊鍔犵殑缃戝叧淇℃伅鐨勭敾闈I + /// </summary> + public class GatewayInfoAddForm : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 缃戝叧鍚嶇О鎺т欢 + /// </summary> + private FrameCaptionInputControl rowGateway = null; + /// <summary> + /// 缃戝叧鍚嶅瓧淇敼鍚庣殑鍥炶皟鍑芥暟 + /// </summary> + public Action<ZbGateway> ActionGatewayReName = null; + /// <summary> + /// 褰撳墠閫夋嫨鐨勭綉鍏� + /// </summary> + private ZbGateway zbGateway = null; + /// <summary> + /// 璁惧鏄庣粏鍒楄〃鎺т欢鐨勬甯� + /// </summary> + private DeviceInformationListControl listDeviceControl = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + /// <param name="i_zbGateway">褰撳墠閫夋嫨鐨勭綉鍏�</param> + public void ShowForm(ZbGateway i_zbGateway) + { + this.zbGateway = i_zbGateway; + + //璁剧疆鏍囬淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorGatewayInformation)); + + //缃戝叧瀹氫綅 + var btnIcon = new MostRightIconControl(69, 69); + btnIcon.UnSelectedImagePath = "Item/Test.png"; + topFrameLayout.AddChidren(btnIcon); + btnIcon.InitControl(); + + btnIcon.ButtonClickEvent += (sender, e) => + { + //娴嬭瘯 + HdlGatewayLogic.Current.SetTestCommand(i_zbGateway); + }; + + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// </summary> + private void InitMiddleFrame() + { + //娓呯┖bodyFrame + this.ClearBodyFrame(); + + //鍥剧墖涓婁笅鐨勯棿璺�(涓婁笅闂磋窛涓�鑷�) + int picSpcae = Application.GetRealHeight(100); + //鍥剧墖 + var btnImage = new PicViewControl(838, 530, true); + btnImage.Y = picSpcae; + btnImage.Gravity = Gravity.CenterHorizontal; + HdlGatewayLogic.Current.SetRealGatewayPictrue(btnImage, zbGateway); + bodyFrameLayout.AddChidren(btnImage); + + //瀹屾垚鎸夐挳 + var btnFinish = new BottomClickButton(); + btnFinish.TextID = R.MyInternationalizationString.uFinish; + bodyFrameLayout.AddChidren(btnFinish); + btnFinish.MouseUpEventHandler += (sender, e) => + { + //瀹屾垚鎸夐挳鎸変笅 + this.FinishButtonClick(); + }; + + //鐧借壊搴曢儴鑳屾櫙 + var frameBottomWhite = new FrameLayout(); + frameBottomWhite.Y = btnFinish.Y - ControlCommonResourse.BottomButtonAndListViewSpace; + frameBottomWhite.Height = bodyFrameLayout.Height - btnFinish.Y + ControlCommonResourse.BottomButtonAndListViewSpace; + frameBottomWhite.BackgroundColor = UserCenterColor.Current.White; + bodyFrameLayout.AddChidren(frameBottomWhite); + //灏嗗畬鎴愭寜閽疆椤� + btnFinish.BringToFront(); + + //鑷畾涔夌殑璁惧鍒楄〃瀹瑰櫒 + this.listDeviceControl = new DeviceInformationListControl(); + //鍒楄〃鎺т欢鏈�澶х殑楂樺害(瀹屾垚鎸夐挳鐨刌杞� - 璁剧疆鐨勯棿闅� - 鍥剧墖Y杞� - 鍥剧墖鐨勪笁鍒嗕箣涓�) + int listViewMaxHeight = btnFinish.Y - ControlCommonResourse.BottomButtonAndListViewSpace - btnImage.Y - btnImage.Height / 3; + //鏄庣粏Frame鐨勬渶灏忛珮搴�(搴曢儴frame鐨刌杞� - 鍥剧墖搴曢儴 - 鍥剧墖涓庡姬搴﹀渾鐨勯棿璺� - 寮у害鍦嗛珮搴�) + int minDetailHeight = frameBottomWhite.Y - btnImage.Bottom - picSpcae - listDeviceControl.halfRoundHeigth; + //鍒濆鍖栨帶浠� + listDeviceControl.InitControl(bodyFrameLayout, frameBottomWhite.Height, listViewMaxHeight, minDetailHeight, 3); + + //璁惧缂栬緫 + var btnTitle = new DetailTitleControl(Application.GetRealWidth(800), listDeviceControl.titleHeight, false); + btnTitle.TextID = R.MyInternationalizationString.uDeviceEditor; + listDeviceControl.AddChidren(btnTitle); + + //娣诲姞鍏ㄩ儴鑿滃崟琛� + this.AddAllMenuRow(); + } + + #endregion + + #region 鈻� 娣诲姞鍏ㄩ儴鑿滃崟琛宊____________________ + + /// <summary> + /// 娣诲姞鍏ㄩ儴鑿滃崟琛� + /// </summary> + private void AddAllMenuRow() + { + //缃戝叧鍚嶇О + string caption = Language.StringByID(R.MyInternationalizationString.uGatewayName); + string nameValue = HdlGatewayLogic.Current.GetGatewayName(zbGateway); + this.rowGateway = new FrameCaptionInputControl(caption, nameValue); + listDeviceControl.AddChidren(rowGateway); + rowGateway.InitControl(); + rowGateway.AddBottomLine(); + + //缃戝叧IP + caption = Language.StringByID(R.MyInternationalizationString.uGatewayIP); + nameValue = HdlGatewayLogic.Current.GetGatewayBaseInfoAttribute(zbGateway, "IpAddress").ToString(); + var btnIp = new FrameCaptionViewControl(caption, nameValue); + listDeviceControl.AddChidren(btnIp); + btnIp.InitControl(); + btnIp.txtView.TextColor = UserCenterColor.Current.TextGrayColor; + btnIp.AddBottomLine(); + + //缃戝叧绫诲瀷 + caption = Language.StringByID(R.MyInternationalizationString.uGatewayType); + nameValue = HdlGatewayLogic.Current.GetGatewayImageText(this.zbGateway); + var btnObject = new FrameCaptionViewControl(caption, nameValue); + listDeviceControl.AddChidren(btnObject); + btnObject.InitControl(); + btnObject.txtView.TextColor = UserCenterColor.Current.TextGrayColor; + btnObject.AddBottomLine(); + } + + #endregion + + #region 鈻� 瀹屾垚鎸夐挳鎸変笅_______________________ + + /// <summary> + /// 瀹屾垚鎸夐挳鎸変笅 + /// </summary> + private void FinishButtonClick() + { + if (string.IsNullOrEmpty(this.rowGateway.Text) == true) + { + //璇疯緭鍏ョ綉鍏冲悕绉� + this.rowGateway.Text = string.Empty; + string msg = Language.StringByID(R.MyInternationalizationString.uGatewayNameMastInput); + this.ShowMassage(ShowMsgType.Error, msg); + return; + } + string nameValue = HdlGatewayLogic.Current.GetGatewayName(zbGateway); + if (nameValue == this.rowGateway.Text) + { + //鍚屽悕涓嶉渶瑕佸鐞� + this.CloseForm(); + return; + } + //淇敼鍚嶅瓧 + this.SetGatewayName(this.rowGateway.Text); + } + + #endregion + + #region 鈻� 淇敼鍚嶅瓧___________________________ + + /// <summary> + /// 璁剧疆缃戝叧鍚嶅瓧 + /// </summary> + /// <param name="gatewayName">缃戝叧鍚嶇О</param> + private async void SetGatewayName(string gatewayName) + { + //鎵撳紑杩涘害鏉� + this.ShowProgressBar(); + //淇敼鏈湴缃戝叧鍚� + var result = await HdlGatewayLogic.Current.ReName(zbGateway, gatewayName); + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + + //缃戝叧淇敼澶辫触 + if (result == false) + { + return; + } + Application.RunOnMainThread(() => + { + this.ActionGatewayReName?.Invoke(zbGateway); + //鍏抽棴鐣岄潰 + this.CloseForm(); + }); + } + #endregion + + #region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鐢婚潰鍏抽棴 + /// </summary> + public override void CloseForm() + { + this.ActionGatewayReName = null; + base.CloseForm(); + } + + #endregion + } +} -- Gitblit v1.8.0