From b78a4d0ca90416d37fcbaf5e54b00f7eaab53919 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 14 十月 2019 17:03:58 +0800
Subject: [PATCH] 2019-10-14-2
---
ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs | 312 +++++++++++++++++++++++++--------------------------
1 files changed, 155 insertions(+), 157 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
index 93d2302..f751770 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/WiredGatewaySearchForm.cs
@@ -1,122 +1,122 @@
-锘縰sing System;
-using System.Collections.Generic;
+锘縰sing System;
+using System.Collections.Generic;
using System.IO;
-using System.Threading.Tasks;
-using ZigBee.Device;
-
-namespace Shared.Phone.UserCenter.GatewayAdd
-{
- /// <summary>
- /// 缃戝叧鎼滅储涓�
- /// </summary>
- public class WiredGatewaySearchForm : EditorCommonForm
+using System.Threading.Tasks;
+using ZigBee.Device;
+
+namespace Shared.Phone.UserCenter.GatewayAdd
+{
+ /// <summary>
+ /// 缃戝叧鎼滅储涓�
+ /// </summary>
+ public class WiredGatewaySearchForm : EditorCommonForm
{
- #region 鈻� 鍙橀噺澹版槑___________________________
-
- /// <summary>
- /// 鍒楄〃鎺т欢
- /// </summary>
- private VerticalScrolViewLayout listView = null;
- /// <summary>
- /// 杩欐槸涓�忔槑鐨勬帶浠�
- /// </summary>
- private FrameLayout frameTransparent = null;
- /// <summary>
- /// 绾跨▼鎵ц涓�
- /// </summary>
- private bool IsThreadAction = true;
- /// <summary>
- /// 鎼滅储鏃堕棿
- /// </summary>
- private int searchTime = 60;
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 鍒楄〃鎺т欢
+ /// </summary>
+ private VerticalScrolViewLayout listView = null;
+ /// <summary>
+ /// 杩欐槸涓�忔槑鐨勬帶浠�
+ /// </summary>
+ private FrameLayout frameTransparent = null;
+ /// <summary>
+ /// 绾跨▼鎵ц涓�
+ /// </summary>
+ private bool IsThreadAction = true;
+ /// <summary>
+ /// 鎼滅储鏃堕棿
+ /// </summary>
+ private int searchTime = 60;
/// <summary>
/// 鍋滄鎼滅储鐨勬寜閿�
- /// </summary>
- private BottomClickButton btnStop = null;
+ /// </summary>
+ private BottomClickButton btnStop = null;
/// <summary>
/// 缃戝叧鐨勪富閿�(value:鍓╀綑妫�娴嬫鏁�,鐢ㄤ簬瀵瑰簲寮傚父鐨勭綉鍏�)
- /// </summary>
+ /// </summary>
private Dictionary<string, int> dicGatewayId = new Dictionary<string, int>();
- #endregion
+ #endregion
#region 鈻� 鍒濆鍖朹____________________________
- /// <summary>
- /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
- /// </summary>
- public void ShowForm()
- {
- //璁剧疆鏍囬淇℃伅
- base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddWiredGateway));
-
- //鍒濆鍖栦腑閮ㄦ帶浠�
- this.InitMiddleFrame();
-
- //寮�鍚嚎绋�
- this.StartThread();
- }
-
- /// <summary>
- /// 鍒濆鍖栦腑閮ㄦ帶浠�
- /// </summary>
- private void InitMiddleFrame()
- {
- //娓呯┖bodyFrame
- this.ClearBodyFrame();
-
- //缃戝叧鍒楄〃锛岃繖涓帶浠剁疆浜庤儗閮�
+ /// <summary>
+ /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+ /// </summary>
+ public void ShowForm()
+ {
+ //璁剧疆鏍囬淇℃伅
+ base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddWiredGateway));
+
+ //鍒濆鍖栦腑閮ㄦ帶浠�
+ this.InitMiddleFrame();
+
+ //寮�鍚嚎绋�
+ this.StartThread();
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栦腑閮ㄦ帶浠�
+ /// </summary>
+ private void InitMiddleFrame()
+ {
+ //娓呯┖bodyFrame
+ this.ClearBodyFrame();
+
+ //缃戝叧鍒楄〃锛岃繖涓帶浠剁疆浜庤儗閮�
listView = new VerticalScrolViewLayout();
- listView.Height = ControlCommonResourse.ListViewRowHeight * 5;
- bodyFrameLayout.AddChidren(listView);
-
- //鍥剧墖,鑳屾櫙瑕侀�忔槑
- frameTransparent = new FrameLayout
- {
- Width = bodyFrameLayout.Width,
- Height = bodyFrameLayout.Height,
- Gravity = Gravity.CenterHorizontal,
- BackgroundColor = UserCenterColor.Current.Transparent
- };
- bodyFrameLayout.AddChidren(frameTransparent);
-
- //鍥剧墖
+ listView.Height = ControlCommonResourse.ListViewRowHeight * 5;
+ bodyFrameLayout.AddChidren(listView);
+
+ //鍥剧墖,鑳屾櫙瑕侀�忔槑
+ frameTransparent = new FrameLayout
+ {
+ Width = bodyFrameLayout.Width,
+ Height = bodyFrameLayout.Height,
+ Gravity = Gravity.CenterHorizontal,
+ BackgroundColor = UserCenterColor.Current.Transparent
+ };
+ bodyFrameLayout.AddChidren(frameTransparent);
+
+ //鍥剧墖
var btnimage = new PicViewControl(620, 620);
btnimage.Y = ControlCommonResourse.ListViewRowHeight * 2;
btnimage.Gravity = Gravity.CenterHorizontal;
- btnimage.UnSelectedImagePath = "Gateway/SearchGateway.png";
+ btnimage.UnSelectedImagePath = "Gateway/SearchGateway.png";
frameTransparent.AddChidren(btnimage);
//鏅鸿兘缃戝叧閰嶇疆缃戠粶涓�
var btnText1 = new NormalViewControl(bodyFrameLayout.Width, false);
btnText1.Y = btnimage.Bottom + Application.GetRealHeight(60);
btnText1.Gravity = Gravity.CenterHorizontal;
- btnText1.TextID = R.MyInternationalizationString.uGatewaySetting;
- frameTransparent.AddChidren(btnText1);
-
- //璇风◢鍊�
+ btnText1.TextID = R.MyInternationalizationString.uGatewaySetting;
+ frameTransparent.AddChidren(btnText1);
+
+ //璇风◢鍊�
var btnText2 = new NormalViewControl(bodyFrameLayout.Width, false);
btnText2.Y = btnText1.Bottom + Application.GetRealHeight(30);
btnText2.Gravity = Gravity.CenterHorizontal;
- btnText2.TextID = R.MyInternationalizationString.uPleaseWait;
- frameTransparent.AddChidren(btnText2);
-
- //鍋滄鎼滅储
+ btnText2.TextID = R.MyInternationalizationString.uPleaseWait;
+ frameTransparent.AddChidren(btnText2);
+
+ //鍋滄鎼滅储
btnStop = new BottomClickButton();
- btnStop.TextID = R.MyInternationalizationString.uStopSearch;
- frameTransparent.AddChidren(btnStop);
-
- btnStop.MouseUpEventHandler += this.btnStop_MouseClick;
+ btnStop.TextID = R.MyInternationalizationString.uStopSearch;
+ frameTransparent.AddChidren(btnStop);
+
+ btnStop.MouseUpEventHandler += this.btnStop_MouseClick;
}
- #endregion
+ #endregion
#region 鈻� 寮�鍚嚎绋媉__________________________
- /// <summary>
- /// 寮�鍚悳绱㈢綉鍏崇殑瀛愮嚎绋�
- /// </summary>
- private void StartThread()
+ /// <summary>
+ /// 寮�鍚悳绱㈢綉鍏崇殑瀛愮嚎绋�
+ /// </summary>
+ private void StartThread()
{
string textValue = btnStop.Text;
//娓呯┖淇濆瓨鐨勪富閿�
@@ -126,12 +126,12 @@
//娓呯┖鍏ㄩ儴鍒楄〃
HdlGatewayLogic.Current.ClearAllRealGateway();
- ZigBee.Common.Application.IsSearchingGateway = true;
-
- //寮�鍚�掕鏃剁嚎绋�
- this.StartTimeCountThread(textValue);
-
- new System.Threading.Thread(async () =>
+ ZigBee.Common.Application.IsSearchingGateway = true;
+
+ //寮�鍚�掕鏃剁嚎绋�
+ this.StartTimeCountThread(textValue);
+
+ HdlThreadLogic.Current.RunThread(async () =>
{
while (this.IsThreadAction)
{
@@ -144,9 +144,8 @@
//妫�娴嬫悳绱㈠埌鐨勭綉鍏筹紝鐒跺悗娣诲姞鍒扮敾闈㈢殑琛岄噷闈�
await this.CheckZbGatewayAndSetRow();
- }
- })
- { IsBackground = true }.Start();
+ }
+ });
}
/// <summary>
@@ -158,7 +157,7 @@
//鎼滅储鏃堕棿
this.searchTime = 60;
- new System.Threading.Thread(() =>
+ HdlThreadLogic.Current.RunThread(() =>
{
while (this.IsThreadAction)
{
@@ -187,18 +186,17 @@
btnStop.Text = textValue;
}
});
- })
- { IsBackground = true }.Start();
+ });
}
- #endregion
+ #endregion
#region 鈻� 缃戝叧妫�娴媉__________________________
- /// <summary>
- /// 妫�娴嬫悳绱㈠埌鐨勭綉鍏筹紝鐒跺悗娣诲姞鍒扮敾闈㈢殑琛岄噷闈�
- /// </summary>
- private async Task<bool> CheckZbGatewayAndSetRow()
+ /// <summary>
+ /// 妫�娴嬫悳绱㈠埌鐨勭綉鍏筹紝鐒跺悗娣诲姞鍒扮敾闈㈢殑琛岄噷闈�
+ /// </summary>
+ private async Task<bool> CheckZbGatewayAndSetRow()
{
List<string> listId = new List<string>();
for (int i = 0; i < ZbGateway.GateWayList.Count; i++)
@@ -223,14 +221,14 @@
this.dicGatewayId[gwId] = this.dicGatewayId[gwId] - 1;
listId.Add(gwId);
}
- }
+ }
if (listId.Count == 0)
{
//娌℃湁鏂扮殑缃戝叧锛屾垨鑰呮鏁板凡缁忕敤瀹�
return true;
- }
- for (int i = 0; i < listId.Count; i++)
- {
+ }
+ for (int i = 0; i < listId.Count; i++)
+ {
ZbGateway way = ZbGateway.GateWayList.Find((obj) => HdlGatewayLogic.Current.GetGatewayId(obj) == listId[i]);
if (way == null)
{
@@ -292,9 +290,9 @@
//娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮敾闈�
this.AddRowLayout(way, mode);
}
- });
- }
- return true;
+ });
+ }
+ return true;
}
#endregion
@@ -302,11 +300,11 @@
#region 鈻� 娣诲姞缃戝叧琛屾帶浠禵____________________
/// <summary>
- /// 娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮敾闈�
- /// </summary>
- /// <param name="zbGateway">Zb gateway.</param>
- /// <param name="mode">缃戝叧缁戝畾妯″紡</param>
- private void AddRowLayout(ZbGateway zbGateway, GatewayBindMode mode)
+ /// 娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮敾闈�
+ /// </summary>
+ /// <param name="zbGateway">Zb gateway.</param>
+ /// <param name="mode">缃戝叧缁戝畾妯″紡</param>
+ private void AddRowLayout(ZbGateway zbGateway, GatewayBindMode mode)
{
if (listView == null)
{
@@ -325,7 +323,7 @@
this.OpenEditorGatewayForm(gatewayRow, mode);
};
//鍚戝彸鍥炬爣
- gatewayRow.frameTable.AddRightIconControl();
+ gatewayRow.frameTable.AddRightArrow();
//缁戝畾
var btnBind = gatewayRow.frameTable.AddMostRightView("", 300);
@@ -354,10 +352,10 @@
}
/// <summary>
- /// 娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮敾闈㈢殑琛�
- /// </summary>
- /// <param name="zbGateway">Zb gateway.</param>
- private void AddFailRowLayout(ZbGateway zbGateway)
+ /// 娣诲姞鎼滅储鍒扮殑缃戝叧鍒扮敾闈㈢殑琛�
+ /// </summary>
+ /// <param name="zbGateway">Zb gateway.</param>
+ private void AddFailRowLayout(ZbGateway zbGateway)
{
if (listView == null)
{
@@ -377,7 +375,7 @@
btnBind.TextColor = UserCenterColor.Current.Red;
}
- #endregion
+ #endregion
#region 鈻� 鎵ц缃戝叧淇濆瓨_______________________
@@ -503,19 +501,19 @@
#endregion
- #region 鈻� 鎸夐挳浜嬩欢___________________________
+ #region 鈻� 鎸夐挳浜嬩欢___________________________
- /// <summary>
- /// 鍋滄鎸夐挳鎸変笅
- /// </summary>
- /// <param name="sender">Sender.</param>
- /// <param name="e">E.</param>
- private void btnStop_MouseClick(object sender, MouseEventArgs e)
- {
- //瀛樺湪璇寜鐨勫彲鑳斤紝鐢婚潰寮�鍚殑2绉掑墠锛岀姝㈡寜涓嬪仠姝㈡寜閽�
- if (this.searchTime >= 58 || this.Parent == null)
- {
- return;
+ /// <summary>
+ /// 鍋滄鎸夐挳鎸変笅
+ /// </summary>
+ /// <param name="sender">Sender.</param>
+ /// <param name="e">E.</param>
+ private void btnStop_MouseClick(object sender, MouseEventArgs e)
+ {
+ //瀛樺湪璇寜鐨勫彲鑳斤紝鐢婚潰寮�鍚殑2绉掑墠锛岀姝㈡寜涓嬪仠姝㈡寜閽�
+ if (this.searchTime >= 58 || this.Parent == null)
+ {
+ return;
}
//瓒呮椂
if (e == null && listView.ChildrenCount == 0)
@@ -523,31 +521,31 @@
//娌℃湁鍙戠幇鏂扮綉鍏�,璇锋鏌ョ綉鍏抽摼鎺ユ槸鍚︽甯�
string msg = Language.StringByID(R.MyInternationalizationString.uNotFoundNewGatewayPleaseCheckMsg);
this.ShowMassage(ShowMsgType.Tip, msg);
- }
- Application.RunOnMainThread(() =>
- {
- this.IsThreadAction = false;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ this.IsThreadAction = false;
if (frameTransparent != null)
{
frameTransparent.Visible = false;
- }
+ }
if (listView != null)
{
listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(18);
- }
- this.searchTime = 60;
- });
- }
-
+ }
+ this.searchTime = 60;
+ });
+ }
+
#endregion
- #region 鈻� 鐣岄潰鍏抽棴___________________________
+ #region 鈻� 鐣岄潰鍏抽棴___________________________
/// <summary>
/// 鐢婚潰鍏抽棴
- /// </summary>
- public override void CloseForm()
- {
+ /// </summary>
+ public override void CloseForm()
+ {
this.IsThreadAction = false;
ZigBee.Common.Application.IsSearchingGateway = false;
@@ -572,15 +570,15 @@
{
//鍒锋柊涓婚〉
UserView.UserPage.Instance.Fresh();
- }
-
- base.CloseForm();
+ }
+
+ base.CloseForm();
}
- #endregion
+ #endregion
#region 鈻� 涓�鑸柟娉昣__________________________
- #endregion
- }
-}
+ #endregion
+ }
+}
--
Gitblit v1.8.0