HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/Category/AddOrEditorSceneForm.cs
@@ -120,18 +120,31 @@
            //初始化添加目标
            this.InitAddTargetControl();
            //分享的场景不能保存
            if (this.editorScene == null || this.editorScene.IsSharedScene == false)
            //完成
            var btnSave = new BottomClickButton();
            btnSave.TextID = R.MyInternationalizationString.uFinish;
            bodyFrameLayout.AddChidren(btnSave);
            btnSave.ButtonClickEvent += (sender, e) =>
            {
                //完成
                var btnSave = new BottomClickButton();
                btnSave.TextID = R.MyInternationalizationString.uFinish;
                bodyFrameLayout.AddChidren(btnSave);
                btnSave.ButtonClickEvent += (sender, e) =>
                {
                    //保存场景数据
                    this.SaveSceneData();
                };
                //保存场景数据
                this.SaveSceneData();
            };
            //分享的场景不能保存
            if (this.editorScene != null && this.editorScene.IsSharedScene == true)
            {
                btnSave.CanClick = false;
            }
            else if (Config.Instance.Home.IsShowTemplate == true)
            {
                //模板场景不能保存
                btnSave.CanClick = false;
            }
            //如果是有模板,有设备的时候,在没有发送成功之前
            else if (Common.Config.Instance.Home.TemplateMode == 2
               && Common.Config.Instance.Home.SendTemplateSuccess == false)
            {
                btnSave.CanClick = false;
            }
        }
@@ -159,8 +172,8 @@
            //场景图片
            this.btnScenePic = new ImageView();
            btnScenePic.Y = Application.GetRealHeight(46);
            btnScenePic.Width = Application.GetMinRealAverage(887);
            btnScenePic.Height = Application.GetMinRealAverage(444);
            btnScenePic.Width = this.GetPictrueRealSize(887);
            btnScenePic.Height = this.GetPictrueRealSize(444);
            btnScenePic.Radius = (uint)Application.GetRealHeight(17);
            btnScenePic.Gravity = Gravity.CenterHorizontal;
            if (this.editorScene == null)
@@ -182,12 +195,18 @@
            btnZhezhao.Height = btnScenePic.Height;
            btnZhezhao.Y = btnScenePic.Y;
            btnZhezhao.Gravity = Gravity.CenterHorizontal;
            btnZhezhao.Radius = btnScenePic.Radius;
            btnZhezhao.Radius = (uint)Application.GetRealHeight(17);
            btnZhezhao.BackgroundColor = UserCenterColor.Current.PictrueZhezhaoColor;
            framePicBack.AddChidren(btnZhezhao);
            //分享的场景不能编辑
            if (this.editorScene == null || this.editorScene.IsSharedScene == false)
            {
                if (Config.Instance.Home.IsShowTemplate == true)
                {
                    //模板场景不允许编辑
                    return;
                }
                btnZhezhao.MouseUpEventHandler += (sender, e) =>
                {
                    //房间图片选择
@@ -224,6 +243,7 @@
            //场景名称
            var rowScene = new FrameCaptionInputControl(Language.StringByID(R.MyInternationalizationString.SceneName), this.cloneScene.Name);
            rowScene.txtInput.PlaceholderText = Language.StringByID(R.MyInternationalizationString.PleaseInputSceneName);
            rowScene.txtInput.MaxByte = 32;//限制只能输入32个字节
            rowScene.Y = btnTitle.Bottom + Application.GetRealHeight(23);
            frameBack.AddChidren(rowScene);
            rowScene.InitControl();
@@ -247,6 +267,11 @@
                    this.nowRoomId = selectId;
                };
            }
            if (Config.Instance.Home.IsShowTemplate == true)
            {
                //模板场景不允许编辑
                rowBelong.CanClick = false;
            }
        }
        #endregion
@@ -258,7 +283,7 @@
        /// </summary>
        private void InitAddTargetControl()
        {
            if (this.frameTargetTableControl == null)
            if (this.frameTargetTableControl == null || this.frameTargetTableControl.Parent == null)
            {
                //添加目标的的容器控件
                this.frameTargetTableControl = new FrameListControl();
@@ -289,13 +314,27 @@
                //显示添加目标菜单
                this.ShowAddTargetMenu();
            };
            if (Config.Instance.Home.IsShowTemplate == true)
            {
                //模板场景不允许编辑
                rowAddTarget.CanClick = false;
            }
            //如果是有模板,有设备的时候,在没有发送成功之前
            if (Common.Config.Instance.Home.TemplateMode == 2
               && Common.Config.Instance.Home.SendTemplateSuccess == false)
            {
                rowAddTarget.CanClick = false;
            }
            HdlThreadLogic.Current.RunThread(async () =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                //从网关获取场景的执行目标
                var result = await this.GetSceneTargetList();
                //添加【执行目标行】
                this.AddTargetRow();
                var result = this.GetSceneTargetList();
                if (result == true)
                {
                    //添加【执行目标行】
                    this.AddTargetRow();
                }
            });
        }
@@ -395,12 +434,15 @@
            //分享的场景不能编辑
            if (this.editorScene == null || this.editorScene.IsSharedScene == false)
            {
                if (Config.Instance.Home.IsShowTemplate == true)
                {
                    //模板场景不允许编辑
                    return;
                }
                //编辑
                var btnEditor = rowDevice.AddEditorControl();
                btnEditor.ButtonClickEvent += (sender, e) =>
                {
                    //隐藏右滑菜单
                    rowDevice.HideMenu();
                    if (device.Type == DeviceType.DimmableLight//调光器
                      || device.Type == DeviceType.ColorDimmableLight)//彩灯
                    {
@@ -520,6 +562,11 @@
            //分享的场景不能编辑
            if (this.editorScene == null || this.editorScene.IsSharedScene == false)
            {
                if (Config.Instance.Home.IsShowTemplate == true)
                {
                    //模板场景不允许编辑
                    return;
                }
                //删除
                var btnDelete = rowScene.AddDeleteControl();
                btnDelete.ButtonClickEvent += (sender, e) =>
@@ -586,12 +633,15 @@
            //分享的场景不能编辑
            if (this.editorScene == null || this.editorScene.IsSharedScene == false)
            {
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    //模板场景不允许编辑
                    return;
                }
                //编辑
                var btnEditor = rowDelay.AddEditorControl();
                btnEditor.ButtonClickEvent += (sender, e) =>
                {
                    //隐藏右滑菜单
                    rowDelay.HideMenu();
                    //延时时间选择
                    var form = new AdjustTargetAddDelayTimeForm();
                    form.AddForm(data.DelayTime);
@@ -629,20 +679,25 @@
            }
        }
        #endregion
        #region ■ 获取执行目标_______________________
        /// <summary>
        /// 从网关获取场景的执行目标
        /// </summary>
        /// <returns></returns>
        private async System.Threading.Tasks.Task<bool> GetSceneTargetList()
        private bool GetSceneTargetList()
        {
            if (this.editorScene == null || this.listAdjustTarget != null)
            {
                return true;
            }
            //打开进度条
            this.ShowProgressBar();
            //获取执行目标列表
            var listData = await HdlSceneLogic.Current.GetAdjustTargetList(this.editorScene);
            var listData = HdlSceneLogic.Current.GetAdjustTargetList(this.editorScene);
            if (listData == null)
            {
                this.CloseProgressBar(ShowReLoadMode.YES);
@@ -675,7 +730,7 @@
            //那个特殊的控件
            this.frameBottomTemp = new FrameLayout();
            frameBottomTemp.Height = bodyFrameLayout.Height - btnTemp.Yaxis + Application.GetRealHeight(23);
            this.listBodyControl.AddChidrenFrame(frameBottomTemp);
            this.listBodyControl.AddChidren(frameBottomTemp);
        }
        #endregion
@@ -788,10 +843,10 @@
        /// <summary>
        /// 保存新建的场景
        /// </summary>
        private async void SaveSceneDataByNewMode()
        private void SaveSceneDataByNewMode()
        {
            //添加场景
            this.editorScene = await HdlSceneLogic.Current.AddNewSceneToGateway(this.cloneScene.Name, this.listAdjustTarget);
            this.editorScene = HdlSceneLogic.Current.AddNewSceneToGateway(this.cloneScene.Name, this.listAdjustTarget);
            //关闭进度条
            this.CloseProgressBar();
@@ -821,6 +876,9 @@
            this.editorScene.IconPath = this.cloneScene.IconPath;
            this.editorScene.Save();
            //新建场景,主页需要重新刷新
            UserView.UserPage.Instance.RefreshAllForm = true;
            HdlThreadLogic.Current.RunMain(() =>
            {
                //调用回调函数
@@ -840,6 +898,8 @@
                var result = await HdlSceneLogic.Current.EditorSceneNameFromGateway(this.editorScene, this.cloneScene.Name);
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
            }
@@ -847,10 +907,10 @@
            {
                //修改场景
                var result = await HdlSceneLogic.Current.EditorSceneFromGateway(this.editorScene, this.listAdjustTarget);
                //关闭进度条
                this.CloseProgressBar();
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
            }
@@ -860,6 +920,15 @@
                //变更房间
                HdlSceneLogic.Current.ChangedSceneRoom(this.editorScene, this.nowRoomId);
            }
            else
            {
                //移除出房间
                var room = HdlRoomLogic.Current.GetRoomBySceneId(this.editorScene.Id);
                if (room != null)
                {
                    HdlSceneLogic.Current.DeleteSceneFromRoom(room, this.editorScene);
                }
            }
            //图片改变了
            if (isScenePictrueChanged == true)
@@ -867,7 +936,7 @@
                if (this.editorScene.IconPathType != 0)
                {
                    //删除自定义图片
                    Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, this.editorScene.IconPath));
                    HdlFileLogic.Current.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, this.editorScene.IconPath));
                    HdlAutoBackupLogic.DeleteFile(this.editorScene.IconPath);
                }
                if (this.cloneScene.IconPathType != 0)
@@ -887,6 +956,12 @@
            this.editorScene.IconPathType = this.cloneScene.IconPathType;
            this.editorScene.IconPath = this.cloneScene.IconPath;
            this.editorScene.Save();
            //编辑场景,主页需要重新刷新
            UserView.UserPage.Instance.RefreshAllForm = true;
            //关闭进度条
            this.CloseProgressBar();
            HdlThreadLogic.Current.RunMain(() =>
            {
@@ -942,11 +1017,9 @@
            //默认图库
            menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.LocalPicture), () =>
            {
                var localPic = new Device.Room.AddRoomSelectPicByLocal();
                UserView.HomePage.Instance.AddChidren(localPic);
                UserView.HomePage.Instance.PageIndex += 1;
                localPic.Show();
                localPic.action = (imgPath) =>
                var form = new SelectLocalSceneImageForm();
                form.AddForm();
                form.FinishSelectEvent = (imgPath) =>
                {
                    if (string.IsNullOrEmpty(imgPath) == true)
                    {