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
ファイル: ExecutionContext.cs プロジェクト: rquackenbush/VPL
        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();
        }
コード例 #3
0
 public object[] CreateServices(IVplServiceContext context)
 {
     return(new object[]
     {
         new MyRuntimeService(),
     });
 }
コード例 #4
0
ファイル: ElementBuilder.cs プロジェクト: CaptiveAire/VPL
        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;
        }
コード例 #5
0
ファイル: ExecutionContext.cs プロジェクト: CaptiveAire/VPL
        internal ExecutionContext(IVplServiceContext serviceContext)
        {
            if (serviceContext == null) throw new ArgumentNullException(nameof(serviceContext));
            _serviceContext = serviceContext;

            _functionService =
                new Lazy<IFunctionService>(() => serviceContext.Services.OfType<IFunctionService>().FirstOrDefault());
        }
コード例 #6
0
ファイル: ElementBuilder.cs プロジェクト: rquackenbush/VPL
        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;
        }
コード例 #7
0
ファイル: Function.cs プロジェクト: CaptiveAire/VPL
        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);
            
        }
コード例 #8
0
        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();
        }
コード例 #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);
        }
コード例 #10
0
ファイル: VplService.cs プロジェクト: CaptiveAire/VPL
 public VplService(IEnumerable<IVplPlugin> plugins = null)
 {
     _serviceContext = new VplServiceContext(plugins);
 }
コード例 #11
0
 public VplService(IEnumerable <IVplPlugin> plugins = null)
 {
     _serviceContext = new VplServiceContext(this, plugins);
 }