using System;
|
using System.Collections.Generic;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class AddSchedule : FrameLayout
|
{
|
VerticalScrolViewLayout bodyView;
|
Action<Timer> action;
|
|
public AddSchedule (Action<Timer> act)
|
{
|
action = act;
|
}
|
|
public void ShowPage (Timer timerTemp,bool isEdit = false)
|
{
|
#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 (Application.DesignHeight - 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),
|
Width = Application.GetRealWidth (160),
|
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);
|
#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.GetRealHeight (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 (Application.DesignHeight - 420 -90),
|
Height = Application.GetRealHeight(420),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
chooseTimeBodyView.AddChidren (chooseTime);
|
|
var bottomView = new FrameLayout () {
|
Y = chooseTime.Bottom,
|
Height = Application.GetRealHeight(90) + 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
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";
|
//}
|
timerTemp.ExecutionTime = 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);
|
var roomDeviceList = new List<Common> { };
|
var roomNameList = new List<string> ();
|
foreach (var room in Room.Lists) {
|
if (string.IsNullOrEmpty (room.Name)) {
|
continue;
|
}
|
roomNameList.Add (room.Name);
|
roomDeviceList.AddRange (room.DeviceList);
|
}
|
if (roomNameList.Count > 0 && !isEdit) {
|
timerTemp.RoomName = roomNameList [0];
|
}
|
btnRoomChoose.Text = timerTemp.RoomName;
|
btnRoomChoose.MouseUpEventHandler += (sender, e) => {
|
var roomDialog = new Dialog ();
|
var chooseRoomView = new FrameLayout () {
|
Animate = Animate.DownToUp,
|
};
|
chooseRoomView.MouseUpEventHandler += (sende1r, e1) => {
|
roomDialog.Close ();
|
};
|
roomDialog.AddChidren (chooseRoomView);
|
|
|
var btnChooseRoomTitle = new Button () {
|
Y = Application.GetRealHeight (Application.DesignHeight - 360 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextID = R.MyInternationalizationString.ChooseRoom,
|
TextColor = SkinStyle.Current.TextColor1,
|
//TextAlignment = TextAlignment.Center,
|
Padding = new Padding(0,0,0,(int)Application.GetRealWidth(470))
|
};
|
chooseRoomView.AddChidren (btnChooseRoomTitle);
|
|
var roomListView = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight (Application.DesignHeight - 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 = timerTemp.RoomName = (sd as Button).Text;
|
roomDialog.Close ();
|
};
|
}
|
|
//var bottomView = new FrameLayout () {
|
// Y = roomListView.Bottom,
|
// Height = Application.GetRealHeight (90) + 1,
|
// BackgroundColor = SkinStyle.Current.ViewColor,
|
//};
|
//chooseRoomView.AddChidren (bottomView);
|
|
//var btnCloseTime = new Button () {
|
// Y = 1,
|
// Width = Application.GetRealWidth (320),
|
// BackgroundColor = SkinStyle.Current.MainColor,
|
// TextID = R.MyInternationalizationString.Close,
|
// TextAlignment = TextAlignment.Center,
|
// TextColor = SkinStyle.Current.TextColor1,
|
//};
|
//bottomView.AddChidren (btnCloseTime);
|
//btnCloseTime.MouseUpEventHandler += (ddf, dddf) => {
|
// roomDialog.Close ();
|
//};
|
|
//var btnSaveTime = new Button () {
|
// X = btnCloseTime.Right + 1,
|
// Y = 1,
|
// Width = Application.GetRealWidth (320),
|
// TextID = R.MyInternationalizationString.SAVE,
|
// TextAlignment = TextAlignment.Center,
|
// BackgroundColor = SkinStyle.Current.MainColor,
|
// TextColor = SkinStyle.Current.TextColor1,
|
//};
|
//bottomView.AddChidren (btnSaveTime);
|
//btnSaveTime.MouseUpEventHandler += (sender3, e3) => {
|
// timerTemp.RoomName = chooseRoomName;
|
// btnRoomChoose.Text = chooseRoomName;
|
// roomDialog.Close ();
|
//};
|
|
roomDialog.Show ();
|
};
|
|
#endregion
|
|
#region Devices
|
var devicesControlDataList = 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 (160),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.DeviceList,
|
};
|
devicesView.AddChidren (btnDeviceTitle);
|
|
var devicesListView = new VerticalScrolViewLayout () {
|
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 110),
|
};
|
bodyView.AddChidren (devicesListView);
|
|
foreach (var deviceCommon in roomDeviceList) {
|
if (deviceCommon == null)
|
continue;
|
|
if (deviceCommon.Type == DeviceType.FoolHeat || deviceCommon.Type == DeviceType.FoolHeatPanel ||
|
deviceCommon.Type == DeviceType.HVAC || deviceCommon.Type == DeviceType.ACInfrared || deviceCommon.Type == DeviceType.ACPanel ||
|
deviceCommon.Type == DeviceType.FreshAir) {
|
continue;
|
} else {
|
var DeviceRowView = new RowLayout () {
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Height = Application.GetRealHeight (110),
|
Tag = deviceCommon.Type + "_" + deviceCommon.CommonLoopID
|
};
|
devicesListView.AddChidren (DeviceRowView);
|
|
|
var btnChoose = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (50),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "CrabtreeAdd/Choose.png",
|
SelectedImagePath = "CrabtreeAdd/ChooseOn.png",
|
//IsSelected = showList.Contains (deviceFilePath),
|
//Tag = deviceFilePath
|
};
|
DeviceRowView.AddChidren (btnChoose);
|
|
|
//Button btnIcon = new Button () {
|
// Width = Application.GetRealHeight (60),
|
// Height = Application.GetRealHeight (60),
|
// X = Application.GetRealWidth (30),
|
// Gravity = Gravity.CenterVertical
|
//};
|
//DeviceRowView.AddChidren (btnIcon);
|
Button btnDeviceName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = deviceCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnChoose.Right + Application.GetRealWidth (10),
|
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 风扇
|
FanModule fanModule = deviceCommon as FanModule;
|
|
tempSwitch.IsSelected = fanModule.Switch == 0 ? false : true;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
|
if (tempSwitch.IsSelected) {
|
Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch });
|
} else {
|
Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, 0 });
|
}
|
};
|
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
var tempCommon = new DeviceInfo () {
|
DevicePath = deviceCommon.SavePath, DeviceType = (int)deviceCommon.Type, SubnetID = deviceCommon.SubnetID,
|
DeviceID = deviceCommon.DeviceID, LoopID = deviceCommon.LoopID, Command = (int)Command.SetSingleLight,
|
SendBytes = new byte [] { fanModule.LoopID, (byte)(tempSwitch.IsSelected == true ? fanModule.Switch : 0) }
|
};
|
devicesControlDataList.Add (tempCommon);
|
} else {
|
devicesControlDataList.Remove (devicesControlDataList.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 || deviceCommon.Type == DeviceType.LightRGB) {
|
#region 调光器A
|
LightDimming dimming = deviceCommon as LightDimming;
|
|
//进度条
|
var tempLightSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (440 - 20),
|
Height = Application.GetRealHeight (130 - 20),
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (20),
|
Visible = dimming.DimmingFunction,
|
Tag = DateTime.MinValue,
|
Progress = dimming.CurrentBrightness,
|
ThumbColor = SkinStyle.Current.ThumbColor
|
};
|
DeviceRowView.AddChidren (tempLightSeekBar);
|
|
//开关按键
|
tempSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Y = Application.GetRealHeight (50),
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
|
tempLightSeekBar.ProgressChanged += (senderp, ep) => {
|
if ((System.DateTime.Now - (DateTime)(tempLightSeekBar.Tag)).TotalMilliseconds < 500) {
|
return;
|
}
|
tempLightSeekBar.Tag = DateTime.Now;
|
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, (byte)ep, 0, 0 }, SendCount.Zero);
|
if (tempLightSeekBar.Progress > 0) {
|
tempSwitch.IsSelected = true;
|
} else {
|
tempSwitch.IsSelected = false;
|
}
|
dimming.CurrentBrightness = (byte)ep;
|
};
|
tempLightSeekBar.MouseUpEventHandler += (sender1, e1) => {
|
//弹起的时候发最后的数据
|
tempLightSeekBar.Tag = DateTime.Now;
|
dimming.LastOpenBrightness = Convert.ToByte (tempLightSeekBar.Progress);
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, (byte)tempLightSeekBar.Progress, 0, 0 });
|
if (tempLightSeekBar.Progress > 0) {
|
tempSwitch.IsSelected = true;
|
} else {
|
tempSwitch.IsSelected = false;
|
}
|
dimming.CurrentBrightness = (byte)tempLightSeekBar.Progress;
|
};
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (dimming.LastOpenBrightness == 0) {
|
dimming.LastOpenBrightness = 100;
|
}
|
if (tempSwitch.IsSelected) {
|
tempLightSeekBar.Progress = dimming.LastOpenBrightness;
|
} else {
|
tempLightSeekBar.Progress = 0;
|
}
|
dimming.CurrentBrightness = (byte)tempLightSeekBar.Progress;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurrentBrightness, 0,0 });
|
};
|
if (dimming.CurrentBrightness > 0) {
|
tempSwitch.IsSelected = true;
|
}
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
var tempCommon = new DeviceInfo () {
|
DevicePath = deviceCommon.SavePath, DeviceType = (int)deviceCommon.Type, SubnetID = deviceCommon.SubnetID,
|
DeviceID = deviceCommon.DeviceID, LoopID = deviceCommon.LoopID, Command = (int)Command.SetSingleLight,
|
SendBytes = new byte [] { dimming.LoopID, dimming.CurrentBrightness }
|
};
|
devicesControlDataList.Add (tempCommon);
|
} else {
|
devicesControlDataList.Remove (devicesControlDataList.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.LightSwitchSocket) {
|
#region 继电器
|
LightSwitch switchLight = deviceCommon as LightSwitch;
|
tempSwitch.IsSelected = switchLight.CurrentBrightness == 100 ? true : false;
|
|
if (deviceCommon.Type == DeviceType.LightEnergySwitch) {
|
Button btnEnergy = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (30),
|
X = tempSwitch.X,
|
Y = tempSwitch.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = DeviceType.LightEnergySwitch.ToString (),
|
Text = "0 W"
|
};
|
DeviceRowView.AddChidren (btnEnergy);
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
switchLight.CurrentBrightness = 100;
|
Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 100, 0, 0 });
|
} else {
|
switchLight.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 0, 0, 0 });
|
}
|
};
|
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
var tempCommon = new DeviceInfo () {
|
DevicePath = deviceCommon.SavePath, DeviceType = (int)deviceCommon.Type, SubnetID = deviceCommon.SubnetID,
|
DeviceID = deviceCommon.DeviceID, LoopID = deviceCommon.LoopID, Command = (int)Command.SetSingleLight,
|
SendBytes = new byte [] { switchLight.LoopID, switchLight.CurrentBrightness }
|
};
|
devicesControlDataList.Add (tempCommon);
|
} else {
|
devicesControlDataList.Remove (devicesControlDataList.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 窗帘
|
CurtainModel curtain = deviceCommon as CurtainModel;
|
tempSwitch.IsSelected = true;
|
curtain.Status = (CurtainStatus)1;
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
curtain.Status = (CurtainStatus)1;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 1 });
|
} else {
|
curtain.Status = (CurtainStatus)2;
|
Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 2 });
|
}
|
};
|
|
btnChoose.MouseUpEventHandler += (dds, ddss) => {
|
btnChoose.IsSelected = !btnChoose.IsSelected;
|
if (btnChoose.IsSelected) {
|
var tempCommon = new DeviceInfo () {
|
DevicePath = deviceCommon.SavePath, DeviceType = (int)curtain.Type, SubnetID = deviceCommon.SubnetID,
|
DeviceID = deviceCommon.DeviceID, LoopID = deviceCommon.LoopID, Command = (int)Command.UpdataCurtainModelStutas,
|
SendBytes = new byte [] { curtain.LoopID, (byte)curtain.Status }
|
};
|
devicesControlDataList.Add (tempCommon);
|
} else {
|
devicesControlDataList.Remove (devicesControlDataList.Find ((obj) => obj.DeviceType == (int)deviceCommon.Type &&
|
obj.SubnetID == deviceCommon.SubnetID && obj.DeviceID == deviceCommon.DeviceID && obj.LoopID == deviceCommon.LoopID));
|
}
|
};
|
#endregion
|
|
}
|
}
|
}
|
|
#endregion
|
|
var saveTimeBottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (Application.DesignHeight - 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
|
timerTemp.TimerName = etName.Text.Trim ();
|
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 setting date!", "Close").Show ();
|
return;
|
}
|
if (string.IsNullOrEmpty (timerTemp.TimerName)) {
|
//new Alert ("", "请填写定时器名称!", "Close").Show ();
|
new Alert ("", "Please set name for the timer!", "Close").Show ();
|
return;
|
}
|
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;
|
timerTemp.Guid = Guid.NewGuid ().ToString ();
|
MainPage.Loading.Start ("Saving...");
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (timerTemp);
|
ResponsePack revertObj = null;
|
if (isEdit) {
|
revertObj = MainPage.RequestHttps ("EditTimer", requestJson);
|
} else {
|
revertObj = MainPage.RequestHttps ("AddTimer", requestJson);
|
}
|
|
Application.RunOnMainThread (() => {
|
if (revertObj.StateCode == "SUCCESS") {
|
this.RemoveFromParent ();
|
action (timerTemp);
|
}
|
});
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
}
|
}
|
}
|