gxc
2019-11-15 05ce435c3b58e53eeab04c672affdeeab75f3036
ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs
@@ -57,6 +57,11 @@
        private CommonForm.CompleteButton confirmBtn;
        /// <summary>
        /// backGround
        /// </summary>
        private Button backGround;
        /// <summary>
        /// 是否修改
        /// </summary>
        public bool isModify;
@@ -327,12 +332,12 @@
            };
            bodyFrameLayout.AddChidren(imgFL);
            var backGround = new Button()
            backGround = new Button()
            {
                Width = Application.GetRealWidth(930),
                Height = Application.GetRealHeight(464),
                Width = Application.GetMinRealAverage(930),
                Height = Application.GetMinRealAverage(464),
                Gravity = Gravity.Center,
                Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius),
                Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius),
                //UnSelectedImagePath = ImagePath
                UnSelectedImagePath = "SceneIcon/3.png"
            };
@@ -452,12 +457,7 @@
            //选择背景图
            EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) =>
            {
                if (curRoom == null)
                {
                    RoomCommon.ShowTipNoRoom();
                    return;
                }
                if (curRoom.IsSharedRoom)
                if (curRoom != null && curRoom.IsSharedRoom)
                {
                    RoomCommon.ShowTipRoomIsShared();
                    return;
@@ -552,30 +552,49 @@
                selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    var sceneView = new SelectScene();
                    UserView.HomePage.Instance.AddChidren(sceneView);
                    UserView.HomePage.Instance.PageIndex += 1;
                    sceneView.beforeSceneTargetDeviceUIs = sceneTargetDevicesList;
                    sceneView.Show();
                    sceneView.selectedAction = (selectedScene) =>
                    var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                    var fileName = $"Scene_{tradeTime}";
                    //通过相机拍照裁剪
                    CropImage.TakePicture((imagePath) =>
                    {
                        sceneTargetDevicesList.Add(selectedScene);
                        RefreshTargetListView();
                    };
                        if (isModify)
                        {
                            if (IconPathType != 0)
                            {
                                Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
                            }
                        }
                        IconPathType = 1;
                        backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
                        backGround.UnSelectedImagePath = imagePath;
                        System.IO.File.Delete(imagePath);
                    }, fileName, 2, 1);
                };
                selectAblumsBtn.MouseUpEventHandler += (send, ee) =>
                {
                    selectFL.RemoveFromParent();
                    var delayTimeView = new SelectDelayTime();
                    UserView.HomePage.Instance.AddChidren(delayTimeView);
                    UserView.HomePage.Instance.PageIndex += 1;
                    delayTimeView.Show();
                    delayTimeView.selectedTimeAction = (second) =>
                    var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                    var fileName = $"Scene_{tradeTime}";
                    //从相册选择图片裁剪
                    CropImage.SelectPicture((imagePath) =>
                    {
                        sceneTargetDevicesList.Add(second);
                        RefreshTargetListView();
                    };
                        if (isModify)
                        {
                            if (IconPathType != 0)
                            {
                                Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
                            }
                        }
                        IconPathType = 2;
                        backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
                        backGround.UnSelectedImagePath = imagePath;
                        System.IO.File.Delete(imagePath);
                    }, fileName, 2,1);
                };
                cancelBtn.MouseUpEventHandler += (send, ee) =>
@@ -818,6 +837,8 @@
                    {
                        try
                        {
                            var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                            var fileName = $"Scene_{tradeTime}";
                            //改名
                            if (modifySceneUI.Name != nameRow.NameText.Text.Trim())
                            {
@@ -849,9 +870,14 @@
                            //图片
                            if(IconPathType==1 || IconPathType ==2)
                            {
                                Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
                                modifySceneUI.IconPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
                            }
                            modifySceneUI.IconPath = backGround.UnSelectedImagePath;
                            else
                            {
                                modifySceneUI.IconPath = backGround.UnSelectedImagePath;
                            }
                            modifySceneUI.IconPathType = IconPathType;
                            CommonPage.Loading.Start();
                            var memberDataList = new List<ZigBee.Device.Scene.AddSceneMemberData>();
@@ -997,6 +1023,19 @@
                    {
                        try
                        {
                            var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                            var fileName = $"Scene_{tradeTime}";
                            string imgPath;
                            //图片
                            if (IconPathType == 1 || IconPathType == 2)
                            {
                                Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
                                imgPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
                            }
                            else
                            {
                                imgPath = backGround.UnSelectedImagePath;
                            }
                            if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null)
                            {
                                Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist);
@@ -1051,7 +1090,7 @@
                                }
                            }
                            var result = await curRoom.AddScene(nameRow.NameText.Text, backGround.UnSelectedImagePath, memberDataList);
                            var result = await curRoom.AddScene(nameRow.NameText.Text, imgPath, memberDataList);
                            if (result == 1)
                            {
                                RemoveFromParent();