Exemple #1
0
            protected virtual XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = (o == null ? new XYPlotLayer(info) : (XYPlotLayer)o);
                int         count;

                // size, position, rotation and scale
                var location = (XYPlotLayerPositionAndSize_V0)info.GetValue("LocationAndSize", s);

                s._cachedLayerSize     = (SizeF)info.GetValue("CachedSize", s);
                s._cachedLayerPosition = (PointF)info.GetValue("CachedPosition", s);
                s.Location             = location.ConvertToCurrentLocationVersion(s._cachedLayerSize, s._cachedLayerPosition);

                // CoordinateSystem
                s.CoordinateSystem = (G2DCoordinateSystem)info.GetValue("CoordinateSystem", s);
                s.CoordinateSystem.UpdateAreaSize(s._cachedLayerSize);

                // linked layers
                count = info.OpenArray("LinkedLayers");
                var linkedLayer = (Main.RelDocNodeProxy)info.GetValue("e", s);

                info.CloseArray(count);

                // Scales
                var linkedScales = (Altaxo.Graph.Scales.Deprecated.LinkedScaleCollection)info.GetValue("Scales", s);

                s.SetupOldAxes(linkedScales);
                ProvideLinkedScalesWithLinkedLayerIndex(s, linkedLayer, info);

                // Grid planes
                s.GridPlanes = (GridPlaneCollection)info.GetValue("GridPlanes", s);

                // Axis Styles
                s.AxisStyles = (AxisStyleCollection)info.GetValue("AxisStyles", s);

                // Legends
                var legends = (IList <IGraphicBase>)info.GetValue("Legends", s);

                // Graphic objects
                s.GraphObjects.AddRange((IEnumerable <IGraphicBase>)info.GetValue("GraphObjects", s));

                foreach (var item in legends)
                {
                    if (item is TextGraphic)
                    {
                        var l = new LegendText((TextGraphic)item);
                        s.GraphObjects.Add(l);
                    }
                }

                // Data Clipping
                s.ClipDataToFrame = (LayerDataClipping)info.GetValue("DataClipping", s);

                // PlotItemCollection
                s.PlotItems = (PlotItemCollection)info.GetValue("Plots", s);

                return(s);
            }
Exemple #2
0
            protected virtual XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = (o == null ? new XYPlotLayer(info) : (XYPlotLayer)o);
                int         count;

                // Background
                var bgs = (IBackgroundStyle)info.GetValue("Background", s);

                if (null != bgs)
                {
                    if (!s.GridPlanes.Contains(CSPlaneID.Front))
                    {
                        s.GridPlanes.Add(new GridPlane(CSPlaneID.Front));
                    }
                    s.GridPlanes[CSPlaneID.Front].Background = bgs.Brush;
                }

                // size, position, rotation and scale
                var location = (XYPlotLayerPositionAndSize_V0)info.GetValue("LocationAndSize", s);

                s._cachedLayerSize     = (SizeF)info.GetValue("CachedSize", s);
                s._cachedLayerPosition = (PointF)info.GetValue("CachedPosition", s);
                s._coordinateSystem.UpdateAreaSize(s._cachedLayerSize);
                s.Location = location.ConvertToCurrentLocationVersion(s._cachedLayerSize, s._cachedLayerPosition);

                // LayerProperties
                bool clipDataToFrame = info.GetBoolean("ClipDataToFrame");

                s._dataClipping = clipDataToFrame ? LayerDataClipping.StrictToCS : LayerDataClipping.None;

                // axis related
                var linkedScales = (Altaxo.Graph.Scales.Deprecated.LinkedScaleCollection)info.GetValue("AxisProperties", s);

                s.SetupOldAxes(linkedScales);

                // Styles
                var ssc    = (G2DScaleStyleCollection)info.GetValue("AxisStyles", s);
                var gplane = new GridPlane(CSPlaneID.Front);

                gplane.GridStyle[0] = ssc.ScaleStyle(0).GridStyle;
                gplane.GridStyle[1] = ssc.ScaleStyle(1).GridStyle;
                s.GridPlanes.Add(gplane);
                foreach (AxisStyle ax in ssc.AxisStyles)
                {
                    s._axisStyles.Add(ax);
                }

                // Legends
                count = info.OpenArray("Legends");
                var legend = (TextGraphic)info.GetValue("e", s);

                info.CloseArray(count);

                // XYPlotLayer specific
                count = info.OpenArray("LinkedLayers");
                var linkedLayer = (Main.RelDocNodeProxy)info.GetValue("e", s);

                info.CloseArray(count);
                ProvideLinkedScalesWithLinkedLayerIndex(s, linkedLayer, info);

                s.GraphObjects.AddRange((IEnumerable <IGraphicBase>)info.GetValue("GraphicGlyphs", s));
                if (null != legend)
                {
                    var legend1 = new LegendText(legend);
                    s.GraphObjects.Add(legend1);
                }
                s.PlotItems = (PlotItemCollection)info.GetValue("Plots", s);

                return(s);
            }