using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
|
namespace Shared.Phone.Device.CommonForm
|
{
|
public class SelectZone : FrameLayout
|
{
|
public Action<Common.Room> ZoneAction;
|
|
private UIPickerView pickView;
|
|
private List<string> floorList = new List<string> { };
|
private List<string> roomList = new List<string> { };
|
private List<string> roomIdList = new List<string> { };
|
private string currentId;
|
public SelectZone()
|
{
|
}
|
|
/// <summary>
|
/// Init
|
/// </summary>
|
public void Init()
|
{
|
var dialog = new FrameLayout()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
|
};
|
AddChidren(dialog);
|
|
dialog.MouseUpEventHandler += (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
|
var backgroundFL = new FrameLayout
|
{
|
Y = Application.GetRealHeight(1115),
|
Height = Application.GetRealHeight(805),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
Radius = (uint)Application.GetRealHeight(20)
|
};
|
dialog.AddChidren(backgroundFL);
|
|
backgroundFL.Animate = Animate.DownToUp;
|
|
var topView = new FrameLayout
|
{
|
Height = Application.GetRealHeight(138)
|
};
|
backgroundFL.AddChidren(topView);
|
|
var cancle = new Button
|
{
|
X = Application.GetRealWidth(80),
|
Width = Application.GetRealWidth(300),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
|
TextID = R.MyInternationalizationString.Cancel,
|
TextSize = 16
|
};
|
topView.AddChidren(cancle);
|
|
var title = new Button
|
{
|
Width = Application.GetRealWidth(300),
|
Gravity = Gravity.CenterHorizontal,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor2,
|
TextID = R.MyInternationalizationString.AddTo,
|
TextSize = 16
|
};
|
topView.AddChidren(title);
|
|
var confrim = new Button
|
{
|
X = Application.GetRealWidth(CommonFormResouce.AppRealWidth - 80 - 300),
|
Width = Application.GetRealWidth(300),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
|
TextID = R.MyInternationalizationString.Confrim,
|
TextSize = 16
|
};
|
topView.AddChidren(confrim);
|
|
pickView = new UIPickerView
|
{
|
Y = Application.GetRealHeight(20 + 138),
|
Height = Application.GetRealHeight(450)
|
};
|
backgroundFL.AddChidren(pickView);
|
|
foreach (var floor in Config.Instance.Home.FloorDics)
|
{
|
floorList.Add(floor.Value);
|
}
|
foreach (var room in Shared.Common.Room.Lists)
|
{
|
roomList.Add(room.Name);
|
roomIdList.Add(room.Id);
|
}
|
|
if (floorList.Count == 0)
|
{
|
pickView.setNPicker(roomList, null, null);
|
pickView.OnSelectChangeEvent += (l1, l2, l3) =>
|
{
|
currentId = roomIdList[l1];
|
};
|
}
|
else
|
{
|
pickView.setNPicker(floorList, roomList, null);
|
pickView.OnSelectChangeEvent += (l1, l2, l3) =>
|
{
|
currentId = roomIdList[l2];
|
};
|
}
|
|
cancle.MouseUpEventHandler += Close;
|
confrim.MouseUpEventHandler += Confrim_MouseEvent;
|
}
|
|
/// <summary>
|
/// Close
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="mouseEventArgs"></param>
|
private void Close(object sender, MouseEventArgs mouseEventArgs)
|
{
|
RemoveFromParent();
|
}
|
|
/// <summary>
|
/// Confrim_MouseEvent
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="mouseEventArgs"></param>
|
private void Confrim_MouseEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
if (Shared.Common.Room.CurrentRoom.GetRoomById(currentId) != null)
|
{
|
ZoneAction?.Invoke(Shared.Common.Room.CurrentRoom.GetRoomById(currentId));
|
}
|
RemoveFromParent();
|
}
|
}
|
}
|