using System;
using Shared;
using Shared.R;
using Shared.Common;
using System.Collections.Generic;
namespace Shared.Phone.Device.Logic
{
public class SecurityMode : FrameLayout
{
public SecurityMode()
{
Tag = "Logic";
}
///
/// 标记是否编辑
///
public bool IsDeviceEditor;
Dictionary actionsInfo = new Dictionary();
public void Show()
{
#region 最上面的布局代码
var topRowLayout = new RowLayout
{
BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor,
Height = Application.GetRealHeight(184),
LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor,
};
this.AddChidren(topRowLayout);
var titleName = new Button
{
TextSize = 16,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth(176),
Width = Application.GetRealWidth(600),
Height = Application.GetRealHeight(69),
Y = Application.GetRealHeight(92),
TextID = MyInternationalizationString.securitymode,
};
topRowLayout.AddChidren(titleName);
var clickBtn = new Button
{
Width = Application.GetRealWidth(81 + 51),
Height = Application.GetRealHeight(58 + 40),
Y = Application.GetRealHeight(98 - 40),
};
topRowLayout.AddChidren(clickBtn);
clickBtn.MouseDownEventHandler += (sender, e) =>
{
RemoveFromParent();
};
var back = new Button
{
Width = Application.GetRealWidth(30),
Height = Application.GetRealHeight(51),
X = Application.GetRealWidth(81),
Y = Application.GetRealHeight(98),
//Gravity = Gravity.CenterVertical;
UnSelectedImagePath = "ZigeeLogic/back.png",
};
topRowLayout.AddChidren(back);
back.MouseDownEventHandler += (sender, e) => {
RemoveFromParent();
};
#endregion
var middle = new FrameLayout();
middle.Y = topRowLayout.Bottom;
middle.Height = Application.GetRealHeight(1920 - 184);
middle.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
this.AddChidren(middle);
var btnsave = new Button
{
Y= middle.Height-Application.GetRealHeight(260),
X = Application.GetRealWidth(85),
Height = Application.GetRealHeight(130),
Width = Application.GetRealWidth(910),
Radius = (uint)Application.GetRealHeight(60),
BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
TextID = MyInternationalizationString.Save,
TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
};
middle.AddChidren(btnsave);
#region ----(在家/离家)布防 撤防 胁迫撤防----
#region 在家布防
var athomeFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(160),
BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
};
middle.AddChidren(athomeFrameLayout);
var athomeiconBtn = new Button
{
Width = Application.GetRealWidth(81),
Height = Application.GetRealHeight(81),
X = Application.GetRealWidth(58),
Y = Application.GetRealHeight(55),
UnSelectedImagePath = "ZigeeLogic/athome.png",
};
athomeFrameLayout.AddChidren(athomeiconBtn);
var athomedefenceRowLayout = new RowLayout
{
Y = Application.GetRealHeight(30),
Width = Application.GetRealWidth(850),
Height = Application.GetRealHeight(130),
X = Application.GetRealWidth(176),
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
};
athomeFrameLayout.AddChidren(athomedefenceRowLayout);
var btnathomedefence = new Button
{
Text = Language.StringByID(MyInternationalizationString.logicathomegarrison),
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
athomedefenceRowLayout.AddChidren(btnathomedefence);
var athomedefenceSelected = new SelectedButton(789);
athomedefenceRowLayout.AddChidren(athomedefenceSelected);
#endregion
#region 离家布防
var leavehomeFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(160),
Y = athomeFrameLayout.Bottom,
BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
};
middle.AddChidren(leavehomeFrameLayout);
var leavehomeiconBtn = new Button
{
Width = Application.GetRealWidth(81),
Height = Application.GetRealHeight(81),
X = Application.GetRealWidth(58),
Y = Application.GetRealHeight(55),
UnSelectedImagePath = "ZigeeLogic/leavehome.png",
};
leavehomeFrameLayout.AddChidren(leavehomeiconBtn);
var leavehomedefenceRowLayout = new RowLayout
{
Y = Application.GetRealHeight(30),
Width = Application.GetRealWidth(850),
Height = Application.GetRealHeight(130),
X = Application.GetRealWidth(176),
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
};
leavehomeFrameLayout.AddChidren(leavehomedefenceRowLayout);
var leavehomebtndefence = new Button
{
Text = Language.StringByID(MyInternationalizationString.logicremovehomegarrison),
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
leavehomedefenceRowLayout.AddChidren(leavehomebtndefence);
var leavehomedefenceSelected = new SelectedButton(789);
leavehomedefenceRowLayout.AddChidren(leavehomedefenceSelected);
#endregion
#region 撤防
var withdrawalFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(160),
Y = leavehomeFrameLayout.Bottom,
BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
};
middle.AddChidren(withdrawalFrameLayout);
var withdrawaliconBtn = new Button
{
Width = Application.GetRealWidth(81),
Height = Application.GetRealHeight(81),
X = Application.GetRealWidth(58),
Y = Application.GetRealHeight(55),
UnSelectedImagePath = "ZigeeLogic/withdrawal.png",
};
withdrawalFrameLayout.AddChidren(withdrawaliconBtn);
var withdrawalRowLayout = new RowLayout
{
Y = Application.GetRealHeight(30),
Width = Application.GetRealWidth(850),
Height = Application.GetRealHeight(130),
X = Application.GetRealWidth(176),
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
};
withdrawalFrameLayout.AddChidren(withdrawalRowLayout);
var btnwithdrawal = new Button
{
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
TextID = MyInternationalizationString.withdrawal,
};
withdrawalRowLayout.AddChidren(btnwithdrawal);
var withdrawalSelected = new SelectedButton(789);
withdrawalRowLayout.AddChidren(withdrawalSelected);
#endregion
#region 胁迫撤防
var urgentwithdFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(160),
Y = withdrawalFrameLayout.Bottom,
BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
};
middle.AddChidren(urgentwithdFrameLayout);
var urgentwithdiconBtn = new Button
{
Width = Application.GetRealWidth(81),
Height = Application.GetRealHeight(81),
X = Application.GetRealWidth(58),
Y = Application.GetRealHeight(55),
UnSelectedImagePath = "ZigeeLogic/withdrawal.png",
};
urgentwithdFrameLayout.AddChidren(urgentwithdiconBtn);
var urgentwithdrawalRowLayout = new RowLayout
{
Y = Application.GetRealHeight(30),
Width = Application.GetRealWidth(850),
Height = Application.GetRealHeight(130),
X = Application.GetRealWidth(176),
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
};
urgentwithdFrameLayout.AddChidren(urgentwithdrawalRowLayout);
var btnurgentwithdrawal = new Button
{
TextID = MyInternationalizationString.urgentwithdrawal,
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
urgentwithdrawalRowLayout.AddChidren(btnurgentwithdrawal);
var urgentwithdrawalSelected = new SelectedButton(789);
urgentwithdrawalRowLayout.AddChidren(urgentwithdrawalSelected);
#endregion
#endregion
///在家布防点击事件
EventHandler athomeclick = (sedner14, e14) =>
{
athomedefenceSelected.Visible = true;
leavehomedefenceSelected.Visible = false;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = false;
};
athomedefenceRowLayout.MouseUpEventHandler += athomeclick;
btnathomedefence.MouseUpEventHandler += athomeclick;
athomedefenceSelected.MouseUpEventHandler += athomeclick;
athomeFrameLayout.MouseUpEventHandler += athomeclick;
athomeiconBtn.MouseUpEventHandler += athomeclick;
///离家布防点击事件
EventHandler leavehomeclick = (sedner14, e14) =>
{
athomedefenceSelected.Visible = false;
leavehomedefenceSelected.Visible = true;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = false;
};
leavehomedefenceRowLayout.MouseUpEventHandler += leavehomeclick;
leavehomebtndefence.MouseUpEventHandler += leavehomeclick;
leavehomedefenceSelected.MouseUpEventHandler += leavehomeclick;
leavehomeFrameLayout.MouseUpEventHandler += leavehomeclick;
leavehomeiconBtn.MouseUpEventHandler += leavehomeclick;
///撤防点击事件
EventHandler disableclick = (seder, e) =>
{
athomedefenceSelected.Visible = false;
leavehomedefenceSelected.Visible = false;
withdrawalSelected.Visible = true;
urgentwithdrawalSelected.Visible = false;
};
withdrawalRowLayout.MouseUpEventHandler += disableclick;
btnwithdrawal.MouseUpEventHandler += disableclick;
withdrawalSelected.MouseUpEventHandler += disableclick;
withdrawalFrameLayout.MouseUpEventHandler += disableclick;
withdrawaliconBtn.MouseUpEventHandler += disableclick;
///胁迫撤防点击事件
EventHandler urgentwithdrawalclick = (seder, e) =>
{
athomedefenceSelected.Visible = false;
leavehomedefenceSelected.Visible = false;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = true;
};
urgentwithdrawalRowLayout.MouseUpEventHandler += urgentwithdrawalclick;
btnurgentwithdrawal.MouseUpEventHandler += urgentwithdrawalclick;
urgentwithdrawalSelected.MouseUpEventHandler+= urgentwithdrawalclick;
urgentwithdFrameLayout.MouseUpEventHandler += urgentwithdrawalclick;
urgentwithdiconBtn.MouseUpEventHandler += urgentwithdrawalclick;
if (IsDeviceEditor)
{
foreach (var actions in Common.Logic.CurrentLogic.Actions)
{
if (actions["LinkType"].ToString() == "6")
{
if (actions["SecuritySetting"].ToString() == "0")
{
if (actions["Password"].ToString() == "888888")
{
athomedefenceSelected.Visible = false;
leavehomedefenceSelected.Visible = false;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = true;
}
else
{
athomedefenceSelected.Visible = false;
leavehomedefenceSelected.Visible = false;
withdrawalSelected.Visible = true;
urgentwithdrawalSelected.Visible = false;
}
}
else if (actions["SecuritySetting"].ToString() == "1")
{
athomedefenceSelected.Visible = true;
leavehomedefenceSelected.Visible = false;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = false;
}
else if (actions["SecuritySetting"].ToString() == "2")
{
athomedefenceSelected.Visible = false;
leavehomedefenceSelected.Visible = true;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = false;
}
break;
}
}
}
btnsave.MouseUpEventHandler += (sender, e) =>
{
if (!athomedefenceSelected.Visible && !leavehomedefenceSelected.Visible && !withdrawalSelected.Visible && !urgentwithdrawalSelected.Visible)
{
return;
}
if (actionsInfo.ContainsKey("LinkType"))
{
actionsInfo.Remove("LinkType");
}
if (actionsInfo.ContainsKey("CheckIASStatus"))
{
actionsInfo.Remove("CheckIASStatus");
}
if (actionsInfo.ContainsKey("IsDelayStart"))
{
actionsInfo.Remove("IsDelayStart");
}
actionsInfo.Add("LinkType", 6);
actionsInfo.Add("CheckIASStatus", 0);
actionsInfo.Add("IsDelayStart", 0);
if (actionsInfo.ContainsKey("Password"))
{
actionsInfo.Remove("Password");
}
if (actionsInfo.ContainsKey("SecuritySetting"))
{
actionsInfo.Remove("SecuritySetting");
}
if (actionsInfo.ContainsKey("SecurityModeId"))
{
actionsInfo.Remove("SecurityModeId");
}
///在家布防
if (athomedefenceSelected.Visible)
{
actionsInfo.Add("SecuritySetting", "1");
actionsInfo.Add("SecurityModeId", "1");
actionsInfo.Add("Password", "666666");
}
///离家布防
if (leavehomedefenceSelected.Visible)
{
actionsInfo.Add("SecuritySetting", "1");
actionsInfo.Add("SecurityModeId", "2");
actionsInfo.Add("Password", "666666");
}
///撤防
if (withdrawalSelected.Visible)
{
actionsInfo.Add("SecuritySetting", "0");
actionsInfo.Add("SecurityModeId", "0");
actionsInfo.Add("Password", "999999");
}
///紧迫撤防
if (urgentwithdrawalSelected.Visible)
{
actionsInfo.Add("SecuritySetting", "0");
actionsInfo.Add("SecurityModeId", "0");
actionsInfo.Add("Password", "888888");
}
LogicIfon.AddSecurityactions(actionsInfo);
this.RemoveFromParent();
var logicCommunalPage = new LogicCommunalPage();
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
UserView.HomePage.Instance.PageIndex += 1;
logicCommunalPage.Show(() => { });
};
}
}
}