/// <summary> 命令通用方法 </summary>
        protected override async void RelayMethod(object obj)
        {
            string command = obj?.ToString();

            if (command == "新建场景")
            {
                SelectTypeControl select = new SelectTypeControl();

                var result = await MessageService.ShowCustomDialog <bool>(select);

                if (!result)
                {
                    return;
                }

                ConfigSceneControl config = new ConfigSceneControl();

                config.Model = new TestViewModel();

                config.Model.Value3 = select.Model?.Value;

                config.Model.Value4 = select.Model?.Value1;

                var result1 = await MessageService.ShowCustomDialog <bool?>(config);

                //  Do :取消
                if (result1 == false)
                {
                    return;
                }

                //  Do :上一步
                if (result1 == null)
                {
                    this.RelayMethod(command); return;
                }

                //  Do :创建
                if (string.IsNullOrEmpty(config.Model.Value) || string.IsNullOrEmpty(config.Model.Value1))
                {
                    MessageService.ShowSnackMessageWithNotice("数据不合法"); return;
                }
                this.Scenes.Add(config.Model);

                this.CurrentTempalte = select.Model;

                this.CurrentScene = config.Model;

                await this.RefreshScene();
            }
            else if (command == "ListBox.MouseDoubleClick.SetSelectedScene")
            {
                this.CurrentScene = this.SelectedScene;

                await this.RefreshScene();
            }
            else if (command == "ListBox.MouseDoubleClick.SetSelectedTemplate")
            {
                this.CurrentTempalte = this.SelectedTemplate;

                await this.RefreshScene();
            }
            else if (command == "Button.Click.Commit")
            {
            }
        }
예제 #2
0
        /// <summary> 命令通用方法 </summary>
        protected override async void RelayMethod(object obj)
        {
            string command = obj?.ToString();

            if (command == "新建场景")
            {
                SelectTypeControl select = new SelectTypeControl();

                var result = await MessageService.ShowCustomDialog <bool>(select);

                if (!result)
                {
                    return;
                }

                ConfigSceneControl config = new ConfigSceneControl();

                config.Model = new TestViewModel();

                config.Model.Value3 = select.Model?.Value;

                config.Model.Value4 = select.Model?.Value1;

                var result1 = await MessageService.ShowCustomDialog <bool?>(config);

                //  Do :取消
                if (result1 == false)
                {
                    return;
                }

                //  Do :上一步
                if (result1 == null)
                {
                    this.RelayMethod(command); return;
                }

                //  Do :创建
                if (string.IsNullOrEmpty(config.Model.Value) || string.IsNullOrEmpty(config.Model.Value1))
                {
                    MessageService.ShowSnackMessageWithNotice("数据不合法"); return;
                }
                this.Scenes.Add(config.Model);

                this.CurrentTempalte = select.Model;

                this.CurrentScene = config.Model;

                await this.RefreshScene();
            }
            else if (command == "ListBox.MouseDoubleClick.SetSelectedScene")
            {
                this.CurrentScene = this.SelectedScene;

                await this.RefreshScene();
            }
            else if (command == "ListBox.MouseDoubleClick.SetSelectedTemplate")
            {
                this.CurrentTempalte = this.SelectedTemplate;

                await this.RefreshScene();
            }
            else if (command == "Button.Click.Commit")
            {
                if (string.IsNullOrEmpty(this.Title))
                {
                    MessageService.ShowSnackMessageWithNotice("请输入标题信息");
                    return;
                }

                if (this.Historys.FirstOrDefault(l => l.Value == this.Title) != null)
                {
                    MessageService.ShowSnackMessageWithNotice("存在重复的标题");
                    return;
                }

                await Task.Run(() =>
                {
                    for (int i = 0; i < 100; i++)
                    {
                        this.Percent = i;

                        Thread.Sleep(50);
                    }
                });

                MessageService.ShowSnackMessageWithNotice("提交成功");

                this.Historys.Add(new TestViewModel()
                {
                    Value = this.Title
                });
            }
        }