using System;
using System.Collections.Generic;
using Shared;
using Shared.Common;
using Shared.Phone;
using Shared.R;
namespace Shared.Phone.Device.Logic
{
public class Cycle : FrameLayout
{
Action action;
public Cycle(Action action)
{
this.action = action;
}
public Cycle()
{
Tag = "Logic";
}
///
/// 选中
///
Button beforeClickButton = new Button();
public void Show()
{
this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
var topFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(140),
Y = Application.GetRealHeight(80),
};
AddChidren(topFrameLayout);
var titleName = new Button
{
TextID = MyInternationalizationString.cycle,
TextSize = 17,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
topFrameLayout.AddChidren(titleName);
var hdl = new Button
{
Width = Application.GetRealWidth(154),
Height = Application.GetRealHeight(90),
X = Application.GetRealWidth(1080 - 170),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "Logo/Logo.png",
};
//topFrameLayout.AddChidren(hdl);
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();
if (action != null)
action();
};
var titlerl = new RowLayout
{
Height = Application.GetRealHeight(180),
// BackgroundColor = 0xff0f0f0f,
Y = Application.GetRealHeight(220),
};
AddChidren(titlerl);
titlerl.AddChidren(
new Button
{
X = Application.GetRealWidth(40),
//Text = "请选择重复执行周期",
TextID = MyInternationalizationString.repeat,
TextSize = 17,
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
}
);
var middle = new VerticalScrolViewLayout();
middle.Y = titlerl.Bottom;
middle.Height = Application.GetRealHeight(1920 - 220 - 180 - 174);
middle.BackgroundColor =ZigbeeColor.Current.LogicBackgroundColor;
this.AddChidren(middle);
var cyclelist = new List();
cyclelist.AddRange(new string[] {
Language.StringByID(MyInternationalizationString.executeonce),
Language.StringByID(MyInternationalizationString.everyday),
//"今年",
//Language.StringByID(MyInternationalizationString.workingday),
//Language.StringByID(MyInternationalizationString.weekend),
Language.StringByID(MyInternationalizationString.monthly),
Language.StringByID(MyInternationalizationString.everyyear),
Language.StringByID(MyInternationalizationString.logicminute),
});
foreach (var name in cyclelist)
{
var cyclerwLayout = new RowLayout
{
Height = Application.GetRealHeight(180),
};
middle.AddChidren(cyclerwLayout);
var btn = new Button
{
Height = Application.GetRealHeight(180),
Width = LayoutParams.MatchParent,
SelectedBackgroundColor = 0xfffe5e00,
};
cyclerwLayout.AddChidren(btn);
var btnName = new Button
{
Gravity = Gravity.CenterVertical,
Text = name,
Width = Application.GetRealWidth(400),
Height = Application.GetRealHeight(100),
X = Application.GetRealWidth(30),
TextSize = 16,
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
cyclerwLayout.AddChidren(btnName);
var btntimeback = new Button
{
Width = Application.GetRealWidth(110),
Height = Application.GetRealHeight(110),
//UnSelectedImagePath = "MusicIcon/Next.png",
SelectedImagePath = "ZigeeLogic/next.png",
X = Application.GetRealWidth(1080 - 140),
};
if (name == Language.StringByID(MyInternationalizationString.monthly) || name == Language.StringByID(MyInternationalizationString.everyyear) || name == Language.StringByID(MyInternationalizationString.logiccustom))
{
cyclerwLayout.AddChidren(btntimeback);
}
//if (timename == name) {
// beforeClickButton.IsSelected = false;
// beforeClickButton = btn;
// btn.IsSelected = true;
//}
EventHandler timeclick = (sender, e) =>
{
if (btnName.Text == Language.StringByID(MyInternationalizationString.logiccustom))
{
var weekPage = new WeekPage();
UserView.HomePage.Instance.AddChidren(weekPage);
UserView.HomePage.Instance.PageIndex += 1;
weekPage.Show();
}
else if (btnName.Text == Language.StringByID(MyInternationalizationString.monthly))
{
var everymonthPage = new EverymonthPage();
UserView.HomePage.Instance.AddChidren(everymonthPage);
UserView.HomePage.Instance.PageIndex += 1;
everymonthPage.Show();
}
else if (btnName.Text == Language.StringByID(MyInternationalizationString.everyyear))
{
var everyyearPage = new EveryyearPage();
UserView.HomePage.Instance.AddChidren(everyyearPage);
UserView.HomePage.Instance.PageIndex += 1;
everyyearPage.Show();
}
else
{
beforeClickButton.IsSelected = false;
beforeClickButton = btn;
btn.IsSelected = true;
if (btnName.Text == Language.StringByID(MyInternationalizationString.everyday))
{
Common.Logic.CurrentLogic.TimeAttribute.Repeat = 2;
}
else if (btnName.Text == Language.StringByID(MyInternationalizationString.executeonce))
{
Common.Logic.CurrentLogic.TimeAttribute.Repeat = 0;
}
}
};
cyclerwLayout.MouseUpEventHandler += timeclick;
btn.MouseUpEventHandler += timeclick;
btnName.MouseUpEventHandler += timeclick;
btntimeback.MouseUpEventHandler += timeclick;
};
var btncomplete = new Button
{
Y = middle.Bottom,
Height = Application.GetRealHeight(174),
TextID = MyInternationalizationString.complete,
//BackgroundColor = 0xff1f1f1f,
TextSize = 16,
TextColor = ZigbeeColor.Current.LogicTextBlackColor,
};
AddChidren(btncomplete);
btncomplete.MouseUpEventHandler += (sedder, e) =>
{
RemoveFromParent();
action();
};
}
}
}