using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.Common;
|
using Shared.R;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.Logic
|
{
|
public class IgnoreTime : FrameLayout
|
{
|
|
public IgnoreTime()
|
{
|
Tag = "Logic";
|
|
}
|
Button selectedIcon = new Button();
|
public void Show(CommonDevice common, string name, bool edit, int timevalue)
|
{
|
|
#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),
|
Text = name,
|
};
|
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 VerticalScrolViewLayout
|
{
|
Y = topRowLayout.Bottom,
|
Height = Application.GetRealHeight(1920 - 184 - 260),
|
BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
|
};
|
this.AddChidren(middle);
|
int selectetimedvalue = 0;
|
var timestrlist = new List<string> { "2", "5", "10", "20", "30", Language.StringByID(MyInternationalizationString.logiccustom) };
|
foreach (var intvalue in timestrlist)
|
{
|
|
var timeframelayout = new FrameLayout
|
{
|
Height = Application.GetRealHeight(160),
|
BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
|
};
|
middle.AddChidren(timeframelayout);
|
|
var timeniconBtn = new Button
|
{
|
Width = Application.GetRealWidth(81),
|
Height = Application.GetRealHeight(81),
|
X = Application.GetRealWidth(58),
|
Y = Application.GetRealHeight(55),
|
UnSelectedImagePath = "ZigeeLogic/point.png",
|
|
};
|
timeframelayout.AddChidren(timeniconBtn);
|
|
var timeRow = new RowLayout
|
{
|
Y = Application.GetRealHeight(30),
|
Width = Application.GetRealWidth(850),
|
Height = Application.GetRealHeight(130),
|
X = Application.GetRealWidth(176),
|
LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
|
};
|
timeframelayout.AddChidren(timeRow);
|
|
var timeBtn = new Button
|
{
|
Text = intvalue.ToString() + Language.StringByID(MyInternationalizationString.Minute),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
Tag = intvalue,
|
};
|
timeRow.AddChidren(timeBtn);
|
|
|
var selected = new SelectedButton(789);
|
timeRow.AddChidren(selected);
|
//判断一个字符是字符串还是数字
|
if (intvalue.Length < 3)
|
{
|
if (timevalue== int.Parse(intvalue) * 60)
|
{
|
selectedIcon.Visible = false;
|
selectedIcon = selected;
|
selected.Visible = true;
|
}
|
}
|
else
|
{
|
timeRow.LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor;
|
}
|
EventHandler<MouseEventArgs> timeclick = (sender, e) =>
|
{
|
selectedIcon.Visible = false;
|
selectedIcon = selected;
|
selected.Visible = true;
|
if (Language.StringByID(MyInternationalizationString.logiccustom) == timeBtn.Tag.ToString())
|
{
|
var secondList = new List<string>();
|
var minuteList = new List<string>();
|
for (int i = 0; i < 61; i++)
|
{
|
if (i < 10)
|
{
|
var a = "0" + i.ToString();
|
secondList.Add(a + " " + Language.StringByID(MyInternationalizationString.second));
|
minuteList.Add(a + " " + Language.StringByID(MyInternationalizationString.minute));
|
}
|
else
|
{
|
secondList.Add(i.ToString() + " " + Language.StringByID(MyInternationalizationString.second));
|
minuteList.Add(i.ToString() + " " + Language.StringByID(MyInternationalizationString.minute));
|
}
|
|
}
|
int selectIndex1 = timevalue / 60;
|
int selectIndex2 = timevalue % 60;
|
PickerView.ShowNormal(minuteList, secondList, new List<string>(), (Index1, Index2, Index3) =>
|
{
|
selectetimedvalue = int.Parse(minuteList[Index1].Split(' ')[0]) * 60 + int.Parse(secondList[Index2].Split(' ')[0]);
|
timemethod(common, selectetimedvalue, timevalue, edit);
|
}, selectIndex1, selectIndex2, 0, Language.StringByID(MyInternationalizationString.logiccustom));
|
}
|
else
|
{
|
selectetimedvalue = int.Parse(timeBtn.Tag.ToString()) * 60;
|
}
|
};
|
timeframelayout.MouseUpEventHandler += timeclick;
|
timeniconBtn.MouseUpEventHandler += timeclick;
|
timeRow.MouseUpEventHandler += timeclick;
|
timeBtn.MouseUpEventHandler += timeclick;
|
selected.MouseUpEventHandler += timeclick;
|
}
|
|
var saveFrameLayout = new FrameLayout
|
{
|
Y = middle.Bottom,
|
Height = Application.GetRealHeight(260),
|
BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
|
};
|
this.AddChidren(saveFrameLayout);
|
|
var btnsave = new Button
|
{
|
X = Application.GetRealWidth(85),
|
Height = Application.GetRealHeight(130),//194
|
Width = Application.GetRealWidth(910),
|
Radius = (uint)Application.GetRealHeight(60),
|
BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
|
TextID = MyInternationalizationString.Save,
|
TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
|
};
|
saveFrameLayout.AddChidren(btnsave);
|
btnsave.MouseUpEventHandler += (sender, e) =>
|
{
|
timemethod(common, selectetimedvalue, timevalue, edit);
|
};
|
}
|
|
public void timemethod(CommonDevice common, int selectetimedvalue, int timevalue, bool edit)
|
{
|
|
var deviceConditionsInfo = new Dictionary<string, string>();
|
deviceConditionsInfo.Add("Type", "1");
|
deviceConditionsInfo.Add("IsValid", "1");
|
deviceConditionsInfo.Add("MacAddr", common.DeviceAddr);
|
deviceConditionsInfo.Add("Epoint", common.DeviceEpoint.ToString());
|
deviceConditionsInfo.Add("Cluster_ID", "1280");
|
deviceConditionsInfo.Add("AttriButeId", "1281");
|
deviceConditionsInfo.Add("AttriButeData1", "0");
|
deviceConditionsInfo.Add("AttriButeData2", "0");
|
deviceConditionsInfo.Add("Range", "1");
|
if (selectetimedvalue != 0)
|
{
|
if (timevalue != selectetimedvalue)
|
{
|
if (deviceConditionsInfo.ContainsKey("IgnoreTime"))
|
{
|
deviceConditionsInfo.Remove("IgnoreTime");
|
}
|
deviceConditionsInfo.Add("IgnoreTime", selectetimedvalue.ToString());
|
LogicIfon.AddDeviceconditions(common, deviceConditionsInfo);
|
}
|
|
}
|
else
|
{
|
if (!edit)
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
|
Language.StringByID(MyInternationalizationString.complete));
|
alert.Show();
|
return;
|
}
|
|
}
|
var logicCommunalPage = new LogicCommunalPage();
|
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
logicCommunalPage.Show(() => { });
|
|
}
|
}
|
}
|