Esempio n. 1
0
        /// <inheritdoc/>
        public sealed override async Task <bool> Initialize()
        {
            sourceResolver = ServiceProvider.Get <IScriptSourceCodeResolver>();
            if (sourceResolver.LatestCompilation == null)
            {
                // Wait for initial compilation to be done before continuing initialization
                var          compilationReady  = new TaskCompletionSource <bool>();
                EventHandler compilationChange = (sender, args) => compilationReady.TrySetResult(true);

                sourceResolver.LatestCompilationChanged += compilationChange;
                await compilationReady.Task;
                sourceResolver.LatestCompilationChanged -= compilationChange;
            }

            properties = GraphViewModel.Create(ServiceProvider, new[] { new SinglePropertyProvider(propertiesNode.Target) });

            // Since Roslyn compilation is ready, regenerate slots
            await RegenerateSlots();

            // Regenerate slot on next compilations
            sourceResolver.LatestCompilationChanged += CompilationUpdated;

            // Listen to changes
            Session.AssetPropertiesChanged += Session_AssetPropertiesChanged;

            // Select first function
            SelectedMethod = Methods.FirstOrDefault();

            // Trigger initial compilation
            TriggerBackgroundCompilation().Forget();

            return(true);
        }
Esempio n. 2
0
 private Task <GraphViewModel> InitializeViewModel(IReadOnlyCollection <IPropertyProviderViewModel> objects, int localToken)
 {
     return(Task.Run(() =>
     {
         GraphViewModel newViewModel = null;
         if (currentToken == localToken)
         {
             lock (lockObject)
             {
                 newViewModel = GraphViewModel.Create(ServiceProvider, objects);
             }
         }
         return newViewModel;
     }));
 }
        public async Task <bool> Initialize()
        {
            SelectedBlocks.CollectionChanged += SelectedBlocks_CollectionChanged;

            parameters = GraphViewModel.Create(ServiceProvider, new[] { new SinglePropertyProvider(parametersNode) });

            using (var transaction = editor.UndoRedoService.CreateTransaction())
            {
                // Add existing blocks and links
                blocksNode.ItemChanged += BlocksContentChanged;
                foreach (var block in (IEnumerable <Block>)blocksNode.Retrieve())
                {
                    await AddBlockViewModel(block);
                }

                linksNode.ItemChanged += LinksContentChanged;
                foreach (var link in (IEnumerable <Link>)linksNode.Retrieve())
                {
                    AddLinkViewModel(link);
                }

                editor.UndoRedoService.SetName(transaction, "Update graph asset");
            }

            // Forward global diagnostics to blocks/links
            editor.Diagnostics.CollectionChanged += Diagnostics_CollectionChanged;

            DeleteSelectionCommand    = new AnonymousCommand(ServiceProvider, DeleteSelection);
            ContextMenuOpeningCommand = new AnonymousCommand <System.Windows.Point>(ServiceProvider, ContextMenuOpening);
            RunBlockTemplateCommand   = new AnonymousCommand <ITemplateDescriptionViewModel>(ServiceProvider, RunBlockTemplate);

            AddNewParameterCommand          = new AnonymousCommand(ServiceProvider, AddNewParameter);
            RemoveSelectedParametersCommand = new AnonymousCommand(ServiceProvider, RemoveSelectedParameters);

            return(true);
        }
Esempio n. 4
0
 public ImportModelFromFileViewModel(IViewModelServiceProvider serviceProvider)
     : base(serviceProvider)
 {
     ReferenceViewModel = GraphViewModel.Create(serviceProvider, new[] { referenceContainer });
 }
Esempio n. 5
0
 public GraphViewModel CreateViewModel()
 {
     return(GraphViewModel.Create(context.ServiceProvider, new[] { PropertyProvider }));
 }
Esempio n. 6
0
 public GraphViewModel CreateViewModel()
 {
     return(GraphViewModel.Create(context.ServiceProvider, PropertiesProvider));
 }