From d569f44a62fa915d4f01a80c21e617f676b6c5ea Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 18 十月 2019 10:12:10 +0800 Subject: [PATCH] 2019.10.18 --- ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 902 ++++++++++++++++++------------------------------------- 1 files changed, 303 insertions(+), 599 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs old mode 100755 new mode 100644 index 15df16b..48f3418 --- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs @@ -2,27 +2,48 @@ using System.Collections.Generic; using System.Globalization; using Shared.Common; +using Shared.Phone.Device.CommonForm; using Shared.Phone.Device.Room; using static ZigBee.Device.Scene; namespace Shared.Phone.Device.Category { - public class CategoryAddScene:FrameLayout + public class CategoryAddScene : FrameLayout { - public static string ImagePath; - public static string SceneText; - public static Shared.Common.Room CurrentRoom; - public static List<SceneTargetDeviceUI> sceneTargetDevicesList=new List<SceneTargetDeviceUI>{}; + #region 鈼� 鍙橀噺____________________________ /// <summary> - /// 璁板綍缂栬緫鍓嶇殑璁惧鍒楄〃 + /// bodyFrameLayout /// </summary> - public static List<SceneTargetDeviceUI> beforeSceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; - public static bool Modify = false; - public static SceneUI ModifySceneUI = null; + private FrameLayout bodyFrameLayout; /// <summary> - /// 鍥剧墖鏉ユ簮 0--鏈湴鍥惧簱 1--鎷嶇収 2--绯荤粺鍥惧簱 + /// floorIds /// </summary> - public static int IconType = 0; + List<string> floorIds = new List<string> { }; + /// <summary> + /// floorNames + /// </summary> + List<string> floorNames = new List<string> { }; + /// <summary> + /// roomNames + /// </summary> + List<List<string>> roomNames = new List<List<string>> { }; + /// <summary> + /// roomNames + /// </summary> + List<List<Common.Room>> rooms = new List<List<Common.Room>> { }; + /// <summary> + /// ImagePath + /// </summary> + private string ImagePath="SceneIcon/1.png"; + /// <summary> + /// curRoom + /// </summary> + private Common.Room curRoom; + /// <summary> + /// sceneTargetDevicesList + /// </summary> + private List<SceneTargetDeviceUI> sceneTargetDevicesList = new List<SceneTargetDeviceUI> { }; + /// <summary> /// 娣诲姞鐩爣鍚庣殑灞曠ず鍒楄〃 /// </summary> @@ -39,20 +60,20 @@ /// 纭畾鎸夐挳鏈�寮�濮嬬殑鍧愭爣 /// </summary> private readonly int ConfirmButton_Y = CommonPage.AppRealHeight - 300; - /// <summary> - /// 纭畾鎸夐挳涓嬬Щ鍚庣殑鍧愭爣 - /// </summary> - private readonly int ConfirmButton_Change_Y = CommonPage.AppRealHeight - 130; - /// <summary> - /// 璁板綍鏇存敼鍓嶇殑鎴块棿 - /// </summary> - private Shared.Common.Room oldRoom; + #endregion + + /// <summary> + /// CategoryAddScene + /// </summary> public CategoryAddScene() { BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; Tag = "categoryAddScene"; } + /// <summary> + /// RemoveFromParent + /// </summary> public override void RemoveFromParent() { Category.instance?.RefreshBodyView(); @@ -64,16 +85,6 @@ public void RefreshTargetListView() { TargetListScrolView.RemoveAll(); - if (sceneTargetDevicesList.Count >= 2) - { - TargetListScrolView.Height = Application.GetRealHeight(TargetListScrolView_RowHeight * 3); - confirmBtn.Y = Application.GetRealHeight(ConfirmButton_Change_Y); - } - else - { - TargetListScrolView.Height = Application.GetRealHeight(TargetListScrolView_RowHeight * 2); - confirmBtn.Y = Application.GetRealHeight(ConfirmButton_Y); - } if (sceneTargetDevicesList.Count > 0) { @@ -81,26 +92,27 @@ { string devImgPath = string.Empty; string devNameText = string.Empty; - if (targetDevice.Type==0) + if (targetDevice.Type == 0) { if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) continue; devImgPath = targetDevice.DeviceUI.IconPath; devNameText = targetDevice.DeviceUI.CommonDevice.DeviceEpointName; } - else if(targetDevice.Type==1) + else if (targetDevice.Type == 1) { devImgPath = "Item/Timer.png"; devNameText = $"{targetDevice.DelayTime} {Language.StringByID(R.MyInternationalizationString.Second)}"; } - else if(targetDevice.Type==2) + else if (targetDevice.Type == 2) { devImgPath = "Item/Scene.png"; devNameText = targetDevice.SceneName; } var targetRowLayout = new RowLayout() { + Height = Application.GetRealHeight(160), LineColor = ZigbeeColor.Current.GXCLineColor, - Height = Application.GetRealHeight(170) + BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor }; TargetListScrolView.AddChidren(targetRowLayout); @@ -147,21 +159,6 @@ TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; targetRowLayout.AddRightView(devRight); - //寤舵椂 - devTimer.MouseUpEventHandler += (sender, e) => - { - /////******鏆傛椂鍏堜笉鍔犲欢鏃讹紝瀹夊崜鎺т欢鏈夐棶棰�*******//// - var tList = new List<string> { }; - for(int i=1;i<=60;i++) - { - tList.Add($"{i} {Language.StringByID(R.MyInternationalizationString.Second)}"); - } - //1-60绉� - PickerView.Show(tList, (obj) => - { - targetDevice.DelayTime =int.Parse(tList[obj].Split(' ')[0]); - },0,"",Language.StringByID(R.MyInternationalizationString.Confrim)); - }; //鍒犻櫎璁惧 devRight.MouseUpEventHandler += (sender, e) => { @@ -190,7 +187,7 @@ var detail = new CategorySceneSelectLightSetting(); UserView.HomePage.Instance.AddChidren(detail); UserView.HomePage.Instance.PageIndex += 1; - detail.Show(targetDevice.DeviceUI,targetDevice.SceneTargetDeviceUIID, taskList[0].Data1); + detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1); } else if (targetDevice.DeviceUI.CommonDevice.Type == ZigBee.Device.DeviceType.AirSwitch) { @@ -231,11 +228,11 @@ UserView.HomePage.Instance.AddChidren(detail); UserView.HomePage.Instance.PageIndex += 1; UserView.HomePage.Instance.ScrollEnabled = false; - if(taskList[0].TaskType==1) + if (taskList[0].TaskType == 1) { detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].Data1, taskList[0].Data2); } - else if(taskList[0].TaskType==3) + else if (taskList[0].TaskType == 3) { detail.Show(targetDevice.DeviceUI, targetDevice.SceneTargetDeviceUIID, taskList[0].TaskType, taskList[0].Data1); @@ -248,10 +245,20 @@ //鏃堕棿闂撮殧 else if (targetDevice.Type == 1) { - var delayTimeView = new CategorySceneSelectedDelayTime(); + var delayTimeView = new SelectDelayTime(); UserView.HomePage.Instance.AddChidren(delayTimeView); UserView.HomePage.Instance.PageIndex += 1; - delayTimeView.Show(1,targetDevice.SceneTargetDeviceUIID); + delayTimeView.sceneTargetDevice = targetDevice; + delayTimeView.Show(); + delayTimeView.selectedTimeAction = (second) => + { + var targetDeviceUI = sceneTargetDevicesList.Find((obj) => obj.SceneTargetDeviceUIID == second.SceneTargetDeviceUIID); + if (targetDeviceUI != null) + { + targetDeviceUI.DelayTime = second.DelayTime; + } + RefreshTargetListView(); + }; } //鍦烘櫙 else if (targetDevice.Type == 2) @@ -259,7 +266,7 @@ var sceneView = new CategorySceneSelectedScene(); UserView.HomePage.Instance.AddChidren(sceneView); UserView.HomePage.Instance.PageIndex += 1; - sceneView.Show(sceneTargetDevicesList,1,targetDevice.SceneTargetDeviceUIID); + sceneView.Show(sceneTargetDevicesList, 1, targetDevice.SceneTargetDeviceUIID); } } devIMG.MouseUpEventHandler += detailMouseUpEventHandler; @@ -274,212 +281,189 @@ /// </summary> public void Show() { - #region topview - var topBGView = new FrameLayout()鈥� {鈥� Height = Application.GetRealHeight(CommonPage.Navigation_Height),鈥� BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor鈥� };鈥� AddChidren(topBGView);鈥� var topView = new FrameLayout()鈥� {鈥� Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),鈥� Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),鈥� BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,鈥� };鈥� AddChidren(topView); - var title = new Button() - { - TextAlignment = TextAlignment.Center, - TextID = R.MyInternationalizationString.AddScence, - TextSize = 20, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500), - Gravity = Gravity.CenterHorizontal - }; - topView.AddChidren(title); - var back = new Device.CommonForm.BackButton() { };鈥� topView.AddChidren(back); - back.MouseUpEventHandler += (sender, e) => - { - this.RemoveFromParent(); - }; - #endregion + Init(); - #region midFL - var midFL = new FrameLayout() + AddTop(); + + AddBodyView(); + + } + + #region Add____________________________________ + + /// <summary> + /// Init + /// </summary> + private void Init() + { + foreach (var floor in Config.Instance.Home.FloorDics) { - Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height), - Y = topView.Bottom, - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, + 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)); + } + } + } + + /// <summary> + /// AddTop + /// </summary> + private void AddTop() + { + var top = new TopFrameLayout(); + AddChidren(top); + top.InitTopview(); + top.SetTopTitle(R.MyInternationalizationString.AddScence); + top.backButton.MouseUpEventHandler += (sender, e) => + { + RemoveFromParent(); }; - this.AddChidren(midFL); - #endregion - #region 鑳屾櫙鍥� 鍚嶇О 鍖哄煙 鎵ц鐩爣 + } + + /// <summary> + /// AddBodyView + /// </summary> + private void AddBodyView() + { + bodyFrameLayout = new FrameLayout() + { + Y = Application.GetRealHeight(184), + Height = Application.GetRealHeight(1737), + BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor, + }; + AddChidren(bodyFrameLayout); + + var imgFL = new FrameLayout + { + Height = Application.GetRealHeight(556), + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor + }; + bodyFrameLayout.AddChidren(imgFL); var backGround = new Button() { - Y = Application.GetRealHeight(50), - Width = Application.GetRealWidth(980), - Height = Application.GetRealHeight(350), - Gravity = Gravity.CenterHorizontal, - Radius = CommonPage.BigFormRadius, - UnSelectedImagePath = ImagePath + Width = Application.GetRealWidth(930), + Height = Application.GetRealHeight(464), + Gravity = Gravity.Center, + Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius), + //UnSelectedImagePath = ImagePath + UnSelectedImagePath = "SceneIcon/3.png" }; - midFL.AddChidren(backGround); - //--鍦烘櫙鍚� - var sceneNameFL = new FrameLayout() + imgFL.AddChidren(backGround); + + var infoFL = new FrameLayout { - Y = backGround.Bottom + Application.GetRealHeight(100), - Height = Application.GetRealHeight(170), + Y = imgFL.Bottom + Application.GetRealHeight(23), + Height = Application.GetRealHeight(418), + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; - midFL.AddChidren(sceneNameFL); - var sceneNameTip = new Button() + bodyFrameLayout.AddChidren(infoFL); + + var infoEdit = new Button { - X = Application.GetRealWidth(50), - Height = Application.GetRealHeight(70), - Width = Application.GetRealWidth(300), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, - TextColor = ZigbeeColor.Current.GXCButtonTipColor, - TextID = R.MyInternationalizationString.SceneName, - }; - sceneNameFL.AddChidren(sceneNameTip); - var sceneNameET = new EditText() - { - X = Application.GetRealWidth(50), - Y = sceneNameTip.Bottom, - Height = Application.GetRealHeight(100) - 1, + X = Application.GetRealWidth(CommonFormResouce.X_Left), + Height = Application.GetRealHeight(130), Width = Application.GetRealWidth(700), + TextID = R.MyInternationalizationString.EditInfo, + TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor, TextAlignment = TextAlignment.CenterLeft, - TextSize = 20, - PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName), - PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, + TextSize = 14 }; - sceneNameFL.AddChidren(sceneNameET); - var sceneNameLine = new Button() - { - Y = sceneNameET.Bottom, - Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor - }; - sceneNameFL.AddChidren(sceneNameLine); - //zone - var zoneFL = new FrameLayout() - { - Y = sceneNameFL.Bottom, - Height = Application.GetRealHeight(170), - }; - midFL.AddChidren(zoneFL); - var zoneTip = new Button() - { - X = Application.GetRealWidth(50), - Height = Application.GetRealHeight(70), - Width = Application.GetRealWidth(300), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, - TextColor = ZigbeeColor.Current.GXCButtonTipColor, - TextID = R.MyInternationalizationString.BelongZone, - }; - zoneFL.AddChidren(zoneTip); - var zone = new Button() - { - X = Application.GetRealWidth(50), - Y = sceneNameTip.Bottom, - Height = Application.GetRealHeight(100) - 1, - Width = Application.GetRealWidth(500), - TextAlignment = TextAlignment.CenterLeft, - TextSize = 20, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - Text = CurrentRoom.Name - }; - zoneFL.AddChidren(zone); - var zoneRight = new Device.CommonForm.SelectedStatuButton() - { - X = Application.GetRealWidth(1080 - 150), - Width = Application.GetMinRealAverage(110), - Height = Application.GetMinRealAverage(110), - UnSelectedImagePath = "Item/Next.png", - SelectedImagePath="Item/NextSelected.png", - Gravity = Gravity.CenterVertical - }; - zoneFL.AddChidren(zoneRight); - var zoneLine = new Button() - { - Y = zone.Bottom, - Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor - }; - zoneFL.AddChidren(zoneLine); - //娣诲姞鎵ц鐩爣 + infoFL.AddChidren(infoEdit); + + + var nameRow = new DeviceInfoEditRow(130); + nameRow.Init(); + nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.SceneName)}:"); + nameRow.SetPlaceHoldText(R.MyInternationalizationString.PleaseInputSceneName); + infoFL.AddChidren(nameRow); + + var zoneRow = new DeviceInfoRow(257); + zoneRow.Init(); + zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)}:"); + //zoneRow.SetTitle(curRoom.Name); + infoFL.AddChidren(zoneRow); + zoneRow.HideLine(false); + var targetFL = new FrameLayout() { - Y = zoneFL.Bottom, - Height = Application.GetRealHeight(170), + Y = infoFL.Bottom + Application.GetRealHeight(23), + Height = Application.GetRealHeight(730) }; - midFL.AddChidren(targetFL); + bodyFrameLayout.AddChidren(targetFL); + + var targetBG = new FrameLayout + { + Height = Application.GetRealHeight(334), + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor + }; + targetFL.AddChidren(targetBG); + + var addTargetFL = new FrameLayout + { + Y=Application.GetRealHeight(46), + Height = Application.GetRealHeight(127), + }; + targetFL.AddChidren(addTargetFL); + var target = new Button() { - X = Application.GetRealWidth(50), - Y = sceneNameTip.Bottom, - Height = Application.GetRealHeight(170) - 1, - Width = Application.GetRealWidth(500), + X = Application.GetRealWidth(CommonFormResouce.X_Left), + Height = Application.GetRealHeight(127) - 1, + Width = Application.GetRealWidth(600), TextAlignment = TextAlignment.CenterLeft, - TextSize = 20, TextColor = ZigbeeColor.Current.GXCTextBlackColor, - TextID = R.MyInternationalizationString.AddRoomScentTargetAction, + TextID = R.MyInternationalizationString.AddScentTargetAction, Gravity = Gravity.CenterVertical }; - targetFL.AddChidren(target); - var targetAdd = new Device.CommonForm.SelectedStatuButton() + addTargetFL.AddChidren(target); + + var targetAdd = new Button { - X = Application.GetRealWidth(1080 - 150), - Width = Application.GetMinRealAverage(110), - Height = Application.GetMinRealAverage(110), + X = Application.GetRealWidth(950), + Y = Application.GetRealHeight(46), + Width = Application.GetMinRealAverage(72), + Height = Application.GetMinRealAverage(72), + Gravity=Gravity.CenterVertical, UnSelectedImagePath = "Item/Add.png", - SelectedImagePath="Item/AddSelected.png", - Gravity = Gravity.CenterVertical }; - targetFL.AddChidren(targetAdd); + addTargetFL.AddChidren(targetAdd); var targetLine = new Button() { Y = target.Bottom, Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor + BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2 }; - targetFL.AddChidren(targetLine); + addTargetFL.AddChidren(targetLine); + //娣诲姞鐩爣鍚庣殑灞曠ず鍒楄〃 TargetListScrolView = new VerticalScrolViewLayout() { - Y = targetFL.Bottom, - Height = Application.GetRealHeight(340+170), - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor + Y = targetLine.Bottom, + Height = Application.GetRealHeight(730-127), + //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; - midFL.AddChidren(TargetListScrolView); - confirmBtn = new CommonForm.CompleteButton() - { - TextID = R.MyInternationalizationString.NextStep, - }; + targetFL.AddChidren(TargetListScrolView); + + confirmBtn = new CommonForm.CompleteButton(1656, 907, 127); AddChidren(confirmBtn); RefreshTargetListView(); - if (!string.IsNullOrEmpty(SceneText)) - { - sceneNameET.Text = SceneText; - } - if(CurrentRoom!=null) - { - } - if(Modify) - { - title.TextID = R.MyInternationalizationString.ModifyScene; - oldRoom = CurrentRoom; - if (ModifySceneUI != null && ModifySceneUI.IsSharedScene) - { - sceneNameET.Enable = false; - } - } - #endregion #region event - //璁板綍杈撳叆鍦烘櫙鍚� - sceneNameET.TextChangeEventHandler += (sender, e) => - { - SceneText = sceneNameET.Text.Trim(); - }; //閫夋嫨鑳屾櫙鍥� EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) => { - if(CurrentRoom.IsSharedRoom) + if (curRoom == null) + { + RoomCommon.ShowTipNoRoom(); + return; + } + if (curRoom.IsSharedRoom) { RoomCommon.ShowTipRoomIsShared(); return; @@ -492,166 +476,43 @@ localPic.action = () => { backGround.UnSelectedImagePath = ImagePath; - IconType = 0; }; - //var selectDialog = new Dialog() - //{ - //}; - //selectDialog.Show(); - - //var itemFL = new FrameLayout() - //{ - // Y = Application.GetRealHeight(1920 - 600), - // Width = Application.GetRealWidth(900), - // Height = Application.GetRealHeight(550), - // Radius = CommonPage.BigFormRadius, - // //BackgroundColor=ZigbeeColor.Current.GXCBackgroundColor, - // Gravity = Gravity.CenterHorizontal - //}; - //selectDialog.AddChidren(itemFL); - - //var localPicBtn = new Button() - //{ - // Height = Application.GetRealHeight(130) - 1, - // TextID = R.MyInternationalizationString.LocalPic, - // TextColor = ZigbeeColor.Current.GXCTextBlackColor, - // TextAlignment = TextAlignment.Center, - // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - //}; - //itemFL.AddChidren(localPicBtn); - //var localPicLine = new Button() - //{ - // Y = localPicBtn.Bottom, - // Height = 1, - // BackgroundColor = ZigbeeColor.Current.GXCLineColor, - //}; - //itemFL.AddChidren(localPicLine); - - //var takePhotoBtn = new Button() - //{ - // Y = localPicLine.Bottom, - // Height = Application.GetRealHeight(130) - 1, - // TextID = R.MyInternationalizationString.TakePhoto, - // TextColor = ZigbeeColor.Current.GXCTextBlackColor, - // TextAlignment = TextAlignment.Center, - // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - //}; - //itemFL.AddChidren(takePhotoBtn); - //var takePhotoLine = new Button() - //{ - // Y = takePhotoBtn.Bottom, - // Height = 1, - // BackgroundColor = ZigbeeColor.Current.GXCLineColor, - //}; - //itemFL.AddChidren(takePhotoLine); - - //var systemPicBtn = new Button() - //{ - // Y = takePhotoLine.Bottom, - // Height = Application.GetRealHeight(130), - // TextID = R.MyInternationalizationString.SystemPic, - // TextColor = ZigbeeColor.Current.GXCTextBlackColor, - // TextAlignment = TextAlignment.Center, - // BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - //}; - //itemFL.AddChidren(systemPicBtn); - - - //var cancelBtn = new Button() - //{ - // Y = systemPicBtn.Bottom + Application.GetRealHeight(30), - // Height = Application.GetRealHeight(150), - // TextID = R.MyInternationalizationString.Cancel, - // TextColor = ZigbeeColor.Current.GXCTextWhiteColor, - // BackgroundColor = ZigbeeColor.Current.GXCButtonBlueColor, - // TextAlignment = TextAlignment.Center, - //}; - //itemFL.AddChidren(cancelBtn); - - ////鏈湴鍥惧簱 - //localPicBtn.MouseUpEventHandler += (send, ee) => - //{ - // selectDialog.Close(); - // var localPic = new CategorySceneSelectImgByLocal(); - // Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic); - // Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - // localPic.Show(); - // localPic.action = () => - // { - // backGround.UnSelectedImagePath = ImagePath; - // IconType = 0; - // }; - //}; - ////鎷嶇収 - //takePhotoBtn.MouseUpEventHandler += (send, ee) => - //{ - // var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - // selectDialog.Close(); - // Camera.TakePicture((obj) => - // { - // if (obj == null) - // { - // return; - // } - // backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png"; - // ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}"; - // IconType = 1; - // }, $"ScenePicture{tradeTime}.png"); - //}; - ////绯荤粺鍥惧簱 - //systemPicBtn.MouseUpEventHandler += (send, ee) => - //{ - // var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - // selectDialog.Close(); - // Camera.SelectPicture((obj) => - // { - // if (obj == null) - // { - // return; - // } - // backGround.UnSelectedImagePath = $"ScenePicture{tradeTime}.png"; - // ImagePath = $"{Config.Instance.HomeId}/{backGround.UnSelectedImagePath}"; - // IconType = 2; - // }, $"ScenePicture{tradeTime}.png"); - //}; - //cancelBtn.MouseUpEventHandler += (send, ee) => - //{ - // selectDialog.Close(); - //}; }; backGround.MouseUpEventHandler += backGroundIMGHander; + + //鍖哄煙 EventHandler<MouseEventArgs> zoneHander = (sender, e) => { - if (CurrentRoom.IsSharedRoom) + PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) => { - RoomCommon.ShowTipRoomIsShared(); - return; - } - var selectRoom = new CategorySceneSelectRoomList(); - UserView.HomePage.Instance.AddChidren(selectRoom); - UserView.HomePage.Instance.PageIndex += 1; - selectRoom.SelectedRoomAction = (room) => - { - CurrentRoom = room; - zone.Text = CurrentRoom.Name; - }; - selectRoom.Show(); + curRoom = rooms[index1][index2]; + zoneRow.NameText.Text = $"{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)); }; - zoneRight.MouseUpEventHandler += zoneHander; - zoneFL.MouseUpEventHandler += zoneHander; - zone.MouseUpEventHandler += zoneHander; + zoneRow.NextBtn.MouseUpEventHandler += zoneHander; + zoneRow.TipBtn.MouseUpEventHandler += zoneHander; + zoneRow.NameText.MouseUpEventHandler += zoneHander; + zoneRow.MouseUpEventHandler += zoneHander; + //鎵ц鐩爣-娣诲姞鎵ц璁惧 EventHandler<MouseEventArgs> targetAddHander = (sender, e) => { - if (CurrentRoom.IsSharedRoom) + + if (curRoom == null) + { + RoomCommon.ShowTipNoRoom(); + return; + } + if (curRoom.IsSharedRoom) { RoomCommon.ShowTipRoomIsShared(); return; } - int selectRow_Height = 130; + int selectRow_Height = 150; + int selectRow_Width = 1034; var selectFL = new FrameLayout() { BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor @@ -660,37 +521,36 @@ var itemFL = new FrameLayout() { - Y = Application.GetRealHeight(CommonPage.AppRealHeight - selectRow_Height * 4 - 20), - Height = Application.GetRealHeight(selectRow_Height * 4 + 20) + Y = Application.GetRealHeight(1276), + Height = Application.GetRealHeight(450), + Width = Application.GetRealWidth(selectRow_Width), + Gravity=Gravity.CenterHorizontal, + Radius = (uint)Application.GetRealHeight(17), + BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor }; selectFL.AddChidren(itemFL); - var selectedFunctionBtn = new Device.CommonForm.SelectedStatuButton() + var selectedFunctionBtn = new Button() { Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.Function, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - TextAlignment = TextAlignment.Center, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 }; itemFL.AddChidren(selectedFunctionBtn); var selectedFunctionLine = new Button() { Y = selectedFunctionBtn.Bottom, Height = 1, - BackgroundColor = ZigbeeColor.Current.GXCLineColor, + BackgroundColor = ZigbeeColor.Current.GXCLineColor }; itemFL.AddChidren(selectedFunctionLine); - var selectedSceneBtn = new Device.CommonForm.SelectedStatuButton() + var selectedSceneBtn = new Button() { Y = selectedFunctionLine.Bottom, Height = Application.GetRealHeight(selectRow_Height) - 1, TextID = R.MyInternationalizationString.Scence, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 }; itemFL.AddChidren(selectedSceneBtn); var selectedSceneLine = new Button() @@ -701,29 +561,29 @@ }; itemFL.AddChidren(selectedSceneLine); - var selectedTimerBtn = new Device.CommonForm.SelectedStatuButton() + var selectedTimerBtn = new Button() { Y = selectedSceneLine.Bottom, - Height = Application.GetRealHeight(selectRow_Height)-1, - TextID = R.MyInternationalizationString.TimeSpan, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor + Height = Application.GetRealHeight(selectRow_Height) - 1, + TextID = R.MyInternationalizationString.Delay, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4 }; itemFL.AddChidren(selectedTimerBtn); - var cancelBtn = new Device.CommonForm.SelectedStatuButton() - { - Y = selectedTimerBtn.Bottom + Application.GetRealHeight(20), - Height = Application.GetRealHeight(selectRow_Height), - TextID = R.MyInternationalizationString.Cancel, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, - SelectedBackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor - }; - itemFL.AddChidren(cancelBtn); - itemFL.Animate = Animate.DownToUp; + var cancelBtn = new Button() + { + Y = Application.GetRealHeight(1742), + Height = Application.GetRealHeight(selectRow_Height), + Width = Application.GetRealWidth(selectRow_Width), + Gravity=Gravity.CenterHorizontal, + TextID = R.MyInternationalizationString.Cancel, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, + BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor, + Radius = (uint)Application.GetRealHeight(17) + }; + selectFL.AddChidren(cancelBtn); + //娣诲姞鍔熻兘 selectedFunctionBtn.MouseUpEventHandler += (send, ee) => { @@ -740,24 +600,30 @@ var sceneView = new CategorySceneSelectedScene(); UserView.HomePage.Instance.AddChidren(sceneView); UserView.HomePage.Instance.PageIndex += 1; - if(Modify) - { - sceneView.Show(sceneTargetDevicesList,-1, "", false, ModifySceneUI.Id); - } - else - { - sceneView.Show(sceneTargetDevicesList); - } + //if (Modify) + //{ + // sceneView.Show(sceneTargetDevicesList, -1, "", false, ModifySceneUI.Id); + //} + //else + //{ + // sceneView.Show(sceneTargetDevicesList); + //} }; //娣诲姞鏃堕棿闂撮殧 selectedTimerBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); - var delayTimeView = new CategorySceneSelectedDelayTime(); + var delayTimeView = new SelectDelayTime(); UserView.HomePage.Instance.AddChidren(delayTimeView); UserView.HomePage.Instance.PageIndex += 1; delayTimeView.Show(); + delayTimeView.selectedTimeAction = (second) => + { + sceneTargetDevicesList.Add(second); + RefreshTargetListView(); + }; }; + cancelBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); @@ -770,54 +636,46 @@ targetAdd.MouseUpEventHandler += targetAddHander; targetFL.MouseUpEventHandler += targetAddHander; target.MouseUpEventHandler += targetAddHander; + addTargetFL.MouseUpEventHandler += targetAddHander; //纭畾娣诲姞鐩爣 confirmBtn.MouseUpEventHandler += async (sender, e) => { - if (CurrentRoom.IsSharedRoom) + if (curRoom == null) + { + RoomCommon.ShowTipNoRoom(); + return; + } + if (curRoom.IsSharedRoom) { RemoveFromParent(); return; } - if (Modify) + + //鏂板 + if (string.IsNullOrEmpty(nameRow.NameText.Text)) + { + var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull), Language.StringByID(R.MyInternationalizationString.Close)); + alert.Show(); + alert.ResultEventHandler += (sendAlert, eAlert) => + { + return; + }; + } + else { try { - CommonPage.Loading.Start(); - //淇敼--鍏堝垽鏂満鏅悕鏄惁鏀瑰彉锛屽啀绉婚櫎璁惧锛屽啀娣诲姞璁惧 - ModifySceneUI.IconPath = ImagePath; - if (ModifySceneUI.Name != sceneNameET.Text.Trim()) + if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) { - if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == sceneNameET.Text.Trim()) != null) - { - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); - return; - } - //淇敼鍚嶅瓧 - var r = await ZigBee.Device.Scene.RenameSceneAsync(ModifySceneUI.Id, sceneNameET.Text.Trim()); - var reName = r.sceneRenameResponseData.Result; - if (reName == 0) - { - //澶辫触 - return; - } - else if (reName == 1) - { - //鎴愬姛 - ModifySceneUI.Name = sceneNameET.Text.Trim(); - - } - else if (reName == 2) - { - //娌℃湁璇ュ満鏅� - return; - } + Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); + return; } - //淇敼璁惧 - var memberDataList = new List<AddSceneMemberData>(); + CommonPage.Loading.Start(); + var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>(); + //绱姞寤舵椂 int AddedDelayTime = 0; for (int i = 0; i < sceneTargetDevicesList.Count; i++) { - //鍚堝苟寤舵椂 var sceneTarget = sceneTargetDevicesList[i]; SceneTargetDeviceUI beforeSceneTarget = null; if (i - 1 >= 0) @@ -826,6 +684,11 @@ } if (sceneTarget.Type == 0) { + if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) + { + continue; + } + if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) { if (i - 1 >= 0) @@ -840,10 +703,7 @@ } } } - if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) - { - continue; - } + var memberData = new ZigBee.Device.Scene.AddSceneMemberData { DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, @@ -881,62 +741,21 @@ memberDataList.Add(memberData); } } - var sceneRemoveMemberData = new SceneRemoveMemberData { }; - var removeSceneDeviceListInfoList = new List<RemoveSceneDeviceListInfo> { }; - for (int i = 0; i < beforeSceneTargetDevicesList.Count; i++) - { - //鍚堝苟寤舵椂 - var sceneTarget = beforeSceneTargetDevicesList[i]; - if (sceneTarget.Type == 0) - { - if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) - { - continue; - } - var removeDevice = new RemoveSceneDeviceListInfo - { - Type = 0, - DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, - Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, - }; - removeSceneDeviceListInfoList.Add(removeDevice); - } - else if (sceneTarget.Type == 2) - { - var removeDevice = new ZigBee.Device.Scene.RemoveSceneDeviceListInfo - { - Type = 1, - ElseScenesId = sceneTarget.ElseScenesId - }; - removeSceneDeviceListInfoList.Add(removeDevice); - } - } - sceneRemoveMemberData.DeviceList = removeSceneDeviceListInfoList; - sceneRemoveMemberData.ScenesId = ModifySceneUI.Id; - var result = await CurrentRoom.ModifyScene(ModifySceneUI,sceneRemoveMemberData, memberDataList); + + var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList); if (result == 1) { - if(oldRoom!=CurrentRoom) - { - oldRoom.SceneUIList.Remove(ModifySceneUI); - oldRoom.SceneUIFilePathList.Remove(ModifySceneUI.FileName); - CurrentRoom.SceneUIList.Add(ModifySceneUI); - CurrentRoom.SceneUIFilePathList.Add(ModifySceneUI.FileName); - oldRoom.Save(); - CurrentRoom.Save(); - } - RemoveFromParent(); } else if (result == 0) { //澶辫触 - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); + CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); } else if (result == -1) { //宸插瓨鍦� - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); + CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); } } catch (Exception ex) @@ -947,129 +766,14 @@ { CommonPage.Loading.Hide(); } - } - //鏂板 - else - { - if (string.IsNullOrEmpty(sceneNameET.Text)) - { - var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.SceneNameCannotBeNull), Language.StringByID(R.MyInternationalizationString.Close)); - alert.Show(); - alert.ResultEventHandler += (sendAlert, eAlert) => - { - return; - }; - } - else - { - try - { - if (Shared.Common.Room.AllRoomSceneUIList.Find(s => s.Name == sceneNameET.Text.Trim()) != null) - { - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); - return; - } - CommonPage.Loading.Start(); - var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>(); - //绱姞寤舵椂 - int AddedDelayTime = 0; - for (int i = 0; i < sceneTargetDevicesList.Count; i++) - { - var sceneTarget = sceneTargetDevicesList[i]; - SceneTargetDeviceUI beforeSceneTarget = null; - if (i - 1 >= 0) - { - beforeSceneTarget = sceneTargetDevicesList[i - 1]; - } - if (sceneTarget.Type == 0) - { - if (sceneTarget.DeviceUI == null || sceneTarget.DeviceUI.CommonDevice == null) - { - continue; - } - if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) - { - if(i-1>=0) - { - for(int k=i-1;k>=0;k--) - { - if(sceneTargetDevicesList[k] == null || sceneTargetDevicesList[k].Type != 1) - { - break; - } - AddedDelayTime += sceneTargetDevicesList[k].DelayTime; - } - } - } - - var memberData = new ZigBee.Device.Scene.AddSceneMemberData - { - DeviceAddr = sceneTarget.DeviceUI.CommonDevice.DeviceAddr, - Type = 0, - ScenesId = 0, - Epoint = sceneTarget.DeviceUI.CommonDevice.DeviceEpoint, - TaskList = sceneTarget.TaskList, - DelayTime = AddedDelayTime - }; - memberDataList.Add(memberData); - } - else if (sceneTarget.Type == 2) - { - if (beforeSceneTarget != null && beforeSceneTarget.Type == 1) - { - if (i - 1 >= 0) - { - for (int k = i - 1; k >= 0; k--) - { - if (sceneTargetDevicesList[k] == null || sceneTargetDevicesList[k].Type != 1) - { - break; - } - AddedDelayTime += sceneTargetDevicesList[k].DelayTime; - } - } - } - var memberData = new ZigBee.Device.Scene.AddSceneMemberData - { - Type = 1, - ScenesId = 0, - ElseScenesId = sceneTarget.ElseScenesId, - DelayTime = AddedDelayTime - }; - memberDataList.Add(memberData); - } - } - - var result = await CurrentRoom.AddScene(sceneNameET.Text, backGround.UnSelectedImagePath, memberDataList); - if (result == 1) - { - RemoveFromParent(); - } - else if (result == 0) - { - //澶辫触 - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); - } - else if (result == -1) - { - //宸插瓨鍦� - CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); - } - } - catch (Exception ex) - { - System.Console.WriteLine($"鍒嗙被娣诲姞鍦烘櫙鍑洪敊{ex.Message}"); - } - finally - { - CommonPage.Loading.Hide(); - } - - } } }; #endregion } + + #endregion + + } } -- Gitblit v1.8.0