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()
{
this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
this.AddChidren(new Button
{
Height = Application.GetRealHeight(80),
});
var topFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(140),
Y = Application.GetRealHeight(80),
};
AddChidren(topFrameLayout);
var titleName = new Button
{
TextID = MyInternationalizationString.securitymode,
TextSize = 17,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
topFrameLayout.AddChidren(titleName);
var back = new Button
{
Width = Application.GetRealWidth(110),
Height = Application.GetRealHeight(110),
X = Application.GetRealWidth(20),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "ZigeeLogic/Back.png",
};
topFrameLayout.AddChidren(back);
back.MouseDownEventHandler += (sender, e) =>
{
RemoveFromParent();
};
var middle = new VerticalScrolViewLayout();
middle.Y = topFrameLayout.Bottom;
middle.Height = Application.GetRealHeight(1920 - 220);
middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
this.AddChidren(middle);
if (actionsInfo.ContainsKey("LinkType"))
{
actionsInfo.Remove("LinkType");
}
if (actionsInfo.ContainsKey("SecurityModeId"))
{
actionsInfo.Remove("SecurityModeId");
}
if (actionsInfo.ContainsKey("CheckIASStatus"))
{
actionsInfo.Remove("CheckIASStatus");
}
if (actionsInfo.ContainsKey("IsDelayStart"))
{
actionsInfo.Remove("IsDelayStart");
}
actionsInfo.Add("LinkType", 6);
actionsInfo.Add("SecurityModeId", 0);
actionsInfo.Add("CheckIASStatus", 0);
actionsInfo.Add("IsDelayStart", 0);
#region ----布防 撤防 胁迫撤防----
var defenceRowLayout = new RowLayout
{
Height = Application.GetRealHeight(180),
};
middle.AddChidren(defenceRowLayout);
var btndefence = new Button
{
Width = Application.GetRealWidth(600),
TextID = MyInternationalizationString.defence,
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth(40),
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
//Text="布防",
};
defenceRowLayout.AddChidren(btndefence);
var defenceSelected = new Button
{
X = Application.GetRealWidth(1080 - 150),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
UnSelectedImagePath = "Item/YesSelected.png",
Visible = false,
Gravity = Gravity.CenterVertical
};
defenceRowLayout.AddChidren(defenceSelected);
var withdrawalRowLayout = new RowLayout
{
Height = Application.GetRealHeight(180),
};
middle.AddChidren(withdrawalRowLayout);
var btnwithdrawal = new Button
{
Width = Application.GetRealWidth(600),
TextID = MyInternationalizationString.withdrawal,
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth(40),
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
//Text = "撤防",
};
withdrawalRowLayout.AddChidren(btnwithdrawal);
var withdrawalSelected = new Button
{
X = Application.GetRealWidth(1080 - 150),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
UnSelectedImagePath = "Item/YesSelected.png",
Visible = false,
Gravity = Gravity.CenterVertical
};
withdrawalRowLayout.AddChidren(withdrawalSelected);
var urgentwithdrawalRowLayout = new RowLayout
{
Height = Application.GetRealHeight(180),
};
middle.AddChidren(urgentwithdrawalRowLayout);
var btnurgentwithdrawal = new Button
{
Width = Application.GetRealWidth(600),
TextID = MyInternationalizationString.urgentwithdrawal,
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth(40),
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
//Text = "胁迫撤防",
};
urgentwithdrawalRowLayout.AddChidren(btnurgentwithdrawal);
var urgentwithdrawalSelected = new Button
{
X = Application.GetRealWidth(1080 - 150),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
UnSelectedImagePath = "Item/YesSelected.png",
Visible = false,
Gravity = Gravity.CenterVertical
};
urgentwithdrawalRowLayout.AddChidren(urgentwithdrawalSelected);
#endregion
string strvalue = "";
///布防点击事件
EventHandler copenclick = (seder, e) =>
{
defenceSelected.Visible = true;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = false;
SecurityView(strvalue);
};
btndefence.MouseUpEventHandler += copenclick;
defenceRowLayout.MouseUpEventHandler += copenclick;
///撤防点击事件
EventHandler disableclick = (seder, e) =>
{
defenceSelected.Visible = false;
withdrawalSelected.Visible = true;
urgentwithdrawalSelected.Visible = false;
if (actionsInfo.ContainsKey("Password"))
{
actionsInfo.Remove("Password");
}
actionsInfo.Add("Password", "999999");
if (actionsInfo.ContainsKey("SecurityModeId"))
{
actionsInfo.Remove("SecurityModeId");
}
if (actionsInfo.ContainsKey("SecuritySetting"))
{
actionsInfo.Remove("SecuritySetting");
}
actionsInfo.Add("SecurityModeId", "0");
actionsInfo.Add("SecuritySetting", "0");
LogicIfon.AddSecurityactions(actionsInfo);
this.RemoveFromParent();
var logicCommunalPage = new LogicCommunalPage();
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
UserView.HomePage.Instance.PageIndex += 1;
logicCommunalPage.Show(() => { });
};
withdrawalRowLayout.MouseUpEventHandler += disableclick;
btnwithdrawal.MouseUpEventHandler += disableclick;
///胁迫撤防点击事件
EventHandler urgentwithdrawalclick = (seder, e) =>
{
defenceSelected.Visible = false;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = true;
if (actionsInfo.ContainsKey("Password"))
{
actionsInfo.Remove("Password");
}
if (actionsInfo.ContainsKey("SecuritySetting"))
{
actionsInfo.Remove("SecuritySetting");
}
actionsInfo.Add("Password", "888888");
actionsInfo.Add("SecuritySetting", "0");
LogicIfon.AddSecurityactions(actionsInfo);
this.RemoveFromParent();
var logicCommunalPage = new LogicCommunalPage();
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
UserView.HomePage.Instance.PageIndex += 1;
logicCommunalPage.Show(() => { });
};
urgentwithdrawalRowLayout.MouseUpEventHandler += urgentwithdrawalclick;
btnurgentwithdrawal.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")
{
defenceSelected.Visible = false;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = true;
}
else
{
defenceSelected.Visible = false;
withdrawalSelected.Visible = true;
urgentwithdrawalSelected.Visible = false;
}
}
else if (actions["SecuritySetting"].ToString() == "1")
{
strvalue = actions["SecurityModeId"].ToString();
defenceSelected.Visible = true;
withdrawalSelected.Visible = false;
urgentwithdrawalSelected.Visible = false;
}
break;
}
}
}
}
void SecurityView(string strvalue)
{
FrameLayout flMain = new FrameLayout { BackgroundColor = 0x00000000 };
this.AddChidren(flMain);
flMain.MouseUpEventHandler += (sender, e) =>
{
flMain.RemoveFromParent();
};
var frameLayout = new FrameLayout
{
Y = Application.GetRealHeight(1920 - 360),
Height = Application.GetRealHeight(360),
BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor,
};
flMain.AddChidren(frameLayout);
var athomeRow = new RowLayout
{
Height = Application.GetRealHeight(180),
};
frameLayout.AddChidren(athomeRow);
var athomeBtn = new Button
{
Width = Application.GetRealWidth(600),
TextID = MyInternationalizationString.athome,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
athomeRow.AddChidren(athomeBtn);
var athomeSelected = new Button
{
X = Application.GetRealWidth(1080 - 150),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
UnSelectedImagePath = "Item/YesSelected.png",
Visible = false,
Gravity = Gravity.CenterVertical
};
athomeRow.AddChidren(athomeSelected);
var leavehomeRow = new RowLayout
{
Height = Application.GetRealHeight(180),
Y = athomeRow.Bottom,
};
frameLayout.AddChidren(leavehomeRow);
var leavehomeBtn = new Button
{
Width = Application.GetRealWidth(600),
TextID = MyInternationalizationString.leavehome,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
leavehomeRow.AddChidren(leavehomeBtn);
var leavehomeSelected = new Button
{
X = Application.GetRealWidth(1080 - 150),
Width = Application.GetMinRealAverage(110),
Height = Application.GetMinRealAverage(110),
UnSelectedImagePath = "Item/YesSelected.png",
Visible = false,
Gravity = Gravity.CenterVertical
};
leavehomeRow.AddChidren(leavehomeSelected);
EventHandler athomeclick = (sender6, e6) =>
{
flMain.RemoveFromParent();
if (actionsInfo.ContainsKey("SecurityModeId"))
{
actionsInfo.Remove("SecurityModeId");
}
if (actionsInfo.ContainsKey("SecuritySetting"))
{
actionsInfo.Remove("SecuritySetting");
}
if (actionsInfo.ContainsKey("Password"))
{
actionsInfo.Remove("Password");
}
actionsInfo.Add("Password", "666666");
actionsInfo.Add("SecurityModeId", "1");
actionsInfo.Add("SecuritySetting", "1");
LogicIfon.AddSecurityactions(actionsInfo);
var logicCommunalPage = new LogicCommunalPage();
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
UserView.HomePage.Instance.PageIndex += 1;
logicCommunalPage.Show(() => { });
};
athomeRow.MouseUpEventHandler += athomeclick;
athomeBtn.MouseUpEventHandler += athomeclick;
athomeSelected.MouseUpEventHandler += athomeclick;
EventHandler leavehomeclick = (sender6, e6) =>
{
flMain.RemoveFromParent();
if (actionsInfo.ContainsKey("SecurityModeId"))
{
actionsInfo.Remove("SecurityModeId");
}
if (actionsInfo.ContainsKey("SecuritySetting"))
{
actionsInfo.Remove("SecuritySetting");
}
if(actionsInfo.ContainsKey("Password"))
{
actionsInfo.Remove("Password");
}
actionsInfo.Add("Password", "666666");
actionsInfo.Add("SecurityModeId", "2");
actionsInfo.Add("SecuritySetting", "1");
LogicIfon.AddSecurityactions(actionsInfo);
var logicCommunalPage = new LogicCommunalPage();
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
UserView.HomePage.Instance.PageIndex += 1;
logicCommunalPage.Show(() => { });
};
leavehomeRow.MouseUpEventHandler += leavehomeclick;
leavehomeBtn.MouseUpEventHandler += leavehomeclick;
leavehomeSelected.MouseUpEventHandler += leavehomeclick;
if (strvalue == "1")
{
athomeSelected.Visible = true;
leavehomeSelected.Visible = false;
}
else if (strvalue == "2")
{
leavehomeSelected.Visible = true;
athomeSelected.Visible = false;
}
}
}
}