public FunctionEditorDialogViewModel(IVplServiceContext context, Function function, Action <FunctionMetadata> saveAction, ITextEditService textEditService, string displayName, IFunctionEditorManager functionEditorManager)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function));
            }
            if (saveAction == null)
            {
                throw new ArgumentNullException(nameof(saveAction));
            }
            if (textEditService == null)
            {
                throw new ArgumentNullException(nameof(textEditService));
            }
            if (functionEditorManager == null)
            {
                throw new ArgumentNullException(nameof(functionEditorManager));
            }

            _context               = context;
            _function              = function;
            _saveAction            = saveAction;
            _textEditService       = textEditService;
            _displayName           = displayName;
            _functionEditorManager = functionEditorManager;

            //Commands
            RunCommand              = new RelayCommand(Run, CanRun);
            StopCommand             = new RelayCommand(Stop, CanStop);
            OkCommand               = new RelayCommand(Ok, CanOk);
            CloseCommand            = new RelayCommand(Cancel, CanCancel);
            SaveCommand             = new RelayCommand(Apply, CanOk);
            AddVariableCommand      = new RelayCommand(AddVariable, CanAddVariable);
            PasteCommand            = new RelayCommand(Paste, CanPaste);
            SelectReturnTypeCommand = new RelayCommand(SelectReturnType);
            ClearReturnTypeCommand  = new RelayCommand(() => ClearReturnType(), CanClearReturnType);
            CheckForErrorsCommand   = new RelayCommand(CheckForErrors);
            ResetZoomCommand        = new RelayCommand(ResetZoom);

            //Create the toolbox
            _tools = new ToolsViewModel <IElementFactory>(context.ElementFactoryManager.Factories.Where(f => f.ShowInToolbox));

            //Select a default type
            SelectedType = context.Types.FirstOrDefault(t => t.Id == VplTypeId.Float);

            function.PropertyChanged += Function_PropertyChanged;

            //Save the initial state
            function.SaveUndoState();

            //Register this window.
            _functionEditorManager.Register(this);

            //Number the statements
            function.NumberStatements();
        }
Пример #2
0
        public MainViewModel(ITextEditService textEditService)
        {
            if (textEditService == null) throw new ArgumentNullException(nameof(textEditService));

            _textEditService = textEditService;

            EditTextCommand = new SimpleRelayCommand(EditText);
        }
        public RepositoriesViewModel(IRegistryClient registryClient, ILifetimeScope lifetimeScope, ITextEditService textEditService)
        {
            _registryClient  = registryClient ?? throw new ArgumentNullException(nameof(registryClient));
            _lifetimeScope   = lifetimeScope ?? throw new ArgumentNullException(nameof(lifetimeScope));
            _textEditService = textEditService ?? throw new ArgumentNullException(nameof(textEditService));

            LoadAllRepositoriesCommand = new RelayCommand(LoadAllRepositories);
            LoadRepositoryCommand      = new RelayCommand(LoadRepository);
        }
Пример #4
0
 public DeviceViewModel(ITokenProvider tokenProvider, ResinDevice model, ITextEditService textEditService, ResinApiClient client, IViewService viewService)
 {
     _tokenProvider   = tokenProvider ?? throw new ArgumentNullException(nameof(tokenProvider));
     _model           = model ?? throw new ArgumentNullException(nameof(model));
     _textEditService = textEditService ?? throw new ArgumentNullException(nameof(textEditService));
     _client          = client ?? throw new ArgumentNullException(nameof(client));
     _viewService     = viewService ?? throw new ArgumentNullException(nameof(viewService));
     InitializeCommands();
 }
        public MainViewModel(ILifetimeScope lifetimeScope, IMessageBoxService messageBoxService, ITextEditService textEditService, IViewService viewService)
        {
            _lifetimeScope     = lifetimeScope;
            _messageBoxService = messageBoxService;
            _textEditService   = textEditService;
            _viewService       = viewService ?? throw new ArgumentNullException(nameof(viewService));

            RefreshCommand = new RelayCommand(Refresh);
            ConnectCommand = new RelayCommand(Connect);
        }
Пример #6
0
        public MainViewModel(ITextEditService textEditService)
        {
            if (textEditService == null)
            {
                throw new ArgumentNullException(nameof(textEditService));
            }

            _textEditService = textEditService;

            EditTextCommand = new SimpleRelayCommand(EditText);
        }
Пример #7
0
 public ApplicationViewModel(ResinApplication model, ITextEditService textEditService, ResinApiClient client, IViewService viewService)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     _textEditService     = textEditService ?? throw new ArgumentNullException(nameof(model));
     _client              = client ?? throw new ArgumentNullException(nameof(client));
     _viewService         = viewService ?? throw new ArgumentNullException(nameof(viewService));
     _model               = model;
     EditVariablesCommand = new RelayCommand(EditVariables);
 }
        public FunctionEditorDialogViewModel(IVplServiceContext context, Function function, Action<FunctionMetadata> saveAction, ITextEditService textEditService, string displayName)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (function == null) throw new ArgumentNullException(nameof(function));
            if (saveAction == null) throw new ArgumentNullException(nameof(saveAction));
            if (textEditService == null) throw new ArgumentNullException(nameof(textEditService));

            _context = context;
            _function = function;
            _saveAction = saveAction;
            _textEditService = textEditService;
            _displayName = displayName;

            //Commands
            RunCommand = new RelayCommand(Run, CanRun);
            StopCommand = new RelayCommand(Stop, CanStop);
            OkCommand = new RelayCommand(Ok, CanOk);
            CloseCommand = new RelayCommand(Cancel, CanCancel);
            SaveCommand = new RelayCommand(Apply, CanOk);
            AddVariableCommand = new RelayCommand(AddVariable, CanAddVariable);
            PasteCommand = new RelayCommand(Paste, CanPaste);
            SelectReturnTypeCommand = new RelayCommand(SelectReturnType);
            ClearReturnTypeCommand = new RelayCommand(() => ClearReturnType(), CanClearReturnType);
            CheckForErrorsCommand = new RelayCommand(CheckForErrors);
            ResetZoomCommand = new RelayCommand(ResetZoom);

            //Create the toolbox
            _tools = new ToolsViewModel<IElementFactory>(context.ElementFactoryManager.Factories.Where(f => f.ShowInToolbox));

            //Select a default type
            SelectedType = context.Types.FirstOrDefault(t => t.Id == VplTypeId.Float);

            function.PropertyChanged += Function_PropertyChanged;

            //Save the initial state
            function.SaveUndoState();
        }