Пример #1
0
        public VisualScriptMethodEditorViewModel(VisualScriptEditorViewModel editor, VisualScriptMethodViewModel method) : base(editor.SafeArgument(nameof(editor)).ServiceProvider)
        {
            this.editor = editor;
            this.method = method;

            var methodNode = editor.Session.AssetNodeContainer.GetNode(method.Method);

            blocksNode     = methodNode[nameof(method.Method.Blocks)].Target;
            linksNode      = methodNode[nameof(method.Method.Links)].Target;
            parametersNode = methodNode[nameof(method.Method.Parameters)].Target;
        }
Пример #2
0
            public SymbolSearchHelper(VisualScriptEditorViewModel viewModel)
            {
                this.viewModel = viewModel;

                viewModel.PropertyChanged += ViewModel_PropertyChanged;
                viewModel.SymbolSearchValues.Clear();
                viewModel.SymbolSearchOpen = true;

                sourceResolver = viewModel.ServiceProvider.Get <IScriptSourceCodeResolver>();

                // Start initial search
                symbolSearchCancellationToken = new CancellationTokenSource();
                Task.Run(() => GenerateSymbolSearchValues(sourceResolver.LatestCompilation, symbolSearchCancellationToken.Token)).Forget();

                // Listen for changes
                sourceResolver.LatestCompilationChanged += RestartSearch;
            }
Пример #3
0
        public BlockTemplateDescriptionCollectionViewModel(VisualScriptEditorViewModel editor) : base(editor.ServiceProvider)
        {
            // Create a template for each non-abstract block type
            foreach (var blockFactory in AssemblyRegistry.FindAll().SelectMany(x => x.GetTypes())
                     .Where(t => !t.IsAbstract && typeof(Block).IsAssignableFrom(t) && t != typeof(MethodCallBlock) && t.GetConstructor(Type.EmptyTypes) != null)
                     .Where(t => TypeDescriptorFactory.Default.AttributeRegistry.GetAttribute <ObsoleteAttribute>(t) == null)
                     .Where(t => TypeDescriptorFactory.Default.AttributeRegistry.GetAttribute <NonInstantiableAttribute>(t) == null)
                     .Select(t => new BlockFromType(t)))
            {
                RegisterBlockTemplate(blockFactory);
            }

            // Use BlockFromMethod for MethodCallBlock
            RegisterBlockTemplate(new BlockFromMethod(editor));

            SelectedGroup = RootGroup;
        }
Пример #4
0
        /// <inheritdoc/>
        public async Task <IAssetEditorViewModel> InitializeEditor(AssetViewModel asset)
        {
            var visualScript = (VisualScriptViewModel)asset;

            var editor = new VisualScriptEditorViewModel(this, visualScript);

            // Don't set the actual Editor property until the editor object is fully initialized - we don't want data bindings to access uninitialized properties
            var result = await editor.Initialize();

            editorInitializationNotifier.SetResult(result);
            if (result)
            {
                return(editor);
            }

            editor.Destroy();
            return(null);
        }
Пример #5
0
 public BlockFromMethod(VisualScriptEditorViewModel editor) : base(typeof(MethodCallBlock))
 {
     this.editor = editor;
 }