private void New()
        {
            try
            {
                if (Save())
                {
                    Filename = null;

                    Project = new ProjectViewModel(_persistor.Create(), _dirtyService, _messageBoxService);

                    _dirtyService.MarkClean();
                }
            }
            catch (Exception ex)
            {
                _messageBoxService.Show(ex);
            }
        }
Beispiel #2
0
        private void Open()
        {
            if (!SaveIfDirty())
            {
                return;
            }

            var options = new FileDialogOptions()
            {
                Filter = Filter
            };

            var result = _fileDialogService.ShowOpenFileDialog(options);

            if (result != null)
            {
                Path = result.FileName;
                Text = File.ReadAllText(result.FileName);

                _dirtyService.MarkClean();
            }
        }
Beispiel #3
0
        public StateDialogViewModel(StateMachineViewModel parent, State model, Action <State> updateParent, IMessageBoxService messageBoxService)
        {
            _parent            = parent ?? throw new ArgumentNullException(nameof(parent));
            _model             = model ?? throw new ArgumentNullException(nameof(model));
            Outputs            = _parent.Outputs ?? throw new ArgumentNullException(nameof(_parent.Outputs));
            _messageBoxService = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService));
            _updateParent      = updateParent;

            InitializeActions();
            OkCommand = new RelayCommand(Ok);

            DirtyService.MarkClean();
        }
        public TransitionEditorViewModel(
            StateMachineTransition model,
            StateMachineViewModel parent,
            Action <StateMachineTransition> updateParentModel,
            IMessageBoxService messageBoxService)
        {
            _model             = model ?? throw new ArgumentNullException(nameof(model));
            _updateParentModel = updateParentModel;
            _parent            = parent ?? throw new ArgumentNullException(nameof(parent));
            _messageBoxService = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService));

            Inputs      = new ObservableCollection <StateMachineInputViewModel>(parent.Inputs);
            Outputs     = new ObservableCollection <StateMachineOutputActionViewModel>(parent.Outputs);
            _transition = ApplicationContainer.Container.Resolve <TransitionViewModel>(
                new TypedParameter(typeof(StateMachineViewModel), parent),
                new TypedParameter(typeof(StateMachineTransition), model)
                );

            Actions = new OrderedListDesigner <StateMachineOutputActionViewModel>(NewFactory, parent.Outputs.Where(o => _transition.Actions.Contains(o.Id)));
            _actions.ListChanged += ActionsOnListChanged;

            Name = Transition.Name;

            Criteria = new CriteriaTransitionViewModel(this, _messageBoxService);

            OkCommand = new RelayCommand(Ok);
            _dirtyService.MarkClean();


            RecalculateConditionText();

            Criteria.PropertyChanged += CriteriaPropertyChanged;

            if (Criteria.RootCondition != null)
            {
                Criteria.RootCondition.ConditionChanged += RootConditionChanged;
            }
        }
 public EnvironmentVariableViewModel(GenericEnvironmentVariable model)
 {
     _model = model ?? throw new ArgumentNullException(nameof(model));
     _dirtyService.MarkClean();
 }
Beispiel #6
0
 private void Save()
 {
     _parent.DirtyService.MarkDirty();
     _dirtyService.MarkClean();
     _updateParent(GetModel());
 }