| | |
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.DeviceRelay
|
| | | namespace Shared.Phone.UserCenter.Device
|
| | | {
|
| | | /// <summary>
|
| | | /// 设备的功能设置界面
|
| | |
| | | /// </summary>
|
| | | private FrameCaptionInputControl btnDeviceName = null;
|
| | | /// <summary>
|
| | | /// 设备Mac地址
|
| | | /// 设备的某一回路
|
| | | /// </summary>
|
| | | private string deviceMac = string.Empty;
|
| | | private CommonDevice deviceObj = null;
|
| | | /// <summary>
|
| | | /// 只显示同一种类型的回路
|
| | | /// </summary>
|
| | | private bool onlyType = false;
|
| | | /// <summary>
|
| | | /// 设备需要保存的设备名字
|
| | | /// </summary>
|
| | |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_deviceMac">设备Mac地址</param>
|
| | | public void ShowForm(string i_deviceMac)
|
| | | /// <param name="i_device">设备的某一回路</param>
|
| | | /// <param name="i_onlyType">只显示同一种类型的回路</param>
|
| | | public void ShowForm(CommonDevice i_device, bool i_onlyType)
|
| | | {
|
| | | this.deviceMac = i_deviceMac;
|
| | | this.deviceObj = i_device;
|
| | | this.onlyType = i_onlyType;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp));
|
| | |
| | | this.ShowProgressBar();
|
| | | foreach (var epoint in dicDeviceSaveName.Keys)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(deviceMac, epoint);
|
| | | var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
|
| | | if (device == null || dicDeviceSaveName[epoint] == string.Empty)
|
| | | {
|
| | | //不能允许空白名字
|
| | |
| | | }
|
| | | foreach (var epoint in dicDeviceFuncType.Keys)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(deviceMac, epoint);
|
| | | var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
|
| | | if (device == null)
|
| | | {
|
| | | continue;
|
| | |
| | | {
|
| | | menuCount = 2;
|
| | | }
|
| | | var frame = new TopRightMenuControl(this, menuCount);
|
| | | var frame = new TopRightMenuControl(menuCount);
|
| | | if (canTest == true)
|
| | | {
|
| | | //定位
|
| | |
| | | var frameBorder = new FrameLayout();
|
| | | frameBorder.Y = Application.GetRealHeight(147);
|
| | | frameBorder.Gravity = Gravity.CenterHorizontal;
|
| | | frameBorder.Width = Application.GetRealWidth(887);
|
| | | frameBorder.Height = Application.GetRealHeight(423);
|
| | | frameBorder.BorderWidth = (uint)Application.GetMinRealAverage(3);
|
| | | frameBorder.Width = Application.GetMinRealAverage(887);
|
| | | frameBorder.Height = Application.GetMinRealAverage(423);
|
| | | frameBorder.BorderWidth = 3;
|
| | | frameBorder.BorderColor = 0xffd0d0d0;
|
| | | bodyFrameLayout.AddChidren(frameBorder);
|
| | |
|
| | |
| | | //需要滑动控件
|
| | | var listControl = new VerticalScrolViewLayout();
|
| | | listControl.Height = frameBorder.Height;
|
| | | bodyFrameLayout.AddChidren(listControl);
|
| | | frameBorder.AddChidren(listControl);
|
| | |
|
| | | listControl.AddChidren(frameBack);
|
| | | }
|
| | |
| | | for (int i = 0; i < listIcon.Count; i++)
|
| | | {
|
| | | var frame = new FrameLayout();
|
| | | frame.Width = Application.GetMinRealAverage(887);
|
| | | frame.Width = frameBorder.Width;
|
| | | frame.Height = Application.GetMinRealAverage(124);
|
| | | frameBack.AddChidren(frame);
|
| | | //初始化一行设备图标
|
| | | this.InitDeviceIconFrame(frame, listIcon[i], i == 0, ref index);
|
| | | this.InitDeviceIconFrame(frame, listIcon[i], ref index);
|
| | |
|
| | | if (listIcon.Count == 1)
|
| | | {
|
| | |
| | | if (listIcon.Count > 2)
|
| | | {
|
| | | //计算真实高度
|
| | | int realHeight = Application.GetMinRealAverage(58 + 58) + (frameBack.ChildrenCount - 1) * Application.GetMinRealAverage(124 + 60);
|
| | | int realHeight = Application.GetMinRealAverage(58 + 58);//上下间距
|
| | | realHeight += frameBack.ChildrenCount * Application.GetMinRealAverage(124);//圆圈高度
|
| | | realHeight += (frameBack.ChildrenCount-1) * Application.GetMinRealAverage(60);//圆圈间距
|
| | | if (realHeight > frameBack.Height)
|
| | | {
|
| | | //变更高度
|
| | |
| | | /// </summary>
|
| | | /// <param name="frame"></param>
|
| | | /// <param name="listDevice"></param>
|
| | | /// <param name="isFirstRow"></param>
|
| | | /// <param name="index"></param>
|
| | | /// <returns></returns>
|
| | | private void InitDeviceIconFrame(FrameLayout frame, List<CommonDevice> listDevice, bool isFirstRow, ref int index)
|
| | | private void InitDeviceIconFrame(FrameLayout frame, List<CommonDevice> listDevice, ref int index)
|
| | | {
|
| | | NormalViewControl btnTemp = null;
|
| | | //间距
|
| | |
| | | //点击事件
|
| | | btnIcon.ButtonClickEvent += this.DeviceEpointSelectEvent;
|
| | |
|
| | | if (i == 0 && isFirstRow == true)
|
| | | if (listDevice[i].DeviceEpoint == deviceObj.DeviceEpoint)
|
| | | {
|
| | | btnTemp = btnIcon;
|
| | | }
|
| | | }
|
| | | if (isFirstRow == true)
|
| | | if (btnTemp != null)
|
| | | {
|
| | | //初始化菜单行
|
| | | this.DeviceEpointSelectEvent(btnTemp, null);
|
| | |
| | | /// <returns></returns>
|
| | | private List<List<CommonDevice>> GetAllDeviceGroup()
|
| | | {
|
| | | var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
|
| | | bool hadDevice = false;
|
| | | var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
|
| | | var listRelay = new List<CommonDevice>();
|
| | | foreach (var device in listDevice)
|
| | | {
|
| | |
| | | //这个界面不处理干接点
|
| | | continue;
|
| | | }
|
| | | if (this.onlyType == true && device.Type != deviceObj.Type)
|
| | | {
|
| | | //只要同一种类型的
|
| | | continue;
|
| | | }
|
| | | listRelay.Add(device);
|
| | | if (device.DeviceEpoint == deviceObj.DeviceEpoint)
|
| | | {
|
| | | //能够匹配得到这个回路
|
| | | hadDevice = true;
|
| | | }
|
| | | }
|
| | | //排序
|
| | | listRelay.Sort((obj1, obj2) =>
|
| | |
| | | }
|
| | | return -1;
|
| | | });
|
| | | if (hadDevice == false)
|
| | | {
|
| | | //如果匹配不到这个回路,则默认第一个
|
| | | this.deviceObj = listRelay[0];
|
| | | }
|
| | |
|
| | | //从下往上4个为一组
|
| | | var listIcon = new List<List<CommonDevice>>();
|
| | | var listTemp = new List<CommonDevice>();
|
| | |
| | | nowContr.TextColor = UserCenterColor.Current.TextColor1;
|
| | |
|
| | | nowSelectControl = nowContr;
|
| | | nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceMac, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
|
| | | nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
|
| | |
|
| | | //重新初始化菜单行
|
| | | this.InitMenuRow();
|