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();
        }
Exemple #2
0
        internal ExecutionContext(IVplServiceContext serviceContext)
        {
            if (serviceContext == null)
            {
                throw new ArgumentNullException(nameof(serviceContext));
            }
            _serviceContext = serviceContext;

            _functionService =
                new Lazy <IFunctionService>(() => serviceContext.Services.OfType <IFunctionService>().FirstOrDefault());

            List <object> runtimeServices = new List <object>();

            //Create the runtime services
            foreach (IVplPlugin plugin in serviceContext.Plugins)
            {
                //Consider each factory
                foreach (IRuntimeServiceFactory factory in plugin.RuntimeServiceFactories)
                {
                    //Create the services
                    object[] services = factory.CreateServices(serviceContext);

                    //Check to see if any were created
                    if (services.Any())
                    {
                        runtimeServices.AddRange(services);
                    }
                }
            }

            _runtimeServices = runtimeServices.ToArray();
        }
 public object[] CreateServices(IVplServiceContext context)
 {
     return(new object[]
     {
         new MyRuntimeService(),
     });
 }
Exemple #4
0
        public ElementBuilder(IElementFactoryManager factoryManager, IVplServiceContext context)
        {
            if (factoryManager == null) throw new ArgumentNullException(nameof(factoryManager));
            if (context == null) throw new ArgumentNullException(nameof(context));

            _factoryManager = factoryManager;
            _context = context;
        }
Exemple #5
0
        internal ExecutionContext(IVplServiceContext serviceContext)
        {
            if (serviceContext == null) throw new ArgumentNullException(nameof(serviceContext));
            _serviceContext = serviceContext;

            _functionService =
                new Lazy<IFunctionService>(() => serviceContext.Services.OfType<IFunctionService>().FirstOrDefault());
        }
Exemple #6
0
        public ElementBuilder(IElementFactoryManager factoryManager, IVplServiceContext context)
        {
            if (factoryManager == null)
            {
                throw new ArgumentNullException(nameof(factoryManager));
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _factoryManager = factoryManager;
            _context        = context;
        }
Exemple #7
0
        public Function(IVplServiceContext context, Guid functionId)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _functionId = functionId;

            _arguments = new OrderedListViewModel<IArgument>(
                CreateArgument,
                deleted: DeleteArgument,
                addedAction: ArgumentAdded);

            _elements = new Elements(this);

            UndoCommand = new RelayCommand(Undo, _undoService.CanUndo);
            RedoCommand = new RelayCommand(Redo, _undoService.CanRedo);
            CopyCommand = new RelayCommand(Copy, CanCopy);
            CutCommand = new RelayCommand(Cut, CanCut);
            PasteCommand = new RelayCommand(Paste, CanPaste);
            SelectAllCommand = new RelayCommand(SelectAll);
            
        }
        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();
        }
Exemple #9
0
        public Function(IVplServiceContext context, Guid functionId)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _context    = context;
            _functionId = functionId;

            _arguments = new OrderedListViewModel <IArgument>(
                CreateArgument,
                deleted: DeleteArgument,
                addedAction: ArgumentAdded);

            _elements = new Elements(this);

            UndoCommand      = new RelayCommand(Undo, _undoService.CanUndo);
            RedoCommand      = new RelayCommand(Redo, _undoService.CanRedo);
            CopyCommand      = new RelayCommand(Copy, CanCopy);
            CutCommand       = new RelayCommand(Cut, CanCut);
            PasteCommand     = new RelayCommand(Paste, CanPaste);
            SelectAllCommand = new RelayCommand(SelectAll);
        }
Exemple #10
0
 public VplService(IEnumerable<IVplPlugin> plugins = null)
 {
     _serviceContext = new VplServiceContext(plugins);
 }
 public VplService(IEnumerable <IVplPlugin> plugins = null)
 {
     _serviceContext = new VplServiceContext(this, plugins);
 }