From c47c3ec2488961b3a006aaebcb03dba582f8b19b Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 12 三月 2020 17:08:42 +0800 Subject: [PATCH] 2020-03-12-1 --- ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs | 205 +++++++++++++++++++++++---------------------------- 1 files changed, 93 insertions(+), 112 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs old mode 100644 new mode 100755 index 932c51b..1b5cb52 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs @@ -21,7 +21,7 @@ /// <summary> /// action /// </summary> - public Action action; + public Action<CommonDevice, Common.Room> EditAction; /// <summary> /// curRoom /// </summary> @@ -39,6 +39,7 @@ /// </summary> private DeviceInfoRow functionTypeRow; + #endregion #region 鈼� 绉婚櫎____________________________ @@ -47,7 +48,7 @@ /// </summary> public override void RemoveFromParent() { - action(); + EditAction = null; base.RemoveFromParent(); } #endregion @@ -69,13 +70,13 @@ /// </summary> /// <param name="device"></param> /// <param name="room"></param> - public void Show(DeviceUI device, Common.Room room) + public void Show(CommonDevice device, Common.Room room) { Init(device); AddTop(); - AddBodyView(device); + AddBodyView(device,room); } @@ -101,7 +102,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device, Common.Room room) { bodyFrameLayout = new FrameLayout() { @@ -143,14 +144,17 @@ }; bodyFrameLayout.AddChidren(deviceIMG); + var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device); + var deviceTypeName = new Button() { Y = Application.GetRealHeight(360), Width = Application.GetRealWidth(900), Height = Application.GetRealHeight(80), TextColor = ZigbeeColor.Current.GXCTextBlackColor, - Text = DeviceUI.GetDeviceTypeName(device.CommonDevice.Type), - Gravity = Gravity.CenterHorizontal + TextID = info.BeloneTextId, + Gravity = Gravity.CenterHorizontal, + TextSize = 15 }; bodyFrameLayout.AddChidren(deviceTypeName); @@ -163,7 +167,7 @@ }; bodyFrameLayout.AddChidren(infoFL); var rectCornerID = HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight; - infoFL.SetCornerWithSameRadius(Application.GetRealHeight(50), rectCornerID); + infoFL.SetCornerWithSameRadius(Application.GetRealHeight(58), rectCornerID); var tipBtn = new Button { @@ -178,33 +182,66 @@ }; infoFL.AddChidren(tipBtn); - var nameRow = new DeviceInfoEditRow(170); + var infoScrolView = new VerticalScrolViewLayout + { + Y = Application.GetRealHeight(170-12), + Height = Application.GetRealHeight(600), + ScrollEnabled = false, + VerticalScrollBarEnabled = false + }; + infoFL.AddChidren(infoScrolView); + + var nameFL = new FrameLayout + { + Height = Application.GetRealHeight(127 + 12) + }; + infoScrolView.AddChidren(nameFL); + var nameRow = new DeviceInfoEditRow(12); nameRow.Init(); nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionName)} : "); - nameRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceEpointName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceEpointName); - infoFL.AddChidren(nameRow); + nameRow.SetTitle(string.IsNullOrEmpty(Common.LocalDevice.Current.GetDeviceEpointName(device)) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : Common.LocalDevice.Current.GetDeviceEpointName(device)); + nameFL.AddChidren(nameRow); - var zoneRow = new DeviceInfoRow(308); + + var zoneFL = new FrameLayout + { + Height = Application.GetRealHeight(127 + 12) + }; + if (room != null && room.IsLove == false) + { + infoScrolView.AddChidren(zoneFL); + } + var zoneRow = new DeviceInfoRow(12); zoneRow.Init(); zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)} : "); zoneRow.SetTitle(roomName); - infoFL.AddChidren(zoneRow); + zoneFL.AddChidren(zoneRow); - var modelRow = new DeviceInfoRow(446); + var modelFL = new FrameLayout + { + Height = Application.GetRealHeight(127 + 12) + }; + infoScrolView.AddChidren(modelFL); + var modelRow = new DeviceInfoRow(12); modelRow.Init(); modelRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongModel)} : "); - modelRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName); + modelRow.SetTitle(string.IsNullOrEmpty(device.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.DeviceName); modelRow.HideNext(true); - infoFL.AddChidren(modelRow); + modelFL.AddChidren(modelRow); - if (device.CommonDevice.Type==ZigBee.Device.DeviceType.OnOffOutput) + if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch) { - functionTypeRow = new DeviceInfoRow(585); + var typeFL = new FrameLayout + { + Height = Application.GetRealHeight(127 + 12) + }; + infoScrolView.AddChidren(typeFL); + functionTypeRow = new DeviceInfoRow(12); functionTypeRow.Init(); functionTypeRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionType)} : "); //functionTypeRow.SetTitle(device.CommonDevice.DfunctionType); - infoFL.AddChidren(functionTypeRow); - var dfunctionType = device.CommonDevice.DfunctionType; + typeFL.AddChidren(functionTypeRow); + var dfunctionType = device.DfunctionType; //鍔熻兘绫诲瀷鐨勭炕璇戝悕瀛� string strT = string.Empty; @@ -224,7 +261,7 @@ functionTypeRow.ClickBtn.MouseUpEventHandler += (sender, e) => { - var DfunctionType = device.CommonDevice.DfunctionType; + var DfunctionType = device.DfunctionType; //鍔熻兘绫诲瀷鐨勭炕璇戝悕瀛� int nowSelectNo = 1; @@ -261,87 +298,35 @@ //璁板綍璧峰綋鍓嶉�夋嫨鐨勫姛鑳界被鍨� if (selectNo == 0) { - device.CommonDevice.DfunctionType = DeviceFunctionType.A寮�鍏�; + device.DfunctionType = DeviceFunctionType.A寮�鍏�; } else if (selectNo == 1) { - device.CommonDevice.DfunctionType = DeviceFunctionType.A鐏厜; + device.DfunctionType = DeviceFunctionType.A鐏厜; } else { - device.CommonDevice.DfunctionType = DeviceFunctionType.A鎻掑骇; + device.DfunctionType = DeviceFunctionType.A鎻掑骇; } }; }; - - //sharedRow = new DeviceInfoRow(723); - //sharedRow.Init(); - //sharedRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.Share)} : "); - //sharedRow.SetTitle("2浜�"); - //infoFL.AddChidren(sharedRow); - } - else - { - //sharedRow = new DeviceInfoRow(585); - //sharedRow.Init(); - //sharedRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.Share)} : "); - //sharedRow.SetTitle("2浜�"); - //infoFL.AddChidren(sharedRow); } - var confirmBtn = new CommonForm.CompleteButton(962, 907, 127); - confirmBtn.SetTitle(R.MyInternationalizationString.Confrim); + + var confirmBtn = new CommonForm.CompleteButton(962, 900, 127); + confirmBtn.SetTitle(R.MyInternationalizationString.Save); infoFL.AddChidren(confirmBtn); #region event EventHandler<MouseEventArgs> selectZoneEvent = (sender, e) => { - List<string> floorIds = new List<string> { }; - List<string> floorNames = new List<string> { }; - List<List<string>> roomNames = new List<List<string>> { }; - List<List<Common.Room>> rooms = new List<List<Common.Room>> { }; - List<Common.Room> rs = new List<Common.Room> { }; - List<string> rNames = new List<string> { }; - if (Config.Instance.Home.FloorDics.Count>0) + var zone = new SelectZone(); + zone.Init(); + zone.ZoneAction += (selectRoom) => { - foreach (var floor in Config.Instance.Home.FloorDics) - { - floorIds.Add(floor.Key); - floorNames.Add(floor.Value); - if (Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count > 0) - { - roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); - rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); - } - } - PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => - { - curRoom = rooms[index1][index2]; - zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(floorIds[index1])} , {rooms[index1][index2].Name}"); - }, 0, 0, Language.StringByID(R.MyInternationalizationString.BelongFloor), - Language.StringByID(R.MyInternationalizationString.Confrim), - Language.StringByID(R.MyInternationalizationString.Cancel)); - } - else - { - for(int i=0;i<Common.Room.Lists.Count;i++) - { - var r = Common.Room.Lists[i]; - if (r.IsLove) - { - continue; - } - rs.Add(r); - rNames.Add(r.Name); - } - PickerView.Show(rNames, (index1) => - { - curRoom = rs[index1]; - zoneRow.SetTitle(rs[index1].Name); - }, 0,Language.StringByID(R.MyInternationalizationString.BelongFloor), - Language.StringByID(R.MyInternationalizationString.Confrim), - Language.StringByID(R.MyInternationalizationString.Cancel)); - } + curRoom = selectRoom; + zoneRow.SetTitle(HdlRoomLogic.Current.GetZoneName(selectRoom)); + }; }; zoneRow.ClickBtn.MouseUpEventHandler += selectZoneEvent; @@ -355,7 +340,7 @@ { deviceIMG.UnSelectedImagePath = unSelectedImagePath; deviceIMG.SelectedImagePath = selectedImagePath; - device.CommonDevice.IsCustomizeImage = true; + device.IsCustomizeImage = true; }; }; deviceIMG.MouseUpEventHandler += selectDeviceIconEvent; @@ -365,61 +350,57 @@ try { CommonPage.Loading.Start(); - if (device.CommonDevice == null) + if (device == null) { - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); + CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain)); return; } - if (device.CommonDevice.Type == ZigBee.Device.DeviceType.OnOffOutput) + if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch) { if (device.IsCustomizeImage == false) { - if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) { - device.CommonDevice.IconPath = "Device/Switch.png"; + device.IconPath = "Device/Switch.png"; } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) { - device.CommonDevice.IconPath = "Device/Socket1.png"; + device.IconPath = "Device/Socket1.png"; } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鐏厜) + else if (device.DfunctionType == DeviceFunctionType.A鐏厜) { - device.CommonDevice.IconPath = "Device/Light.png"; + device.IconPath = "Device/Light.png"; } } else { //鏀瑰浘鐗� - device.CommonDevice.IconPath = deviceIMG.UnSelectedImagePath; + device.IconPath = deviceIMG.UnSelectedImagePath; } } else { //鏀瑰浘鐗� - device.CommonDevice.IconPath = deviceIMG.UnSelectedImagePath; + device.IconPath = deviceIMG.UnSelectedImagePath; } bool result; new System.Threading.Thread(async () => { - result = await LocalDevice.Current.ReName(device.CommonDevice, nameRow.NameText.Text.Trim()); + result = await LocalDevice.Current.ReName(device, nameRow.NameText.Text.Trim()); Application.RunOnMainThread(() => { CommonPage.Loading.Hide(); if (result) { - var alertSuccess = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.Success), Language.StringByID(R.MyInternationalizationString.Confrim)); - alertSuccess.Show(); - alertSuccess.ResultEventHandler += (senderSuccess, eSuccess) => - { - //鏀规埧闂� - Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, curRoom.Id); - device.CommonDevice.ReSave(); - RemoveFromParent(); - }; + //鏀规埧闂� + HdlRoomLogic.Current.ChangedRoom(device, curRoom.Id); + device.ReSave(); + EditAction?.Invoke(device, curRoom); + RemoveFromParent(); } else { - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); + CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.FailedPleaseTryAgain)); } }); }) @@ -438,11 +419,11 @@ /// Init /// </summary> /// <param name="device"></param> - public void Init(DeviceUI device) + public void Init(CommonDevice device) { - roomName = device.GetZone(); - befRoom = Common.Room.CurrentRoom.GetRoomByDevice(device.CommonDevice); - curRoom = Common.Room.CurrentRoom.GetRoomByDevice(device.CommonDevice); + roomName = HdlRoomLogic.Current.GetRoomNameByDevice(device, "锛�"); + befRoom = HdlRoomLogic.Current.GetRoomByDevice(device); + curRoom = HdlRoomLogic.Current.GetRoomByDevice(device); } #endregion } -- Gitblit v1.8.0