/// <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); }
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); }
public ImportModelFromFileViewModel(IViewModelServiceProvider serviceProvider) : base(serviceProvider) { ReferenceViewModel = GraphViewModel.Create(serviceProvider, new[] { referenceContainer }); }
public GraphViewModel CreateViewModel() { return(GraphViewModel.Create(context.ServiceProvider, new[] { PropertyProvider })); }
public GraphViewModel CreateViewModel() { return(GraphViewModel.Create(context.ServiceProvider, PropertiesProvider)); }