using System;
|
using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.R;
|
namespace SuperGateWay
|
{
|
public class EveryyearPage:FrameLayout
|
{
|
|
/// <summary>
|
/// 开始日期
|
/// </summary>
|
Button btnStartdate;
|
/// <summary>
|
/// 结束日期
|
/// </summary>
|
Button btndateEnddate;
|
public void Show (GateWay superGateWay)
|
{
|
|
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) => {
|
#region 隐藏
|
|
//if (IsSelected) {
|
//} else {
|
// if (btnStartdate.Tag.ToString () != "0" && btndateEnddate.Tag.ToString () != "0") {
|
// if (Logic.CurrentLogic.date.ContainsKey ("type") && Logic.CurrentLogic.date.ContainsKey ("week")) {
|
// Logic.CurrentLogic.date.Remove ("type");
|
// Logic.CurrentLogic.date.Remove ("week");
|
// }
|
// if (Logic.CurrentLogic.date.ContainsKey ("type") && Logic.CurrentLogic.date.ContainsKey ("date")) {
|
// Logic.CurrentLogic.date.Remove ("type");
|
// Logic.CurrentLogic.date.Remove ("date");
|
// }
|
// Logic.CurrentLogic.date.Add ("type", "day");
|
// Logic.CurrentLogic.date.Add ("date", btnStartdate.Text + "-" + btndateEnddate.Text);
|
// }
|
//}
|
RemoveFromParent ();
|
|
#endregion
|
|
};
|
|
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 dateRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
};
|
middle.AddChidren (dateRowLayout);
|
|
var dateVerticalScrolViewLayout = new VerticalScrolViewLayout {
|
Height = 0,
|
BackgroundColor = 0xff121212,
|
};
|
///
|
middle.AddChidren (dateVerticalScrolViewLayout);
|
//Date
|
var btndate = new Button {
|
Width = Application.GetRealWidth (200),
|
X = Application.GetRealHeight (40),
|
TextAlignment = TextAlignment.CenterLeft,
|
//Text = "日期",
|
TextID = MyInternationalizationString.date,
|
TextSize = 16,
|
};
|
dateRowLayout.AddChidren (btndate);
|
|
var btndisplaydate = new Button {
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (150),
|
Width = Application.GetRealWidth (300),
|
Gravity = Gravity.CenterVertical,
|
};
|
dateRowLayout.AddChidren (btndisplaydate);
|
|
var btndateback = new Button {
|
Width = Application.GetRealWidth (87),
|
Height = Application.GetRealHeight (100),
|
UnSelectedImagePath = "MusicIcon/Next.png",
|
SelectedImagePath = "MusicIcon/NextSelecte.png",
|
X = Application.GetRealWidth (550),
|
};
|
dateRowLayout.AddChidren (btndateback);
|
|
///日期点击事件
|
string startvalue = "";
|
string endvalue = "";
|
var list = new List<KeyValuePair<string, string []>> { };
|
for (int month = 1; month <= 12; month++) {
|
int days = DateTime.DaysInMonth (DateTime.Now.Year, month);
|
var listValues = new List<string> { };
|
for (int day = 1; day <= days; day++) {
|
listValues.Add (day.ToString () + " " + Language.StringByID (MyInternationalizationString.day));
|
}
|
list.Add (new KeyValuePair<string, string []> (month.ToString () + " " + Language.StringByID (MyInternationalizationString.month), listValues.ToArray ()));
|
}
|
EventHandler<MouseEventArgs> dateclick = (sender, e) => {
|
dateRowLayout.BackgroundColor = 0xffFE5E00;
|
|
btndisplaydate.IsSelected = !btndisplaydate.IsSelected;
|
if (btndisplaydate.IsSelected) {
|
dateVerticalScrolViewLayout.Height = Application.GetRealWidth (200);
|
|
var startdateRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
};
|
dateVerticalScrolViewLayout.AddChidren (startdateRowLayout);
|
|
var startdatetext = new Button {
|
X = Application.GetRealWidth (40),
|
TextAlignment = TextAlignment.CenterLeft,
|
Gravity = Gravity.CenterVertical,
|
//Text = "起始日期",
|
Width = Application.GetRealWidth (210),
|
TextID = MyInternationalizationString.startdate,
|
};
|
startdateRowLayout.AddChidren (startdatetext);
|
|
///显示起始日期控件
|
btnStartdate = new Button {
|
Width = Application.GetRealWidth (200),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (250),
|
Gravity = Gravity.CenterVertical,
|
Tag = 0,
|
TextAlignment = TextAlignment.CenterLeft,
|
|
};
|
startdateRowLayout.AddChidren (btnStartdate);
|
|
var btnStartdateback = new Button {
|
Width = Application.GetRealWidth (87),
|
Height = Application.GetRealHeight (100),
|
UnSelectedImagePath = "MusicIcon/Next.png",
|
SelectedImagePath = "MusicIcon/NextSelecte.png",
|
X = Application.GetRealWidth (550),
|
};
|
startdateRowLayout.AddChidren (btnStartdateback);
|
|
var enddateRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
};
|
dateVerticalScrolViewLayout.AddChidren (enddateRowLayout);
|
|
var enddtaetext = new Button {
|
X = Application.GetRealWidth (40),
|
TextAlignment = TextAlignment.CenterLeft,
|
Gravity = Gravity.CenterVertical,
|
TextID = MyInternationalizationString.enddate,
|
Width = Application.GetRealWidth (210),
|
//Text = "结束日期",
|
};
|
enddateRowLayout.AddChidren (enddtaetext);
|
|
///显示结束日期控件
|
btndateEnddate = new Button {
|
Width = Application.GetRealWidth (200),
|
Height = Application.GetRealHeight (100),
|
X = Application.GetRealWidth (250),
|
Gravity = Gravity.CenterVertical,
|
Tag = 0,
|
TextAlignment = TextAlignment.CenterLeft,
|
|
};
|
enddateRowLayout.AddChidren (btndateEnddate);
|
|
|
var btnenddateback = new Button {
|
Width = Application.GetRealWidth (87),
|
Height = Application.GetRealHeight (100),
|
UnSelectedImagePath = "MusicIcon/Next.png",
|
SelectedImagePath = "MusicIcon/NextSelecte.png",
|
X = Application.GetRealWidth (550),
|
};
|
enddateRowLayout.AddChidren (btnenddateback);
|
if (startvalue != "" && endvalue != "") {
|
btnStartdate.Text = startvalue;
|
btndateEnddate.Text = endvalue;
|
|
btnStartdate.Tag = startvalue.Replace ("/", "");
|
btndateEnddate.Tag = endvalue.Replace ("/", "");
|
}
|
var y = DateTime.Now.ToString ("yyyy");
|
///起始日期点击事件
|
EventHandler<MouseEventArgs> startdateclick = (sender33, e33) => {
|
//var list = new List<KeyValuePair<string, string []>> { };
|
//for (int month = 1; month <= 12; month++) {
|
// int days = DateTime.DaysInMonth (DateTime.Now.Year, month);
|
// var listValues = new List<string> { };
|
// for (int day = 1; day <= days; day++) {
|
// listValues.Add (day.ToString () + " " + Language.StringByID (MyInternationalizationString.day));
|
// }
|
// list.Add (new KeyValuePair<string, string []> (month.ToString () + " " + Language.StringByID (MyInternationalizationString.month), listValues.ToArray ()));
|
//}
|
|
|
//PickerView.Show (list, (obj) => {
|
// var month = obj.Split (',') [0].Split (' ') [0];
|
// var day = obj.Split (',') [1].Split (' ') [0];
|
// if (month.Length < 2) {
|
// month = "0" + month;
|
// }
|
// if (day.Length < 2) {
|
// day = "0" + day;
|
// }
|
// var leng = month + day;
|
|
// if (btndateEnddate.Tag.ToString () != "0" && int.Parse (btndateEnddate.Tag.ToString ()) < int.Parse (leng)) {
|
// var alert = new Alert (Language.StringByID (MyInternationalizationString.Prompt),
|
// Language.StringByID (MyInternationalizationString.monthday),
|
// Language.StringByID (MyInternationalizationString.OK));
|
// alert.Show ();
|
// } else {
|
// btnStartdate.Text = month + "/" + day;
|
// btnStartdate.Tag = leng;
|
|
// if (string.IsNullOrEmpty (btndateEnddate.Text)) {
|
// btndateEnddate.Text = month + "/" + day;
|
// btndateEnddate.Tag = leng;
|
// }
|
|
// 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", "every_year");
|
// Logic.CurrentLogic.date.Add ("date",y+"/"+ btnStartdate.Text + "-" + y +"/" + btndateEnddate.Text);
|
|
|
// }
|
|
//}, Language.StringByID (MyInternationalizationString.complete),"");
|
|
};
|
startdateRowLayout.MouseUpEventHandler += startdateclick;
|
btnStartdate.MouseUpEventHandler += startdateclick;
|
startdatetext.MouseUpEventHandler += startdateclick;
|
btnStartdateback.MouseUpEventHandler += startdateclick;
|
|
///结束日期点击事件
|
EventHandler<MouseEventArgs> enddateclick = (sender1, e1) => {
|
|
//var list1 = new List<KeyValuePair<string, string []>> { };
|
//for (int month = 1; month <= 12; month++) {
|
// int days = DateTime.DaysInMonth (DateTime.Now.Year, month);
|
// var listValues = new List<string> { };
|
// for (int day = 1; day <= days; day++) {
|
// listValues.Add (day.ToString () + " " + Language.StringByID (MyInternationalizationString.day));
|
// }
|
// list1.Add (new KeyValuePair<string, string []> (month.ToString () + " " + Language.StringByID (MyInternationalizationString.month), listValues.ToArray ()));
|
//}
|
|
//PickerView.Show (list, (obj) => {
|
// var month = obj.Split (',') [0].Split (' ') [0];
|
// var day = obj.Split (',') [1].Split (' ') [0];
|
// if (month.Length < 2) {
|
// month = "0" + month;
|
// }
|
// if (day.Length < 2) {
|
// day = "0" + day;
|
// }
|
// var leng = month + day;
|
|
// if (btnStartdate.Tag.ToString () != "0" && int.Parse (btnStartdate.Tag.ToString ()) > int.Parse (leng)) {
|
// var alert = new Alert (Language.StringByID (MyInternationalizationString.Prompt),
|
// Language.StringByID (MyInternationalizationString.monthday),
|
// Language.StringByID (MyInternationalizationString.OK));
|
// alert.Show ();
|
// } else {
|
// btndateEnddate.Text = month + "/" + day;
|
// btndateEnddate.Tag = leng;
|
|
// if (string.IsNullOrEmpty (btnStartdate.Text)) {
|
// btnStartdate.Text = month + "/" + day;
|
// btnStartdate.Tag = leng;
|
// }
|
// 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", "every_year");
|
// Logic.CurrentLogic.date.Add ("date", y +"/" + btnStartdate.Text + "-" + y +"/" + btndateEnddate.Text);
|
// }
|
|
//}, Language.StringByID (MyInternationalizationString.complete),"");
|
|
|
};
|
enddateRowLayout.MouseUpEventHandler += enddateclick;
|
enddtaetext.MouseUpEventHandler += enddateclick;
|
btndateEnddate.MouseUpEventHandler += enddateclick;
|
btnenddateback.MouseUpEventHandler += enddateclick;
|
} else {
|
dateVerticalScrolViewLayout.Height = 0;
|
}
|
};
|
dateRowLayout.MouseUpEventHandler += dateclick;
|
btndate.MouseUpEventHandler += dateclick;
|
btndisplaydate.MouseUpEventHandler += dateclick;
|
btndateback.MouseUpEventHandler += dateclick;
|
|
|
if (Logic.CurrentLogic.date.ContainsKey ("type")) {
|
var type = Logic.CurrentLogic.date ["type"]?.ToString ();
|
switch (type) {
|
case "every_year": {
|
var datetext = Logic.CurrentLogic.date ["date"]?.ToString ();
|
if (datetext != "") {
|
string [] s = datetext.Split ('-');
|
var startmonth = datetext.Split ('-') [0].Split ('/') [1];
|
var startday = datetext.Split ('-') [0].Split ('/') [2];
|
if (startmonth.Length < 2) {
|
startmonth = "0" + startmonth;
|
}
|
if (startday.Length < 2) {
|
startday = "0" + startday;
|
}
|
|
var endmonth = datetext.Split ('-') [1].Split ('/') [1];
|
var endday = datetext.Split ('-') [1].Split ('/') [2];
|
if (endmonth.Length < 2) {
|
endmonth = "0" + endmonth;
|
}
|
if (endday.Length < 2) {
|
endday = "0" + endday;
|
}
|
|
startvalue = startmonth + "/" + startday;
|
endvalue = endmonth + "/" + endday;
|
|
if (s [0] == s [1]) {
|
btndisplaydate.Text = startmonth + "/" + startday;
|
} else {
|
btndisplaydate.Text = startmonth + "/" + startday + "-" + endmonth + "/" + endday;
|
}
|
}
|
}
|
break;
|
}
|
}
|
|
}
|
}
|
}
|