Beispiel #1
0
        public virtual void Read(XElement parent, IGraphSceneDisplayMesh <IVisual, IVisualEdge> mesh)
        {
            var node = ReadElement(parent, NodeNames.Mesh);

            if (node == null)
            {
                return;
            }

            FileNames = ReadElements(ReadElement(node, NodeNames.Files), NodeNames.File)
                        .Select(n => ReadString(n, NodeNames.Name))
                        .ToList();

            Displays = new List <GraphSceneDisplayMemento> ();

            var displaySerializer = new GraphSceneDisplayXmlSerializer {
                Mesh = mesh
            };

            foreach (var dnode in ReadElements(ReadElement(node, NodeNames.Displays), GraphSceneDisplayXmlSerializer.NodeNames.Display))
            {
                var displayMemento = displaySerializer.ReadDisplay(dnode);
                Displays.Add(displayMemento);
            }
        }
Beispiel #2
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);
        }