From e79b65b97a8ae1eae5ee172dea1b52d041006599 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 02 九月 2020 17:24:32 +0800
Subject: [PATCH] 2020-09-02-3
---
ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs | 306 +++++++++++++++++++++-----------------------------
1 files changed, 130 insertions(+), 176 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
index 7662561..0277750 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Manage/GatewayListForm.cs
@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Text;
-using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.GatewayManage
@@ -39,16 +38,20 @@
//璁剧疆鏍囬淇℃伅
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uGatewayManagement));
- //娣诲姞鍥炬爣
- var btnAdd = new MostRightIconControl(69, 69);
- btnAdd.UnSelectedImagePath = "Item/Add.png";
- topFrameLayout.AddChidren(btnAdd);
- btnAdd.InitControl();
- btnAdd.ButtonClickEvent += (sender, e) =>
+ //灞曠ず妯℃澘涓嶅厑璁哥紪杈�
+ if (Config.Instance.Home.IsShowTemplate == false)
{
- var form = new GatewayAdd.NewGateWayMenuSelectForm();
- form.AddForm();
- };
+ //娣诲姞鍥炬爣
+ var btnAdd = new MostRightIconControl(69, 69);
+ btnAdd.UnSelectedImagePath = "Item/Add.png";
+ topFrameLayout.AddChidren(btnAdd);
+ btnAdd.InitControl();
+ btnAdd.ButtonClickEvent += (sender, e) =>
+ {
+ var form = new GatewayAdd.NewGateWayMenuSelectForm();
+ form.AddForm();
+ };
+ }
//鍒濆鍖栦腑閮ㄦ帶浠�
this.InitMiddleFrame();
@@ -88,36 +91,25 @@
if (listway.Count == 0)
{
//杩樻病鏈夌粦瀹氱綉鍏冲摝
- var btnPic = new PicViewControl(683, 392);
- btnPic.UnSelectedImagePath = "Item/NoFunction.png";
- btnPic.Y = (int)(bodyFrameLayout.Height * 0.382) - Application.GetRealHeight(392 / 2);
- btnPic.Gravity = Gravity.CenterHorizontal;
- bodyFrameLayout.AddChidren(btnPic);
-
- var btnView = new NormalViewControl(bodyFrameLayout.Width, Application.GetRealHeight(50), false);
- btnView.Y = btnPic.Bottom + Application.GetRealHeight(32);
- btnView.TextID = R.MyInternationalizationString.uHadNotBindGatewayMsg;
- btnView.TextAlignment = TextAlignment.Center;
- btnView.TextSize = 12;
- btnView.TextColor = UserCenterColor.Current.TextGrayColor1;
- bodyFrameLayout.AddChidren(btnView);
+ this.ShowNotDataImage(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uHadNotBindGatewayMsg));
return;
}
for (int i = 0; i < listway.Count; i++)
{
//娣诲姞琛�
- var gwId = HdlGatewayLogic.Current.GetGatewayId(listway[i]);
- this.AddRowLayout(gwId, i != listway.Count - 1);
+ this.AddRowLayout(listway[i].GwId, i != listway.Count - 1);
}
//璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
this.listview.AdjustRealHeight(Application.GetRealHeight(23));
- //璁剧疆鎺ュ彈鍦ㄧ嚎鐘舵�佹帹閫�
- this.AddGatewayOnlinePush();
- //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
- this.StartGatewayOnlieCheckThread(listway);
+ //濡傛灉鏄睍绀烘ā鏉跨殑璇�,涓嶉渶瑕佹娴�
+ if (Common.Config.Instance.Home.IsShowTemplate == false)
+ {
+ //寮�鍚綉鍏冲湪绾跨洃娴嬬殑绾跨▼
+ this.StartGatewayOnlieCheckThread(listway);
+ }
}
#endregion
@@ -142,53 +134,69 @@
{
gatewayRow.frameTable.AddBottomLine();
}
- //鎻愮ず鏈夋柊鐗堟湰
- var btnNew = new RowNewVersionTipView();
+ //鎻愮ず鏂扮増鏈�
+ var btnNew = new InformationTipView(gatewayRow.btnIcon);
btnNew.Visible = false;
- gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEventOnly);
+ gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEvent);
gatewayRow.AddTag("btnNew", btnNew);
//鍗曞嚮浜嬩欢
gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
{
-
+ if (UserCenterResourse.HideOption.GotoGatewayProductInfoForm == 1)
+ {
+ //寮哄埗璺宠浆
+ var form2 = new GatewayProductInfoForm();
+ form2.AddForm(gateway);
+ return;
+ }
+ var form = new GatewayInfoEditorForm();
+ form.AddForm(gateway);
};
- //鍒囨崲
- var btnSwitch = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
- btnSwitch.BackgroundColor = 0xfffb744a;
- btnSwitch.TextAlignment = TextAlignment.Center;
- btnSwitch.TextColor = UserCenterColor.Current.White;
- btnSwitch.TextSize = 12;
- btnSwitch.TextID = R.MyInternationalizationString.uSwitch1;
- if (strWayId == GatewayResourse.AppOldSelectGatewayId)
+ //濡傛灉鏄睍绀烘ā鏉跨殑璇�,涓嶈兘缂栬緫
+ if (Common.Config.Instance.Home.IsShowTemplate == true)
{
- btnSwitch.TextID = R.MyInternationalizationString.uRefresh;
+ return;
}
- gatewayRow.AddRightView(btnSwitch);
- btnSwitch.ButtonClickEvent += (sender, e) =>
+
+ //闈炶櫄鎷熶綇瀹�,鎵嶆湁杩欎釜鍔熻兘
+ if (Common.Config.Instance.Home.IsVirtually == false)
{
- //鏄惁鍒囨崲鍒皗0}缃戝叧?
- string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]");
+ //鍒囨崲
+ var btnSwitch = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
+ btnSwitch.BackgroundColor = 0xfffb744a;
+ btnSwitch.TextAlignment = TextAlignment.Center;
+ btnSwitch.TextColor = UserCenterColor.Current.White;
+ btnSwitch.TextSize = 12;
+ btnSwitch.TextID = R.MyInternationalizationString.uSwitch1;
if (strWayId == GatewayResourse.AppOldSelectGatewayId)
{
- //鏄惁閲嶆柊鍒锋柊{0}缃戝叧?
- msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + gatewayRow.btnName.Text + "]");
+ btnSwitch.TextID = R.MyInternationalizationString.uRefresh;
}
- this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+ gatewayRow.AddRightView(btnSwitch);
+ btnSwitch.ButtonClickEvent += (sender, e) =>
{
- //鎵ц鍒囨崲缃戝叧鎿嶄綔
- this.DoSwitchGateway(strWayId, gatewayRow.IsOnline);
- });
- };
+ //鏄惁鍒囨崲鍒皗0}缃戝叧?
+ string msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToSwitchTheGateway), "[" + gatewayRow.btnName.Text + "]");
+ if (strWayId == GatewayResourse.AppOldSelectGatewayId)
+ {
+ //鏄惁閲嶆柊鍒锋柊{0}缃戝叧?
+ msg = string.Format(Language.StringByID(R.MyInternationalizationString.uConfirmWantToRefreshTheGateway), "[" + gatewayRow.btnName.Text + "]");
+ }
+ this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+ {
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ //鎵ц鍒囨崲缃戝叧鎿嶄綔
+ this.DoSwitchGateway(strWayId);
+ });
+ });
+ };
+ }
//瀹氫綅
- var btnPosition = new NormalViewControl(Application.GetRealWidth(184), gatewayRow.Height, false);
- btnPosition.BackgroundColor = 0xff4a4a4a;
- btnPosition.TextAlignment = TextAlignment.Center;
- btnPosition.TextColor = UserCenterColor.Current.White;
- btnPosition.TextSize = 12;
+ var btnPosition = gatewayRow.AddEditorControl(false);
btnPosition.TextID = R.MyInternationalizationString.uFixedPosition;
- gatewayRow.AddRightView(btnPosition);
btnPosition.ButtonClickEvent += (sender, e) =>
{
//鍙戦�佸畾浣嶅懡浠�
@@ -213,15 +221,28 @@
}
this.ShowMassage(ShowMsgType.Confirm, msg, () =>
{
- this.DeleteGateway(strWayId, gatewayRow);
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ this.DeleteGateway(strWayId);
+ });
});
};
this.dicRowContr[strWayId] = gatewayRow;
//璁剧疆涓�涓�夋嫨缃戝叧鐨勯粯璁ゅ��
- if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && gatewayRow.IsOnline == true)
+ if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true)
{
- this.SaveGatewayIdToLocation(strWayId);
+ HdlGatewayLogic.Current.SaveGatewayIdToLocation(strWayId);
+ }
+
+ //褰撳墠缃戝叧鐨勮鏍�
+ if (strWayId == GatewayResourse.AppOldSelectGatewayId)
+ {
+ var btnNow = new IconViewControl(52);
+ btnNow.Y = Application.GetMinReal(23) + gatewayRow.frameTable.chidrenYaxis;
+ btnNow.UnSelectedImagePath = "Item/NowAcctionTip.png";
+ btnNow.X = gatewayRow.btnName.X + gatewayRow.btnName.GetRealWidthByText();
+ gatewayRow.frameTable.AddChidren(btnNow, ChidrenBindMode.BindEvent);
}
}
@@ -234,10 +255,14 @@
/// </summary>
/// <param name="strWayId"></param>
/// <param name="row"></param>
- private async void DeleteGateway(string strWayId, GatewayRowControl row)
+ private void DeleteGateway(string strWayId)
{
+ //鎵撳紑杩涘害鏉�
+ this.ShowProgressBar();
//鍒犻櫎浜戠缃戝叧
- bool result = await HdlGatewayLogic.Current.DeleteGateway(strWayId);
+ bool result = HdlGatewayLogic.Current.DeleteGateway(strWayId);
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar();
if (result == false)
{
return;
@@ -247,15 +272,13 @@
{
//濡傛灉瑙i櫎缁戝畾鐨勭綉鍏虫槸褰撳墠鎵�閫夋嫨鐨勭綉鍏崇殑璇濓紝鍒欏叧闂澶囩鐞嗙晫闈�
this.closeDeviceManagForm = true;
- this.SaveGatewayIdToLocation(string.Empty);
+ HdlGatewayLogic.Current.SaveGatewayIdToLocation(string.Empty);
}
-
- //绉婚櫎
- if (this.dicRowContr.ContainsKey(strWayId) == true)
+ HdlThreadLogic.Current.RunMain(() =>
{
- this.dicRowContr.Remove(strWayId);
- }
- row?.RemoveFromParent();
+ //鍒濆鍖栦腑閮ㄦ帶浠�
+ this.InitMiddleFrame();
+ });
}
#endregion
@@ -267,108 +290,32 @@
/// </summary>
/// <param name="gatewayId"></param>
/// <param name="online"></param>
- private async void DoSwitchGateway(string gatewayId,bool online)
+ private void DoSwitchGateway(string gatewayId)
{
- if (online == true)
+ var result = HdlGatewayLogic.Current.DoSwitchGateway(gatewayId);
+ if (result == false)
{
- //閲嶆柊鑾峰彇鍦ㄧ嚎缃戝叧鐨勪俊鎭�
- var result = await this.GetOnlineGatewayInfo(gatewayId);
- if (result == false)
- {
- return;
- }
+ return;
}
- //鍒囨崲缃戝叧,淇濆瓨缂撳瓨
- this.SaveGatewayIdToLocation(gatewayId);
//濡傛灉閫夋嫨浜嗗埛鏂扮殑缃戝叧锛屽垯涓嶅叧闂鐞嗙晫闈�
this.closeDeviceManagForm = false;
- if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false)
+ HdlThreadLogic.Current.RunMain(() =>
{
- //鍒锋柊涓荤敾闈�
- var form = new Device.DeviceListMainForm();
- this.AddFromAndRemoveNowForm(form);
- }
- else
- {
- //鍏抽棴鐣岄潰
- this.CloseForm();
- //鍒锋柊涓荤敾闈�(涓嶉噸鏂拌幏鍙栬澶囩姸鎬�)
- this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false);
- }
- }
-
- /// <summary>
- /// 鑾峰彇鍦ㄧ嚎缃戝叧淇℃伅
- /// </summary>
- /// <param name="gatewayId"></param>
- /// <returns></returns>
- private async Task<bool> GetOnlineGatewayInfo(string gatewayId)
- {
- //鏄剧ず杩涘害鏉�
- this.ShowProgressBar();
- //鑾峰彇缃戝叧
- var gateway = HdlGatewayLogic.Current.GetLocalGateway(gatewayId);
-
- //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D
- ZbGateway realWay = null;
- bool getGatewayInfo = true;
- if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gatewayId) == true)
- {
- //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆)
- if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
+ if (UserCenterResourse.DicActionForm.ContainsKey("DeviceListMainForm") == false)
{
- int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay);
- if (result2 == 0)
- {
- //鍑虹幇鏈煡閿欒,璇风◢鍚庡啀璇�
- this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain));
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
- }
- else if (result2 == -1)
- {
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
- return false;
- }
- //閲嶆柊缁戝畾缃戝叧閲岄潰宸茬粡閲嶆柊鑾峰彇浜嗙綉鍏充俊鎭�
- getGatewayInfo = false;
+ //鍒锋柊涓荤敾闈�
+ var form = new Device.DeviceListMainForm();
+ this.AddFromAndRemoveNowForm(form);
}
- }
-
- if (getGatewayInfo == true)
- {
- //鑾峰彇缃戝叧淇℃伅
- var info = await HdlGatewayLogic.Current.GetGatewayNewInfoAsync(gateway);
- if (info == null)
+ else
{
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
- return false;
+ //鍏抽棴鐣岄潰
+ this.CloseForm();
+ //鍒锋柊涓荤敾闈�(涓嶉噸鏂拌幏鍙栬澶囩姸鎬�)
+ this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame");
}
- }
-
- //鑾峰彇鍏ㄩ儴璁惧
- bool result = await Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(gateway);
- //鍏抽棴杩涘害鏉�
- this.CloseProgressBar();
- if (result == false)
- {
- return false;
- }
- return true;
- }
-
- /// <summary>
- /// 淇濆瓨閫夋嫨鐨勭綉鍏矷D鍒版湰鍦�
- /// </summary>
- /// <param name="gatewayId"></param>
- private void SaveGatewayIdToLocation(string gatewayId)
- {
- GatewayResourse.AppOldSelectGatewayId = gatewayId;
- byte[] data = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(GatewayResourse.AppOldSelectGatewayId));
- Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile, data);
+ });
}
#endregion
@@ -409,7 +356,7 @@
return;
}
bool online = HdlGatewayLogic.Current.CheckGatewayOnlineByFlag(way);
- this.GatewayOnlinePush(way, online);
+ this.GatewayOnlinePush(way, online, true);
}
//缃戝叧鏂扮増鏈娴�
this.CheckGatewayNewVersion(listway);
@@ -421,20 +368,21 @@
/// </summary>
/// <param name="gateWay">缃戝叧瀵硅薄</param>
/// <param name="online">鍦ㄧ嚎鐘舵�佸彉鏇村悗鐨勭姸鎬�</param>
- public override void GatewayOnlinePush(ZbGateway gateWay, bool online)
+ /// <param name="hadGwOnline">2020.05.25杩藉姞:姝や綇瀹呮槸鍚︽嫢鏈夌綉鍏冲湪绾�</param>
+ public override void GatewayOnlinePush(ZbGateway gateWay, bool online, bool hadGwOnline)
{
- Application.RunOnMainThread(() =>
+ HdlThreadLogic.Current.RunMain(() =>
{
if (this.Parent == null)
{
return;
}
- string gwid = HdlGatewayLogic.Current.GetGatewayId(gateWay);
+ string gwid = gateWay.GwId;
if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null)
{
- this.dicRowContr[gwid].RefreshControl(gateWay);
+ this.dicRowContr[gwid].IsOnline = online;
}
- });
+ }, ShowErrorMode.NO);
}
#endregion
@@ -445,7 +393,7 @@
/// 缃戝叧鏂扮増鏈娴�
/// </summary>
/// <param name="listWays"></param>
- private async void CheckGatewayNewVersion(List<ZbGateway> listWays)
+ private void CheckGatewayNewVersion(List<ZbGateway> listWays)
{
foreach (var way in listWays)
{
@@ -459,7 +407,7 @@
continue;
}
//鑾峰彇鏈�鏂扮増鏈�
- var result = await HdlGatewayLogic.Current.GetGatewayAllNewVersion(way, ShowErrorMode.NO);
+ var result = HdlGatewayLogic.Current.GetGatewayAllNewVersion(way, ShowErrorMode.NO);
if (result == null)
{
continue;
@@ -467,12 +415,12 @@
if (result[0] != null || result[1] != null || result[2] != null)
{
//鏈夋柊鐗堟湰
- string gwid = HdlGatewayLogic.Current.GetGatewayId(way);
- Application.RunOnMainThread(() =>
+ string gwid = way.GwId;
+ HdlThreadLogic.Current.RunMain(() =>
{
if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null)
{
- var btnNew = (RowNewVersionTipView)this.dicRowContr[gwid].GetTagByKey("btnNew");
+ var btnNew = (InformationTipView)this.dicRowContr[gwid].GetTagByKey("btnNew");
if (btnNew != null)
{
btnNew.Visible = true;
@@ -490,11 +438,11 @@
/// <summary>
/// 鐢婚潰鍏抽棴
/// </summary>
- public override void CloseForm()
+ public override void CloseFormBefore()
{
- base.CloseForm();
+ base.CloseFormBefore();
- if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && this.closeDeviceManagForm == true)
+ if (this.closeDeviceManagForm == true)
{
//鍏抽棴鐣岄潰
HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
@@ -511,6 +459,12 @@
/// </summary>
public override int FormActionAgainEvent()
{
+ //杩涘埌杩欎釜鐣岄潰,鐞嗚涓婂墠鍥炵殑缃戝叧id鏄湁鐨�,濡傛灉涓虹┖浜�,搴旇鏄綋鍓嶇殑缃戝叧琚В缁戜簡
+ if (GatewayResourse.AppOldSelectGatewayId == string.Empty)
+ {
+ //鍏抽棴璁惧鍒楄〃
+ this.closeDeviceManagForm = true;
+ }
//鍒濆鍖栦腑閮ㄦ帶浠�
this.InitMiddleFrame();
return 1;
--
Gitblit v1.8.0