New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 做成一个简单设备选择的行控件
|
| | | /// </summary>
|
| | | public class DeviceSimpleSelectControl : FrameRowControl
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备对象
|
| | | /// </summary>
|
| | | public CommonDevice device
|
| | | {
|
| | | get { return Common.LocalDevice.Current.GetDevice(MainKeys); }
|
| | | }
|
| | | /// <summary>
|
| | | /// 选择控件
|
| | | /// </summary>
|
| | | private MostRightIconControl btnSelect = null;
|
| | |
|
| | | /// <summary>
|
| | | /// 选择的状态是否能够取消
|
| | | /// </summary>
|
| | | public bool SelectCancel = true;
|
| | | /// <summary>
|
| | | /// 状态
|
| | | /// </summary>
|
| | | private StatuMode Statu = StatuMode.UN_SELECT;
|
| | | /// <summary>
|
| | | /// 是否处于选择状态
|
| | | /// </summary>
|
| | | public bool IsSelected
|
| | | {
|
| | | get { return Statu == StatuMode.SELECT; }
|
| | | set
|
| | | {
|
| | | if (value == false)
|
| | | {
|
| | | if (SelectCancel == true)
|
| | | {
|
| | | this.SetUnselectStatu();
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | this.SetSelectStatu();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 做成一个简单设备选择的行控件
|
| | | /// </summary>
|
| | | /// <param name="i_device">设备对象</param>
|
| | | /// <param name="autoSelect">当点击此控件时,是否自动设置选择状态</param>
|
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
| | | public DeviceSimpleSelectControl(CommonDevice i_device, bool autoSelect, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
| | | {
|
| | | this.MainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(i_device);
|
| | | if (autoSelect == true)
|
| | | {
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.IsSelected = Statu == StatuMode.SELECT ? false : true;
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化内部控件
|
| | | /// </summary>
|
| | | public void InitControl()
|
| | | {
|
| | | //图标
|
| | | var btnIcon = this.AddLeftIcon();
|
| | | Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
|
| | |
|
| | | //设备
|
| | | string eName = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | this.AddLeftCaption(eName, 850);
|
| | |
|
| | | btnSelect = this.AddMostRightEmptyIcon(58, 58);
|
| | | btnSelect.Visible = false;
|
| | | btnSelect.UnSelectedImagePath = "Item/ItemSelected.png";
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 选择状态___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设定选择状态
|
| | | /// </summary>
|
| | | private void SetSelectStatu()
|
| | | {
|
| | | if (Statu == StatuMode.SELECT)
|
| | | {
|
| | | return;
|
| | | }
|
| | | btnSelect.Visible = true;
|
| | | //状态变更
|
| | | Statu = StatuMode.SELECT;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置非选择状态
|
| | | /// </summary>
|
| | | private void SetUnselectStatu()
|
| | | {
|
| | | if (Statu == StatuMode.UN_SELECT)
|
| | | {
|
| | | return;
|
| | | }
|
| | | btnSelect.Visible = false;
|
| | | //状态变更
|
| | | Statu = StatuMode.UN_SELECT;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|