using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.Phone.Device.Category;
|
using Shared.Phone.Device.CommonForm;
|
using Shared.Phone.UserView;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.Room
|
{
|
public class UnallocatedRoom:FrameLayout
|
{
|
#region ◆ 变量____________________________
|
/// <summary>
|
/// bodyFrameLayout
|
/// </summary>
|
private FrameLayout bodyFrameLayout;
|
|
private Button addBtn;
|
|
private FrameLayout itemView;
|
/// <summary>
|
/// editStatus
|
/// </summary>
|
private bool SelectAll;
|
|
/// <summary>
|
/// low_High
|
/// </summary>
|
private const int low_High = 127;
|
/// <summary>
|
/// 功能
|
/// </summary>
|
private ButtonLineForm functionBtn;
|
/// <summary>
|
/// 场景
|
/// </summary>
|
private ButtonLineForm sceneBtn;
|
/// <summary>
|
/// 中部背景bodyView
|
/// </summary>
|
public FrameLayout functionSceneBodyView;
|
/// <summary>
|
/// 当前功能类型按钮
|
/// </summary>
|
private FunctionButton tempFunctionTypeBtn;
|
/// <summary>
|
/// 功能类型按钮
|
/// </summary>
|
private FunctionButton functionTypeIMG;
|
/// <summary>
|
/// 功能类型
|
/// </summary>
|
private HorizontalScrolViewLayout functionTypeScrowView;
|
/// <summary>
|
/// 设备类型RowLayout
|
/// </summary>
|
private RowLayout typeRowLayout;
|
/// <summary>
|
/// 相同的设备列表
|
/// </summary>
|
public VerticalScrolViewLayout deviceListScrolView;
|
|
#endregion
|
|
public UnallocatedRoom()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
}
|
|
/// <summary>
|
/// 未分配房间管理
|
/// </summary>
|
public void Show()
|
{
|
AddTop();
|
|
AddBodyView();
|
}
|
|
|
#region Add____________________________________
|
|
/// <summary>
|
/// AddTop
|
/// </summary>
|
public void AddTop()
|
{
|
var top = new TopFrameLayout();
|
AddChidren(top);
|
top.InitTopview();
|
top.SetTopTitle(R.MyInternationalizationString.Unallocated);
|
top.backButton.MouseUpEventHandler += (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
|
addBtn = new Button()
|
{
|
X = Application.GetRealWidth(800),
|
Width = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(80),
|
Gravity = Gravity.CenterVertical,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextSize = CommonFormResouce.TopTitle_TextSize,
|
TextAlignment = TextAlignment.CenterRight,
|
TextID = R.MyInternationalizationString.AllSelect
|
};
|
top.topView.AddChidren(addBtn);
|
|
addBtn.MouseUpEventHandler += Edit_MouseUpEventHandler;
|
}
|
|
/// <summary>
|
/// AddBodyView
|
/// </summary>
|
public void AddBodyView()
|
{
|
bodyFrameLayout = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(184),
|
Height = Application.GetRealHeight(1737),
|
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
|
};
|
AddChidren(bodyFrameLayout);
|
|
var functionSceneBG = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(low_High),
|
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
|
};
|
bodyFrameLayout.AddChidren(functionSceneBG);
|
|
//功能
|
functionBtn = new ButtonLineForm(CommonFormResouce.X_Left, 34, 150, 68);
|
functionSceneBG.AddChidren(functionBtn);
|
functionBtn.Init();
|
functionBtn.SetTitle(R.MyInternationalizationString.Function);
|
functionBtn.IsSelected = true;
|
|
//场景
|
sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 34, 150, 68);
|
functionSceneBG.AddChidren(sceneBtn);
|
sceneBtn.Init();
|
sceneBtn.SetTitle(R.MyInternationalizationString.Scence);
|
|
//选择功能分栏
|
functionBtn.NameBtn.MouseUpEventHandler += FunctionBtn_MouseUpEventHandler;
|
//选择场景分栏
|
sceneBtn.NameBtn.MouseUpEventHandler += SceneBtn_MouseUpEventHandler;
|
|
//功能和场景bodyView
|
functionSceneBodyView = new FrameLayout()
|
{
|
Y= Application.GetRealHeight(187-58),
|
Height = Application.GetRealHeight(1607),
|
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
|
};
|
bodyFrameLayout.AddChidren(functionSceneBodyView);
|
|
RefreshBodyView();
|
|
}
|
|
/// <summary>
|
/// 选择功能分栏
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void FunctionBtn_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
|
{
|
functionBtn.IsSelected = true;
|
sceneBtn.IsSelected = false;
|
RefreshBodyView();
|
}
|
|
/// <summary>
|
/// 选择场景分栏
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void SceneBtn_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
|
{
|
functionBtn.IsSelected = false;
|
sceneBtn.IsSelected = true;
|
RefreshBodyView();
|
}
|
|
/// <summary>
|
/// 编辑
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="mouseEventArgs"></param>
|
private void Edit_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
|
{
|
SelectAll = !SelectAll;
|
if (SelectAll)
|
{
|
addBtn.TextID = R.MyInternationalizationString.Cancel;
|
}
|
else
|
{
|
addBtn.TextID = R.MyInternationalizationString.AllSelect;
|
}
|
|
if (functionBtn.IsSelected)
|
{
|
functionSceneBodyView.RemoveAll();
|
ShowFunction(SelectAll);
|
}
|
else if (sceneBtn.IsSelected)
|
{
|
functionSceneBodyView.RemoveAll();
|
ShowScene(SelectAll);
|
}
|
}
|
|
#endregion
|
|
#region ◆ 刷新____________________________
|
/// <summary>
|
/// 刷新bodyView
|
/// </summary>
|
public void RefreshBodyView()
|
{
|
functionSceneBodyView.RemoveAll();
|
SelectAll = false;
|
if (functionBtn.IsSelected)
|
{
|
ShowFunction(SelectAll);
|
}
|
else if (sceneBtn.IsSelected)
|
{
|
ShowScene(SelectAll);
|
}
|
}
|
|
#endregion
|
|
#region ◆ 功能____________________________
|
/// <summary>
|
/// 功能
|
/// </summary>
|
public void ShowFunction(bool selectAll)
|
{
|
SelectAll = selectAll;
|
//选择功能--直接从房间的devicelist中获取
|
if (Common.Room.AllRoomDeviceUIList == null)
|
{
|
return;
|
}
|
if (Common.Room.AllRoomDeviceUIList.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();
|
tempFunctionTypeBtn.Init("", "");
|
|
foreach (var deviceType in Common.Room.AllRoomDeviceTypeList)
|
{
|
typeRowLayout = new RowLayout()
|
{
|
Width = Application.GetRealWidth(CommonPage.AppRealWidth / 5),
|
LineColor = ZigbeeColor.Current.GXCBackgroundColor,
|
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 == Shared.Common.Room.AllRoomDeviceUIList[0].CommonDevice.Type)
|
{
|
ShowSameTypeFunction(functionTypeIMG.ImageBtn, null);
|
}
|
}
|
}
|
}
|
|
/// <summary>
|
/// 显示相同类型的功能
|
/// </summary>
|
/// <param name="typeSender">typeSender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void ShowSameTypeFunction(object typeSender, MouseEventArgs mouseEventArgs)
|
{
|
//选择功能--直接从房间的devicelist中获取
|
tempFunctionTypeBtn.IsSelected = false;
|
tempFunctionTypeBtn = (typeSender as Button).Parent as FunctionButton;
|
((typeSender as Button).Parent as FunctionButton).IsSelected = true;
|
|
deviceListScrolView.RemoveAll();
|
|
var sameTypeList = new List<DeviceUI> { };
|
var selectedList = new List<DeviceUI> { };
|
foreach (var devieceUI in Common.Room.AllRoomDeviceUIList)
|
{
|
if (devieceUI == null || devieceUI.CommonDevice == null)
|
{
|
continue;
|
}
|
if (devieceUI.CommonDevice.Type.ToString() == (typeSender as Button).Tag.ToString())
|
{
|
if (!sameTypeList.Contains(devieceUI))
|
{
|
sameTypeList.Add(devieceUI);
|
}
|
}
|
}
|
|
if (SelectAll)
|
{
|
selectedList.AddRange(sameTypeList);
|
}
|
foreach (var deviceUI in sameTypeList)
|
{
|
var deviceTypeRowLayout = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(127 + 35),
|
Tag = deviceUI
|
};
|
deviceListScrolView.AddChidren(deviceTypeRowLayout);
|
|
var deviceRow = new SelectFunctionView(0, 35);
|
deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
|
deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName);
|
deviceRow.SetStatu(deviceUI.CommonDevice.IsOnline == 1);
|
deviceRow.SetSelectStatu(SelectAll);
|
deviceTypeRowLayout.AddChidren(deviceRow);
|
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
deviceRow.SelectBtn.IsSelected = !deviceRow.SelectBtn.IsSelected;
|
if (deviceRow.SelectBtn.IsSelected)
|
{
|
if (!selectedList.Contains(deviceUI))
|
{
|
selectedList.Add(deviceUI);
|
}
|
}
|
else
|
{
|
if (selectedList.Contains(deviceUI))
|
{
|
selectedList.Remove(deviceUI);
|
}
|
}
|
};
|
deviceRow.NameBtn.MouseUpEventHandler += eventHandler;
|
deviceRow.ImageBtn.MouseUpEventHandler += eventHandler;
|
deviceRow.MouseUpEventHandler+=eventHandler;
|
deviceRow.SelectBtn.MouseUpEventHandler += eventHandler;
|
|
var add = new Button
|
{
|
Y = Application.GetRealHeight(1428),
|
Width = Application.GetRealWidth(1034),
|
Height = Application.GetRealHeight(156),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
Radius = (uint)Application.GetRealHeight(17),
|
TextID = R.MyInternationalizationString.AddTo,
|
Gravity = Gravity.CenterHorizontal
|
};
|
functionSceneBodyView.AddChidren(add);
|
add.MouseUpEventHandler += (sender, e) =>
|
{
|
var selectZone = new SelectZone();
|
CommonPage.Instance.AddChidren(selectZone);
|
selectZone.Init();
|
selectZone.ZoneAction = (r) =>
|
{
|
foreach (var d in selectedList)
|
{
|
r.AddDevice(d.FileName);
|
}
|
};
|
};
|
}
|
}
|
|
/// <summary>
|
/// 提示没有功能
|
/// </summary>
|
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,
|
TextID = R.MyInternationalizationString.NoFunction,
|
//Text = "没有功能 \n 请在个人中心中--设备管理处添加",
|
TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
|
TextAlignment = TextAlignment.Center,
|
IsMoreLines = true
|
};
|
functionSceneBodyView.AddChidren(noFunctionTip);
|
}
|
|
#endregion
|
|
#region ◆ 场景____________________________
|
/// <summary>
|
/// 选择场景--所有房间的所有场景
|
/// </summary>
|
public void ShowScene(bool selectAll)
|
{
|
//刷新场景
|
//var reFreshResult=await Shared.Common.Room.RefreshSceneUIList();
|
Shared.Common.SceneRoomUI.GetAllSceneRoomUIList();
|
if (SceneRoomUI.AllSceneRoomUIList == null)
|
{
|
return;
|
}
|
var sceneList = SceneRoomUI.AllSceneRoomUIList;
|
List<SceneRoomUI> selectedList = new List<SceneRoomUI>();
|
if(selectAll)
|
{
|
selectedList.AddRange(sceneList);
|
}
|
if (sceneList.Count == 0)
|
{
|
ShowNoSceneTip();
|
}
|
else
|
{
|
var sceneScrolView = new VerticalScrolViewLayout
|
{
|
Y = Application.GetRealHeight(0)
|
};
|
functionSceneBodyView.AddChidren(sceneScrolView);
|
foreach (var sceneRoomUI in sceneList)
|
{
|
var sceneFL = new FrameLayout()
|
{
|
Width=Application.GetRealWidth(CommonFormResouce.AppRealWidth),
|
Height = Application.GetRealHeight(397+58),
|
Gravity = Gravity.CenterHorizontal,
|
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
|
Tag = sceneRoomUI
|
};
|
sceneScrolView.AddChidren(sceneFL);
|
|
var sceneImg = new Button()
|
{
|
X=Application.GetRealWidth(179),
|
Y=Application.GetRealHeight(58),
|
Width = Application.GetRealWidth(844),
|
Height = Application.GetRealHeight(397),
|
UnSelectedImagePath = sceneRoomUI.sceneUI.IconPath,
|
Radius = (uint)Application.GetRealHeight(17)
|
};
|
sceneImg.UnSelectedImagePath = "Room/r0.png";
|
sceneFL.AddChidren(sceneImg);
|
|
var selectedBtn = new Button
|
{
|
X = Application.GetRealWidth(919),
|
Y = Application.GetRealHeight(92),
|
Width = Application.GetMinRealAverage(60),
|
Height = Application.GetMinRealAverage(60),
|
UnSelectedImagePath = "Room/ItemUnSelected.png",
|
SelectedImagePath = "Room/ItemSelected.png",
|
IsSelected= selectAll
|
};
|
sceneFL.AddChidren(selectedBtn);
|
|
var leftFL = new FrameLayout
|
{
|
X = Application.GetRealWidth(CommonFormResouce.X_Left),
|
Y = Application.GetRealHeight(58 + 58),
|
Width = Application.GetRealWidth(251),
|
Height = Application.GetRealHeight(282),
|
BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2
|
};
|
sceneFL.AddChidren(leftFL);
|
|
var collectionBtn = new Button
|
{
|
X = Application.GetRealWidth(23),
|
Y = Application.GetRealHeight(23),
|
Width = Application.GetMinRealAverage(65),
|
Height = Application.GetMinRealAverage(65),
|
UnSelectedImagePath = "Item/Collection.png",
|
SelectedImagePath = "Item/CollectionSelected.png"
|
};
|
leftFL.AddChidren(collectionBtn);
|
|
var sceneNameBtn = new Button()
|
{
|
Width = Application.GetRealWidth(176),
|
Height = Application.GetRealHeight(200),
|
TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
|
Text = sceneRoomUI.sceneUI.Name,
|
Gravity = Gravity.Center,
|
IsMoreLines = true
|
};
|
leftFL.AddChidren(sceneNameBtn);
|
|
EventHandler<MouseEventArgs> eventHandler = (sender,e) =>
|
{
|
selectedBtn.IsSelected = !selectedBtn.IsSelected;
|
if(selectedBtn.IsSelected)
|
{
|
if(!selectedList.Contains(sceneRoomUI))
|
{
|
selectedList.Add(sceneRoomUI);
|
}
|
}
|
else
|
{
|
if (selectedList.Contains(sceneRoomUI))
|
{
|
selectedList.Remove(sceneRoomUI);
|
}
|
}
|
};
|
selectedBtn.MouseUpEventHandler += eventHandler;
|
sceneImg.MouseUpEventHandler += eventHandler;
|
}
|
|
var add = new Button
|
{
|
Y = Application.GetRealHeight(1428),
|
Width = Application.GetRealWidth(1034),
|
Height = Application.GetRealHeight(156),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
|
Radius = (uint)Application.GetRealHeight(17),
|
TextID = R.MyInternationalizationString.AddTo,
|
Gravity=Gravity.CenterHorizontal
|
};
|
functionSceneBodyView.AddChidren(add);
|
add.MouseUpEventHandler += (sender, e) =>
|
{
|
var selectZone = new SelectZone();
|
CommonPage.Instance.AddChidren(selectZone);
|
selectZone.Init();
|
selectZone.ZoneAction = (r) =>
|
{
|
foreach(var s in selectedList)
|
{
|
r.AddScene(s.sceneUI);
|
}
|
};
|
};
|
}
|
}
|
|
/// <summary>
|
/// 显示没有场景
|
/// </summary>
|
private void ShowNoSceneTip()
|
{
|
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 noScenceTip = new Button()
|
{
|
Y = noFunction.Bottom + Application.GetRealHeight(32),
|
Height = Application.GetRealHeight(200),
|
Width = Application.GetRealWidth(700),
|
Gravity = Gravity.CenterHorizontal,
|
TextID = R.MyInternationalizationString.NoScene,
|
TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor,
|
TextAlignment = TextAlignment.Center,
|
IsMoreLines = true
|
};
|
functionSceneBodyView.AddChidren(noScenceTip);
|
}
|
#endregion
|
}
|
}
|