using Shared.Phone.UserCenter;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.MainPage.Controls
|
{
|
/// <summary>
|
/// 未分配界面的设备选择控件
|
/// </summary>
|
public class DeviceSelectUnallocatedControl : FrameRowControl
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 设备对象
|
/// </summary>
|
public CommonDevice device;
|
/// <summary>
|
/// 状态
|
/// </summary>
|
private StatuMode Statu = StatuMode.UN_SELECT;
|
/// <summary>
|
/// 是否处于选择状态
|
/// </summary>
|
public bool IsSelected
|
{
|
get { return Statu == StatuMode.SELECT; }
|
set
|
{
|
if (value == false)
|
{
|
this.SetUnselectStatu();
|
}
|
else
|
{
|
this.SetSelectStatu();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 设备图标背景控件
|
/// </summary>
|
private FrameLayout frameIconBackGroud = null;
|
/// <summary>
|
/// 设备图标控件
|
/// </summary>
|
private IconViewControl btnDeviceIcon = null;
|
/// <summary>
|
/// 设备名字控件
|
/// </summary>
|
private NormalViewControl btnDeviceName = null;
|
/// <summary>
|
/// 选择控件
|
/// </summary>
|
private MostRightIconControl btnSelect = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 未分配界面的设备选择控件
|
/// </summary>
|
/// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
public DeviceSelectUnallocatedControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
{
|
this.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
|
}
|
|
/// <summary>
|
/// 初始化控件
|
/// </summary>
|
/// <param name="i_device">设备对象</param>
|
public void InitControl(CommonDevice i_device)
|
{
|
this.device = i_device;
|
//设备图标背景控件
|
this.frameIconBackGroud = new FrameLayout();
|
frameIconBackGroud.Height = this.GetPictrueRealSize(112);
|
frameIconBackGroud.Width = this.GetPictrueRealSize(112);
|
frameIconBackGroud.Gravity = Gravity.CenterVertical;
|
frameIconBackGroud.X = Application.GetRealWidth(46);
|
frameIconBackGroud.Radius = (uint)this.GetPictrueRealSize(112 / 2);
|
frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
|
this.AddChidren(frameIconBackGroud, ChidrenBindMode.NotBind);
|
if (chidrenYaxis != 0)
|
{
|
frameIconBackGroud.Y += chidrenYaxis;
|
}
|
|
//设备图标控件
|
this.btnDeviceIcon = new IconViewControl(78);
|
btnDeviceIcon.Gravity = Gravity.Center;
|
HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnDeviceIcon, i_device);
|
frameIconBackGroud.AddChidren(btnDeviceIcon);
|
//重新绑定事件
|
this.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEvent);
|
|
//设备名字
|
this.btnDeviceName = new NormalViewControl(Application.GetRealWidth(600), this.Height, false);
|
btnDeviceName.X = Application.GetRealWidth(181);
|
btnDeviceName.Text = HdlDeviceCommonLogic.Current.GetDeviceEpointName(i_device);
|
btnDeviceName.SelectedTextColor = Common.ZigbeeColor.Current.GXCTextSelectedColor;
|
btnDeviceName.Gravity = Gravity.CenterVertical;
|
this.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
|
if (chidrenYaxis != 0)
|
{
|
btnDeviceName.Y += chidrenYaxis;
|
}
|
|
//选择控件
|
this.btnSelect = new MostRightIconControl(70, 70);
|
btnSelect.X = Application.GetRealWidth(895);
|
btnSelect.UseClickStatu = false;
|
btnSelect.UnSelectedImagePath = "Room/ItemUnSelected_Black.png";
|
btnSelect.SelectedImagePath = "Room/ItemSelected.png";
|
this.AddChidren(btnSelect, ChidrenBindMode.NotBind);
|
btnSelect.InitControl();
|
//复合控件需要特殊处理
|
this.ChangedChidrenBindMode(btnSelect, ChidrenBindMode.BindEvent);
|
if (chidrenYaxis != 0)
|
{
|
btnSelect.btnIcon.Y += chidrenYaxis;
|
}
|
|
//底线
|
var btnBottomLine = new NormalViewControl(Application.GetRealWidth(835), HdlControlResourse.BottomLineHeight, false);
|
btnBottomLine.X = Application.GetRealWidth(181);
|
btnBottomLine.Y = this.Height - HdlControlResourse.BottomLineHeight;
|
btnBottomLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
|
this.AddChidren(btnBottomLine, ChidrenBindMode.NotBind);
|
}
|
|
#endregion
|
|
#region ■ 选择状态___________________________
|
|
/// <summary>
|
/// 设定选择状态
|
/// </summary>
|
private void SetSelectStatu()
|
{
|
if (Statu == StatuMode.SELECT)
|
{
|
return;
|
}
|
btnDeviceIcon.IsSelected = true;
|
btnDeviceName.IsSelected = true;
|
frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCSelectedBackgroundColor;
|
btnSelect.IsSelected = true;
|
//状态变更
|
Statu = StatuMode.SELECT;
|
}
|
|
/// <summary>
|
/// 设置非选择状态
|
/// </summary>
|
private void SetUnselectStatu()
|
{
|
if (Statu == StatuMode.UN_SELECT)
|
{
|
return;
|
}
|
btnDeviceIcon.IsSelected = false;
|
btnDeviceName.IsSelected = false;
|
frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
|
btnSelect.IsSelected = false;
|
//状态变更
|
Statu = StatuMode.UN_SELECT;
|
}
|
#endregion
|
}
|
}
|