| | |
| | | /// <summary>
|
| | | /// 界面关闭事件(该事件目前给分类界面的自定义行控件使用)
|
| | | /// </summary>
|
| | | public Action<CommonDevice, Room> FormCloseEvent = null;
|
| | | public Action FormCloseEvent = null;
|
| | | /// <summary>
|
| | | /// 设备对象
|
| | | /// </summary>
|
| | | private CommonDevice device;
|
| | | /// <summary>
|
| | | /// 房间对象(这个房间有可能是喜爱)
|
| | | /// 房间对象(这个房间有可能是喜爱,有可能是null)
|
| | | /// </summary>
|
| | | private Room room = null;
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listview = null;
|
| | | private FrameListControl listview = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listBackControl = new VerticalFrameControl();
|
| | | listBackControl.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listBackControl);
|
| | |
|
| | | //初始化桌布
|
| | | var tableContr = new InformationEditorControl();
|
| | | this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 418, 1319);
|
| | | this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1319);
|
| | |
|
| | | //图片
|
| | | var btnPic = new DeviceInfoIconControl();
|
| | | btnPic.Y = Application.GetRealHeight(46);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | bodyFrameLayout.AddChidren(btnPic);
|
| | | listBackControl.frameTable.AddChidren(btnPic);
|
| | | btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
|
| | | btnPic.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var localPic = new Device.CommonForm.DeviceIconSelectedIMGByLocal();
|
| | | UserView.HomePage.Instance.AddChidren(localPic);
|
| | | UserView.HomePage.Instance.PageIndex += 1;
|
| | | localPic.Show();
|
| | | localPic.action = (unSelectedImagePath, selectedImagePath) =>
|
| | | var form = new SelectLocalDeviceImageForm();
|
| | | form.AddForm();
|
| | | form.FinishSelectEvent = (unSelectedImagePath) =>
|
| | | {
|
| | | //变更图片
|
| | | device.IconPath = unSelectedImagePath;
|
| | |
| | | var btnBelongType = new NormalViewControl(700, 62, true);
|
| | | btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
|
| | | btnBelongType.Gravity = Gravity.CenterHorizontal;
|
| | | btnBelongType.TextID = infoType.BeloneTextId;
|
| | | btnBelongType.Text = infoType.BeloneText;
|
| | | btnBelongType.TextSize = 15;
|
| | | btnBelongType.TextAlignment = TextAlignment.Center;
|
| | | bodyFrameLayout.AddChidren(btnBelongType);
|
| | | listBackControl.frameTable.AddChidren(btnBelongType);
|
| | |
|
| | | //功能名称
|
| | | string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
|
| | | string deviceName = LocalDevice.Current.GetDeviceEpointName(device);
|
| | | var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
|
| | | btnNote.txtInput.MaxByte = 48;//限制只能输入48个字节
|
| | | listview.AddChidren(btnNote);
|
| | | btnNote.InitControl();
|
| | | //划线
|
| | |
| | | };
|
| | |
|
| | | //喜爱房间不允许变更区域
|
| | | if (this.room.IsLove == false)
|
| | | if (this.room == null || this.room.IsLove == false)
|
| | | {
|
| | | //所属区域
|
| | | var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
|
| | |
| | | }
|
| | |
|
| | | //所属模块
|
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongModel);
|
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
|
| | | deviceName = Common.LocalDevice.Current.GetDeviceMacName(device);
|
| | | var rowBelongModul = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
|
| | | listview.AddChidren(rowBelongModul);
|
| | |
| | | this.AddFunctionTypeRowByAdmin(btnBelongType);
|
| | |
|
| | | //初始化桌布完成
|
| | | tableContr.FinishInitControl(bodyFrameLayout, this.listview);
|
| | | tableContr.FinishInitControl();
|
| | | tableContr = null;
|
| | |
|
| | | //保存
|
| | |
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listBackControl = new VerticalFrameControl();
|
| | | listBackControl.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listBackControl);
|
| | |
|
| | | //初始化桌布
|
| | | var tableContr = new InformationEditorControl();
|
| | | this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 418, 1319);
|
| | | this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1319);
|
| | |
|
| | | //图片
|
| | | var btnPic = new DeviceInfoIconControl();
|
| | | btnPic.Y = Application.GetRealHeight(92);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | bodyFrameLayout.AddChidren(btnPic);
|
| | | listBackControl.frameTable.AddChidren(btnPic);
|
| | | btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | //设备所属类型
|
| | |
| | | var btnBelongType = new NormalViewControl(700, 62, true);
|
| | | btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
|
| | | btnBelongType.Gravity = Gravity.CenterHorizontal;
|
| | | btnBelongType.TextID = infoType.BeloneTextId;
|
| | | btnBelongType.Text = infoType.BeloneText;
|
| | | btnBelongType.TextSize = 15;
|
| | | btnBelongType.TextAlignment = TextAlignment.Center;
|
| | | bodyFrameLayout.AddChidren(btnBelongType);
|
| | | listBackControl.frameTable.AddChidren(btnBelongType);
|
| | |
|
| | | //功能名称
|
| | | string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
|
| | |
| | | btnNote.AddBottomLine();
|
| | |
|
| | | //喜爱房间不允许出现区域
|
| | | if (this.room.IsLove == false)
|
| | | if (this.room == null || this.room.IsLove == false)
|
| | | {
|
| | | //所属区域
|
| | | caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
|
| | |
| | | }
|
| | |
|
| | | //所属模块
|
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongModel);
|
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
|
| | | nameValue = Common.LocalDevice.Current.GetDeviceMacName(device);
|
| | | var rowBelongModul = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
|
| | | rowBelongModul.UseClickStatu = false;
|
| | |
| | | this.AddFunctionTypeRowByMember();
|
| | |
|
| | | //初始化桌布完成
|
| | | tableContr.FinishInitControl(bodyFrameLayout, this.listview);
|
| | | tableContr.FinishInitControl();
|
| | | tableContr = null;
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | private void AddFunctionTypeRowByAdmin(NormalViewControl btnBelongType)
|
| | | {
|
| | | //如果是继电器,空气开关,调光器的话
|
| | | if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight
|
| | | || device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.AirSwitch)
|
| | | //自定义功能类型控件
|
| | | var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
|
| | | if (rowFunction.CanShowRow == true)
|
| | | {
|
| | | //功能类型的翻译名字
|
| | | int nowSelectNo = 1;
|
| | | string strType = string.Empty;
|
| | | if (this.device.DfunctionType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uLight);
|
| | | nowSelectNo = 1;
|
| | | }
|
| | | else if (this.device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
|
| | | nowSelectNo = 0;
|
| | | }
|
| | | else if (this.device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
|
| | | nowSelectNo = 2;
|
| | | }
|
| | | //功能类型
|
| | | var btnFunction = new FrameCaptionViewControl(Language.StringByID(R.MyInternationalizationString.uFunctionType), strType, listview.rowSpace / 2);
|
| | | btnFunction.UseClickStatu = false;
|
| | | listview.AddChidren(btnFunction);
|
| | | btnFunction.InitControl();
|
| | | listview.AddChidren(rowFunction);
|
| | | rowFunction.InitControl();
|
| | | //底线
|
| | | btnFunction.AddBottomLine();
|
| | | //如果是空气开关和继电器,才能修改
|
| | | if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch)
|
| | | rowFunction.AddBottomLine();
|
| | | rowFunction.FinishSelectEvent += (index) =>
|
| | | {
|
| | | //右箭头
|
| | | btnFunction.AddRightArrow();
|
| | | btnFunction.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示列表
|
| | | var listText = new List<string>();
|
| | | listText.Add(Language.StringByID(R.MyInternationalizationString.uSwitch));//开关
|
| | | listText.Add(Language.StringByID(R.MyInternationalizationString.uLight));//灯光
|
| | | listText.Add(Language.StringByID(R.MyInternationalizationString.uSocket1));//插座
|
| | | //标题:选择功能类型
|
| | | var title = Language.StringByID(R.MyInternationalizationString.uSelectFunctionType);
|
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.AddForm(title, listText, nowSelectNo);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | btnFunction.Text = listText[selectNo];
|
| | | //当类型变更时,头上的类型也一起变更
|
| | | btnBelongType.Text = listText[selectNo];
|
| | | nowSelectNo = selectNo;
|
| | | //记录起当前选择的功能类型
|
| | | if (selectNo == 0)
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A开关;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | | {
|
| | | //重新设置图片
|
| | | this.device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | }
|
| | | else if (selectNo == 1)
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | | {
|
| | | //重新设置图片
|
| | | this.device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A插座;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | | {
|
| | | //重新设置图片
|
| | | this.device.IconPath = "Device/Socket1.png";
|
| | | }
|
| | | }
|
| | | this.device.ReSave();
|
| | | };
|
| | | };
|
| | | }
|
| | | //当类型变更时,头上的类型也一起变更
|
| | | btnBelongType.Text = rowFunction.Text;
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | private void AddFunctionTypeRowByMember()
|
| | | {
|
| | | //如果是继电器,空气开关,调光器的话
|
| | | if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight
|
| | | || device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.AirSwitch)
|
| | | //自定义功能类型控件
|
| | | var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
|
| | | if (rowFunction.CanShowRow == true)
|
| | | {
|
| | | //功能类型的翻译名字
|
| | | string strType = string.Empty;
|
| | | if (this.device.DfunctionType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uLight);
|
| | | }
|
| | | else if (this.device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
|
| | | }
|
| | | else if (this.device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
|
| | | }
|
| | |
|
| | | //功能类型
|
| | | var btnFunction = new FrameCaptionViewControl(Language.StringByID(R.MyInternationalizationString.uFunctionType), strType, listview.rowSpace / 2);
|
| | | btnFunction.UseClickStatu = false;
|
| | | listview.AddChidren(btnFunction);
|
| | | btnFunction.InitControl();
|
| | | //强制干涉不能选择
|
| | | rowFunction.SetCanSelect = false;
|
| | | listview.AddChidren(rowFunction);
|
| | | rowFunction.InitControl();
|
| | | //底线
|
| | | btnFunction.AddBottomLine();
|
| | | rowFunction.AddBottomLine();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// 设备重命名
|
| | | /// </summary>
|
| | | /// <param name="i_deviceName">deviceName.</param>
|
| | | private async void DeviceReName(string i_deviceName, bool closeForm)
|
| | | private void DeviceReName(string i_deviceName, bool closeForm)
|
| | | {
|
| | | //修改MAC名
|
| | | string deviceName = i_deviceName.Trim();
|
| | | var result = await LocalDevice.Current.ReName(this.device, deviceName);
|
| | | var result = LocalDevice.Current.ReName(this.device, deviceName);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | |
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | this.FormCloseEvent?.Invoke(this.device, this.room);
|
| | | this.FormCloseEvent?.Invoke();
|
| | | this.FormCloseEvent = null;
|
| | |
|
| | | base.CloseFormBefore();
|