using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.UserView;
using ZigBee.Device;
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;
///
/// 当前楼层id
///
private string curFloorId;
///
/// 选择楼层
///
private Button selectFloorBtn;
///
/// 场景功能中部背景bodyView
///
public FrameLayout functionSceneBodyView;
///
/// deviceUI
///
public CommonDevice 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;
///
/// dList
///
private List devList;
///
/// 相同类型的设备列表
///
private Dictionary> typeDeviceDic;
///
/// 设备类型的图id
///
private Dictionary typeIdDic;
///
/// 当前选中房间
///
private Common.Room curRoom;
#endregion
///
/// RemoveFromParent
///
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()
{
InitData();
if (sceneTargetDevice == null)
{
sceneTargetDevice = new SceneTargetDeviceUI { Type = 0 };
}
AddTop();
AddBodyView();
RefreshBodyView(Config.Instance.Home.CurrentFloorId);
}
///
/// InitData
///
private void InitData()
{
typeDeviceDic = new Dictionary> { };
typeIdDic = new Dictionary { };
}
///
/// RefreshData
///
private void RefreshData(Common.Room room)
{
devList = UserCenter.HdlRoomLogic.Current.GetRoomListDevice(room);
typeDeviceDic.Clear();
typeIdDic.Clear();
foreach (var device in devList)
{
var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device);
if (info.BeloneType == DeviceBeloneType.A开关 || info.BeloneType == DeviceBeloneType.A彩灯
|| info.BeloneType == DeviceBeloneType.A插座 || info.BeloneType == DeviceBeloneType.A智能空开
|| info.BeloneType == DeviceBeloneType.A灯光 || info.BeloneType == DeviceBeloneType.A空调
|| info.BeloneType == DeviceBeloneType.A窗帘 || info.BeloneType == DeviceBeloneType.A继电器
|| info.BeloneType == DeviceBeloneType.A调光器
)
{
if (typeDeviceDic.ContainsKey(info.BeloneTextId) == false)
{
var sameDevList = new List { };
sameDevList.Add(device);
typeDeviceDic[info.BeloneTextId] = sameDevList;
}
else
{
typeDeviceDic[info.BeloneTextId].Add(device);
}
typeIdDic[info.BeloneTextId] = info.ConcreteType;
}
}
}
#region Add____________________________________
///
/// AddTop
///
private void AddTop()
{
var top = new TopFrameLayout();
AddChidren(top);
top.InitTopview();
top.SetTopTitle(R.MyInternationalizationString.AddFunction);
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,
TextSize=14,
IsBold=true
};
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.changeFloor = false;
floors.CurFloorId = curFloorId;
floors.Init(580, 184, Direction.Right);
floors.FloorAction += (floorId) =>
{
curFloorId = 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(279+35+1218),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
};
bodyFrameLayout.AddChidren(functionSceneBodyView);
RoomButton curBtn = new RoomButton(0, 0);
var lisrRoom = UserCenter.HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(floorId);
foreach (var room in lisrRoom)
{
var row = new FrameLayout()
{
Width = Application.GetRealWidth(255),
Height = Application.GetRealHeight(167)
};
roomFL.AddChidren(row);
RoomButton roomBtn = new RoomButton(0, 0);
roomBtn.Gravity = Gravity.Center;
roomBtn.Init();
roomBtn.SetTitle(room.Name);
row.AddChidren(roomBtn);
if (room.IsLove)
{
roomBtn.IsSelected = true;
curBtn = roomBtn;
this.curRoom = room;
RefreshFunction(room);
}
roomBtn.ButtonClickEvent += (sender, e) =>
{
if (sender == curBtn)
{
return;
}
sender.IsSelected = true;
curBtn.IsSelected = false;
curBtn = sender;
this.curRoom = room;
RefreshFunction(room);
};
}
if (deviceUI != null)
{
ShowSelectAction(deviceUI, sceneTargetDevice);
}
}
///
/// RefreshFunction
///
///
private void RefreshFunction(Common.Room room)
{
RefreshData(room);
functionSceneBodyView.RemoveAll();
if (typeDeviceDic.Count == 0)
{
ShowNoFunctionTip();
}
else
{
var functionTypeView1 = new FrameLayout
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Height = Application.GetRealHeight(160),
Width = Application.GetRealWidth(1028),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
functionSceneBodyView.AddChidren(functionTypeView1);
functionTypeView1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft);
var functionTypeView2 = new FrameLayout
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Y = Application.GetRealHeight(150),
Height = Application.GetRealHeight(279 - 150),
Width = Application.GetRealWidth(1028),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
functionSceneBodyView.AddChidren(functionTypeView2);
functionTypeView2.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft);
functionTypeScrowView = new HorizontalScrolViewLayout
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Height = Application.GetRealHeight(279),
Width = Application.GetRealWidth(1028)
};
functionSceneBodyView.AddChidren(functionTypeScrowView);
deviceListScrolView = new VerticalScrolViewLayout
{
X = Application.GetRealWidth(CommonFormResouce.X_Left),
Y = Application.GetRealHeight(35 + 275),
Width = Application.GetRealWidth(1028),
Height = Application.GetRealHeight(1218),
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
};
functionSceneBodyView.AddChidren(deviceListScrolView);
deviceListScrolView.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
tempFunctionTypeBtn = new FunctionButton();
tempFunctionTypeBtn.Init("","");
foreach (var deviceType in typeIdDic)
{
var typeRowLayout = new FrameLayout()
{
Width = Application.GetRealWidth(220),
};
functionTypeScrowView.AddChidren(typeRowLayout);
var functionTypeIMG = new FunctionButton()
{
Tag = deviceType.Key
};
string imgPath = string.Empty;
string imgSeletedPath = string.Empty;
Common.LocalDevice.Current.GetDeviceObjectIcon(deviceType.Value, ref imgPath, ref imgSeletedPath);
functionTypeIMG.Init(imgPath, imgSeletedPath);
functionTypeIMG.SetTitle(deviceType.Key);
typeRowLayout.AddChidren(functionTypeIMG);
functionTypeIMG.ClickBtn.MouseUpEventHandler += ShowSameTypeFunction;
if (functionTypeScrowView.ChildrenCount == 1)
{
ShowSameTypeFunction(functionTypeIMG.ImageBtn, null);
}
}
}
}
///
/// 显示相同类型的功能
///
/// typeSender.
/// The ${ParameterType} instance containing the event data.
private void 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 { };
sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())];
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);
deviceRow.Init(device.IconPath, device.OnlineIconPath, true);
deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(device));
deviceRow.IsSelected = true;
deviceRow.HideSwitchBtn(false);
deviceRow.NameBtn.BackgroundColor = ZigbeeColor.Current.GXCRedColor;
deviceTypeRowLayout.AddChidren(deviceRow);
deviceRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
{
ShowSelectAction(device, sceneTargetDevice);
};
}
}
///
/// 提示没有功能
///
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(CommonDevice device, SceneTargetDeviceUI sceneTarget)
{
var dialog = new FrameLayout()
{
BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
};
AddChidren(dialog);
dialog.MouseUpEventHandler += (sender, e) =>
{
dialog.RemoveFromParent();
};
if (device.Type == ZigBee.Device.DeviceType.OnOffOutput)
{
SelectOnoffOutput(dialog, device, sceneTarget);
}
else if (device.Type == ZigBee.Device.DeviceType.AirSwitch)
{
SelectOnoffOutput(dialog, device, sceneTarget);
}
else if (device.Type == ZigBee.Device.DeviceType.DimmableLight)
{
SelectDimmableLight(dialog, device, sceneTarget);
}
else if (device.Type == ZigBee.Device.DeviceType.WindowCoveringDevice)
{
SelectWindowCoveringDevice(dialog, device, sceneTarget);
}
else if (device.Type == ZigBee.Device.DeviceType.Thermostat)
{
SelectThermostat(dialog, device, sceneTarget);
}
}
///
/// 灯光
///
///
///
///
private void SelectOnoffOutput(FrameLayout dialog, CommonDevice 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(58),
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 = 14,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(600),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 16,
Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 14,
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, CommonDevice 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(58),
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 = 14,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(600),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 16,
Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 14,
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.OnProgressChangedEvent += (sender, e) =>
{
open.IsSelected = true;
shut.IsSelected = false;
open.SetSeekBarTitle();
};
if (sceneTarget.TaskList.Count > 0)
{
if (sceneTarget.TaskList[0].Data1 == 1)
{
open.IsSelected = false;
shut.IsSelected = true;
}
else
{
open.IsSelected = true;
shut.IsSelected = false;
open.SetSeekBarProgress(sceneTarget.TaskList[0].Data2);
}
}
comfrimBtn.MouseUpEventHandler = (sender, e) =>
{
var taskList = new List { };
int taskType = 6;
int data1 = 0;
int data2 = 0;
if (shut.IsSelected)
{
//关
data1 = 1;
data2 = 0;
}
else
{
//百分比
data1 = 5;
data2 = open.SeekBar.Progress;
}
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, CommonDevice 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(58),
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 = 14,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(600),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 16,
TextAlignment = TextAlignment.CenterLeft,
Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 14,
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.OnProgressChangedEvent += (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.SetSeekBarProgress(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, CommonDevice 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(58),
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 = 14,
TextAlignment = TextAlignment.CenterLeft,
TextID = R.MyInternationalizationString.Cancel
};
titleFL.AddChidren(cancleBtn);
var deviceName = new Button
{
Width = Application.GetRealWidth(600),
Gravity = Gravity.CenterHorizontal,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = 16,
TextAlignment = TextAlignment.CenterLeft,
Text = Common.LocalDevice.Current.GetDeviceEpointName(device)
};
titleFL.AddChidren(deviceName);
var comfrimBtn = new Button
{
X = Application.GetRealWidth(800),
Width = Application.GetRealWidth(200),
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
TextSize = 14,
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();
};
}
}
}