using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.Common;
|
using Shared.Phone;
|
using Shared.R;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.Logic
|
{
|
public class TimePage : FrameLayout
|
{
|
public TimePage()
|
{
|
Tag = "Logic";
|
}
|
public bool IsDeviceEditor1;
|
public string str1;
|
|
Dictionary<string, string> timeBucketConditionsInfo = new Dictionary<string, string>();
|
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
|
{
|
Text = Language.StringByID(MyInternationalizationString.addtime),
|
TextSize = 17,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth(150),
|
};
|
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();
|
IsDeviceEditor1 = false;
|
};
|
|
|
var middle = new VerticalScrolViewLayout();
|
middle.Y = topFrameLayout.Bottom;
|
middle.Height = Application.GetRealHeight(1920- 220 - 200);
|
middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
this.AddChidren(middle);
|
|
|
#region -----立即执行
|
var row = new RowLayout
|
{
|
Height = Application.GetRealHeight(250),
|
};
|
middle.AddChidren(row);
|
|
var btnTextTitle = new Button
|
{
|
Height = Application.GetRealHeight(50),
|
Width = Application.GetRealWidth(800),
|
Y = Application.GetRealHeight(20),
|
X = Application.GetRealWidth(40),
|
// Text = "请选择时间类型",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
TextID = MyInternationalizationString.Selectedtimetype,
|
};
|
row.AddChidren(btnTextTitle);
|
|
var btnTypeTextTitle = new Button
|
{
|
Y = Application.GetRealHeight(20 + 50),
|
// Text = "类型",
|
X = Application.GetRealWidth(40),
|
TextAlignment = TextAlignment.CenterLeft,
|
Height = Application.GetRealHeight(180),
|
Width = Application.GetRealWidth(400),
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
TextID = MyInternationalizationString.type,
|
};
|
row.AddChidren(btnTypeTextTitle);
|
|
var btnTypeText = new Button
|
{
|
Y = Application.GetRealHeight(20 + 50),
|
X = Application.GetRealWidth(1080 - 500 - 40),
|
//Text = "时间范围",
|
TextAlignment = TextAlignment.CenterRight,
|
Height = Application.GetRealHeight(180),
|
Width = Application.GetRealWidth(500),
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
TextID = MyInternationalizationString.timeframe,
|
};
|
row.AddChidren(btnTypeText);
|
#endregion
|
|
var timestartrow = new RowLayout
|
{
|
Height = Application.GetRealHeight(180),
|
};
|
middle.AddChidren(timestartrow);
|
|
var btnstarttimetext = new Button
|
{
|
TextAlignment = TextAlignment.CenterLeft,
|
Width = Application.GetRealWidth(300),
|
X = Application.GetRealWidth(30),
|
TextID = MyInternationalizationString.starttime,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
};
|
timestartrow.AddChidren(btnstarttimetext);
|
|
var btnstarttime = new Button
|
{
|
X = Application.GetRealWidth(330),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(600),
|
TextAlignment = TextAlignment.CenterLeft,
|
Tag = "0",
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
};
|
timestartrow.AddChidren(btnstarttime);
|
|
var btnstartback = new Button
|
{
|
Width = Application.GetRealWidth(110),
|
Height = Application.GetRealHeight(110),
|
UnSelectedImagePath = "ZigeeLogic/next.png",
|
SelectedImagePath = "ZigeeLogic/NextSelecte.png",
|
X = Application.GetRealWidth(1080-140),
|
Gravity = Gravity.CenterVertical,
|
};
|
timestartrow.AddChidren(btnstartback);
|
|
var timeendrow = new RowLayout
|
{
|
Height = Application.GetRealHeight(180),
|
};
|
middle.AddChidren(timeendrow);
|
var btnendtimetext = new Button
|
{
|
TextAlignment = TextAlignment.CenterLeft,
|
Width = Application.GetRealWidth(300),
|
X = Application.GetRealWidth(30),
|
TextID = MyInternationalizationString.endtime,
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
};
|
timeendrow.AddChidren(btnendtimetext);
|
|
var btnendtime = new Button
|
{
|
X = Application.GetRealWidth(330),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(600),
|
TextAlignment = TextAlignment.CenterLeft,
|
Tag = "0",
|
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
|
};
|
timeendrow.AddChidren(btnendtime);
|
|
var btnendtimeback = new Button
|
{
|
Width = Application.GetRealWidth(110),
|
Height = Application.GetRealHeight(110),
|
UnSelectedImagePath = "ZigeeLogic/next.png",
|
SelectedImagePath = "ZigeeLogic/NextSelecte.png",
|
X = Application.GetRealWidth(1080-140),
|
Gravity = Gravity.CenterVertical,
|
};
|
timeendrow.AddChidren(btnendtimeback);
|
|
|
if (IsDeviceEditor1)
|
{
|
if (str1 != null)
|
{
|
|
string[] timestr = str1.Split('-');
|
string[] starttime = timestr[0].Split(':');
|
string[] endtime = timestr[1].Split(':');
|
string s1 = "", s2 = "";
|
if (starttime[1].Length < 2)
|
{
|
s1 = "0" + starttime[1];
|
}
|
else
|
{
|
s1 = starttime[1];
|
}
|
if (endtime[1].Length < 2)
|
{
|
s2 = "0" + endtime[1];
|
}
|
else
|
{
|
s2 = endtime[1];
|
}
|
btnstarttime.Text = starttime[0] + ":" + s1;
|
btnendtime.Text =endtime[0] + ":" + s2;
|
|
//btnstarttime.Text = timestr[0];
|
//btnendtime.Text = timestr[1];
|
if (timeBucketConditionsInfo.ContainsKey("StartHour"))
|
{
|
timeBucketConditionsInfo.Remove("StartHour");
|
}
|
if (timeBucketConditionsInfo.ContainsKey("StartMin"))
|
{
|
timeBucketConditionsInfo.Remove("StartMin");
|
}
|
if (timeBucketConditionsInfo.ContainsKey("StopHour"))
|
{
|
timeBucketConditionsInfo.Remove("StopHour");
|
}
|
if (timeBucketConditionsInfo.ContainsKey("StopMin"))
|
{
|
timeBucketConditionsInfo.Remove("StopMin");
|
}
|
timeBucketConditionsInfo.Add("StartHour", starttime[0]);
|
timeBucketConditionsInfo.Add("StartMin", starttime[1]);
|
timeBucketConditionsInfo.Add("StopHour", endtime[0]);
|
timeBucketConditionsInfo.Add("StopMin", endtime[1]);
|
btnstarttime.Tag = int.Parse(starttime[0]) * 60 + int.Parse(starttime[1]);
|
btnendtime.Tag = int.Parse(endtime[0]) * 60 + int.Parse(endtime[1]);
|
}
|
|
}
|
|
EventHandler<MouseEventArgs> stattimeclick = (sender, e) =>
|
{
|
|
var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
|
AddChidren(flMain);
|
flMain.MouseUpEventHandler += (sender11, e11) =>
|
{
|
flMain.RemoveFromParent();
|
};
|
|
var timeview = new TimeView
|
{
|
Y = Application.GetRealHeight(1920 - 600),
|
Height = Application.GetRealHeight(600),
|
BackgroundColor =ZigbeeColor.Current.LogicTimeViewColor,
|
Width = Application.GetRealWidth(1080),
|
};
|
flMain.AddChidren(timeview);
|
|
|
var btnSave = new Button
|
{
|
Y = Application.GetRealHeight(1920 - 600),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealHeight(150),
|
Text = Language.StringByID(MyInternationalizationString.complete),
|
// TextColor = 0xFF121212,
|
TextColor =ZigbeeColor.Current.LogicTimeViewSaveButton,
|
//TextAlignment = TextAlignment.CenterRight
|
X = Application.GetRealWidth(1080 - 200),
|
};
|
flMain.AddChidren(btnSave);
|
|
btnSave.MouseUpEventHandler += (sender2, e2) =>
|
{
|
flMain.RemoveFromParent();
|
|
var startval = timeview.Hour * 60 + timeview.Minute;
|
|
if (btnendtime.Tag.ToString() != "0" && startval.ToString()==btnendtime.Tag.ToString())
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.nottime),
|
Language.StringByID(MyInternationalizationString.confrim));
|
alert.Show();
|
return;
|
}
|
if (btnendtime.Tag.ToString() != "0" && startval > int.Parse(btnendtime.Tag.ToString()))
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.timesetting),
|
Language.StringByID(MyInternationalizationString.confrim));
|
alert.Show();
|
return;
|
}
|
if (timeBucketConditionsInfo.ContainsKey("StartHour"))
|
{
|
timeBucketConditionsInfo.Remove("StartHour");
|
}
|
if (timeBucketConditionsInfo.ContainsKey("StartMin"))
|
{
|
timeBucketConditionsInfo.Remove("StartMin");
|
}
|
btnstarttime.Tag = timeview.Hour * 60 + timeview.Minute;
|
timeBucketConditionsInfo.Add("StartHour", timeview.Hour.ToString());
|
timeBucketConditionsInfo.Add("StartMin", timeview.Minute.ToString());
|
btnstarttime.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2?"0"+timeview.Minute.ToString():timeview.Minute.ToString());
|
};
|
};
|
timestartrow.MouseUpEventHandler += stattimeclick;
|
btnstarttimetext.MouseUpEventHandler += stattimeclick;
|
btnstarttime.MouseUpEventHandler += stattimeclick;
|
btnstartback.MouseUpEventHandler += stattimeclick;
|
|
EventHandler<MouseEventArgs> endtimeclick = (sender, e) =>
|
{
|
|
var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
|
AddChidren(flMain);
|
flMain.MouseUpEventHandler += (sender11, e11) =>
|
{
|
flMain.RemoveFromParent();
|
};
|
|
var timeview = new TimeView
|
{
|
Y = Application.GetRealHeight(1920 - 600),
|
Height = Application.GetRealHeight(600),
|
BackgroundColor =ZigbeeColor.Current.LogicTimeViewColor,
|
Width = Application.GetRealWidth(1080),
|
};
|
flMain.AddChidren(timeview);
|
|
|
var btnSave = new Button
|
{
|
Y = Application.GetRealHeight(1920 - 600),
|
Width = Application.GetRealWidth(200),
|
Height = Application.GetRealHeight(150),
|
Text = Language.StringByID(MyInternationalizationString.complete),
|
//TextColor = 0xFF121212,
|
TextColor =ZigbeeColor.Current.LogicTimeViewSaveButton,
|
//TextAlignment = TextAlignment.CenterRight
|
X = Application.GetRealWidth(1080 - 200),
|
};
|
flMain.AddChidren(btnSave);
|
|
btnSave.MouseUpEventHandler += (sender2, e2) =>
|
{
|
flMain.RemoveFromParent();
|
|
var endval = timeview.Hour * 60 + timeview.Minute;
|
|
if (btnstarttime.Tag.ToString() != "0" && endval.ToString() == btnstarttime.Tag.ToString())
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.nottime),
|
Language.StringByID(MyInternationalizationString.confrim));
|
alert.Show();
|
return;
|
}
|
if (btnstarttime.Tag.ToString() != "0" && endval < int.Parse(btnstarttime.Tag.ToString()))
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.timesetting),
|
Language.StringByID(MyInternationalizationString.confrim));
|
alert.Show();
|
return;
|
}
|
|
if (timeBucketConditionsInfo.ContainsKey("StopHour"))
|
{
|
timeBucketConditionsInfo.Remove("StopHour");
|
}
|
if (timeBucketConditionsInfo.ContainsKey("StopMin"))
|
{
|
timeBucketConditionsInfo.Remove("StopMin");
|
}
|
btnendtime.Tag = timeview.Hour * 60 + timeview.Minute;
|
timeBucketConditionsInfo.Add("StopHour",timeview.Hour.ToString());
|
timeBucketConditionsInfo.Add("StopMin", timeview.Minute.ToString());
|
btnendtime.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2?"0"+timeview.Minute.ToString():timeview.Minute.ToString());
|
};
|
};
|
timeendrow.MouseUpEventHandler += endtimeclick;
|
btnendtimetext.MouseUpEventHandler += endtimeclick;
|
btnendtime.MouseUpEventHandler += endtimeclick;
|
btnendtimeback.MouseUpEventHandler += endtimeclick;
|
|
var fra = new FrameLayout
|
{
|
Y = middle.Bottom,
|
Height = Application.GetRealHeight(200),
|
BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
|
};
|
this.AddChidren(fra);
|
var btncomplete = new Button
|
{
|
X = Application.GetRealWidth(290),
|
Height = Application.GetRealHeight(150),//194
|
Width = Application.GetRealWidth(500),
|
Radius = (uint)Application.GetRealHeight(50),
|
BackgroundColor = ZigbeeColor.Current.LogicButtonBlueColor,
|
TextID = MyInternationalizationString.Save,
|
};
|
fra.AddChidren(btncomplete);
|
|
timeBucketConditionsInfo.Add("Type","5");
|
timeBucketConditionsInfo.Add("IsValid", "1");
|
///完成点击事件
|
EventHandler<MouseEventArgs>completeclick=(sender, e) =>
|
{
|
|
if (string.IsNullOrEmpty(btnstarttime.Text) || string.IsNullOrEmpty(btnendtime.Text))
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.completeNext),
|
Language.StringByID(MyInternationalizationString.complete));
|
alert.Show();
|
return;
|
}
|
if (btnstarttime.Text == btnendtime.Text)
|
{
|
var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
|
Language.StringByID(MyInternationalizationString.sametime),
|
Language.StringByID(MyInternationalizationString.complete));
|
alert.Show();
|
return;
|
}
|
|
if (IsDeviceEditor1)
|
{
|
for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
|
{
|
if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "5")
|
{
|
|
var timeBucketInfo = Common.Logic.CurrentLogic.Conditions[i];
|
var s = timeBucketInfo["StartHour"] + ":" + timeBucketInfo["StartMin"] + "-" + timeBucketInfo["StopHour"] + ":" + timeBucketInfo["StopMin"];
|
if (str1 == s)
|
{
|
Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
|
Common.Logic.CurrentLogic.Conditions.Insert(i, timeBucketConditionsInfo);
|
}
|
|
}
|
}
|
}
|
else
|
{
|
Common.Logic.CurrentLogic.Conditions.Add(timeBucketConditionsInfo);
|
}
|
|
//LogicIfon.logicIfon.Addconditions(timeBucketConditionsInfo,timeBucketConditionsInfo.Type);
|
|
var logicCommunalPage = new LogicCommunalPage { };
|
UserView.HomePage.Instance.AddChidren(logicCommunalPage);
|
UserView.HomePage.Instance.PageIndex += 1;
|
logicCommunalPage.Show(() => { });
|
};
|
|
fra.MouseUpEventHandler += completeclick;
|
btncomplete.MouseUpEventHandler += completeclick;
|
}
|
|
}
|
}
|