using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.SimpleControl.R;
|
using SmartHome;
|
namespace SuperGateWay
|
{
|
public class WeekPage : FrameLayout
|
{
|
public WeekPage ()
|
{
|
Tag = "Logic";
|
}
|
public void Show (GateWay superGateWay, Action<List<int>> action)
|
{
|
var weeklist = new List<string> ();
|
var objects = new List<int> ();
|
this.AddChidren (new Button {
|
Height = Application.GetRealHeight (30),
|
BackgroundColor = 0xFF1F1F1F,
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (30),
|
BackgroundColor = 0xFF1F1F1F,
|
};
|
AddChidren (topFrameLayout);
|
|
var titleName = new Button {
|
TextID = MyInternationalizationString.cycle,
|
TextSize = 17,
|
};
|
topFrameLayout.AddChidren (titleName);
|
|
var hdl = new Button {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Logo/Logo.png",
|
};
|
topFrameLayout.AddChidren (hdl);
|
|
var back = new Button {
|
Width = Application.GetRealWidth (82),
|
Height = Application.GetRealHeight (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
|
};
|
topFrameLayout.AddChidren (back);
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
if (action != null) {
|
action (objects);
|
}
|
};
|
|
var titlerl = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff0f0f0f,
|
Y = Application.GetRealHeight (130),
|
};
|
AddChidren (titlerl);
|
|
titlerl.AddChidren (
|
new Button {
|
X = Application.GetRealWidth (40),
|
//Text = "请选择重复执行周期",
|
TextID = MyInternationalizationString.repeat,
|
TextSize = 17,
|
TextAlignment = TextAlignment.CenterLeft
|
}
|
);
|
|
var middle = new VerticalScrolViewLayout ();
|
middle.Y = titlerl.Bottom;
|
middle.Height = Application.GetRealHeight (Application.DesignHeight - 130 - 100);
|
middle.BackgroundColor = 0xff2F2F2F;
|
this.AddChidren (middle);
|
|
var cyclelist = new List<string> ();
|
|
if(Logic.CurrentLogic.date.ContainsKey ("type")) {
|
var type = Logic.CurrentLogic.date ["type"]?.ToString ();
|
if (type == "week") {
|
var weekvalue = Newtonsoft.Json.JsonConvert.DeserializeObject<int []> (Newtonsoft.Json.JsonConvert.SerializeObject (Logic.CurrentLogic.date ["week"]));
|
for (int i = 0; i < 7; i++) {
|
int a = Array.IndexOf (weekvalue, i);
|
if (a != -1) {
|
///周
|
if (i == 1) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.mon));
|
} else if (i == 2) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.tue));
|
} else if (i == 3) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.wed));
|
} else if (i == 4) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.thu));
|
} else if (i == 5) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.frl));
|
} else if (i == 6) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.sat));
|
} else if (i == 0) {
|
weeklist.Add (Language.StringByID (MyInternationalizationString.sun));
|
}
|
}
|
}
|
|
}
|
}
|
|
cyclelist.AddRange (new string [] {
|
Language.StringByID(MyInternationalizationString.mon),
|
Language.StringByID(MyInternationalizationString.tue),
|
Language.StringByID(MyInternationalizationString.wed),
|
Language.StringByID(MyInternationalizationString.thu),
|
Language.StringByID(MyInternationalizationString.frl),
|
Language.StringByID(MyInternationalizationString.sat),
|
Language.StringByID(MyInternationalizationString.sun),
|
});
|
foreach (var name in cyclelist) {
|
var cyclerwLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
};
|
middle.AddChidren (cyclerwLayout);
|
|
var btnname = new Button {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (350),
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = name,
|
};
|
cyclerwLayout.AddChidren (btnname);
|
|
var btnCheck = new Button {
|
Width = Application.GetRealWidth (60),
|
Height = Application.GetRealHeight (59),
|
Gravity = Gravity.CenterVertical,
|
X = Application.GetRealWidth (520),
|
SelectedImagePath = "Light/CheckOn.png",
|
UnSelectedImagePath = "Light/Check.png",
|
};
|
cyclerwLayout.AddChidren (btnCheck);
|
|
var str = weeklist.Find ((o) => { return o == name; });
|
if (str != null) {
|
btnCheck.IsSelected = true;
|
}
|
///选中时间
|
btnCheck.MouseUpEventHandler += (sender1, e1) => {
|
//var objects = new List<object> ();
|
objects.Clear ();
|
btnCheck.IsSelected = !btnCheck.IsSelected;
|
if (btnCheck.IsSelected) {
|
var d = weeklist.Find ((o) => { return o == name; });
|
if (d == null) {
|
weeklist.Add (name);
|
}
|
} else {
|
weeklist.RemoveAll ((o) => {
|
return o == name;
|
});
|
}
|
foreach (var strname in weeklist) {
|
if (Language.StringByID (MyInternationalizationString.mon) == strname) {
|
objects.Add (1);
|
}else if (Language.StringByID (MyInternationalizationString.tue) == strname) {
|
objects.Add (2);
|
} else if (Language.StringByID (MyInternationalizationString.wed) == strname) {
|
objects.Add (3);
|
} else if (Language.StringByID (MyInternationalizationString.thu) == strname) {
|
objects.Add (4);
|
} else if (Language.StringByID (MyInternationalizationString.frl) == strname) {
|
objects.Add (5);
|
} else if (Language.StringByID (MyInternationalizationString.sat) == strname) {
|
objects.Add (6);
|
} else if (Language.StringByID (MyInternationalizationString.sun) == strname) {
|
objects.Add (0);
|
}
|
}
|
|
if (Logic.CurrentLogic.date.ContainsKey ("type")) {
|
Logic.CurrentLogic.date.Remove ("type");
|
}
|
if (Logic.CurrentLogic.date.ContainsKey ("week")) {
|
Logic.CurrentLogic.date.Remove ("week");
|
}
|
if (Logic.CurrentLogic.date.ContainsKey ("date")) {
|
Logic.CurrentLogic.date.Remove ("date");
|
}
|
Logic.CurrentLogic.date.Add ("type", "week");
|
Logic.CurrentLogic.date.Add ("week", objects.ToArray ());
|
};
|
}
|
|
}
|
|
}
|
}
|