From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/CommonForm/EditorCommonForm.cs |  487 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 487 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/CommonForm/EditorCommonForm.cs b/ZigbeeApp/Shared/Phone/CommonForm/EditorCommonForm.cs
new file mode 100644
index 0000000..c8aaf72
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/CommonForm/EditorCommonForm.cs
@@ -0,0 +1,487 @@
+锘縰sing Shared.Phone.UserCenter;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Shared.Phone
+{
+    /// <summary>
+    /// 涓汉涓績鐨勫叡閫氬熀灞傜敾闈紝缁ф壙浜庢鍏遍�氱殑鐢婚潰锛岃浣跨敤AddForm()鍑芥暟锛�
+    /// 鎴栬�匒ddFromAndRemoveNowForm()鍑芥暟瀹炵幇娣诲姞鐢婚潰锛岀劧鍚庡湪鍚勮嚜鐨勭敾闈腑锛�
+    /// 瀹炵幇涓�涓猄howForm()鐨勫嚱鏁�(鍙傛暟鐢辨坊鍔犵敾闈㈡椂锛屼娇鐢ㄧ殑鍑芥暟鐨勫弬鏁版寚瀹�)
+    /// </summary>
+    public class EditorCommonForm : CommonFormBase
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 杩斿洖鎸夐敭鐨勭偣鍑讳簨浠�(濡傛灉瀹炵幇姝や簨浠�,鍒欏簳灞傜殑浜嬩欢灏嗕笉浼氬啀瑙﹀彂)
+        /// </summary>
+        public Action<BackViewControl> BackButtonClickEvent = null;
+        /// <summary>
+        /// TopMenuFrameLayout
+        /// </summary>
+        public NormalFrameLayout topMenuFrameLayout = null;
+        /// <summary>
+        /// TopFrameLayout
+        /// </summary>
+        public NormalFrameLayout topFrameLayout = null;
+        /// <summary>
+        /// bodyFrameLayout
+        /// </summary>
+        public NormalFrameLayout bodyFrameLayout = null;
+        /// <summary>
+        /// 宸︽粦浣胯兘
+        /// </summary>
+        private bool m_ScrollEnabled = true;
+        /// <summary>
+        /// 宸︽粦浣胯兘(鐣岄潰鍏抽棴鏃�,搴曞眰浼氳繕鍘�,鏃犻渶鍐嶅鐞�)
+        /// </summary>
+        public bool ScrollEnabled
+        {
+            get { return m_ScrollEnabled; }
+            set
+            {
+                if (UserView.HomePage.Instance.ScrollEnabled != value)
+                {
+                    UserView.HomePage.Instance.ScrollEnabled = value;
+                    this.m_ScrollEnabled = value;
+                }
+            }
+        }
+        /// <summary>
+        /// 缂撳瓨鍚姩鍙傛暟
+        /// </summary>
+        private object[] m_parameter = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鍒濆鍖栫晫闈㈡鏋�
+        /// </summary>
+        public override void InitForm()
+        {
+            base.InitForm();
+
+            //鍒濆鍖栧ご閮ㄦ帶浠�
+            this.InitTopFrameLayout();
+
+            //鍒濆鍖栦腑閮ㄦ帶浠�
+            this.InitBodyFrameLayout();
+
+            //鍒濆宸︽粦浣胯兘鍙�
+            this.ScrollEnabled = true;
+        }
+
+        /// <summary>
+        /// 鎵цShowForm()鏂规硶
+        /// </summary>
+        /// <param name="parameter">鍚姩鍙傛暟</param>
+        public override void LoadShowFormMethod(params object[] parameter)
+        {
+            this.m_parameter = parameter;
+            base.LoadShowFormMethod(parameter);
+        }
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖栫晫闈________________________
+
+        #region 鈻� Top________________________________
+
+        /// <summary>
+        /// 鍒濆鍖栧ご閮ㄦ帶浠�
+        /// </summary>
+        public void InitTopFrameLayout()
+        {
+            if (topFrameLayout != null)
+            {
+                topFrameLayout.RemoveAll();
+            }
+
+            //TopMenuFrameLayout鍋氭垚
+            topMenuFrameLayout = new NormalFrameLayout();
+            topMenuFrameLayout.Height = ControlCommonResourse.TopMenuFrameHeight;
+            topMenuFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
+            topMenuFrameLayout.Name = "topMenuFrameLayout";
+            this.AddChidren(topMenuFrameLayout);
+
+            //TopFrameLayout鍋氭垚
+            topFrameLayout = new NormalFrameLayout();
+            topFrameLayout.Height = ControlCommonResourse.TopFrameHeight;
+            topFrameLayout.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
+            topFrameLayout.Y = topMenuFrameLayout.Bottom;
+            topFrameLayout.Name = "topFrameLayout";
+            this.AddChidren(topFrameLayout);
+
+            //绾�
+            var btnLine = new NormalViewControl(topFrameLayout.Width, 1, false);
+            btnLine.BackgroundColor = 0x40000000;
+            btnLine.Y = topFrameLayout.Height - 1;
+            topFrameLayout.AddChidren(btnLine);
+            topFrameLayout.AddTag("btnLine", btnLine);
+
+            //杩斿洖閿�
+            var btnBack = new BackViewControl();
+            topFrameLayout.AddChidren(btnBack);
+            btnBack.InitControl();
+            btnBack.ButtonClickEvent += (sender, e) =>
+            {
+                if (this.BackButtonClickEvent != null)
+                {
+                    //濡傛灉瀹炵幇姝や簨浠�,鍒欏簳灞傜殑浜嬩欢灏嗕笉浼氬啀瑙﹀彂
+                    BackButtonClickEvent(btnBack);
+                    return;
+                }
+                //鐢婚潰鍏抽棴
+                this.CloseForm();
+            };
+            topFrameLayout.AddTag("btnBack", btnBack);
+
+            //鏍囬
+            var txttitle = new Button();
+            txttitle.Name = "txtTitle";
+            txttitle.TextSize = 17;
+            txttitle.X = Application.GetRealWidth(161);
+            txttitle.Height = Application.GetRealHeight(75);
+            txttitle.Width = Application.GetRealWidth(850);
+            txttitle.Gravity = Gravity.CenterVertical;
+            txttitle.TextColor = UserCenterColor.Current.TopLayoutTitleText;
+            txttitle.TextAlignment = TextAlignment.CenterLeft;
+            txttitle.IsBold = true;
+            topFrameLayout.AddChidren(txttitle);
+
+            topFrameLayout.AddTag("txtTitle", txttitle);
+        }
+
+        #endregion
+
+        #region 鈻� Middle_____________________________
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄦ帶浠�
+        /// </summary>
+        public void InitBodyFrameLayout()
+        {
+            if (bodyFrameLayout != null)
+            {
+                bodyFrameLayout.RemoveAll();
+            }
+            bodyFrameLayout = new NormalFrameLayout();
+            bodyFrameLayout.Height = ControlCommonResourse.BodyFrameHeight;
+            bodyFrameLayout.Y = topFrameLayout.Bottom;
+            bodyFrameLayout.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
+            bodyFrameLayout.Name = "bodyFrameLayout";
+            this.AddChidren(bodyFrameLayout);
+        }
+
+        #endregion
+
+        #endregion
+
+        #region 鈻� 娣诲姞鐣岄潰___________________________
+
+        /// <summary>
+        /// 娣诲姞鐢婚潰,鍚姩鍙傛暟鐢辨寚瀹氱敾闈㈢殑ShowForm鍑芥暟鎵�鎸囧畾
+        /// </summary>
+        /// <param name="parameter">鍚姩鍙傛暟锛氬弬鏁扮敱鎸囧畾鐢婚潰鐨凷howForm鍑芥暟鎵�鎸囧畾</param>
+        public override void AddForm(params object[] parameter)
+        {
+            //鐣岄潰鍔犺浇涓�
+            ControlCommonResourse.IsFormAdding = true;
+
+            base.AddForm(parameter);
+
+            //妫�娴嬭兘鍚﹁拷鍔犵敾闈� 2020.05.14鑸嶅純
+            //if (UserCenterLogic.CheckCanAddForm(this) == false)
+            //{
+            //    return;
+            //}
+
+            UserView.HomePage.Instance.AddChidren(this);
+            UserView.HomePage.Instance.PageIndex += 1;
+
+            //鍒濆鍖栫晫闈㈡鏋�
+            this.InitForm();
+
+            //鎵цShowForm()鏂规硶
+            this.LoadShowFormMethod(parameter);
+
+            //鐣岄潰鍔犺浇缁撴潫
+            ControlCommonResourse.IsFormAdding = false;
+        }
+
+        #endregion
+
+        #region 鈻� 鍏抽棴鐣岄潰___________________________
+
+        /// <summary>
+        /// 鐢婚潰鍏抽棴
+        /// </summary>
+        public override void CloseFormBefore()
+        {
+            base.CloseFormBefore();
+
+            //宸︽粦浣胯兘
+            this.ScrollEnabled = true;
+
+            this.BackButtonClickEvent = null;
+
+            this.m_parameter = null;
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+        }
+
+        #endregion
+
+        #region 鈻� 娣诲姞甯姪鎺т欢_______________________
+
+        /// <summary>
+        /// 娣诲姞鏌ョ湅甯姪鎺т欢
+        /// </summary>
+        /// <returns></returns>
+        public NormalViewControl AddHelpControl()
+        {
+            //鏌ョ湅甯姪
+            var btnHelp = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false);
+            btnHelp.Y = Application.GetRealHeight(1388);
+            btnHelp.TextSize = 12;
+            btnHelp.TextAlignment = TextAlignment.Center;
+            btnHelp.TextColor = UserCenterColor.Current.TextOrangeColor;
+            btnHelp.Text = Language.StringByID(R.MyInternationalizationString.uSearchHelp);
+            bodyFrameLayout.AddChidren(btnHelp);
+            //搴曠嚎
+            int lineWidth = btnHelp.GetRealWidthByText();
+            var btnLine = new NormalViewControl(lineWidth, ControlCommonResourse.BottomLineHeight, false);
+            btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
+            btnLine.Gravity = Gravity.CenterHorizontal;
+            btnLine.Y = btnHelp.Bottom - Application.GetRealHeight(8);
+            bodyFrameLayout.AddChidren(btnLine);
+
+            return btnHelp;
+        }
+
+        #endregion
+
+        #region 鈻� 鏄剧ず閲嶆柊鍔犺浇_______________________
+
+        /// <summary>
+        /// 鏄剧ず閲嶆柊鍔犺浇鐨勭晫闈�(涓昏鏄敤鍦ㄧ晫闈㈠姞杞介敊璇椂锛屽啀娆″姞杞�)
+        /// </summary>
+        public override void ShowReLoadView()
+        {
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                if (bodyFrameLayout == null || bodyFrameLayout.Parent == null)
+                {
+                    return;
+                }
+                //鍒囨崲涓洪噸鏂板姞杞芥ā寮忔椂鐨勪簨浠�
+                this.ReLoadModelEventMethod();
+
+                var frame = new FrameLayout();
+                frame.BackgroundColor = UserCenterColor.Current.White;
+                bodyFrameLayout.AddChidren(frame);
+
+                //閲嶆柊鍔犺浇
+                var btnReLoad = new BottomClickButton();
+                btnReLoad.Gravity = Gravity.Center;
+                btnReLoad.TextID = R.MyInternationalizationString.uDoReload;
+                frame.AddChidren(btnReLoad);
+                btnReLoad.ButtonClickEvent += (sender, e) =>
+                {
+                    //鐐瑰嚮閲嶆柊鍔犺浇鏃�,鍏佽鍐嶆鑱旂綉
+                    HdlWifiLogic.Current.CanAccessHttp = true;
+
+                    //娓呴櫎鍏ㄩ儴鎺т欢
+                    this.ClearBodyFrame();
+
+                    //鎵цShowForm()鏂规硶瀹炵幇閲嶆柊鍔犺浇
+                    this.LoadShowFormMethod(this.m_parameter);
+                };
+
+                //娓呴櫎topFrameLayout鐨勯潪榛樿鐨勬帶浠�
+                var list = new List<View>();
+                for (int i = 0; i < topFrameLayout.ChildrenCount; i++)
+                {
+                    var view = topFrameLayout.GetChildren(i);
+                    if (view.Name == "btnBack" || view.Name == "txtTitle")
+                    {
+                        //杩欓噷鏄粯璁ょ殑搴曞眰鎺т欢
+                        continue;
+                    }
+                    list.Add(view);
+                }
+                foreach (var view in list)
+                {
+                    view?.RemoveFromParent();
+                }
+            });
+        }
+
+        /// <summary>
+        /// 鍒囨崲涓恒�愰噸鏂板姞杞芥ā寮忋�戞椂鐨勪簨浠跺嚱鏁�,鏃ㄥ湪鍏抽棴鎵�鏈夌嚎绋嬩俊鎭�
+        /// </summary>
+        public virtual void ReLoadModelEventMethod()
+        {
+        }
+
+        #endregion
+
+        #region 鈻� 鏄剧ず寮圭獥杈撳叆鐣岄潰___________________
+
+        /// <summary>
+        /// <para>鏄剧ず涓�涓狣ialog鐨勫脊绐楄緭鍏ョ晫闈�,瀹冧笉浼氳嚜鍔ㄥ叧闂�,闇�瑕佹墜鍔ㄥ叧闂�</para>
+        /// <para>.CloseDialog()涓哄叧闂脊绐�</para>
+        /// <para>濡傛灉杈撳叆妗嗙殑鍐呭涓虹┖,骞朵笖璁剧疆鏈夈�恑_TipText銆�,鍒欎笉浼氳皟鐢ㄥ洖璋冨嚱鏁�,骞朵笖鎻愮ず銆恑_TipText銆戠殑鍐呭</para>
+        /// </summary>
+        /// <param name="i_TitleText">寮圭獥鐨勬爣棰樹俊鎭�</param>
+        /// <param name="i_InputText">杈撳叆妗嗗垵濮嬪寲鍊�(蹇界暐璇疯缃负null)</param>
+        /// <param name="i_TipText">杈撳叆妗嗙伆鑹插瓧浣撹鏄�(蹇界暐璇疯缃负null)</param>
+        /// <param name="i_ComfirmClickEvent">纭鎸夐挳浜嬩欢</param>
+        /// <returns></returns>
+        public void ShowDialogInputForm(string i_TitleText, string i_InputText, string i_TipText, Action<DialogInputControl, string> i_ComfirmClickEvent)
+        {
+            //鐢熸垚涓�涓脊绐楃敾闈�
+            var dialogForm = new DialogInputControl();
+            //鏍囬
+            dialogForm.SetTitleText(i_TitleText);
+            //杈撳叆妗嗙伆鑹插瓧浣撹鏄�
+            if (i_TipText != null)
+            {
+                dialogForm.SetTipText(i_TipText);
+            }
+            //杈撳叆妗嗗垵濮嬪��
+            if (i_InputText != null)
+            {
+                dialogForm.Text = i_InputText;
+            }
+
+            //鎸変笅纭鎸夐挳
+            dialogForm.ComfirmClickEvent += ((textValue) =>
+            {
+                i_ComfirmClickEvent?.Invoke(dialogForm, textValue);
+            });
+        }
+
+        #endregion
+
+        #region 鈻� 鏄剧ず娌℃湁鏁版嵁鐨勫浘鍍忔樉绀虹壒鏁坃________
+
+        /// <summary>
+        /// 鏄剧ず娌℃湁鏁版嵁鐨勫浘鍍忔樉绀虹壒鏁�
+        /// </summary>
+        /// <param name="frameTable">瀹瑰櫒</param>
+        /// <param name="i_Text">鏄剧ず鏂囧瓧</param>
+        /// <param name="Imagepath">鍥惧儚鍦板潃</param>
+        /// <param name="imageWith">鍥惧儚瀹藉害(闈炵湡瀹炲��)</param>
+        /// <param name="imageHeight">鍥惧儚楂樺害(闈炵湡瀹炲��)</param>
+        public void ShowNotDataImage(FrameLayout frameTable, string i_Text, string Imagepath = "Item/NoFunction.png", int imageWith = 683, int imageHeight = 392)
+        {
+            this.ShowNotDataImage(frameTable, new string[] { i_Text }, Imagepath, imageWith, imageHeight);
+        }
+
+        /// <summary>
+        /// 鏄剧ず娌℃湁鏁版嵁鐨勫浘鍍忔樉绀虹壒鏁�
+        /// </summary>
+        /// <param name="frameTable">瀹瑰櫒</param>
+        /// <param name="listText">鏄剧ず鏂囧瓧</param>
+        /// <param name="Imagepath">鍥惧儚鍦板潃</param>
+        /// <param name="imageWith">鍥惧儚瀹藉害(闈炵湡瀹炲��)</param>
+        /// <param name="imageHeight">鍥惧儚楂樺害(闈炵湡瀹炲��)</param>
+        public void ShowNotDataImage(FrameLayout frameTable, string[] listText, string Imagepath = "Item/NoFunction.png", int imageWith = 683, int imageHeight = 392)
+        {
+            var btnPic = new PicViewControl(imageWith, imageHeight);
+            btnPic.UnSelectedImagePath = Imagepath;
+            btnPic.Y = (int)(frameTable.Height * 0.382) - Application.GetRealHeight(imageHeight / 2);
+            btnPic.Gravity = Gravity.CenterHorizontal;
+            frameTable.AddChidren(btnPic);
+
+            int yy = btnPic.Bottom + Application.GetRealHeight(32);
+            for (int i = 0; i < listText.Length; i++)
+            {
+                var btnView = new NormalViewControl(frameTable.Width, Application.GetRealHeight(50), false);
+                btnView.Y = yy;
+                btnView.Text = listText[i];
+                btnView.TextAlignment = TextAlignment.Center;
+                btnView.TextSize = 12;
+                btnView.TextColor = UserCenterColor.Current.TextGrayColor1;
+                frameTable.AddChidren(btnView);
+
+                yy = btnView.Bottom;
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+
+        /// <summary>
+        /// <para>鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�</para>
+        /// <para>閲嶅啓鐨勬椂鍊欒繑鍥炲�艰杩斿洖1(杩斿洖鍊兼槸缁欏簳灞備娇鐢ㄧ殑)</para>
+        /// </summary>
+        public virtual int FormActionAgainEvent()
+        {
+            return -1;
+        }
+
+        #endregion
+
+        #region 鈻� 娓呯┖BodyFrame______________________
+
+        /// <summary>
+        /// 娓呯┖BodyFrame
+        /// </summary>
+        public void ClearBodyFrame()
+        {
+            if (this.Parent == null)
+            {
+                return;
+            }
+            if (bodyFrameLayout == null || bodyFrameLayout.Parent == null)
+            {
+                return;
+            }
+            bodyFrameLayout.RemoveAll();
+        }
+
+        #endregion
+
+        #region 鈻� 涓�鑸殑鏂规硶_________________________
+
+        /// <summary>
+        /// 璁剧疆鏍囬淇℃伅
+        /// </summary>
+        /// <param name="title">Title.</param>
+        public void SetTitleText(string title)
+        {
+            //璁剧疆澶撮儴淇℃伅
+            var btntitle = (Button)topFrameLayout.GetTagByKey("txtTitle");
+            btntitle.Text = title;
+        }
+
+        /// <summary>
+        /// 绉婚櫎杩斿洖閿�
+        /// </summary>
+        public void RemoveBackButton()
+        {
+            //绉婚櫎杩斿洖閿�
+            var back = (BackViewControl)topFrameLayout.GetTagByKey("btnBack");
+            back?.RemoveFromParent();
+        }
+
+        /// <summary>
+        /// 鑾峰彇杩斿洖閿�
+        /// </summary>
+        public BackViewControl GetBackButton()
+        {
+            //绉婚櫎杩斿洖閿�
+            var back = (BackViewControl)topFrameLayout.GetTagByKey("btnBack");
+            return back;
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0