protected override async Task OnInitialize(ModelDescriptor modelDescriptor, Properties status) { if (!(modelDescriptor is FileDescriptor fileDescriptor)) { throw new InvalidOperationException(); } if (session == null) { Owner = fileDescriptor.Owner; filePath = fileDescriptor.FilePath; DocumentTitle = fileDescriptor.FilePath.FileName; figmaDelegate = new FigmaDesignerDelegate(); var localPath = Path.Combine(filePath.ParentDirectory.FullPath, FigmaBundle.ResourcesDirectoryName); fileProvider = new ControlFileNodeProvider(localPath) { File = filePath.FullPath }; rendererService = new ControlViewRenderingService(fileProvider); //we generate a new file provider for embeded windows var tmpRemoteProvider = new FileNodeProvider(localPath) { File = filePath.FullPath }; rendererService.CustomConverters.Add(new EmbededWindowConverter(tmpRemoteProvider) { LiveButtonAlwaysVisible = false }); rendererService.CustomConverters.Add(new EmbededSheetDialogConverter(tmpRemoteProvider)); layoutManager = new StoryboardLayoutManager(); session = new FigmaDesignerSession(fileProvider, rendererService, layoutManager); //session.ModifiedChanged += HandleModifiedChanged; session.ReloadFinished += Session_ReloadFinished; surface = new FigmaDesignerSurface(figmaDelegate, session) { Session = session }; surface.FocusedViewChanged += Surface_FocusedViewChanged; var window = NSApplication.SharedApplication.MainWindow; surface.SetWindow(new WindowInternalWrapper(window)); surface.StartHoverSelection(); //IdeApp.Workbench.ActiveDocumentChanged += OnActiveDocumentChanged; IdeApp.Workbench.DocumentOpened += OnDocumentOpened; } await RefreshAll(); await base.OnInitialize(modelDescriptor, status); }
public override void InitializeFigmaComponent() { InternalInitializeComponent(); FileProvider = new FileNodeProvider("Resources"); RendererService = new ViewRenderService(FileProvider); }