HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-11-04 c7698e163e43cea9e7f8ee45f8e3f91c9265cca4
ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
@@ -15,22 +15,22 @@
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
        /// <summary>
        /// floorIds
        /// </summary>
        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>
        ///// floorIds
        ///// </summary>
        //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>
@@ -273,16 +273,16 @@
        /// </summary>
        private void Init()
        {
            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));
                }
            }
            //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));
            //    }
            //}
        }
        /// <summary>
@@ -370,7 +370,7 @@
            zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)}:");
            //zoneRow.SetTitle(curRoom.Name);
            infoFL.AddChidren(zoneRow);
            zoneRow.HideLine(false);
            zoneRow.HideLine(true);
            var targetFL = new FrameLayout()
            {
@@ -452,43 +452,182 @@
            //选择背景图
            EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) =>
            {
                if (curRoom == null)
                {
                    RoomCommon.ShowTipNoRoom();
                    return;
                }
                if (curRoom.IsSharedRoom)
                if (curRoom != null && curRoom.IsSharedRoom)
                {
                    RoomCommon.ShowTipRoomIsShared();
                    return;
                }
                var localPic = new CategorySceneSelectImgByLocal();
                Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                localPic.Show();
                localPic.action = (imgPath) =>
                int selectRow_Height = 150;
                int selectRow_Width = 1034;
                var selectFL = new FrameLayout()
                {
                    IconPathType = 0;
                    backGround.UnSelectedImagePath = imgPath;
                    BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
                };
                AddChidren(selectFL);
                var itemFL = new FrameLayout()
                {
                    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);
                itemFL.Animate = Animate.DownToUp;
                var selectLocalPicture = new Button()
                {
                    Height = Application.GetRealHeight(selectRow_Height) - 1,
                    TextID = R.MyInternationalizationString.LocalPicture,
                    TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
                };
                itemFL.AddChidren(selectLocalPicture);
                var selectLocalLine = new Button()
                {
                    Y = selectLocalPicture.Bottom,
                    Height = 1,
                    BackgroundColor = ZigbeeColor.Current.GXCLineColor
                };
                itemFL.AddChidren(selectLocalLine);
                var selectPhotographBtn = new Button()
                {
                    Y = selectLocalLine.Bottom,
                    Height = Application.GetRealHeight(selectRow_Height) - 1,
                    TextID = R.MyInternationalizationString.Photograph,
                    TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
                };
                itemFL.AddChidren(selectPhotographBtn);
                var selectPhotographLine = new Button()
                {
                    Y = selectPhotographBtn.Bottom,
                    Height = 1,
                    BackgroundColor = ZigbeeColor.Current.GXCLineColor,
                };
                itemFL.AddChidren(selectPhotographLine);
                var selectAblumsBtn = new Button()
                {
                    Y = selectPhotographLine.Bottom,
                    Height = Application.GetRealHeight(selectRow_Height) - 1,
                    TextID = R.MyInternationalizationString.MyAblums,
                    TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
                };
                itemFL.AddChidren(selectAblumsBtn);
                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);
                selectLocalPicture.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    var localPic = new CategorySceneSelectImgByLocal();
                    Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
                    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                    localPic.Show();
                    localPic.action = (imgPath) =>
                    {
                        IconPathType = 0;
                        backGround.UnSelectedImagePath = imgPath;
                    };
                };
                selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    IconPathType = 1;
                    //通过相机拍照裁剪
                    CropImage.TakePicture((imagePath) =>
                    {
                        Console.WriteLine("SelectPicture 裁剪图片返回路径: " + imagePath);
                    }, "HDLPIC");
                };
                selectAblumsBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    IconPathType = 2;
                    //从相册选择图片裁剪
                    CropImage.SelectPicture((imagePath) =>
                    {
                        Console.WriteLine("SelectPicture 裁剪图片返回路径: " + imagePath);
                    }, "HDLPIC");
                };
                cancelBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                };
                selectFL.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                };
            };
            backGround.MouseUpEventHandler += backGroundIMGHander;
            //区域
            EventHandler<MouseEventArgs> zoneHander = (sender, e) =>
            {
                PickerView.ShowSecondary(floorNames, roomNames, (index1, index2) =>
                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)
                {
                    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));
                    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));
                }
            };
            zoneRow.NextBtn.MouseUpEventHandler += zoneHander;
            zoneRow.TipBtn.MouseUpEventHandler += zoneHander;
            zoneRow.NameText.MouseUpEventHandler += zoneHander;
            zoneRow.MouseUpEventHandler += zoneHander;
            zoneRow.ClickBtn.MouseUpEventHandler += zoneHander;
            //执行目标-添加执行设备
            EventHandler<MouseEventArgs> targetAddHander = (sender, e) =>
@@ -523,6 +662,7 @@
                    BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
                };
                selectFL.AddChidren(itemFL);
                itemFL.Animate = Animate.DownToUp;
                var selectedFunctionBtn = new Button()
                {
@@ -699,7 +839,8 @@
                            {
                            }
                            modifySceneUI.IconPath = backGround.UnSelectedImagePath;
                            CommonPage.Loading.Start();
                            var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>();
                            for (int i = 0; i < sceneTargetDevicesList.Count; i++)
@@ -797,6 +938,7 @@
                            {
                                if (modifyRoom != curRoom)
                                {
                                    modifyRoom.SceneUIList.Remove(modifySceneUI);
                                    modifyRoom.SceneUIFilePathList.Remove(modifySceneUI.FileName);
                                    curRoom.SceneUIList.Add(modifySceneUI);
@@ -931,7 +1073,5 @@
        }
        #endregion
    }
}