Beispiel #1
0
        /// <summary>
        /// Create a new singleton variable.
        /// </summary>
        private void AddSingletonVariableAction()
        {
            var singletonVariableEditorViewModel = new SingletonVariableEditorViewModel();
            var dialogResult = this.windowManager.ShowDialog(singletonVariableEditorViewModel);

            if (!dialogResult.GetValueOrDefault())
            {
                return;
            }
            var singletonVariableModel = new SingletonVariableBuilder().WithName(singletonVariableEditorViewModel.VariableName)
                                         .WithDomain(singletonVariableEditorViewModel.DomainExpression)
                                         .Inside(Workspace.WorkspaceModel.Model)
                                         .Build();

            this.Workspace.AddSingletonVariable(singletonVariableModel);
            this.eventAggregator.PublishOnUIThread(new SingletonVariableAddedMessage(singletonVariableModel));
        }
        public override void Edit()
        {
            var singletonVariableEditorViewModel = new SingletonVariableEditorViewModel();

            singletonVariableEditorViewModel.VariableName     = SingletonVariable.Name;
            singletonVariableEditorViewModel.DomainExpression = SingletonVariable.DomainExpression.Text;
            var oldName = SingletonVariable.Name.Text;
            var result  = _windowManager.ShowDialog(singletonVariableEditorViewModel);

            if (!result.HasValue)
            {
                return;
            }
            DisplayName          = SingletonVariable.Name.Text = singletonVariableEditorViewModel.VariableName;
            DomainExpressionText = SingletonVariable.DomainExpression.Text = singletonVariableEditorViewModel.DomainExpression;
            if (oldName != singletonVariableEditorViewModel.VariableName)
            {
                _eventAggregator.PublishOnUIThread(new VariableRenamedMessage(new ModelName(oldName), SingletonVariable));
            }
        }