public static void ApplyBackGraph(this IGraphSceneDisplayMesh <IVisual, IVisualEdge> mesh, IThingGraph root) { var backMesh = mesh.BackHandler <IThing, ILink> (); var g = backMesh.WrapGraph(root); backMesh.RegisterBackGraph(g); var displays = mesh.Displays; displays.ForEach(d => { var scene = backMesh.CreateScene(g); mesh.AddScene(scene); d.Data = scene; }); }
public virtual void SetDocument(GraphCursor <IVisual, IVisualEdge> source) { var pagesDisplay = this.PagesDisplay; // bring the docpages into view: var docManager = new DigidocViz(); var pageScene = new Scene(); pagesDisplay.Data = pageScene; var doc = source.Graph.ThingOf(source.Cursor); IGraph <IVisual, IVisualEdge> targetGraph = null; targetGraph = Mesh.CreateSinkGraph(source.Graph); pageScene.Graph = targetGraph; Mesh.AddScene(pageScene); var targetDocument = targetGraph.VisualOf(doc); this.DocumentVisual = targetDocument; // get the pages and add them to scene: var pages = docManager.Pages(targetGraph, targetDocument).OrderBy(e => e, new VisualComparer()).ToList(); pages.ForEach(page => pagesDisplay.Data.Add(page)); var distance = pagesDisplay.Layout.Distance; pagesDisplay.Layout.Border = this.Border; var aligner = new Aligner <IVisual, IVisualEdge> (pagesDisplay.Data, pagesDisplay.Layout); var dd = this.Border.Height; var options = new AlignerOptions { Distance = new Size(dd, dd), AlignX = Alignment.End, AlignY = Alignment.Start, Dimension = Dimension.X, PointOrderDelta = 1 }; aligner.OneColumn(pages, (Point)this.Border, options); aligner.Locator.Commit(aligner.GraphScene.Requests); new State { Hollow = true }.CopyTo(pagesDisplay.State); pagesDisplay.Text = source.Cursor.Data == null ? CommonSchema.NullString : source.Cursor.Data.ToString(); pagesDisplay.Viewport.Reset(); pagesDisplay.BackendRenderer.Render(); // show first page: var firstPage = pages.FirstOrDefault(); if (firstPage != null) { pageScene.Focused = firstPage; pagesDisplay.OnSceneFocusChanged(); } pagesDisplay.Perform(); var pageCache = new Set <IVisual> (pages); var moveResize = pagesDisplay.ActionDispatcher.GetAction <GraphItemMoveResizeAction <IVisual, IVisualEdge> > (); moveResize.FocusFilter = e => pageCache.Contains(e) ? null : e; }