public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { PlotItemCollection s = null != o ? (PlotItemCollection)o : new PlotItemCollection(); int count = info.OpenArray(); IGPlotItem[] plotItems = new IGPlotItem[count]; for (int i = 0; i < count; i++) { s.Add((IGPlotItem)info.GetValue("PlotItem", s)); } info.CloseArray(count); s._styles = (PlotGroupStyleCollection)info.GetValue("GroupStyles", s); return(s); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { PlotItemCollection s = null != o ? (PlotItemCollection)o : new PlotItemCollection(); int count = info.OpenArray(); IGPlotItem[] plotItems = new IGPlotItem[count]; for (int i = 0; i < count; i++) { plotItems[i] = (IGPlotItem)info.GetValue("PlotItem", s); } info.CloseArray(count); count = info.OpenArray(); // PlotGroups PGTrans[] plotGroups = new PGTrans[count]; for (int i = 0; i < count; i++) { plotGroups[i].PlotGroup = (PlotGroupMemento)info.GetValue(s); } info.CloseArray(count); // now assemble the new tree based collection based on the both fields for (int pix = 0; pix < plotItems.Length; pix++) { // look if this plotItem is member of some group int foundidx = -1; for (int grx = 0; grx < plotGroups.Length; grx++) { if (Array.IndexOf <int>(plotGroups[grx].PlotGroup._plotItemIndices, pix) >= 0) { foundidx = grx; break; } } if (foundidx < 0) // if not found in some group, add the item directly { s.Add(plotItems[pix]); } else { if (plotGroups[foundidx].PlotItemCollection == null) { PlotItemCollection newColl = new PlotItemCollection(); plotGroups[foundidx].PlotItemCollection = newColl; s.Add(plotGroups[foundidx].PlotItemCollection); // now set the properties of this new collection bool serial = !plotGroups[foundidx].PlotGroup._concurrently; IPlotGroupStyle curr = null; IPlotGroupStyle prev = null; if (0 != (plotGroups[foundidx].PlotGroup._plotGroupStyle & Version0PlotGroupStyle.Color)) { curr = new ColorGroupStyle(); newColl.GroupStyles.Add(curr); } if (0 != (plotGroups[foundidx].PlotGroup._plotGroupStyle & Version0PlotGroupStyle.Line)) { prev = curr; curr = new LineStyleGroupStyle(); newColl.GroupStyles.Add(curr, serial ? (prev == null?null:prev.GetType()) : null); } if (0 != (plotGroups[foundidx].PlotGroup._plotGroupStyle & Version0PlotGroupStyle.Symbol)) { prev = curr; curr = new SymbolShapeStyleGroupStyle(); newColl.GroupStyles.Add(curr, serial ? (prev == null ? null : prev.GetType()) : null); } } // now add the item to this collection plotGroups[foundidx].PlotItemCollection.Add(plotItems[pix]); } } return(s); }