using System;
|
using System.Collections.Generic;
|
using Shared.SimpleControl.Phone.Music;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class AddSchedule : FrameLayout
|
{
|
VerticalScrolViewLayout bodyView;
|
FrameLayout devicesListView;
|
Action<Timer> action;
|
List<Common> roomDeviceList = new List<Common>();
|
List<string> roomNameList = new List<string> ();
|
List<DeviceInfo> timerControlDeviceList = new List<DeviceInfo> ();
|
|
public AddSchedule (Action<Timer> act)
|
{
|
action = act;
|
}
|
public override void RemoveFromParent ()
|
{
|
UserMiddle.SettingPageView.ScrollEnabled = true;
|
base.RemoveFromParent ();
|
}
|
|
public void ShowPage (Timer timerTemp, List<Timer> listTimer, bool isEdit = false)
|
{
|
UserMiddle.SettingPageView.ScrollEnabled = false;
|
timerTemp.RegionID = UserConfig.Instance.CurrentRegion.Id;
|
#region topview
|
var topView = new RowLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
AddChidren (topView);
|
|
var title = new Button () {
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Schedule,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextSize = 19,
|
};
|
topView.AddChidren (title);
|
|
var back = new Button () {
|
Height = Application.GetRealHeight (100),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
(Parent as PageLayout).PageIndex -= 1;
|
};
|
|
var logo = new Button () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
X = Application.GetRealWidth (486),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (logo);
|
#endregion
|
|
bodyView = new VerticalScrolViewLayout () {
|
Y = topView.Bottom,
|
Height = Application.GetRealHeight (1136 - 126 - 90),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
AddChidren (bodyView);
|
|
#region ---------nameView
|
var nameView = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
bodyView.AddChidren (nameView);
|
|
var btnName = new Button () {
|
X = Application.GetRealWidth (50),
|
Y = Application.GetRealHeight (20),
|
Width = Application.GetRealWidth (160),
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.LableName,
|
};
|
nameView.AddChidren (btnName);
|
|
var etName = new EditText () {
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (380),
|
Height = Application.GetRealHeight (60),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 1,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = timerTemp.TimerName
|
};
|
nameView.AddChidren (etName);
|
etName.EditorEnterAction += (obj) => {
|
Application.HideSoftInput ();
|
};
|
#endregion
|
|
#region --------time
|
var timeView = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
bodyView.AddChidren (timeView);
|
|
var btnTime = new Button () {
|
X = Application.GetRealWidth (50),
|
Width = Application.GetRealWidth (160),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Time,
|
};
|
timeView.AddChidren (btnTime);
|
|
var btnTimeIcon = new Button () {
|
X = btnTime.Right + Application.GetRealWidth (190),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealWidth (75),
|
UnSelectedImagePath = "CrabtreeAdd/Timer.png",
|
};
|
timeView.AddChidren (btnTimeIcon);
|
|
var btnTimelbl = new Button () {
|
X = btnTimeIcon.Right,
|
Width = Application.GetRealWidth (110),
|
Text = timerTemp.ExecutionTime,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
timeView.AddChidren (btnTimelbl);
|
|
btnTimelbl.MouseUpEventHandler += (timeSender, eee) => {
|
var dialog = new Dialog ();
|
var chooseTimeBodyView = new FrameLayout () {
|
};
|
dialog.AddChidren (chooseTimeBodyView);
|
|
var chooseTime = new TimeView () {
|
Y = Application.GetRealHeight (1136 - 420 - 90),
|
Height = Application.GetRealHeight (420),
|
BackgroundColor = 0xFFD7D7D7,
|
//BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
chooseTimeBodyView.AddChidren (chooseTime);
|
|
var bottomView = new FrameLayout () {
|
Y = chooseTime.Bottom,
|
Height = Application.GetRealHeight (90) + 1,
|
BackgroundColor = 0xFFD7D7D7,
|
};
|
chooseTimeBodyView.AddChidren (bottomView);
|
|
var btnCloseTime = new Button () {
|
Y = 1,
|
Width = Application.GetRealWidth (320),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
TextID = R.MyInternationalizationString.Close,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
bottomView.AddChidren (btnCloseTime);
|
btnCloseTime.MouseUpEventHandler += (ddf, dddf) => {
|
chooseTimeBodyView.RemoveAll ();
|
chooseTimeBodyView.RemoveFromParent ();
|
dialog.Close ();
|
};
|
|
var btnSaveTime = new Button () {
|
X = btnCloseTime.Right + 1,
|
Y = 1,
|
Width = Application.GetRealWidth (320),
|
TextID = R.MyInternationalizationString.SAVE,
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
bottomView.AddChidren (btnSaveTime);
|
btnSaveTime.MouseUpEventHandler += (sender3, e3) => {
|
var chooseHour = chooseTime.Hour - timerTemp.TimeZone;
|
var chooseTimeString = chooseTime.Hour.ToString ().PadLeft (2, '0') + ":" + chooseTime.Minute.ToString ().PadLeft (2, '0');
|
//if (chooseTime.Hour > 12) {
|
// chooseTimeString = (chooseTime.Hour -12) + ":" + chooseTime.Minute + " PM";
|
//} else {
|
// chooseTimeString = chooseTime.Hour + ":" + chooseTime.Minute + " AM";
|
//}
|
btnTimelbl.Text = chooseTimeString;
|
dialog.Close ();
|
};
|
|
|
dialog.Show ();
|
};
|
#endregion
|
|
#region --------Reapeat
|
var repeatView = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
bodyView.AddChidren (repeatView);
|
|
var btnRepeat = new Button () {
|
X = Application.GetRealWidth (50),
|
Width = Application.GetRealWidth (160),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Repeat,
|
};
|
repeatView.AddChidren (btnRepeat);
|
|
var btnSunday = new Button () {
|
X = btnRepeat.Right,
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "S",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("0"),
|
Tag = 0,
|
};
|
repeatView.AddChidren (btnSunday);
|
|
|
var btnMonday = new Button () {
|
X = btnSunday.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "M",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("1"),
|
Tag = 1,
|
};
|
repeatView.AddChidren (btnMonday);
|
|
|
var btnTuesday = new Button () {
|
X = btnMonday.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "T",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("2"),
|
Tag = 2,
|
};
|
repeatView.AddChidren (btnTuesday);
|
|
var btnWednesday = new Button () {
|
X = btnTuesday.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "W",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("3"),
|
Tag = 3,
|
};
|
repeatView.AddChidren (btnWednesday);
|
|
var btnThursday = new Button () {
|
X = btnWednesday.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "T",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("4"),
|
Tag = 4,
|
};
|
repeatView.AddChidren (btnThursday);
|
|
|
var btnFriday = new Button () {
|
X = btnThursday.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "F",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("5"),
|
Tag = 5,
|
};
|
repeatView.AddChidren (btnFriday);
|
|
|
var btnSaturday = new Button () {
|
X = btnFriday.Right + Application.GetRealWidth (15),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (45),
|
Height = Application.GetMinRealAverage (45),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = "S",
|
TextSize = 16,
|
Radius = (uint)Application.GetMinRealAverage (22),
|
BorderWidth = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
IsSelected = timerTemp.Periodicity.Contains ("6"),
|
Tag = 6,
|
};
|
repeatView.AddChidren (btnSaturday);
|
|
EventHandler<MouseEventArgs> repeatHandler = (sdd, s) => {
|
//EveryDay = 0, //每天
|
//WorkingDay, //工作日
|
//Weekend, //周末
|
//Week, //指定星期几
|
//Period, //指定时间段
|
//AppointDay, //指定日 Periodicity
|
(sdd as Button).IsSelected = !(sdd as Button).IsSelected;
|
|
};
|
btnMonday.MouseUpEventHandler += repeatHandler;
|
btnFriday.MouseUpEventHandler += repeatHandler;
|
btnThursday.MouseUpEventHandler += repeatHandler;
|
btnSunday.MouseUpEventHandler += repeatHandler;
|
btnTuesday.MouseUpEventHandler += repeatHandler;
|
btnSaturday.MouseUpEventHandler += repeatHandler;
|
btnWednesday.MouseUpEventHandler += repeatHandler;
|
|
#endregion
|
|
#region -----Room
|
var roomView = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
bodyView.AddChidren (roomView);
|
|
var btnRoom = new Button () {
|
X = Application.GetRealWidth (50),
|
Width = Application.GetRealWidth (160),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Room,
|
};
|
roomView.AddChidren (btnRoom);
|
|
var roomContenView = new FrameLayout () {
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (380),
|
Height = Application.GetRealHeight (60),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 1,
|
};
|
roomView.AddChidren (roomContenView);
|
|
var downSelectedButton = new Button () {
|
X = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (55),
|
UnSelectedImagePath = "Item/Down.png",
|
SelectedImagePath = "Item/DownSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
roomContenView.AddChidren (downSelectedButton);
|
|
var btnRoomChoose = new Button () {
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (380),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
roomContenView.AddChidren (btnRoomChoose);
|
|
roomNameList.Add ("ALL");
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
roomNameList.Add (room.Name);
|
if (timerTemp.RoomName == "ALL") {
|
roomDeviceList.AddRange (room.DeviceList);
|
} else {
|
if(timerTemp.RoomName == room.Name) {
|
roomDeviceList.Clear ();
|
roomDeviceList.AddRange (room.DeviceList);
|
}
|
}
|
}
|
if (roomNameList.Count > 0 && !isEdit) {
|
timerTemp.RoomName = roomNameList [0];
|
}
|
btnRoomChoose.Text = timerTemp.RoomName;
|
|
#endregion
|
|
#region Devices
|
try {
|
timerControlDeviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DeviceInfo>> (timerTemp.ControlDeviceData);//devicesControlDataList
|
} catch {
|
timerControlDeviceList = null;
|
}
|
|
if (timerControlDeviceList == null)
|
timerControlDeviceList = new List<DeviceInfo> ();
|
|
var devicesView = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
bodyView.AddChidren (devicesView);
|
|
var btnDeviceTitle = new Button () {
|
X = Application.GetRealWidth (50),
|
Width = Application.GetRealWidth (260),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.DeviceList,
|
};
|
devicesView.AddChidren (btnDeviceTitle);
|
|
devicesListView = new FrameLayout () {
|
Height = Application.GetRealHeight (130 * roomDeviceList.Count),
|
};
|
bodyView.AddChidren (devicesListView);
|
|
MainPage.Loading.Start ("Please wait...");
|
InitDeviceListView (roomDeviceList, timerControlDeviceList, devicesListView);
|
#endregion
|
|
|
#region -----Room
|
btnRoomChoose.MouseUpEventHandler += (sender, e) => {
|
Application.HideSoftInput ();
|
var roomDialog = new Dialog ();
|
var chooseRoomView = new FrameLayout () {
|
Animate = Animate.DownToUp,
|
};
|
chooseRoomView.MouseUpEventHandler += (sende1r, e1) => {
|
roomDialog.Close ();
|
};
|
roomDialog.AddChidren (chooseRoomView);
|
|
var chooseRoomTitleView = new FrameLayout () {
|
Y = Application.GetRealHeight (1136 - 360 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
chooseRoomView.AddChidren (chooseRoomTitleView);
|
|
var btnChooseRoomTitle = new Button () {
|
X = Application.GetRealWidth (40),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextID = R.MyInternationalizationString.ChooseRoom,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.CenterLeft
|
};
|
chooseRoomTitleView.AddChidren (btnChooseRoomTitle);
|
|
var roomListView = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight (1136 - 360),
|
Height = Application.GetRealHeight (360),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
chooseRoomView.AddChidren (roomListView);
|
|
foreach (var roomName in roomNameList) {
|
var btnRoomNameChoose = new Button () {
|
Height = Application.GetRealHeight (90),
|
Text = roomName,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
};
|
roomListView.AddChidren (btnRoomNameChoose);
|
|
var btnLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.BorderColor
|
};
|
roomListView.AddChidren (btnLine);
|
|
btnRoomNameChoose.MouseUpEventHandler += (sd, ds) => {
|
btnRoomChoose.Text = (sd as Button).Text;
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
if (btnRoomChoose.Text == "ALL") {
|
roomDeviceList.AddRange (room.DeviceList);
|
} else {
|
if (btnRoomChoose.Text == room.Name) {
|
roomDeviceList.Clear ();
|
roomDeviceList.AddRange (room.DeviceList);
|
}
|
}
|
}
|
timerControlDeviceList = new List<DeviceInfo> ();
|
InitDeviceListView (roomDeviceList, timerControlDeviceList, devicesListView);
|
roomDialog.Close ();
|
};
|
}
|
|
roomDialog.Show ();
|
};
|
#endregion
|
|
var saveTimeBottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (1136 - 90),
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
AddChidren (saveTimeBottomView);
|
|
var btnSaveTimerBottom = new Button () {
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.SAVE,
|
TextSize = 18,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
saveTimeBottomView.AddChidren (btnSaveTimerBottom);
|
|
btnSaveTimerBottom.MouseUpEventHandler += (ll, kk) => {
|
//WorkingDay, //工作日
|
//Weekend, //周末
|
//Week, //指定星期几
|
//Period, //指定时间段
|
//AppointDay, //指定日 Periodicity
|
|
if (btnMonday.IsSelected == false && btnFriday.IsSelected == false && btnThursday.IsSelected == false && btnSunday.IsSelected == false && btnTuesday.IsSelected == false && btnSaturday.IsSelected == false && btnWednesday.IsSelected == false) {
|
//new Alert ("", "请选择日期!", "Close").Show ();
|
new Alert ("", "Please select the days.", "Close").Show ();
|
return;
|
}
|
|
string mTimerName = etName.Text.Trim ();
|
if (string.IsNullOrEmpty (mTimerName)) {
|
//new Alert ("", "请填写定时器名称!", "Close").Show ();
|
new Alert ("", "Please fill the tab Lable name.", "Close").Show ();
|
return;
|
}
|
//else if (listTimer.Find ((obj) => obj.TimerName == timerTemp.TimerName) != null && !isEdit) {//2020-01-09 编辑的时候也提示重复名字
|
// //if (isEdit) {
|
|
// //}
|
// new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
|
// return;
|
//}
|
|
if (timerControlDeviceList.Count == 0) {
|
new Alert ("", "Please choose at least one device!", "Close").Show ();
|
return;
|
}
|
|
//名字重复判断限制
|
var mTimer = listTimer.Find ((obj) => obj.TimerName == mTimerName);
|
if (isEdit) {
|
if (mTimer != null && mTimer.Id != timerTemp.Id) {
|
new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
|
return;
|
}
|
} else {
|
if (mTimer != null) {
|
new Alert ("", "The timer name already exists. Please change it before saving it.", "Close").Show ();
|
return;
|
}
|
}
|
|
//2020-02-10 时间重复判断限制
|
string mExecutionTime = btnTimelbl.Text;
|
//timerTemp.ExecutionTime = btnTimelbl.Text;
|
var mTimerExecutionTime = listTimer.Find ((obj) => (obj.ExecutionTime == mExecutionTime));
|
if (isEdit) {
|
if (mTimerExecutionTime != null && mTimerExecutionTime.Id != timerTemp.Id) {
|
new Alert ("", "The timer time already exists. Please change it before saving it.", "Close").Show ();
|
return;
|
}
|
} else {
|
if (mTimerExecutionTime != null) {
|
new Alert ("", "The timer time already exists. Please change it before saving it.", "Close").Show ();
|
return;
|
}
|
}
|
|
timerTemp.Periodicity = "";
|
if (btnMonday.IsSelected == true && btnFriday.IsSelected == true && btnThursday.IsSelected == true && btnSunday.IsSelected == true && btnTuesday.IsSelected == true && btnSaturday.IsSelected == true && btnWednesday.IsSelected == true) {
|
timerTemp.TimerType = TimerType.EveryDay;
|
} else if (btnSunday.IsSelected == true && btnSaturday.IsSelected == true && btnMonday.IsSelected == false && btnFriday.IsSelected == false && btnThursday.IsSelected == false && btnTuesday.IsSelected == false && btnWednesday.IsSelected == false) {
|
timerTemp.TimerType = TimerType.Weekend;
|
} else if (btnSunday.IsSelected == false && btnSaturday.IsSelected == false && btnMonday.IsSelected == true && btnFriday.IsSelected == true && btnThursday.IsSelected == true && btnTuesday.IsSelected == true && btnWednesday.IsSelected) {
|
timerTemp.TimerType = TimerType.WorkingDay;
|
} else {
|
timerTemp.TimerType = TimerType.Week;
|
timerTemp.Periodicity = "";
|
}
|
if (btnSunday.IsSelected) {
|
timerTemp.Periodicity += "0,";
|
}
|
if (btnSaturday.IsSelected) {
|
timerTemp.Periodicity += "6,";
|
}
|
if (btnMonday.IsSelected) {
|
timerTemp.Periodicity += "1,";
|
}
|
if (btnFriday.IsSelected) {
|
timerTemp.Periodicity += "5,";
|
}
|
if (btnThursday.IsSelected) {
|
timerTemp.Periodicity += "4,";
|
}
|
if (btnTuesday.IsSelected) {
|
timerTemp.Periodicity += "2,";
|
}
|
if (btnWednesday.IsSelected) {
|
timerTemp.Periodicity += "3,";
|
}
|
|
if (timerTemp.Periodicity [timerTemp.Periodicity.Length - 1] == ',') {
|
timerTemp.Periodicity = timerTemp.Periodicity.Remove (timerTemp.Periodicity.Length - 1, 1);
|
}
|
|
|
|
timerTemp.IsStart = true;
|
if (string.IsNullOrEmpty (timerTemp.Id)) {
|
timerTemp.Id = Guid.NewGuid ().ToString ();
|
}
|
timerTemp.ControlDeviceData = Newtonsoft.Json.JsonConvert.SerializeObject (timerControlDeviceList);
|
MainPage.Loading.Start ("Saving...");
|
timerTemp.RoomName = btnRoomChoose.Text;
|
timerTemp.ExecutionTime = btnTimelbl.Text;
|
timerTemp.TimerName = etName.Text.Trim ();
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (timerTemp);
|
ResponsePack revertObj = null;
|
if (isEdit) {
|
revertObj = MainPage.RequestHttps (API.EditTimer, requestJson);
|
} else {
|
revertObj = MainPage.RequestHttps (API.AddTimer, requestJson);
|
}
|
|
Application.RunOnMainThread (() => {
|
if (revertObj == null) {
|
new Alert ("", "Unable to save data, please check the network.", "Close").Show ();
|
} else if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) {
|
this.RemoveFromParent ();
|
action (timerTemp);
|
} else {
|
ShowErrorInfo (revertObj.StateCode);
|
}
|
});
|
} catch (Exception ex) {
|
Utlis.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
}
|
|
|
|
/// <summary>
|
//(1)Success 则调用此接口成功
|
//(2)NoRecord 住宅未绑定网关!
|
//(3)NoExist 住宅不存在!
|
//(4)Exist 生成的Guid已存在!
|
/// </summary>
|
void ShowErrorInfo (string stateCodeStr)
|
{
|
string mes = "";
|
if (stateCodeStr == "NoRecord") {
|
// 住宅未绑定网关!
|
mes = ErrorCode.HomeNoRecord;
|
} else if (stateCodeStr == "NoExist") {
|
//住宅不存在!
|
mes = ErrorCode.HomeNoExist;
|
} else if (stateCodeStr == "Exist") {
|
//生成的Guid已存在!
|
mes = ErrorCode.GuidExist;
|
} else if (stateCodeStr == ErrorCode.NetworkError) {
|
mes = ErrorCode.NetworkError;
|
} else {
|
mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
|
|
}
|
if (!string.IsNullOrEmpty (mes)) {
|
//Application.RunOnMainThread (() => {
|
new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
//});
|
}
|
|
}
|
|
private static void InitDeviceListView (List<Common> roomDeviceList, List<DeviceInfo> timerControlDeviceList, FrameLayout devicesListView)
|
{
|
devicesListView.RemoveAll ();
|
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
int iniIndex = 0;
|
for (int i = 0; i < timerControlDeviceList.Count;) {
|
if (timerControlDeviceList [i] == null) {
|
timerControlDeviceList.RemoveAt (i);
|
} else {
|
i++;
|
}
|
}
|
|
#if __IOS__
|
|
|
#else
|
//刷新devicesListView 高度
|
devicesListView.Height = Application.GetRealHeight (130 * roomDeviceList.Count);
|
#endif
|
|
foreach (var deviceCommon2 in roomDeviceList) {
|
if (deviceCommon2 == null)
|
continue;
|
var deviceCommon = new DeviceInfo () {
|
DevicePath = deviceCommon2.SavePath, DeviceType = (int)deviceCommon2.Type, SubnetID = deviceCommon2.SubnetID,
|
DeviceID = deviceCommon2.DeviceID, LoopID = deviceCommon2.LoopID, Command = (int)Command.SetSingleLight,
|
Type = deviceCommon2.Type,Name = deviceCommon2.Name,SavePath = deviceCommon2.SavePath,
|
};
|
if (deviceCommon.Type == DeviceType.LightDimming || deviceCommon.Type == DeviceType.FanModule ||
|
deviceCommon.Type == DeviceType.LightSwitch || deviceCommon.Type == DeviceType.LightEnergySwitch || deviceCommon.Type == DeviceType.LightEnergySocket || deviceCommon.Type == DeviceType.LightSwitchSocket ||
|
deviceCommon.Type == DeviceType.CurtainModel || deviceCommon.Type == DeviceType.CurtainRoller || deviceCommon.Type == DeviceType.CurtainTrietex) {
|
Application.RunOnMainThread (() => {
|
try {
|
DeviceInfo timerControlDevice = null;
|
try {
|
timerControlDevice = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
|
} catch { }
|
if (timerControlDevice != null)
|
deviceCommon.SendBytes = timerControlDevice.SendBytes;
|
var DeviceRowView = new RowLayout () {
|
Y = Application.GetRealHeight (130 * iniIndex),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Height = Application.GetRealHeight (110),
|
Tag = deviceCommon.Type + "_" + deviceCommon.CommonLoopID
|
};
|
devicesListView.AddChidren (DeviceRowView);
|
iniIndex++;
|
|
var btnChoose = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "CrabtreeAdd/Choose.png",
|
SelectedImagePath = "CrabtreeAdd/ChooseOn.png",
|
IsSelected = timerControlDevice != null,
|
//Tag = deviceFilePath
|
};
|
DeviceRowView.AddChidren (btnChoose);
|
|
Button btnDeviceName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = Application.GetRealHeight (70),
|
Text = deviceCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnChoose.Right + Application.GetRealWidth (10),
|
Y = Application.GetRealHeight (20),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (btnDeviceName);
|
Button tempSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = deviceCommon.CommonLoopID,
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
|
|
if (deviceCommon.Type == DeviceType.FanModule) {
|
#region 风扇
|
tempSwitch.RemoveFromParent ();
|
//FanModule fanModule = deviceCommon as FanModule;
|
|
DeviceRowView.Height = Application.GetRealHeight (130);
|
btnChoose.Y = Application.GetRealHeight (5);
|
btnDeviceName.Y = Application.GetRealHeight (0);
|
|
var btnFanLevel = new Button () {
|
X = btnChoose.X + Application.GetRealWidth (10),
|
Y = btnChoose.Bottom,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (45),
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
Text = "OFF",
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
DeviceRowView.AddChidren (btnFanLevel);
|
|
var wi = Application.GetRealWidth (480 / 8);
|
for (int i = 0; i < 9; i++) {
|
var btnFanLevelTip = new Button () {
|
X = btnFanLevel.Right + wi * i - Application.GetRealWidth (0),
|
Y = btnFanLevel.Y - Application.GetRealHeight (5),
|
Width = wi,
|
Height = Application.GetRealHeight (27),
|
TextAlignment = TextAlignment.TopLeft,
|
Text = i.ToString (),
|
TextColor = SkinStyle.Current.TextColor1,
|
TextSize = 12,
|
};
|
DeviceRowView.AddChidren (btnFanLevelTip);
|
if (i == 0) {
|
btnFanLevelTip.Text = "OFF";
|
btnFanLevelTip.TextSize = 11;
|
}
|
}
|
|
var fanLevel = new HorizontalSeekBar () {
|
X = btnFanLevel.Right,
|
Y = btnFanLevel.Y + Application.GetRealHeight (10),
|
Width = Application.GetRealWidth (492),
|
Height = Application.GetRealHeight (45),
|
ThumbColor = SkinStyle.Current.ThumbColor,
|
ProgressColor = SkinStyle.Current.SelectedColor,
|
ThumbRadius = Application.GetRealWidth (3),
|
Max = 8,
|
Progress = 2,// (int)(deviceCommon.SendBytes[1]),
|
|
};
|
DeviceRowView.AddChidren (fanLevel);
|
fanLevel.ProgressChanged += (sender, e) => {
|
try {
|
if (!btnChoose.IsSelected) {
|
btnChoose.IsSelected = true;
|
}
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)(fanLevel.Progress) };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)fanLevel.Progress };
|
}
|
if (e == 0) {
|
btnFanLevel.Text = "OFF";
|
} else {
|
btnFanLevel.Text = "S" + e.ToString ();
|
}
|
} catch (Exception ex) {
|
Utlis.WriteLine ("ss1: " + ex.Message);
|
}
|
};
|
|
if (timerControlDevice != null) {
|
if (timerControlDevice.SendBytes [1] == 0) {
|
btnFanLevel.Text = "OFF";
|
} else {
|
btnFanLevel.Text = "S" + timerControlDevice.SendBytes [1].ToString ();
|
}
|
fanLevel.Progress = timerControlDevice.SendBytes [1];
|
}
|
|
fanLevel.MouseDownEventHandler += (sss, ff) => {
|
try {
|
timerControlDevice = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
|
if (!btnChoose.IsSelected) {
|
btnChoose.IsSelected = true;
|
}
|
if (timerControlDevice == null) {
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)(fanLevel.Progress) };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)fanLevel.Progress };
|
}
|
}
|
timerControlDevice.SendBytes [1] = (byte)fanLevel.Progress;
|
} catch { }
|
};
|
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)(fanLevel.Progress) };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)fanLevel.Progress };
|
}
|
} else {
|
timerControlDeviceList.Remove (timerControlDeviceList.Find ((obj) => obj.DeviceType == (int)deviceCommon.Type &&
|
obj.SubnetID == deviceCommon.SubnetID && obj.DeviceID == deviceCommon.DeviceID && obj.LoopID == deviceCommon.LoopID));
|
}
|
};
|
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightDimming || deviceCommon.Type == DeviceType.LightDALI) {
|
#region 调光器A
|
tempSwitch.RemoveFromParent ();
|
|
DeviceRowView.Height = Application.GetRealHeight (130);
|
btnChoose.Y = Application.GetRealHeight (20);
|
btnDeviceName.Y = Application.GetRealHeight (15);
|
|
var btnLevel = new Button () {
|
X = btnChoose.X + Application.GetRealWidth (10),
|
Y = btnChoose.Bottom,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (45),
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
Text = "OFF",
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
DeviceRowView.AddChidren (btnLevel);
|
|
var levelBar = new HorizontalSeekBar () {
|
X = btnLevel.Right,
|
Y = btnLevel.Y,
|
Width = Application.GetRealWidth (460),
|
Height = Application.GetRealHeight (45),
|
ThumbColor = SkinStyle.Current.ThumbColor,
|
ProgressColor = SkinStyle.Current.SelectedColor,
|
ThumbRadius = 6,
|
Max = 100,
|
};
|
DeviceRowView.AddChidren (levelBar);
|
levelBar.ProgressChanged += (sender, e) => {
|
if (!btnChoose.IsSelected) {
|
btnChoose.IsSelected = true;
|
}
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)levelBar.Progress };
|
//timerControlDevice = deviceCommon;
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)levelBar.Progress };
|
}
|
if (e == 0) {
|
btnLevel.Text = "OFF";
|
} else {
|
btnLevel.Text = e.ToString () + "%";
|
}
|
};
|
|
|
if (timerControlDevice != null) {
|
if (timerControlDevice.SendBytes [1] == 0) {
|
btnLevel.Text = "OFF";
|
} else {
|
btnLevel.Text = timerControlDevice.SendBytes [1].ToString () + "%";
|
}
|
levelBar.Progress = timerControlDevice.SendBytes [1];
|
}
|
|
levelBar.MouseDownEventHandler += (sss, ff) => {
|
try {
|
timerControlDevice = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
|
if (!btnChoose.IsSelected) {
|
btnChoose.IsSelected = true;
|
}
|
if (timerControlDevice == null) {
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)(levelBar.Progress) };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)levelBar.Progress };
|
}
|
}
|
} catch { }
|
};
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)(levelBar.Progress) };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)levelBar.Progress };
|
}
|
} else {
|
timerControlDeviceList.Remove (timerControlDeviceList.Find ((obj) => obj.DeviceType == (int)deviceCommon.Type &&
|
obj.SubnetID == deviceCommon.SubnetID && obj.DeviceID == deviceCommon.DeviceID && obj.LoopID == deviceCommon.LoopID));
|
}
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightSwitch || deviceCommon.Type == DeviceType.LightEnergySwitch || deviceCommon.Type == DeviceType.LightEnergySocket || deviceCommon.Type == DeviceType.LightSwitchSocket) {
|
#region 继电器
|
//LightSwitch switchLight = deviceCommon as LightSwitch;
|
//tempSwitch.IsSelected = switchLight.CurrentBrightness == 100 ? true : false;
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
var CurrentBrightness = 0;
|
if (tempSwitch.IsSelected) {
|
CurrentBrightness = 100;
|
} else {
|
CurrentBrightness = 0;
|
}
|
if (!btnChoose.IsSelected) {
|
btnChoose.IsSelected = true;
|
}
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
}
|
};
|
if (timerControlDevice != null) {
|
try {
|
tempSwitch.IsSelected = timerControlDevice.SendBytes [1] == 100;
|
} catch { }
|
}
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
var CurrentBrightness = 0;
|
if (tempSwitch.IsSelected) {
|
CurrentBrightness = 100;
|
} else {
|
CurrentBrightness = 0;
|
}
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null)
|
timerControlDeviceList.Add (deviceCommon);
|
else {
|
timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
}
|
} else {
|
timerControlDeviceList.Remove (timerControlDeviceList.Find ((obj) => obj.DeviceType == (int)deviceCommon.Type &&
|
obj.SubnetID == deviceCommon.SubnetID && obj.DeviceID == deviceCommon.DeviceID && obj.LoopID == deviceCommon.LoopID));
|
}
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.CurtainModel || deviceCommon.Type == DeviceType.CurtainTrietex || deviceCommon.Type == DeviceType.CurtainRoller) {
|
#region 窗帘
|
//2020-07-09 刷新控制操作码
|
deviceCommon.Command = (int)Command.UpdataCurtainModelStutas;
|
tempSwitch.RemoveFromParent ();
|
var tempSwitch1 = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 1,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.ButtonColor,
|
SelectedBackgroundColor = SkinStyle.Current.SelectedColor,
|
Text = "CLOSE",
|
Tag = deviceCommon.CommonLoopID,
|
};
|
DeviceRowView.AddChidren (tempSwitch1);
|
|
|
tempSwitch1.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch1.IsSelected = !tempSwitch1.IsSelected;
|
|
var CurrentBrightness = 0;
|
if (tempSwitch1.IsSelected) {
|
CurrentBrightness = 1;
|
tempSwitch1.Text = "OPEN";
|
tempSwitch1.BackgroundColor = SkinStyle.Current.SelectedColor;
|
} else {
|
CurrentBrightness = 2;
|
tempSwitch1.Text = "CLOSE";
|
tempSwitch1.BackgroundColor = SkinStyle.Current.ButtonColor;
|
}
|
if (!btnChoose.IsSelected) {
|
btnChoose.IsSelected = true;
|
}
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
//2020-07-09
|
DeviceInfo mDeviceInfo = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
|
if (mDeviceInfo == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
mDeviceInfo.Command = (int)Command.UpdataCurtainModelStutas;
|
mDeviceInfo.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
}
|
};
|
|
if (timerControlDevice != null) {
|
try {
|
if (timerControlDevice.SendBytes [1] == 1) {
|
tempSwitch1.Text = "OPEN";
|
tempSwitch1.IsSelected = true;
|
tempSwitch1.BackgroundColor = SkinStyle.Current.SelectedColor;
|
} else {
|
tempSwitch1.Text = "CLOSE";
|
tempSwitch1.IsSelected = false;
|
tempSwitch1.BackgroundColor = SkinStyle.Current.ButtonColor;
|
}
|
} catch { }
|
}
|
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
var CurrentBrightness = 0;
|
if (tempSwitch.IsSelected) {
|
CurrentBrightness = 1;
|
} else {
|
CurrentBrightness = 2;
|
}
|
deviceCommon.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
|
//if (timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath) == null) {
|
// timerControlDeviceList.Add (deviceCommon);
|
//} else {
|
// timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath).SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
//}
|
|
//2020-07-09
|
DeviceInfo mDeviceInfo = timerControlDeviceList.Find ((obj) => obj.DevicePath == deviceCommon.SavePath);
|
if (mDeviceInfo == null) {
|
timerControlDeviceList.Add (deviceCommon);
|
} else {
|
mDeviceInfo.Command = (int)Command.UpdataCurtainModelStutas;
|
mDeviceInfo.SendBytes = new byte [] { deviceCommon.LoopID, (byte)CurrentBrightness };
|
}
|
} else {
|
timerControlDeviceList.Remove (timerControlDeviceList.Find ((obj) => obj.DeviceType == (int)deviceCommon.Type &&
|
obj.SubnetID == deviceCommon.SubnetID && obj.DeviceID == deviceCommon.DeviceID && obj.LoopID == deviceCommon.LoopID));
|
}
|
};
|
#endregion
|
}
|
}catch(Exception ex) {
|
Utlis.WriteLine ("AddSchedule error : "+ ex.Message);
|
}
|
});
|
}
|
}
|
} catch (Exception ex) {
|
Utlis.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
}
|
}
|
}
|