New file |
| | |
| | | using Shared.Common;
|
| | | using Shared.Phone.Device.CommonForm;
|
| | | using Shared.Phone.UserCenter;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.MainPage.Controls
|
| | | {
|
| | | /// <summary>
|
| | | /// 安防快捷方式控件
|
| | | /// </summary>
|
| | | public class SafetyShortcutControl : Button
|
| | | {
|
| | | /// <summary>
|
| | | /// dialog
|
| | | /// </summary>
|
| | | private Dialog dialog;
|
| | | /// <summary>
|
| | | /// SafetyShortcut
|
| | | /// </summary>
|
| | | public SafetyShortcutControl()
|
| | | {
|
| | | this.Height = Application.GetMinRealAverage(69);
|
| | | this.Width = Application.GetMinRealAverage(69);
|
| | | this.UnSelectedImagePath = "Item/SafetyShortcut.png";
|
| | | this.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | Show();
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Show
|
| | | /// </summary>
|
| | | private void Show()
|
| | | {
|
| | | Common.CommonPage.Instance.IsDrawerLockMode = true;
|
| | |
|
| | | dialog = new Dialog();
|
| | | dialog.BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor;
|
| | | dialog.Show();
|
| | | var closeBGview = new FrameLayout();
|
| | | dialog.AddChidren(closeBGview);
|
| | | closeBGview.MouseUpEventHandler += (send1, e1) =>
|
| | | {
|
| | | dialog.Close();
|
| | | };
|
| | |
|
| | | var bg = new Button
|
| | | {
|
| | | X = Application.GetRealWidth(495),
|
| | | Y = Application.GetRealHeight(161),
|
| | | Width = Application.GetRealWidth(449),
|
| | | Height = Application.GetRealHeight(495),
|
| | | UnSelectedImagePath = "Item/SafetyShortcut_background.png"
|
| | | };
|
| | | closeBGview.AddChidren(bg);
|
| | |
|
| | | var bg1 = new FrameLayout
|
| | | {
|
| | | X = Application.GetRealWidth(495),
|
| | | Y = Application.GetRealHeight(161),
|
| | | Width = Application.GetRealWidth(449),
|
| | | Height = Application.GetRealHeight(495),
|
| | | };
|
| | | closeBGview.AddChidren(bg1);
|
| | |
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | //刷新
|
| | | var result = await HdlSafeguardLogic.Current.ReFreshByGateway();
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //是否设置有内部防区
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | RefreshSafeZone(bg1, HdlSafeguardLogic.Current.IsHadInternalDefenseArea());
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 显示防区
|
| | | /// </summary>
|
| | | /// <param name="statu">true 3个防区 false 2个防区</param>
|
| | | private void RefreshSafeZone(FrameLayout layout, bool statu)
|
| | | {
|
| | | if (statu)
|
| | | {
|
| | | ShowThreeSafeType(layout);
|
| | | }
|
| | | else
|
| | | {
|
| | | ShowTwoSafeType(layout);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 布防撤防
|
| | | /// </summary>
|
| | | /// <param name="layout"></param>
|
| | | private void ShowTwoSafeType(FrameLayout layout)
|
| | | {
|
| | | Device.CommonForm.LeftIconButtonRow tempRow;
|
| | | var atHome = new Device.CommonForm.LeftIconButtonRow(449, 150);
|
| | | atHome.Y = Application.GetRealHeight(32);
|
| | | atHome.Init("Item/SafetyShortcut_item.png", "Item/SafetyShortcut_itemSelected.png", Language.StringByID(R.MyInternationalizationString.uGarrison));
|
| | | layout.AddChidren(atHome);
|
| | | atHome.Tag = GarrisonMode.AtHome;
|
| | | if (HdlSafeguardLogic.Current.NowGarrisonMode == GarrisonMode.AtHome)
|
| | | {
|
| | | atHome.IsSelected = true;
|
| | | tempRow = atHome;
|
| | | }
|
| | | atHome.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | dialog.Close();
|
| | | if (sender.IsSelected)
|
| | | {
|
| | | return;
|
| | | }
|
| | | CommonPage.Loading.Start();
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | var result = await HdlSafeguardLogic.Current.SetSafetyGarrisonByModel(GarrisonMode.AtHome);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | if (result == GarrisonMode.AtHome)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uSetGarrisonSuccess));
|
| | | }
|
| | | else
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uSetGarrisonFail));
|
| | | }
|
| | | });
|
| | |
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | };
|
| | |
|
| | |
|
| | | var withdrawGarriso = new Device.CommonForm.LeftIconButtonRow(449, 150);
|
| | | withdrawGarriso.Y = atHome.Bottom + Application.GetRealHeight(3);
|
| | | withdrawGarriso.Init("Item/SafetyShortcut_item.png", "Item/SafetyShortcut_itemSelected.png", Language.StringByID(R.MyInternationalizationString.uWithdrawGarrison));
|
| | | layout.AddChidren(withdrawGarriso);
|
| | | withdrawGarriso.Tag = GarrisonMode.RemoveGarrison;
|
| | | if (HdlSafeguardLogic.Current.NowGarrisonMode == GarrisonMode.None)
|
| | | {
|
| | | withdrawGarriso.IsSelected = true;
|
| | | tempRow = withdrawGarriso;
|
| | | }
|
| | | withdrawGarriso.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | dialog.Close();
|
| | | if (sender.IsSelected)
|
| | | {
|
| | | return;
|
| | | }
|
| | | CommonPage.Loading.Start();
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | var result = await HdlSafeguardLogic.Current.RemoveSafetyGarrison(GarrisonMode.RemoveGarrison, true);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | if (result == 1)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonSuccess));
|
| | | }
|
| | | else
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonFail));
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 在家 离家 撤防
|
| | | /// </summary>
|
| | | /// <param name="layout"></param>
|
| | | private void ShowThreeSafeType(FrameLayout layout)
|
| | | {
|
| | | var atHome = new Device.CommonForm.LeftIconButtonRow(449, 150);
|
| | | atHome.Y = Application.GetRealHeight(32);
|
| | | atHome.Init("Item/SafetyShortcut_item.png", "Item/SafetyShortcut_itemSelected.png", Language.StringByID(R.MyInternationalizationString.uAtHomeGarrison));
|
| | | layout.AddChidren(atHome);
|
| | | if (HdlSafeguardLogic.Current.NowGarrisonMode == GarrisonMode.AtHome)
|
| | | {
|
| | | atHome.IsSelected = true;
|
| | | }
|
| | | atHome.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | dialog.Close();
|
| | | if (sender.IsSelected)
|
| | | {
|
| | | return;
|
| | | }
|
| | | CommonPage.Loading.Start();
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | var result = await HdlSafeguardLogic.Current.SetSafetyGarrisonByModel(GarrisonMode.AtHome);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | if (result == GarrisonMode.AtHome)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uSetAtHomeGarrisonSuccess));
|
| | | }
|
| | | else
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uSetGarrisonFail));
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | };
|
| | |
|
| | |
|
| | | var removeHome = new Device.CommonForm.LeftIconButtonRow(449, 150);
|
| | | removeHome.Y = atHome.Bottom + Application.GetRealHeight(3);
|
| | | removeHome.Init("Item/SafetyShortcut_item.png", "Item/SafetyShortcut_itemSelected.png", Language.StringByID(R.MyInternationalizationString.uRemoveHomeGarrison));
|
| | | layout.AddChidren(removeHome);
|
| | | if (HdlSafeguardLogic.Current.NowGarrisonMode == GarrisonMode.RemoveHome)
|
| | | {
|
| | | removeHome.IsSelected = true;
|
| | | }
|
| | | removeHome.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | dialog.Close();
|
| | | if (sender.IsSelected)
|
| | | {
|
| | | return;
|
| | | }
|
| | | CommonPage.Loading.Start();
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | var result = await HdlSafeguardLogic.Current.SetSafetyGarrisonByModel(GarrisonMode.RemoveHome);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | if (result == GarrisonMode.RemoveHome)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uSetRemoveHomeGarrisonSuccess));
|
| | | }
|
| | | else
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uSetGarrisonFail));
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | };
|
| | |
|
| | | var withdrawGarriso = new Device.CommonForm.LeftIconButtonRow(449, 150);
|
| | | withdrawGarriso.Y = removeHome.Bottom + Application.GetRealHeight(3);
|
| | | withdrawGarriso.Init("Item/SafetyShortcut_item.png", "Item/SafetyShortcut_itemSelected.png", Language.StringByID(R.MyInternationalizationString.uWithdrawGarrison));
|
| | | layout.AddChidren(withdrawGarriso);
|
| | | withdrawGarriso.HidenLine(true);
|
| | | if (HdlSafeguardLogic.Current.NowGarrisonMode == GarrisonMode.None)
|
| | | {
|
| | | withdrawGarriso.IsSelected = true;
|
| | | }
|
| | | withdrawGarriso.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | dialog.Close();
|
| | | if (sender.IsSelected)
|
| | | {
|
| | | return;
|
| | | }
|
| | | CommonPage.Loading.Start();
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | var result = await HdlSafeguardLogic.Current.RemoveSafetyGarrison(GarrisonMode.RemoveGarrison, true);
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | CommonPage.Loading.Hide();
|
| | | if (result == 1)
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonSuccess));
|
| | | }
|
| | | else
|
| | | {
|
| | | CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonFail));
|
| | | }
|
| | | });
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// RemoveFromParent
|
| | | /// </summary>
|
| | | public override void RemoveFromParent()
|
| | | {
|
| | | Common.CommonPage.Instance.IsDrawerLockMode = false;
|
| | | base.RemoveFromParent();
|
| | | }
|
| | | }
|
| | | }
|