using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
namespace Shared.Phone.Device.Category
|
{
|
/// <summary>
|
/// Category scene select curtain setting.
|
/// </summary>
|
public class CategorySceneSelectCurtainSetting:FrameLayout
|
{
|
/// <summary>
|
/// Initializes a new instance of the
|
/// <see cref="T:Shared.Phone.Device.Category.CategorySceneSelectCurtainSetting"/> class.
|
/// </summary>
|
public CategorySceneSelectCurtainSetting()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor;
|
Tag = "categoryAddScene";
|
}
|
/// <summary>
|
/// Removes from parent.
|
/// </summary>
|
public override void RemoveFromParent()
|
{
|
UserView.HomePage.Instance.ScrollEnabled = true;
|
base.RemoveFromParent();
|
}
|
/// <summary>
|
// 显示卷帘的详细设置界面 默认state = -1(新增--默认打开) 0 打开 1关闭 5百分比, percent =-1不选择 百分比
|
// 窗帘设备 Data1(数值): 0 打开/ 1关闭/ 2 停止转动/ 4 调整到指定高度/ 5 调整到指定的百分比处位置 / 7 调整到指定倾斜角/ 8 调整到指定的百分比倾斜度
|
// state=5&&percen!=-1 显示百分比
|
/// </summary>
|
/// <param name="device">Device.</param>
|
/// <param name="state">State.</param>
|
/// <param name="percent">Percent.</param>
|
/// <param name="isFromRoom">If set to <c>true</c> is from room.</param>
|
public void Show(DeviceUI device, string targetDeviceID = "", int state = -1, int percent =-1, bool isFromRoom = false)
|
{
|
#region topview
|
var topBGView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(CommonPage.Navigation_Height),
|
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
|
};
|
AddChidren(topBGView);
|
var topView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),
|
Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),
|
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,
|
};
|
AddChidren(topView);
|
|
var title = new Button()
|
{
|
Text = device.CommonDevice.DeviceEpointName != "" ? device.CommonDevice.DeviceEpointName : Language.StringByID(R.MyInternationalizationString.UnknowDevice),
|
TextSize = 20,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
|
Gravity = Gravity.CenterHorizontal
|
};
|
topView.AddChidren(title);
|
var back = new Device.CommonForm.BackButton() { };
|
topView.AddChidren(back);
|
back.MouseUpEventHandler += (sender, e) =>
|
{
|
this.RemoveFromParent();
|
};
|
#endregion
|
|
#region midFL
|
var midFL = new VerticalScrolViewLayout()
|
{
|
Y = topView.Bottom,
|
Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
ScrollEnabled = false
|
};
|
AddChidren(midFL);
|
var openRowView = new RowLayout()
|
{
|
Height = Application.GetRealHeight(170),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
LineColor = ZigbeeColor.Current.GXCLineColor
|
};
|
midFL.AddChidren(openRowView);
|
var openFL= new FrameLayout()
|
{
|
Height = Application.GetRealHeight(170),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
};
|
openRowView.AddChidren(openFL);
|
var openBtn = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Width = Application.GetRealWidth(500),
|
TextID = R.MyInternationalizationString.Open,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
//SelectedBackgroundColor=ZigbeeColor.Current.GXCBlack70Color,
|
Gravity = Gravity.CenterVertical
|
};
|
openFL.AddChidren(openBtn);
|
var openBtnSelected = new Button()
|
{
|
X = openRowView.Width - Application.GetRealWidth(150),
|
Width = Application.GetMinRealAverage(110),
|
Height = Application.GetMinRealAverage(110),
|
UnSelectedImagePath = "Item/YesSelected.png",
|
Visible = false,
|
Gravity = Gravity.CenterVertical
|
};
|
openFL.AddChidren(openBtnSelected);
|
|
|
var closeRowView = new RowLayout()
|
{
|
Height = Application.GetRealHeight(170),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
LineColor = ZigbeeColor.Current.GXCLineColor
|
};
|
midFL.AddChidren(closeRowView);
|
var closeFL = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(170),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
};
|
closeRowView.AddChidren(closeFL);
|
var closeBtn = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Width = Application.GetRealWidth(500),
|
TextID = R.MyInternationalizationString.uSimpleClose,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
//SelectedBackgroundColor = ZigbeeColor.Current.GXCBlack70Color,
|
Gravity = Gravity.CenterVertical
|
};
|
closeFL.AddChidren(closeBtn);
|
var closeBtnSelected = new Button()
|
{
|
X = openRowView.Width - Application.GetRealWidth(150),
|
Width = Application.GetMinRealAverage(110),
|
Height = Application.GetMinRealAverage(110),
|
UnSelectedImagePath = "Item/YesSelected.png",
|
Visible = false,
|
Gravity = Gravity.CenterVertical
|
};
|
closeFL.AddChidren(closeBtnSelected);
|
|
var percentRowView = new RowLayout()
|
{
|
Height = Application.GetRealHeight(170),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
LineColor = ZigbeeColor.Current.GXCLineColor
|
};
|
midFL.AddChidren(percentRowView);
|
var percentBtn = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Width = Application.GetRealWidth(500),
|
TextID = R.MyInternationalizationString.Percent,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
//SelectedBackgroundColor = ZigbeeColor.Current.GXCBlack70Color,
|
Gravity = Gravity.CenterVertical
|
};
|
percentRowView.AddChidren(percentBtn);
|
|
//var dimmingNextBtn = new Button()
|
//{
|
// X = closeRowView.Width - Application.GetRealWidth(150),
|
// Height = Application.GetMinRealAverage(110),
|
// Width = Application.GetMinRealAverage(110),
|
// UnSelectedImagePath = "Item/Next.png",
|
// SelectedImagePath = "Item/DownSelected.png",
|
// Gravity = Gravity.CenterVertical
|
//};
|
//percentRowView.AddChidren(dimmingNextBtn);
|
var percentSliderRowView = new RowLayout()
|
{
|
Height = Application.GetRealHeight(240),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
LineColor = ZigbeeColor.Current.GXCBackgroundColor,
|
Tag = "deviceRowViewDetail"
|
};
|
midFL.AddChidren(percentSliderRowView);
|
var seekBar = new HorizontalSeekBar()
|
{
|
X = Application.GetRealWidth(CommonPage.XLeft),
|
Width = Application.GetRealWidth(CommonPage.AppRealWidth - 200 - CommonPage.XLeft),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = ZigbeeColor.Current.GXCSliderUnSelectedColor,
|
ProgressColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
ThumbColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
Max = 100,
|
Progress = (state==5 && percent!=-1)?percent:0
|
};
|
percentSliderRowView.AddChidren(seekBar);
|
var seekBarTitle = new Button()
|
{
|
X = Application.GetRealWidth(CommonPage.AppRealWidth - 200),
|
Width = Application.GetRealWidth(200),
|
Gravity = Gravity.CenterVertical,
|
Text = $"{seekBar.Progress} %",
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor
|
};
|
percentSliderRowView.AddChidren(seekBarTitle);
|
|
var confirmBtn = new Device.CommonForm.CompleteButton(1,2,3);
|
AddChidren(confirmBtn);
|
|
if (state == -1)
|
{
|
closeBtn.IsSelected = false;
|
closeBtnSelected.Visible = false;
|
openBtn.IsSelected = true;
|
openBtnSelected.Visible = true;
|
percentBtn.IsSelected = false;
|
}
|
else if (state == 0)
|
{
|
closeBtn.IsSelected = false;
|
closeBtnSelected.Visible = false;
|
openBtn.IsSelected = true;
|
openBtnSelected.Visible = true;
|
percentBtn.IsSelected = false;
|
}
|
else if (state == 1)
|
{
|
closeBtn.IsSelected = true;
|
closeBtnSelected.Visible = true;
|
openBtn.IsSelected = false;
|
openBtnSelected.Visible = false;
|
percentBtn.IsSelected = false;
|
}
|
else if(state == 5)
|
{
|
closeBtn.IsSelected = false;
|
closeBtnSelected.Visible = false;
|
openBtn.IsSelected = false;
|
openBtnSelected.Visible = false;
|
percentBtn.IsSelected = true;
|
}
|
|
#endregion
|
|
#region event
|
seekBar.ProgressChanged += (sender2, e2) =>
|
{
|
openBtn.IsSelected = false;
|
openBtnSelected.Visible = false;
|
closeBtn.IsSelected = false;
|
closeBtnSelected.Visible = false;
|
percentBtn.IsSelected = true;
|
seekBarTitle.Text = $"{seekBar.Progress}%";
|
};
|
|
EventHandler<MouseEventArgs> openEvent = (sender, e) =>
|
{
|
openBtn.IsSelected = true;
|
openBtnSelected.Visible = true;
|
closeBtn.IsSelected = false;
|
closeBtnSelected.Visible = false;
|
percentBtn.IsSelected = false;
|
seekBar.Progress = 0;
|
seekBarTitle.Text = "0%";
|
};
|
openBtn.MouseUpEventHandler += openEvent;
|
openRowView.MouseUpEventHandler += openEvent;
|
openFL.MouseUpEventHandler += openEvent;
|
|
EventHandler<MouseEventArgs> closeEvent = (sender, e) =>
|
{
|
openBtn.IsSelected = false;
|
openBtnSelected.Visible = false;
|
closeBtn.IsSelected = true;
|
closeBtnSelected.Visible = true;
|
percentBtn.IsSelected = false;
|
seekBar.Progress = 0;
|
seekBarTitle.Text = "0%";
|
};
|
closeBtn.MouseUpEventHandler += closeEvent;
|
closeRowView.MouseUpEventHandler += closeEvent;
|
closeFL.MouseUpEventHandler += closeEvent;
|
|
EventHandler<MouseEventArgs> nextHandler = (sender, e) =>
|
{
|
//openBtn.IsSelected = false;
|
//closeBtn.IsSelected = false;
|
//percentBtn.IsSelected = true;
|
|
//dimmingNextBtn.IsSelected = !dimmingNextBtn.IsSelected;
|
//if (dimmingNextBtn.IsSelected)
|
//{
|
// var dimmingSliderRowView = new RowLayout()
|
// {
|
// Height = Application.GetRealHeight(240),
|
// BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
// LineColor = ZigbeeColor.Current.GXCBackgroundColor,
|
// Tag = "deviceRowViewDetail"
|
// };
|
// midFL.AddChidren(dimmingSliderRowView);
|
// var seekBar = new HorizontalSeekBar()
|
// {
|
// X = Application.GetRealWidth(50),
|
// Width = Application.GetRealWidth(1080 - 200 - 50),
|
// Gravity = Gravity.CenterVertical,
|
// BackgroundColor = ZigbeeColor.Current.GXCSliderUnSelectedColor,
|
// ProgressColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
// ThumbColor = ZigbeeColor.Current.GXCButtonBlueColor,
|
// Max = 100,
|
// Progress = 50
|
// };
|
// dimmingSliderRowView.AddChidren(seekBar);
|
// var seekBarTitle = new Button()
|
// {
|
// X = Application.GetRealWidth(1080 - 200),
|
// Width = Application.GetRealWidth(150),
|
// Gravity = Gravity.CenterVertical,
|
// Text = $"{seekBar.Progress}%",
|
// TextColor = ZigbeeColor.Current.GXCTextBlackColor
|
// };
|
// dimmingSliderRowView.AddChidren(seekBarTitle);
|
// seekBar.ProgressChanged += (sender2, e2) =>
|
// {
|
// seekBarTitle.Text = $"{seekBar.Progress}%";
|
// };
|
//}
|
//else
|
//{
|
// midFL.RemoveViewByTag("deviceRowViewDetail");
|
//}
|
};
|
//dimmingNextBtn.MouseUpEventHandler += nextHandler;
|
//percentRowView.MouseUpEventHandler += nextHandler;
|
|
//确定
|
confirmBtn.MouseUpEventHandler += (sender, e) =>
|
{
|
if (device.CommonDevice == null) return;
|
var taskList = new List<ZigBee.Device.Scene.TaskListInfo> { };
|
//窗帘设备 Data1(数值): 0 打开/ 1关闭/ 2 停止转动/ 4 调整到指定高度/ 5 调整到指定的百分比处位置 / 7 调整到指定倾斜角/ 8 调整到指定的百分比倾斜度
|
//窗帘设备,Data2数值如下
|
//【当Data1=4或7,Data2为调整的高度或倾斜角度 倾斜角度单位为0.1°】。
|
//【当Data1=5 或 8,Data2为百分比,0-100表示0%-100%】
|
int taskType = 6;
|
int data1 = 0;
|
int data2 = 0;
|
|
if (openBtn.IsSelected)
|
{
|
//开
|
data1 = 0;
|
data2 = 0;
|
}
|
else if (closeBtn.IsSelected)
|
{
|
//关
|
data1 = 1;
|
data2 = 0;
|
}
|
else if(percentBtn.IsSelected)
|
{
|
//百分比
|
data1 = 5;
|
data2 = seekBar.Progress;
|
}
|
var taskInfo = new ZigBee.Device.Scene.TaskListInfo
|
{
|
TaskType = taskType,
|
Data1 = data1,
|
Data2 = data2
|
};
|
taskList.Add(taskInfo);
|
var sceneTargetDevice = new SceneTargetDeviceUI { };
|
sceneTargetDevice.DeviceUI = device;
|
sceneTargetDevice.TaskList = taskList;
|
sceneTargetDevice.Type = 0;
|
//新增的
|
if (state == -1)
|
{
|
|
if (isFromRoom)
|
{
|
//回到房间添加场景界面
|
var sameScene = CategoryAddScene.sceneTargetDevicesList.Find((obj) => obj.DeviceUI == sceneTargetDevice.DeviceUI);
|
if (sameScene == null)
|
{
|
Room.AddRoomScene.sceneTargetDevicesList.Add(sceneTargetDevice);
|
UserView.HomePage.Instance.RemoveViewByTag("categoryAddScene");
|
var roomAddScene = new Room.AddRoomScene();
|
UserView.HomePage.Instance.AddChidren(roomAddScene);
|
UserView.HomePage.Instance.PageIndex += 1;
|
roomAddScene.Show(Room.AddRoomScene.CurrentRoom);
|
}
|
else
|
{
|
//提示该设备已加入
|
var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.ThisSceneHadTheDevice), Language.StringByID(R.MyInternationalizationString.Close));
|
alert.Show();
|
alert.ResultEventHandler += (sendAlert, eAlert) =>
|
{
|
return;
|
};
|
}
|
}
|
else
|
{
|
//回到分类
|
var sameScene = CategoryAddScene.sceneTargetDevicesList.Find((obj) => obj.DeviceUI == sceneTargetDevice.DeviceUI);
|
if (sameScene == null)
|
{
|
CategoryAddScene.sceneTargetDevicesList.Add(sceneTargetDevice);
|
UserView.HomePage.Instance.RemoveViewByTag("categoryAddScene");
|
var categoryAddScene = new CategoryAddScene();
|
UserView.HomePage.Instance.AddChidren(categoryAddScene);
|
UserView.HomePage.Instance.PageIndex += 1;
|
categoryAddScene.Show();
|
}
|
else
|
{
|
//提示该设备已加入
|
var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.ThisSceneHadTheDevice), Language.StringByID(R.MyInternationalizationString.Close));
|
alert.Show();
|
alert.ResultEventHandler += (sendAlert, eAlert) =>
|
{
|
return;
|
};
|
}
|
}
|
}
|
//修改
|
else
|
{
|
if(isFromRoom)
|
{
|
var targetDeviceUI = Room.AddRoomScene.sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == targetDeviceID);
|
if (targetDeviceUI != null)
|
{
|
targetDeviceUI.DeviceUI = sceneTargetDevice.DeviceUI;
|
targetDeviceUI.TaskList = sceneTargetDevice.TaskList;
|
targetDeviceUI.Type = sceneTargetDevice.Type;
|
}
|
UserView.HomePage.Instance.RemoveViewByTag("categoryAddScene");
|
var roomAddScene = new Room.AddRoomScene();
|
UserView.HomePage.Instance.AddChidren(roomAddScene);
|
UserView.HomePage.Instance.PageIndex += 1;
|
roomAddScene.Show(Room.AddRoomScene.CurrentRoom);
|
}
|
else
|
{
|
var targetDeviceUI = CategoryAddScene.sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == targetDeviceID);
|
if (targetDeviceUI != null)
|
{
|
targetDeviceUI.DeviceUI = sceneTargetDevice.DeviceUI;
|
targetDeviceUI.TaskList = sceneTargetDevice.TaskList;
|
targetDeviceUI.Type = sceneTargetDevice.Type;
|
}
|
UserView.HomePage.Instance.RemoveViewByTag("categoryAddScene");
|
var categoryAddScene = new CategoryAddScene();
|
UserView.HomePage.Instance.AddChidren(categoryAddScene);
|
UserView.HomePage.Instance.PageIndex += 1;
|
categoryAddScene.Show();
|
}
|
}
|
};
|
#endregion
|
}
|
|
}
|
}
|