From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SearchEditText.cs | 196 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 196 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SearchEditText.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SearchEditText.cs
new file mode 100755
index 0000000..20b5552
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SearchEditText.cs
@@ -0,0 +1,196 @@
+锘縰sing System;
+using System.Threading.Tasks;
+
+namespace Shared.Phone.UserCenter
+{
+ /// <summary>
+ /// 鍒朵綔涓�涓牴鎹敭鍊艰繘琛屾悳绱㈢殑鎺т欢
+ /// 娣诲姞鎺т欢鍚庯紝璇疯皟鐢↙oadEvent()鍑芥暟杩涜鍥炶皟鍑芥暟鐨勭粦瀹�
+ /// </summary>
+ public class SearchTextControl : FrameLayout
+ {
+ #region 鈻� 鍙橀噺澹版槑__________________________
+ /// <summary>
+ /// 涓轰簡瀵瑰簲瀛愮嚎绋�
+ /// </summary>
+ private string m_Text = string.Empty;
+ /// <summary>
+ /// 鏂囨湰鍊�
+ /// </summary>
+ /// <value>The text.</value>
+ public string Text
+ {
+ get
+ {
+ return m_Text;
+ }
+ set
+ {
+ this.m_Text = value;
+ txtSearch.Text = this.m_Text;
+ }
+ }
+ /// <summary>
+ /// 鎼滅储鎺т欢
+ /// </summary>
+ private TextInputControl txtSearch = null;
+ /// <summary>
+ /// 鍥炶皟鍑芥暟
+ /// </summary>
+ private Action<string> actionMethod = null;
+ /// <summary>
+ /// 娌℃湁杈撳叆閿�肩殑鏄剧ず鏂囨湰
+ /// </summary>
+ private string tipText = string.Empty;
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹___________________________
+ /// <summary>
+ /// 鍒朵綔涓�涓牴鎹敭鍊艰繘琛屾悳绱㈢殑鎺т欢
+ /// 娣诲姞鎺т欢鍒扮埗鎺т欢鍚庯紝璇疯皟鐢˙indEvent()鍑芥暟杩涜鍥炶皟鍑芥暟鐨勭粦瀹�
+ /// </summary>
+ /// <param name="i_tipText">娌℃湁杈撳叆閿�肩殑鏄剧ず鏂囨湰</param>
+ /// <param name="width">瀹藉害</param>
+ /// <param name="height">楂樺害</param>
+ public SearchTextControl(string i_tipText, int width = 965, int height = 104)
+ {
+ this.tipText = i_tipText;
+ //妗屽竷鎺т欢
+ this.Width = Application.GetRealWidth(width);
+ this.Height = Application.GetRealHeight(height);
+ this.Gravity = Gravity.CenterHorizontal;
+ this.Radius = (uint)Application.GetRealHeight(17);
+ this.BackgroundColor = 0xfff8f7f7;
+ }
+
+ /// <summary>
+ /// 鎺т欢鍒濆鍖�
+ /// </summary>
+ /// <param name="action">鍥炶皟鍑芥暟锛氬�兼槸杈撳叆鐨勫叧閿瓧</param>
+ private void InitControl(Action<string> action)
+ {
+ //鎼滅储鍥炬爣
+ var btnIcon = new IconViewControl(52);
+ btnIcon.Gravity = Gravity.CenterVertical;
+ btnIcon.X = ControlCommonResourse.XXLeft;
+ btnIcon.UnSelectedImagePath = "Item/Search.png";
+ this.AddChidren(btnIcon);
+
+ //鍙栨秷
+ var btnCancel = new IconViewControl(58);
+ btnCancel.X = this.Width - ControlCommonResourse.XXLeft / 2 - btnCancel.IconSize;
+ btnCancel.UnSelectedImagePath = "Item/CancelIcon.png";
+ btnCancel.Gravity = Gravity.CenterVertical;
+ this.AddChidren(btnCancel);
+ btnCancel.ButtonClickEvent += (sender, e) =>
+ {
+ this.Text = string.Empty;
+ };
+
+ //杈撳叆鏂囨湰
+ int textWidth = btnCancel.X - Application.GetRealWidth(132 + 10);
+ txtSearch = new TextInputControl(textWidth, Application.GetRealHeight(49), false);
+ txtSearch.X = Application.GetRealWidth(132);
+ txtSearch.PlaceholderText = this.tipText;
+ txtSearch.Gravity = Gravity.CenterVertical;
+ txtSearch.TextSize = 12;
+ txtSearch.PlaceholderTextColor = UserCenterColor.Current.TextGrayColor1;
+ this.AddChidren(txtSearch);
+
+ string oldText = string.Empty;
+ //鍊兼敼鍙樹簨浠�
+ txtSearch.TextChangeEventHandler += (sender, e) =>
+ {
+ this.nextSearchKeys = txtSearch.Text.Trim();
+ this.m_Text = this.nextSearchKeys;
+ if (oldText == this.nextSearchKeys)
+ {
+ //杈撳叆鐨勫�间竴鏍�
+ return;
+ }
+ oldText = this.nextSearchKeys;
+ //鍏佽鎵ц鍥炶皟鍑芥暟
+ this.isCanSearch = true;
+ };
+ }
+ #endregion
+
+ #region 鈻� 缁戝畾浜嬩欢__________________________
+
+ /// <summary>
+ /// 缁戝畾浜嬩欢
+ /// </summary>
+ /// <param name="action">鍥炶皟鍑芥暟锛氬�兼槸杈撳叆鐨勫叧閿瓧</param>
+ public void BindEvent(Action<string> action)
+ {
+ this.actionMethod = action;
+
+ //鎺т欢鍒濆鍖�
+ this.InitControl(action);
+
+ //鎵撳紑鎼滅储閿�肩殑绾跨▼
+ this.StartSearchKeysThead();
+ }
+
+ #endregion
+
+ #region 鈻� 寮�鍚嚎绋媉_________________________
+
+ /// <summary>
+ /// 鑳藉惁鎵ц鎼滅储
+ /// </summary>
+ private bool isCanSearch = false;
+ /// <summary>
+ /// 涓嬩竴涓悳绱㈤敭鍊�
+ /// </summary>
+ private string nextSearchKeys = string.Empty;
+ /// <summary>
+ /// 鎵撳紑鎼滅储閿�肩殑绾跨▼
+ /// </summary>
+ private void StartSearchKeysThead()
+ {
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ while (this.Parent != null)
+ {
+ //鏍规嵁閫昏緫锛屼笉鑳藉鎼滅储鐨勮瘽锛岀瓑寰�
+ if (this.isCanSearch == false)
+ {
+ System.Threading.Thread.Sleep(1000);
+ continue;
+ }
+ //鑾峰彇褰撳墠鐬棿鐨勯敭鍊�
+ string nowSearchKeys = nextSearchKeys;
+
+ //鏍规嵁鎼滅储閿�硷紝璋冪敤鍥炶皟鍑芥暟
+ this.actionMethod(nowSearchKeys);
+
+ //澶勭悊瀹屾瘯鍚庯紝濡傛灉褰撳墠鐨勬绱㈤敭鍊间笌涓嬩竴涓绱㈤敭鍊间竴鏍风殑璇�
+ //璇存槑鐢ㄦ埛宸茬粡涓嶅啀杈撳叆閿�间簡锛岃繖涓椂鍊欙紝鍋滄鎼滅储
+ if (nowSearchKeys == nextSearchKeys)
+ {
+ this.isCanSearch = false;
+ }
+
+ //濡傛灉褰撳墠鐨勬绱㈤敭鍊间笌涓嬩竴涓绱㈤敭鍊间笉涓�鏍风殑璇�
+ //閭e氨璇存槑锛岀敤鎴峰啀娆¤緭鍏ヤ簡閿�硷紝杩欎釜鏃跺�欙紝璁╃嚎绋嬬户缁窇涓嬪幓
+ }
+ });
+ }
+ #endregion
+
+ #region 鈻� 鎺т欢鎽ф瘉__________________________
+
+ /// <summary>
+ /// 鎺т欢鎽ф瘉
+ /// </summary>
+ public override void RemoveFromParent()
+ {
+ actionMethod = null;
+ base.RemoveFromParent();
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0