Beispiel #1
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var s = null != o ? (WorksheetViewLayout)o : new WorksheetViewLayout();

                var surr = new XmlSerializationSurrogate0
                {
                    _TableController = s
                };

                if (info.CurrentElementName == "Controller")
                {
                    info.OpenElement();
                    surr._PathToLayout = (AbsoluteDocumentPath)info.GetValue("Layout", s);
                    info.CloseElement();
                }
                else if (info.CurrentElementName == "BaseType")
                {
                    info.GetString("BaseType");
                    surr._PathToLayout = (AbsoluteDocumentPath)info.GetValue("Layout", s);
                }
                else
                {
                    surr._PathToLayout = (AbsoluteDocumentPath)info.GetValue("Layout", s);
                }

                info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished);

                return(s);
            }
Beispiel #2
0
            protected virtual void Deserialize(ColumnStyleDictionary s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var surr = new XmlSerializationSurrogate0
                {
                    _unresolvedColumns    = new Dictionary <Main.AbsoluteDocumentPath, ColumnStyle>(),
                    _deserializedInstance = s
                };

                info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished);

                int count;

                count = info.OpenArray(); // DefaultColumnStyles
                for (int i = 0; i < count; i++)
                {
                    info.OpenElement(); // "e"
                    string typeName = info.GetString("Type");
                    //Type t = Type.ReflectionOnlyGetType(typeName, false, false);
                    var t     = Type.GetType(typeName, false, false);
                    var style = (ColumnStyle)info.GetValue("Style", s);
                    if (null != style)
                    {
                        style.ParentObject = s;
                    }
                    s._defaultColumnStyles[t] = style;
                    info.CloseElement(); // "e"
                }
                info.CloseArray(count);

                // deserialize the columnstyles
                // this must be deserialized in a new instance of this surrogate, since we can not resolve it immediately
                count = info.OpenArray();
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        info.OpenElement(); // "e"
                        var key = (Main.AbsoluteDocumentPath)info.GetValue("Column", s);
                        var val = (ColumnStyle)info.GetValue("Style", s);
                        surr._unresolvedColumns.Add(key, val);
                        info.CloseElement();
                    }
                }
                info.CloseArray(count);
            }
Beispiel #3
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int count     = info.OpenArray("ColorSets");
                var colorSets = new Tuple <IColorSet, bool> [count];

                for (int i = 0; i < count; ++i)
                {
                    info.OpenElement(); // e
                    colorSets[i] = new Tuple <IColorSet, bool>((IColorSet)info.GetValue("ColorSet", null), info.GetBoolean("IsPlotColorSet"));
                    info.CloseElement();
                }

                info.CloseArray(count);

                return(new ColorSetBag(colorSets));
            }
Beispiel #4
0
            protected virtual DataTableMultipleColumnProxy SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var s = (o == null ? new DataTableMultipleColumnProxy() : (DataTableMultipleColumnProxy)o);

                s.InternalSetDataTable((DataTableProxy)info.GetValue("Table", s));
                s._groupNumber = info.GetInt32("Group");

                s._useAllAvailableDataRows = info.GetBoolean("UseAllAvailableDataRows");

                int countBundles = info.OpenArray("DataColumnsBundles");

                for (int b = 0; b < countBundles; b++)
                {
                    info.OpenElement();
                    string identifier             = info.GetString("Identifier");
                    int?   MaximumNumberOfColumns = info.GetNullableInt32("MaximumNumberOfColumns");

                    var columnBundleInfo = new ColumnBundleInfo(MaximumNumberOfColumns);

                    int countColumns = info.OpenArray();
                    for (int i = 0; i < countColumns; i++)
                    {
                        s.InternalAddDataColumnNoClone(columnBundleInfo, (IReadableColumnProxy)info.GetValue("e", s));
                    }
                    info.CloseArray(countColumns);

                    s._dataColumnBundles.Add(identifier, columnBundleInfo);

                    info.CloseElement();
                }
                info.CloseArray(countBundles);

                if (!s._useAllAvailableDataRows)
                {
                    s._participatingDataRows = (AscendingIntegerCollection)info.GetValue("DataRows", s);
                }
                else
                {
                    s._participatingDataRows = new AscendingIntegerCollection();
                }

                s._isDirty = true;

                s._parent = parent as Main.IDocumentNode;
                return(s);
            }
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                AscendingIntegerCollection s = null != o ? (AscendingIntegerCollection)o : new AscendingIntegerCollection();

                int count = info.OpenArray();

                for (int i = 0; i < count; i++)
                {
                    info.OpenElement();
                    int rangestart = info.GetInt32("Start");
                    int rangecount = info.GetInt32("Count");
                    info.CloseElement();
                    s.AddRange(rangestart, rangecount);
                }
                info.CloseArray(count);
                return(s);
            }
Beispiel #6
0
            public void Deserialize(PropertyBagLazyLoaded s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var assemblyVersionString = info.GetStringAttribute("AssemblyVersion");

                s.AssemblyVersionLoadedFrom = Version.Parse(assemblyVersionString);

                int count = info.OpenArray("Properties");

                for (int i = 0; i < count; i++)
                {
                    info.OpenElement(); // "e"
                    string propkey          = info.GetString("Key");
                    string valueAsXmlString = info.GetElementAsOuterXml("Value");
                    info.CloseElement(); // "e"
                    s._propertiesLazyLoaded[propkey] = valueAsXmlString;
                }
                info.CloseArray(count);
            }
Beispiel #7
0
            protected virtual void Deserialize(WorksheetLayout s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XmlSerializationSurrogate0 surr = new XmlSerializationSurrogate0();

                surr.m_ColStyles              = new System.Collections.Hashtable();
                surr.m_TableLayout            = s;
                info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished);


                s.m_Guid                      = System.Xml.XmlConvert.ToGuid(info.GetString("Guid"));
                surr.m_PathToTable            = (Main.DocumentPath)info.GetValue("Table", s);
                s.m_RowHeaderStyle            = (RowHeaderStyle)info.GetValue("RowHeaderStyle", s);
                s.m_ColumnHeaderStyle         = (ColumnHeaderStyle)info.GetValue("ColumnHeaderStyle", s);
                s.m_PropertyColumnHeaderStyle = (ColumnHeaderStyle)info.GetValue("PropertyColumnHeaderStyle", s);


                int count;

                count = info.OpenArray(); // DefaultColumnStyles

                for (int i = 0; i < count; i++)
                {
                    object defstyle = info.GetValue("DefaultColumnStyle", s);
                    s.DefaultColumnStyles.Add(defstyle.GetType(), defstyle);
                }
                info.CloseArray(count);


                // deserialize the columnstyles
                // this must be deserialized in a new instance of this surrogate, since we can not resolve it immediately
                count = info.OpenArray();
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        info.OpenElement(); // "e"
                        Main.DocumentPath key = (Main.DocumentPath)info.GetValue("Column", s);
                        object            val = info.GetValue("Style", s);
                        surr.m_ColStyles.Add(key, val);
                        info.CloseElement();
                    }
                }
                info.CloseArray(count);
            }
Beispiel #8
0
            public virtual void Deserialize(GraphDocument s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                //  info.GetBaseValueEmbedded(s,typeof(GraphDocument).BaseType,parent);
                s._name = info.GetString("Name");
                var pageBounds      = (RectangleF)info.GetValue("PageBounds", s);
                var printableBounds = (RectangleF)info.GetValue("PrintableBounds", s);

#pragma warning disable CS0618 // Type or member is obsolete
                var layers = (XYPlotLayer.XYPlotLayerCollection)info.GetValue("LayerList", s);
#pragma warning restore CS0618 // Type or member is obsolete
                if (layers.GraphSize.IsEmpty)
                {
                    s._rootLayer.Location = new ItemLocationDirect {
                        SizeX = RADouble.NewAbs(printableBounds.Size.Width), SizeY = RADouble.NewAbs(printableBounds.Size.Height)
                    }
                }
                ;
                else
                {
                    s._rootLayer.Location = new ItemLocationDirect {
                        SizeX = RADouble.NewAbs(layers.GraphSize.Width), SizeY = RADouble.NewAbs(layers.GraphSize.Height)
                    }
                };

                foreach (var l in layers)
                {
                    s._rootLayer.Layers.Add(l);
                }

                // new in version 1 - Add graph properties
                int numberproperties = info.OpenArray(); // "GraphProperties"
                var pb = numberproperties == 0 ? null : s.PropertyBagNotNull;
                for (int i = 0; i < numberproperties; i++)
                {
                    info.OpenElement(); // "e"
                    string propkey = info.GetString("Key");
                    object propval = info.GetValue("Value", s.PropertyBagNotNull);
                    info.CloseElement(); // "e"
                    pb.SetValue(propkey, propval);
                }
                info.CloseArray(numberproperties);
            }
        }
Beispiel #9
0
            protected virtual ScaleCollection SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                ScaleCollection s = null != o ? (ScaleCollection)o : new ScaleCollection(info);

                int count = info.OpenArray("Members");

                s._scales = new Scale[count];
                for (int i = 0; i < count; ++i)
                {
                    info.OpenElement(); // e
                    var scale       = (Scale)info.GetValue("Scale", s);
                    var tickspacing = (Ticks.TickSpacing)info.GetValue("TickSpacing", s);
                    scale.TickSpacing  = tickspacing;
                    scale.ParentObject = s;
                    s._scales[i]       = scale;
                    info.CloseElement();
                }
                info.CloseArray(count);

                return(s);
            }
Beispiel #10
0
            public void Deserialize(PropertyBag s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var assemblyVersionString = info.GetStringAttribute("AssemblyVersion");

                if (!string.IsNullOrEmpty(assemblyVersionString))
                {
                    s.AssemblyVersionLoadedFrom = Version.Parse(assemblyVersionString);
                }


                int count = info.OpenArray("Properties");

                for (int i = 0; i < count; ++i)
                {
                    info.OpenElement(); // "e"
                    string propkey = info.GetString("Key");
                    object value   = info.GetValueOrOuterXml("Value", s, out var isOuterXml);
                    info.CloseElement(); // "e"

                    if (isOuterXml)
                    {
                        s._properties[propkey] = value;
                        s._propertiesLazyLoaded.Add(propkey);
                    }
                    else
                    {
                        s._properties[propkey] = value;
                        s._propertiesLazyLoaded.Remove(propkey);

                        if (value is IDocumentLeafNode valueLeafNode)
                        {
                            valueLeafNode.ParentObject = s;
                        }
                    }
                }
                info.CloseArray(count);
            }
Beispiel #11
0
            public virtual void Deserialize(DataTable s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                s._tableName   = info.GetString("Name");
                s._dataColumns = (DataColumnCollection)info.GetValue("DataCols", s);
                s._dataColumns.ParentObject     = s;
                s._propertyColumns              = (DataColumnCollection)info.GetValue("PropCols", s);
                s._propertyColumns.ParentObject = s;

                // new in version 1
                s._tableScript = (TableScript)info.GetValue("TableScript", s);

                // new in version 2 - Add table properties
                int numberproperties = info.OpenArray(); // "TableProperties"

                for (int i = 0; i < numberproperties; i++)
                {
                    info.OpenElement(); // "e"
                    string propkey = info.GetString("Key");
                    object propval = info.GetValue("Value", parent);
                    info.CloseElement(); // "e"
                    s.SetTableProperty(propkey, propval);
                }
                info.CloseArray(numberproperties);
            }
Beispiel #12
0
            public virtual void Deserialize(GraphDocument s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                //  info.GetBaseValueEmbedded(s,typeof(GraphDocument).BaseType,parent);
                s._name            = info.GetString("Name");
                s._pageBounds      = (RectangleF)info.GetValue("PageBounds", s);
                s._printableBounds = (RectangleF)info.GetValue("PrintableBounds", s);

                s._layers = (XYPlotLayerCollection)info.GetValue("LayerList", s);
                s._layers.ParentObject = s;
                s._layers.SetPrintableGraphBounds(s._printableBounds, false);

                // new in version 1 - Add graph properties
                int numberproperties = info.OpenArray(); // "GraphProperties"

                for (int i = 0; i < numberproperties; i++)
                {
                    info.OpenElement(); // "e"
                    string propkey = info.GetString("Key");
                    object propval = info.GetValue("Value", parent);
                    info.CloseElement(); // "e"
                    s.SetGraphProperty(propkey, propval);
                }
                info.CloseArray(numberproperties);
            }