using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.UserView;
namespace Shared.Phone.Device.Category
{
public class SelectDevice : FrameLayout
{
#region ◆ 变量____________________________
///
/// bodyFrameLayout
///
private FrameLayout bodyFrameLayout;
///
/// selectedTimeAction
///
public Action selectedAction;
///
/// sceneTargetDevice
///
public SceneTargetDeviceUI sceneTargetDevice;
///
/// BeforesceneTargetDeviceUIs
///
public List beforeSceneTargetDeviceUIs = new List { };
///
/// 楼层
///
private Button floorBtn;
///
/// 选择楼层
///
private Button selectFloorBtn;
///
/// 场景功能中部背景bodyView
///
public FrameLayout functionSceneBodyView;
///
/// deviceUI
///
public DeviceUI deviceUI;
///
/// 功能类型
///
private HorizontalScrolViewLayout functionTypeScrowView;
///
/// 相同的设备列表
///
public VerticalScrolViewLayout deviceListScrolView;
///
/// 当前功能类型按钮
///
private FunctionButton tempFunctionTypeBtn;
///
/// 设备类型RowLayout
///
private FrameLayout typeRowLayout;
///
/// 功能类型按钮
///
private FunctionButton functionTypeIMG;
///
/// 温度
///
private int tempId;
///
/// 模式
///
private int modelId;
///
/// 风速
///
private int fanid;
#endregion
public override void RemoveFromParent()
{
HomePage.Instance.ScrollEnabled = true;
base.RemoveFromParent();
}
///
/// SelectDevice
///
public SelectDevice()
{
HomePage.Instance.ScrollEnabled = false;
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
}
///
/// Show
///
public void Show()
{
if (sceneTargetDevice == null)
{
sceneTargetDevice = new SceneTargetDeviceUI { Type = 0 };
}
AddTop();
AddBodyView();
RefreshBodyView(Config.Instance.Home.CurrentFloorId);
}
#region Add____________________________________
///
/// AddTop
///
private void AddTop()
{
var top = new TopFrameLayout();
AddChidren(top);
top.InitTopview();
top.SetTopTitle(R.MyInternationalizationString.AddScence);
top.backButton.MouseUpEventHandler += (sender, e) =>
{
RemoveFromParent();
};
floorBtn = new Button()
{
X = Application.GetRealWidth(750),
Width = Application.GetRealWidth(200),
Height = Application.GetRealHeight(60),
Gravity = Gravity.CenterVertical,
TextAlignment = TextAlignment.CenterRight,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
};
selectFloorBtn = new Button()
{
X = Application.GetRealWidth(950),
Width = Application.GetMinRealAverage(69),
Height = Application.GetMinRealAverage(69),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "Item/Drop_Down.png"
};
if (Config.Instance.Home.FloorDics.Count > 0)
{
floorBtn.Text = Config.Instance.Home.GetCurrentFloorName;
top.topView.AddChidren(floorBtn);
top.topView.AddChidren(selectFloorBtn);
floorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler;
selectFloorBtn.MouseUpEventHandler += SelectedFloor_MouseUpEventHandler;
}
}
///
/// 选择楼层
///
/// Sender.
/// The ${ParameterType} instance containing the event data.
private void SelectedFloor_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
{
var floors = new SelectFloor();
AddChidren(floors);
floors.Init(580, 184, Direction.Right);
floors.FloorAction += (floorId) =>
{
floorBtn.Text = Config.Instance.Home.GetFloorNameById(floorId);
RefreshBodyView(floorId);
};
}
///
/// AddBodyView
///
private void AddBodyView()
{
bodyFrameLayout = new FrameLayout()
{
Y = Application.GetRealHeight(184),
Height = Application.GetRealHeight(1737),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
};
AddChidren(bodyFrameLayout);
}
#endregion
///
/// RefreshBodyView
///
private void RefreshBodyView(string floorId)
{
AddRoomView(floorId);
}
///
/// AddRoomView
///
private void AddRoomView(string floorId)
{
var roomFL = new HorizontalScrolViewLayout()
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Height = Application.GetRealHeight(204),
Width = Application.GetRealWidth(CommonPage.AppRealWidth - CommonFormResouce.X_Left),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
};
bodyFrameLayout.AddChidren(roomFL);
//功能和场景bodyView
functionSceneBodyView = new FrameLayout()
{
Y = roomFL.Bottom,
Height = Application.GetRealHeight(910 + 622),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
};
bodyFrameLayout.AddChidren(functionSceneBodyView);
Button curBtn = new Button();
foreach (var room in Common.Room.CurrentRoom.GetRoomsByFloorIdAppendLoveRoom(floorId))
{
var row = new FrameLayout()
{
Width = Application.GetRealWidth(187 + 50),
Height = Application.GetRealHeight(204),
};
roomFL.AddChidren(row);
var roomBtn = new Button()
{
Width = Application.GetRealWidth(187),
Height = Application.GetRealHeight(78),
Radius = (uint)Application.GetRealHeight(78 / 2),
Gravity = Gravity.Center,
Text = room.Name,
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor,
BackgroundColor = ZigbeeColor.Current.GXCButtonUnSelectedColor3,
SelectedBackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor,
BorderColor = ZigbeeColor.Current.GXCBorderUnSelectedColor,
BorderWidth = 1
};
row.AddChidren(roomBtn);
if (room.IsLove)
{
roomBtn.IsSelected = true;
curBtn = roomBtn;
RefreshFunction(room);
}
roomBtn.MouseUpEventHandler += (sender, e) =>
{
if ((sender as Button) == curBtn)
{
return;
}
(sender as Button).IsSelected = true;
curBtn.IsSelected = false;
curBtn = sender as Button;
RefreshFunction(room);
};
}
if (deviceUI != null)
{
ShowSelectAction(deviceUI, sceneTargetDevice);
}
}
///
/// RefreshFunction
///
///
private void RefreshFunction(Common.Room room)
{
functionSceneBodyView.RemoveAll();
if (room.DeviceUIList.Count == 0)
{
ShowNoFunctionTip();
}
else
{
functionTypeScrowView = new HorizontalScrolViewLayout
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Height = Application.GetRealHeight(279),
Width = Application.GetRealWidth(1028),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
functionSceneBodyView.AddChidren(functionTypeScrowView);
deviceListScrolView = new VerticalScrolViewLayout
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Y = functionTypeScrowView.Bottom + Application.GetRealHeight(50),
Width = Application.GetRealWidth(1028),
Height = functionSceneBodyView.Height - Application.GetRealHeight(279 + 50) - 1,
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
functionSceneBodyView.AddChidren(deviceListScrolView);
tempFunctionTypeBtn = new FunctionButton();
EventHandler ShowSameTypeFunction = (object typeSender, MouseEventArgs mouseEventArgs) =>
{
tempFunctionTypeBtn.IsSelected = false;
tempFunctionTypeBtn = (typeSender as Button).Parent as FunctionButton;
((typeSender as Button).Parent as FunctionButton).IsSelected = true;
deviceListScrolView.RemoveAll();
var sameTypeList = new List { };
foreach (var devieceUI in room.DeviceUIList)
{
if (devieceUI == null || devieceUI.CommonDevice == null)
{
continue;
}
if (devieceUI.CommonDevice.Type.ToString() == (typeSender as Button).Tag.ToString())
{
if (!sameTypeList.Contains(devieceUI))
{
sameTypeList.Add(devieceUI);
}
}
}
foreach (var device in sameTypeList)
{
if (beforeSceneTargetDeviceUIs.Find((obj) => obj.DeviceUI.DeviceEpoint == device.DeviceEpoint && obj.DeviceUI.DeviceAddr == device.DeviceAddr) != null)
{
continue;
}
var deviceTypeRowLayout = new FrameLayout()
{
Height = Application.GetRealHeight(127 + 35),
Tag = device
};
deviceListScrolView.AddChidren(deviceTypeRowLayout);
var deviceRow = new FunctionRow(0, 35);
deviceTypeRowLayout.AddChidren(deviceRow);
deviceRow.Init(device.IconPath, device.OnlineIconPath,true);
deviceRow.SetTitle(device.CommonDevice.DeviceEpointName);
deviceRow.SetStatu(device.CommonDevice.IsOnline == 1);
deviceRow.HideSwitchBtn(false);
deviceRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
{
ShowSelectAction(device, sceneTargetDevice);
};
}
};
foreach (var deviceType in Common.Room.GetdeviceTypes(room))
{
typeRowLayout = new FrameLayout()
{
Width = Application.GetRealWidth(CommonPage.AppRealWidth / 5),
Tag = deviceType
};
functionTypeScrowView.AddChidren(typeRowLayout);
functionTypeIMG = new FunctionButton()
{
Tag = deviceType
};
functionTypeIMG.Init(DeviceUI.GetDeviceTypeUnSelectedImagePath(deviceType), DeviceUI.GetDeviceTypeUnSelectedImagePath(deviceType));
functionTypeIMG.SetTitle(DeviceUI.GetDeviceTypeName(deviceType));
typeRowLayout.AddChidren(functionTypeIMG);
functionTypeIMG.ClickBtn.MouseUpEventHandler += ShowSameTypeFunction;
if (deviceType == room.DeviceUIList[0].CommonDevice.Type)
{
ShowSameTypeFunction(functionTypeIMG.ClickBtn, null);
}
}
}
}
///
/// 提示没有功能
///
private void ShowNoFunctionTip()
{
var noFunction = new Button()
{
Y = Application.GetRealHeight(320),
Width = Application.GetMinRealAverage(757),
Height = Application.GetMinRealAverage(435),
UnSelectedImagePath = "Item/NoFunction.png",
Gravity = Gravity.CenterHorizontal
};
functionSceneBodyView.AddChidren(noFunction);
var noFunctionTip = new Button()
{
Y = noFunction.Bottom + Application.GetRealHeight(32),
Height = Application.GetRealHeight(200),
Width = Application.GetRealWidth(700),
Gravity = Gravity.CenterHorizontal,
Text = Language.StringByID(R.MyInternationalizationString.NoFunction).Replace("{\\r\\n}", "\r\n"),
TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
TextAlignment = TextAlignment.Center,
IsMoreLines = true
};
functionSceneBodyView.AddChidren(noFunctionTip);
}
///
/// ShowSelectAction
///
///
private void ShowSelectAction(DeviceUI device, SceneTargetDeviceUI sceneTarget)
{
var dialog = new FrameLayout()
{
BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
};
AddChidren(dialog);
dialog.MouseUpEventHandler += (sender, e) =>
{
dialog.RemoveFromParent();
};
if (device.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput)
{
SelectOnoffOutput(dialog, device, sceneTarget);
}
else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch)
{
SelectOnoffOutput(dialog, device, sceneTarget);
}
else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DimmableLight)
{
SelectDimmableLight(dialog, device, sceneTarget);
}
else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.WindowCoveringDevice)
{
SelectWindowCoveringDevice(dialog, device, sceneTarget);
}
else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.Thermostat)
{
SelectThermostat(dialog, device, sceneTarget);
}
}
///
/// 灯光
///
///
///
///
private void SelectOnoffOutput(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget)
{
var selectFL = new FrameLayout
{
Y = Application.GetRealHeight(1391),
Height = Application.GetRealHeight(530),
};
dialog.AddChidren(selectFL);
selectFL.Animate = Animate.DownToUp;
var titleBG = new FrameLayout
{
Height = Application.GetRealHeight(138 * 2),
Radius = (uint)Application.GetRealHeight(20),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(titleBG);
var titleFL = new FrameLayout
{
Height = Application.GetRealHeight(138),
};
selectFL.AddChidren(titleFL);
var line = new Button
{
Y = titleFL.Height - 1,
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
};
titleFL.AddChidren(line);
var cancleBtn = new Button
{
X = Application.GetRealWidth(80),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(400),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
Text = device.CommonDevice.DeviceEpointName
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 15,
TextAlignment = TextAlignment.CenterRight,
TextID = R.MyInternationalizationString.Complete
};
titleFL.AddChidren(comfrimBtn);
var itemFL = new FrameLayout
{
Y = titleFL.Bottom,
Height = Application.GetRealHeight(392),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(itemFL);
var open = new SelectSceneStatuRow(0, 60);
itemFL.AddChidren(open);
open.Init();
open.SetTitle(R.MyInternationalizationString.Open);
open.IsSelected = true;
var shut = new SelectSceneStatuRow(0, 60 + 127 + 30);
itemFL.AddChidren(shut);
shut.Init();
shut.hideLine(true);
shut.SetTitle(R.MyInternationalizationString.Shut);
open.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
};
shut.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = false;
shut.IsSelected = true;
};
cancleBtn.MouseUpEventHandler = (sender, e) =>
{
dialog.RemoveAll();
dialog.RemoveFromParent();
};
if (sceneTarget.TaskList.Count > 0)
{
if (sceneTarget.TaskList[0].Data1 == 1)
{
open.IsSelected = true;
shut.IsSelected = false;
}
else
{
open.IsSelected = false;
shut.IsSelected = true;
}
}
comfrimBtn.MouseUpEventHandler = (sender, e) =>
{
var taskList = new List { };
int taskType = 1;
int data1 = 0;
int data2 = 0;
if (open.IsSelected)
{
//开
data1 = 1;
data2 = 0;
}
else
{
//关
data1 = 0;
data2 = 0;
}
var taskInfo = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = data1,
Data2 = data2
};
taskList.Add(taskInfo);
sceneTargetDevice.TaskList = taskList;
sceneTargetDevice.DeviceUI = device;
selectedAction?.Invoke(sceneTargetDevice);
RemoveFromParent();
};
}
///
/// 窗帘
///
///
///
///
private void SelectWindowCoveringDevice(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget)
{
var selectFL = new FrameLayout
{
Y = Application.GetRealHeight(1169),
Height = Application.GetRealHeight(752),
};
dialog.AddChidren(selectFL);
selectFL.Animate = Animate.DownToUp;
var titleBG = new FrameLayout
{
Height = Application.GetRealHeight(138 * 2),
Radius = (uint)Application.GetRealHeight(20),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(titleBG);
var titleFL = new FrameLayout
{
Height = Application.GetRealHeight(138),
};
selectFL.AddChidren(titleFL);
var line = new Button
{
Y = titleFL.Height - 1,
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
};
titleFL.AddChidren(line);
var cancleBtn = new Button
{
X = Application.GetRealWidth(80),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(400),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
Text = device.CommonDevice.DeviceEpointName
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 15,
TextAlignment = TextAlignment.CenterRight,
TextID = R.MyInternationalizationString.Complete
};
titleFL.AddChidren(comfrimBtn);
var itemFL = new FrameLayout
{
Y = titleFL.Bottom,
Height = Application.GetRealHeight(613),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(itemFL);
var open = new SelectDeviceWithSeekBarRow(0, 60);
itemFL.AddChidren(open);
open.Init();
open.SetTitle(R.MyInternationalizationString.Open);
open.IsSelected = true;
var shut = new SelectSceneStatuRow(0, 60 + 348 + 30);
itemFL.AddChidren(shut);
shut.Init();
shut.hideLine(true);
shut.SetTitle(R.MyInternationalizationString.Shut);
open.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
};
shut.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = false;
shut.IsSelected = true;
};
cancleBtn.MouseUpEventHandler = (sender, e) =>
{
dialog.RemoveAll();
dialog.RemoveFromParent();
};
open.SeekBar.ProgressChanged += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
open.SetSeekBarTitle();
};
if (sceneTarget.TaskList.Count > 0)
{
if (sceneTarget.TaskList[0].Data1 == 0)
{
open.IsSelected = false;
shut.IsSelected = true;
}
else
{
open.IsSelected = true;
shut.IsSelected = false;
open.SetProgress(sceneTarget.TaskList[0].Data1);
}
}
comfrimBtn.MouseUpEventHandler = (sender, e) =>
{
var taskList = new List { };
int taskType = 6;
int data1 = 0;
int data2 = 0;
if (shut.IsSelected)
{
//关
data1 = 0;
data2 = 0;
}
else
{
//百分比
data1 = open.SeekBar.Progress;
data2 = 0;
}
var taskInfo = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = data1,
Data2 = data2
};
taskList.Add(taskInfo);
sceneTargetDevice.TaskList = taskList;
sceneTargetDevice.DeviceUI = device;
selectedAction?.Invoke(sceneTargetDevice);
RemoveFromParent();
};
}
///
/// 调光灯
///
///
///
///
private void SelectDimmableLight(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget)
{
var selectFL = new FrameLayout
{
Y = Application.GetRealHeight(1169),
Height = Application.GetRealHeight(752),
};
dialog.AddChidren(selectFL);
selectFL.Animate = Animate.DownToUp;
var titleBG = new FrameLayout
{
Height = Application.GetRealHeight(138 * 2),
Radius = (uint)Application.GetRealHeight(20),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(titleBG);
var titleFL = new FrameLayout
{
Height = Application.GetRealHeight(138),
};
selectFL.AddChidren(titleFL);
var line = new Button
{
Y = titleFL.Height - 1,
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
};
titleFL.AddChidren(line);
var cancleBtn = new Button
{
X = Application.GetRealWidth(80),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(400),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
Text = device.CommonDevice.DeviceEpointName
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 15,
TextAlignment = TextAlignment.CenterRight,
TextID = R.MyInternationalizationString.Complete
};
titleFL.AddChidren(comfrimBtn);
var itemFL = new FrameLayout
{
Y = titleFL.Bottom,
Height = Application.GetRealHeight(613),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(itemFL);
var open = new SelectDeviceWithSeekBarRow(0, 60);
itemFL.AddChidren(open);
open.Init(254);
open.SetTitle(R.MyInternationalizationString.Open);
open.IsSelected = true;
var shut = new SelectSceneStatuRow(0, 60 + 348 + 30);
itemFL.AddChidren(shut);
shut.Init();
shut.hideLine(true);
shut.SetTitle(R.MyInternationalizationString.Shut);
open.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
};
shut.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = false;
shut.IsSelected = true;
};
cancleBtn.MouseUpEventHandler = (sender, e) =>
{
dialog.RemoveAll();
dialog.RemoveFromParent();
};
open.SeekBar.ProgressChanged += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
open.SetSeekBarTitle();
};
if (sceneTarget.TaskList.Count > 0)
{
if (sceneTarget.TaskList[0].Data1 == 0)
{
open.IsSelected = false;
shut.IsSelected = true;
}
else
{
open.IsSelected = true;
shut.IsSelected = false;
open.SetProgress(sceneTarget.TaskList[0].Data1);
}
}
comfrimBtn.MouseUpEventHandler = (sender, e) =>
{
var taskList = new List { };
int taskType = 3;
int data1 = 0;
int data2 = 0;
if (shut.IsSelected)
{
//关
data1 = 0;
data2 = 0;
}
else
{
//百分比
data1 = open.SeekBar.Progress;
data2 = 0;
}
var taskInfo = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = data1,
Data2 = data2
};
taskList.Add(taskInfo);
sceneTargetDevice.TaskList = taskList;
sceneTargetDevice.DeviceUI = device;
selectedAction?.Invoke(sceneTargetDevice);
RemoveFromParent();
};
}
///
/// 空调
///
///
///
///
private void SelectThermostat(FrameLayout dialog, DeviceUI device, SceneTargetDeviceUI sceneTarget)
{
var selectFL = new FrameLayout
{
Y = Application.GetRealHeight(815),
Height = Application.GetRealHeight(1106),
};
dialog.AddChidren(selectFL);
selectFL.Animate = Animate.DownToUp;
var titleBG = new FrameLayout
{
Height = Application.GetRealHeight(138 * 2),
Radius = (uint)Application.GetRealHeight(20),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(titleBG);
var titleFL = new FrameLayout
{
Height = Application.GetRealHeight(138),
};
selectFL.AddChidren(titleFL);
var line = new Button
{
Y = titleFL.Height - 1,
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2
};
titleFL.AddChidren(line);
var cancleBtn = new Button
{
X = Application.GetRealWidth(80),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(400),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 15,
TextAlignment = TextAlignment.CenterLeft,
Text = device.CommonDevice.DeviceEpointName
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 15,
TextAlignment = TextAlignment.CenterRight,
TextID = R.MyInternationalizationString.Complete
};
titleFL.AddChidren(comfrimBtn);
var itemFL = new FrameLayout
{
Y = titleFL.Bottom,
Height = Application.GetRealHeight(968),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
selectFL.AddChidren(itemFL);
var open = new SelectDeviceWithPickViewRow(0, 60);
itemFL.AddChidren(open);
open.Init();
open.SetTitle(R.MyInternationalizationString.Open);
open.IsSelected = true;
open.pickerView.OnSelectChangeEvent = (l1, l2, l3) =>
{
tempId = l1;
modelId = l2;
fanid = l3;
};
var shut = new SelectSceneStatuRow(0, 60 + 703 + 30);
itemFL.AddChidren(shut);
shut.Init();
shut.hideLine(true);
shut.SetTitle(R.MyInternationalizationString.Shut);
open.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
};
shut.ClickButton.MouseUpEventHandler += (sender, e) =>
{
open.IsSelected = false;
shut.IsSelected = true;
};
cancleBtn.MouseUpEventHandler = (sender, e) =>
{
dialog.RemoveAll();
dialog.RemoveFromParent();
};
if (sceneTarget.TaskList.Count > 0)
{
if (sceneTarget.TaskList.Count == 1)
{
open.IsSelected = false;
shut.IsSelected = true;
}
else
{
open.IsSelected = true;
shut.IsSelected = false;
for (int i = 0; i < sceneTarget.TaskList.Count; i++)
{
var tasklist = sceneTarget.TaskList[i];
if (tasklist.Data1 == 6)
{
fanid = open.fanList.IndexOf(tasklist.Data2);
}
if (tasklist.Data1 == 3)
{
modelId = open.modeList.IndexOf(tasklist.Data2);
}
if (tasklist.Data1 == 4 || tasklist.Data1 == 5)
{
tempId = open.temperatureList.IndexOf(tasklist.Data2/100);
}
}
open.pickerView.setCurrentItems(tempId, modelId, fanid);
}
}
comfrimBtn.MouseUpEventHandler = (sender, e) =>
{
var taskList = new List { };
int taskType = 5;
int data1 = 0;
int data2 = 0;
if (shut.IsSelected)
{
//关
data1 = 3;
data2 = 0;
var taskInfo = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = data1,
Data2 = data2
};
taskList.Add(taskInfo);
}
else
{
//fan
var taskInfo = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = 6,
Data2 = open.fanList[fanid]
};
taskList.Add(taskInfo);
//mode
var taskInfo2 = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = 3,
Data2 = open.modeList[modelId]
};
taskList.Add(taskInfo2);
//tem
if (open.modeList[modelId] == 4)
{
//heat
var taskInfo3 = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = 4,
Data2 = open.temperatureList[tempId]*100
};
taskList.Add(taskInfo3);
}
else
{
//heat
var taskInfo3 = new ZigBee.Device.Scene.TaskListInfo
{
TaskType = taskType,
Data1 = 5,
Data2 = open.temperatureList[tempId]*100
};
taskList.Add(taskInfo3);
}
}
sceneTargetDevice.TaskList = taskList;
sceneTargetDevice.DeviceUI = device;
selectedAction?.Invoke(sceneTargetDevice);
RemoveFromParent();
};
}
}
}