Exemplo n.º 1
0
        public virtual XElement Write(IGraphSceneDisplayMesh <IVisual, IVisualEdge> mesh)
        {
            var result = new XElement(NodeNames.Mesh);

            var backHandler = mesh.BackHandler <IThing, ILink>();

            var thingGraphs = new XElement(NodeNames.Files,
                                           backHandler.BackGraphs
                                           .Select(g => ThingMeshHelper.GetIori(g))
                                           .Where(i => i != null)
                                           .Select(i => new XElement(NodeNames.File, Write(NodeNames.Name, i.ToString()))));

            result.Add(thingGraphs);

            var displaySerializer = new GraphSceneDisplayXmlSerializer();
            var displays          = new XElement(NodeNames.Displays);

            foreach (var disp in mesh.Displays.Where(d => d.Data != null))
            {
                var iori = ThingMeshHelper.GetIori(backHandler.BackGraphOf(disp.Data.Graph));
                if (disp.DataId == 0)
                {
                    disp.DataId = Isaac.Long;
                }
                displays.Add(displaySerializer.Write(new GraphSceneDisplayMemento(disp)
                {
                    Iori = iori
                }));
            }
            result.Add(displays);

            return(result);
        }
Exemplo n.º 2
0
        ScenesOfBackGraph <TItem, TEdge> (this IGraphSceneDisplayMesh <TItem, TEdge> mesh, IGraph <TItem, TEdge> graph) where TEdge : TItem, IEdge <TItem>
        {
            var backMesh = mesh.BackHandler(graph);

            if (backMesh == null)
            {
                return(new IGraphScene <TItem, TEdge> [0]);
            }
            return(backMesh.ScenesOfBackGraph(graph));
        }
Exemplo n.º 3
0
        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;
            });
        }
Exemplo n.º 4
0
        public static void RemoveBackGraph(this IGraphSceneDisplayMesh <IVisual, IVisualEdge> mesh, IThingGraph backGraph)
        {
            var backMesh = mesh.BackHandler <IThing, ILink> ();

            mesh.Displays
            .Join(backMesh.ScenesOfBackGraph(backGraph),
                  d => d.Data,
                  s => s, (d, s) => d)
            .ForEach(d => {
                mesh.ClearDisplaysOf(d.Data);
                mesh.RemoveScene(d.Data);
            });

            backMesh.ScenesOfBackGraph(backGraph).ToArray().ForEach(s => mesh.RemoveScene(s));
            backMesh.UnregisterBackGraph(backGraph);
        }