From 34b65350abbb8b740b9c3bc0b43254cbbe23fcb5 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 19 五月 2020 09:31:44 +0800
Subject: [PATCH] 合并代码,更改面板目标信息
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetyMasterControl.cs | 433 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 433 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetyMasterControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetyMasterControl.cs
new file mode 100755
index 0000000..736f59c
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SafetyMasterControl.cs
@@ -0,0 +1,433 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shared.Phone.UserCenter
+{
+ /// <summary>
+ /// 瀹夐槻绠$悊涓婚〉鐨勬帶浠�
+ /// </summary>
+ public class SafetyMasterControl : FrameLayout
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 鍦ㄥ甯冮槻
+ /// </summary>
+ private GarrisonControl btnAthomeGarrison = null;
+ /// <summary>
+ /// 绂诲甯冮槻
+ /// </summary>
+ private GarrisonControl btnRemovehomeGarrison = null;
+ /// <summary>
+ /// 鎾ら槻
+ /// </summary>
+ private GarrisonControl btnReGarrisonGarrison = null;
+ /// <summary>
+ /// 妗屽竷鎺т欢
+ /// </summary>
+ private FrameLayout frameTable = null;
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鍒濆鍖�
+ /// </summary>
+ public SafetyMasterControl()
+ {
+ this.Gravity = Gravity.CenterHorizontal;
+ this.Width = Application.GetRealWidth(964);
+ this.Height = Application.GetRealHeight(340);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栨帶浠�
+ /// </summary>
+ public void InitControl()
+ {
+ this.btnAthomeGarrison = null;
+ this.btnReGarrisonGarrison = null;
+ this.btnRemovehomeGarrison = null;
+
+ this.frameTable = new FrameLayout();
+ frameTable.Height = this.Height;
+ frameTable.Width = this.Width;
+ frameTable.Radius = (uint)Application.GetRealHeight(58);
+ frameTable.BackgroundColor = UserCenterColor.Current.White;
+ this.AddChidren(frameTable);
+
+ //鍙充笂鍦嗚鑳屾櫙
+ var btnTopRight = new NormalViewControl(150, 60, true);
+ btnTopRight.BackgroundColor = UserCenterColor.Current.White;
+ btnTopRight.RadiusEx = 17;
+ this.AddChidren(btnTopRight);
+ btnTopRight.X = this.Width - btnTopRight.Width;
+
+ //宸︿笅鍦嗚鑳屾櫙
+ var btnBottomRight = new NormalViewControl(150, 60, true);
+ btnBottomRight.BackgroundColor = UserCenterColor.Current.White;
+ btnBottomRight.RadiusEx = 17;
+ this.AddChidren(btnBottomRight);
+ btnBottomRight.Y = this.Height - btnBottomRight.Height;
+
+ //璁剧疆鏈夊唴閮ㄩ槻鍖�
+ if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == true)
+ {
+ //鍦ㄥ甯冮槻
+ btnAthomeGarrison = new GarrisonControl();
+ frameTable.AddChidren(btnAthomeGarrison);
+ btnAthomeGarrison.InitControl(GarrisonMode.AtHome);
+ btnAthomeGarrison.ButtonClickEvent += (sender, e) =>
+ {
+ if (btnAthomeGarrison.btnIcon.IsSelected == false)
+ {
+ this.SetSafetyGarrisonModeInAtHome();
+ }
+ };
+ //绂诲甯冮槻
+ btnRemovehomeGarrison = new GarrisonControl();
+ btnRemovehomeGarrison.X = btnAthomeGarrison.Right + Application.GetRealWidth(32);
+ frameTable.AddChidren(btnRemovehomeGarrison);
+ btnRemovehomeGarrison.InitControl(GarrisonMode.RemoveHome);
+ btnRemovehomeGarrison.ButtonClickEvent += (sender, e) =>
+ {
+ if (btnRemovehomeGarrison.btnIcon.IsSelected == false)
+ {
+ this.SetSafetyGarrisonModeInRemoveHome();
+ }
+ };
+ //鎾ら槻
+ btnReGarrisonGarrison = new GarrisonControl();
+ btnReGarrisonGarrison.X = btnRemovehomeGarrison.Right + Application.GetRealWidth(32);
+ frameTable.AddChidren(btnReGarrisonGarrison);
+ btnReGarrisonGarrison.InitControl(GarrisonMode.RemoveGarrison);
+ btnReGarrisonGarrison.ButtonClickEvent += (sender, e) =>
+ {
+ this.RemoveSafetyGarrisonMode();
+ };
+ }
+ else
+ {
+ //甯冮槻
+ btnAthomeGarrison = new GarrisonControl();
+ btnAthomeGarrison.X = Application.GetRealWidth(166);
+ frameTable.AddChidren(btnAthomeGarrison);
+ btnAthomeGarrison.InitControl(GarrisonMode.AtHome);
+ btnAthomeGarrison.ButtonClickEvent += (sender, e) =>
+ {
+ if (btnAthomeGarrison.btnIcon.IsSelected == false)
+ {
+ this.SetSafetyGarrisonModeInAtHome();
+ }
+ };
+ //鎾ら槻
+ btnReGarrisonGarrison = new GarrisonControl();
+ btnReGarrisonGarrison.X = btnAthomeGarrison.Right + Application.GetRealWidth(32);
+ frameTable.AddChidren(btnReGarrisonGarrison);
+ btnReGarrisonGarrison.InitControl(GarrisonMode.RemoveGarrison);
+ btnReGarrisonGarrison.ButtonClickEvent += (sender, e) =>
+ {
+ this.RemoveSafetyGarrisonMode();
+ };
+ }
+ //鏍规嵁甯冮槻妯″紡锛岃缃浘鏍囩殑閫夋嫨鐘舵��
+ this.SetIconStatuByGarrisonMode(HdlSafeguardLogic.Current.NowGarrisonMode);
+ }
+
+ #endregion
+
+ #region 鈻� 甯冮槻鎾ら槻___________________________
+
+ /// <summary>
+ /// 鍦ㄥ甯冮槻
+ /// </summary>
+ private async void SetSafetyGarrisonModeInAtHome()
+ {
+ //鎵撳紑杩涘害鏉�
+ ProgressBar.Show(string.Empty);
+ //鍦ㄥ甯冮槻
+ GarrisonMode mode = await HdlSafeguardLogic.Current.SetSafetyGarrisonByModel(GarrisonMode.AtHome);
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ if (mode == GarrisonMode.None)
+ {
+ return;
+ }
+
+ Application.RunOnMainThread(() =>
+ {
+ //鏍规嵁甯冮槻妯″紡锛岃缃浘鏍囩殑閫夋嫨鐘舵��
+ this.SetIconStatuByGarrisonMode(mode);
+ if (mode == GarrisonMode.RemoveGarrison)
+ {
+ return;
+ }
+
+ //濡傛灉璁剧疆鏈夊唴閮ㄩ槻鍖�
+ string msg = string.Empty;
+ if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == true)
+ {
+ //鍦ㄥ甯冮槻璁剧疆鎴愬姛
+ msg = Language.StringByID(R.MyInternationalizationString.uSetAtHomeGarrisonSuccess);
+ }
+ else
+ {
+ //甯冮槻璁剧疆鎴愬姛
+ msg = Language.StringByID(R.MyInternationalizationString.uSetGarrisonSuccess);
+ }
+ var control = new ShowMsgControl(ShowMsgType.Tip, msg);
+ control.Show();
+ });
+ }
+
+ /// <summary>
+ /// 绂诲甯冮槻
+ /// </summary>
+ private async void SetSafetyGarrisonModeInRemoveHome()
+ {
+ //鎵撳紑杩涘害鏉�
+ ProgressBar.Show(string.Empty);
+ //绂诲甯冮槻
+ GarrisonMode mode = await HdlSafeguardLogic.Current.SetSafetyGarrisonByModel(GarrisonMode.RemoveHome);
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+
+ if (mode == GarrisonMode.None)
+ {
+ return;
+ }
+
+ Application.RunOnMainThread(() =>
+ {
+ //鏍规嵁甯冮槻妯″紡锛岃缃浘鏍囩殑閫夋嫨鐘舵��
+ this.SetIconStatuByGarrisonMode(mode);
+ if (mode == GarrisonMode.RemoveGarrison)
+ {
+ return;
+ }
+ //绂诲甯冮槻璁剧疆鎴愬姛
+ string msg = Language.StringByID(R.MyInternationalizationString.uSetRemoveHomeGarrisonSuccess);
+ var control = new ShowMsgControl(ShowMsgType.Tip, msg);
+ control.Show();
+ });
+ }
+
+ /// <summary>
+ /// 鎾ら槻
+ /// </summary>
+ private async void RemoveSafetyGarrisonMode()
+ {
+ //鎵撳紑杩涘害鏉�
+ ProgressBar.Show(string.Empty);
+ //鎾ら槻
+ var result = await HdlSafeguardLogic.Current.RemoveSafetyGarrison(GarrisonMode.RemoveGarrison, false);
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+
+ if (result == -1)
+ {
+ return;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ //鏍规嵁甯冮槻妯″紡锛岃缃浘鏍囩殑閫夋嫨鐘舵��
+ this.SetIconStatuByGarrisonMode(GarrisonMode.RemoveGarrison);
+
+ //绂诲甯冮槻璁剧疆鎴愬姛
+ string msg = Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonSuccess);
+ var control = new ShowMsgControl(ShowMsgType.Tip, msg);
+ control.Show();
+ });
+ }
+
+ /// <summary>
+ /// 鏍规嵁甯冮槻妯″紡锛岃缃浘鏍囩殑閫夋嫨鐘舵��
+ /// </summary>
+ /// <param name="mode"></param>
+ public void SetIconStatuByGarrisonMode(GarrisonMode mode)
+ {
+ //鍦ㄥ甯冮槻
+ if (mode == GarrisonMode.AtHome)
+ {
+ this.btnAthomeGarrison?.SetActionStatu(true);
+ this.btnRemovehomeGarrison?.SetActionStatu(false);
+ this.btnReGarrisonGarrison?.SetActionStatu(false);
+ }
+ //绂诲甯冮槻
+ else if (mode == GarrisonMode.RemoveHome)
+ {
+ this.btnAthomeGarrison?.SetActionStatu(false);
+ this.btnRemovehomeGarrison?.SetActionStatu(true);
+ this.btnReGarrisonGarrison?.SetActionStatu(false);
+ }
+ //鎾ら槻
+ else
+ {
+ this.btnAthomeGarrison?.SetActionStatu(false);
+ this.btnRemovehomeGarrison?.SetActionStatu(false);
+ this.btnReGarrisonGarrison?.SetActionStatu(true);
+ }
+ }
+
+ #endregion
+
+ #region 鈻� 涓�鑸柟娉昣__________________________
+
+ /// <summary>
+ /// 璁剧疆甯冮槻鎸夐挳鐨勫彲瑙嗙姸鎬�
+ /// </summary>
+ public void SetButtonVisible()
+ {
+ //璁剧疆鏈夊唴閮ㄩ槻鍖�
+ if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == true
+ && btnRemovehomeGarrison != null)
+ {
+ //娌″繀瑕佸啀鍒濆鍖栫晫闈�
+ return;
+ }
+ Application.RunOnMainThread(() =>
+ {
+ //娓呯┖鍏ㄩ儴鎺т欢
+ this.RemoveAll();
+ //閲嶆柊鍒濆鍖栨帶浠�
+ this.InitControl();
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 灏佽鎺т欢___________________________
+
+ /// <summary>
+ /// 灏佽鐨勫竷闃叉帶浠�
+ /// </summary>
+ private class GarrisonControl : FrameLayoutStatuControl
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 鑳屾櫙鎺т欢
+ /// </summary>
+ private NormalViewControl btnBack = null;
+ /// <summary>
+ /// 鍥炬爣鎺т欢
+ /// </summary>
+ public IconViewControl btnIcon = null;
+ /// <summary>
+ /// 鏂囨湰鎺т欢
+ /// </summary>
+ private NormalViewControl btnText = null;
+ /// <summary>
+ /// 閫夋嫨鐘舵�佺殑鑳屾櫙鑹�
+ /// </summary>
+ private uint selectBackColor = 0;
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 灏佽鐨勫竷闃叉帶浠�
+ /// </summary>
+ public GarrisonControl()
+ {
+ //鍏抽棴鐘舵�佹樉绀�
+ this.UseClickStatu = false;
+ this.Gravity = Gravity.CenterVertical;
+ this.Width = Application.GetRealWidth(300);
+ this.Height = Application.GetRealHeight(216);
+ }
+
+ /// <summary>
+ /// 鍒濆鍖栨帶浠�
+ /// </summary>
+ /// <param name="garrison">闃插尯妯″紡</param>
+ public void InitControl(GarrisonMode garrison)
+ {
+ //绉婚櫎搴曞眰浜嬩欢
+ this.RemoveBaseClickEvent();
+
+ //鑳屾櫙
+ int backHeight = this.GetPictrueRealSize(132);
+ btnBack = new NormalViewControl(backHeight, backHeight, false);
+ btnBack.Gravity = Gravity.CenterHorizontal;
+ btnBack.Radius = (uint)backHeight / 2;
+ btnBack.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
+ this.AddChidren(btnBack, ChidrenBindMode.BindEventOnly);
+
+ //鍥炬爣
+ btnIcon = new IconViewControl(81);
+ btnIcon.Y = Application.GetRealHeight(26);
+ btnIcon.Gravity = Gravity.CenterHorizontal;
+ this.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly);
+
+ //鏂囨湰
+ btnText = new NormalViewControl(this.Width, Application.GetRealHeight(58), false);
+ btnText.TextColor = UserCenterColor.Current.TextGrayColor3;
+ btnText.Y = Application.GetRealHeight(158);
+ btnText.TextAlignment = TextAlignment.Center;
+ this.AddChidren(btnText, ChidrenBindMode.NotBind);
+
+ if (garrison == GarrisonMode.AtHome)
+ {
+ this.selectBackColor = 0xffffa200;
+ btnIcon.UnSelectedImagePath = "Safeguard/ProtectionAtHome.png";
+ btnIcon.SelectedImagePath = "Safeguard/ProtectionAtHomeSelected.png";
+
+ //璁剧疆鏈夊唴閮ㄩ槻鍖�
+ if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == true)
+ {
+ btnText.TextID = R.MyInternationalizationString.uAtHomeGarrison;
+ }
+ else
+ {
+ btnText.TextID = R.MyInternationalizationString.uGarrison;
+ }
+ }
+ else if (garrison == GarrisonMode.RemoveHome)
+ {
+ this.selectBackColor = 0xff35b87f;
+ btnIcon.UnSelectedImagePath = "Safeguard/ProtectionRemoveHome.png";
+ btnIcon.SelectedImagePath = "Safeguard/ProtectionRemoveHomeSelected.png";
+ btnText.TextID = R.MyInternationalizationString.uRemoveHomeGarrison;
+ }
+ else if (garrison == GarrisonMode.RemoveGarrison)
+ {
+ this.selectBackColor = 0xff4a90e2;
+ btnIcon.UnSelectedImagePath = "Safeguard/WithdrawGarrison.png";
+ btnIcon.SelectedImagePath = "Safeguard/WithdrawGarrisonSelected.png";
+ btnText.TextID = R.MyInternationalizationString.uWithdrawGarrison;
+ }
+ }
+ #endregion
+
+ #region 鈻� 涓�鑸柟娉昣__________________________
+
+ /// <summary>
+ /// 璁剧疆鎺т欢鐨勬縺娲荤姸鎬�
+ /// </summary>
+ /// <param name="actionStatu">璁剧疆鎺т欢鐨勬縺娲荤姸鎬� true:婵�娲荤姸鎬�(閫変腑) false:闈炴縺娲荤姸鎬�</param>
+ public void SetActionStatu(bool actionStatu)
+ {
+ if (actionStatu == true)
+ {
+ btnIcon.IsSelected = true;
+ btnBack.BackgroundColor = selectBackColor;
+ btnText.TextColor = selectBackColor;
+ }
+ else
+ {
+ btnIcon.IsSelected = false;
+ btnBack.BackgroundColor = UserCenterColor.Current.BodyFrameLayout;
+ btnText.TextColor = UserCenterColor.Current.TextGrayColor3;
+ }
+ }
+
+ #endregion
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0