Ejemplo n.º 1
0
        protected override IEnumerable <Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName()
        {
            if (null != _columnHeaderStyle)
            {
                yield return(new Main.DocumentNodeAndName(_columnHeaderStyle, () => _columnHeaderStyle = null, "ColumnHeaderStyle"));
            }

            if (null != _rowHeaderStyle)
            {
                yield return(new Main.DocumentNodeAndName(_rowHeaderStyle, () => _rowHeaderStyle = null, "RowHeaderStyle"));
            }

            if (null != _propertyColumnHeaderStyle)
            {
                yield return(new Main.DocumentNodeAndName(_propertyColumnHeaderStyle, () => _propertyColumnHeaderStyle = null, "PropertyColumnHeaderStyle"));
            }

            if (null != _dataColumnStyles)
            {
                yield return(new Main.DocumentNodeAndName(_dataColumnStyles, () => _dataColumnStyles = null, "DataColumnStyles"));
            }

            if (null != _propertyColumnStyles)
            {
                yield return(new Main.DocumentNodeAndName(_propertyColumnStyles, () => _propertyColumnStyles = null, "PropertyColumnStyles"));
            }
        }
Ejemplo n.º 2
0
        // TODO (Wpf) Uncomment the next serialization if this is also implemented in Altaxo3

        /*
         *
         *          // New in version 2 (2010-08): the key of the default styles is now the type of the column (before it was the type of default style)
         *          // both data columns and property columns have their own default styles
         *          // ColumnDictionary now has its own serialization code
         *          [Altaxo.Serialization.Xml.XmlSerializationSurrogateFor(typeof(WorksheetLayout), 2)]
         *          class XmlSerializationSurrogate2 : Altaxo.Serialization.Xml.IXmlSerializationSurrogate
         *          {
         *                  protected WorksheetLayout _deserializedInstance;
         *                  protected Main.DocumentPath _unresolvedPathToTable;
         *
         *                  public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
         *                  {
         *                          WorksheetLayout s = (WorksheetLayout)obj;
         *
         *                          info.AddValue("Guid", System.Xml.XmlConvert.ToString(s._guid));
         *                          info.AddValue("Table", Main.DocumentPath.GetAbsolutePath(s._dataTable));
         *                          info.AddValue("RowHeaderStyle", s._rowHeaderStyle);
         *                          info.AddValue("ColumnHeaderStyle", s._columnHeaderStyle);
         *                          info.AddValue("PropertyColumnHeaderStyle", s._propertyColumnHeaderStyle);
         *
         *                          info.AddValue("DataColumnStyles", s._dataColumnStyles);
         *                          info.AddValue("PropertyColumnStyles", s._propertyColumnStyles);
         *                  }
         *
         *                  public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
         *                  {
         *                          WorksheetLayout s = null != o ? (WorksheetLayout)o : new WorksheetLayout();
         *                          Deserialize(s, info, parent);
         *                          return s;
         *                  }
         *
         *                  protected virtual void Deserialize(WorksheetLayout s, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
         *                  {
         *                          XmlSerializationSurrogate2 surr = new XmlSerializationSurrogate2();
         *                          surr._deserializedInstance = s;
         *                          info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.EhDeserializationFinished);
         *
         *                          s._guid = System.Xml.XmlConvert.ToGuid(info.GetString("Guid"));
         *                          surr._unresolvedPathToTable = (Main.DocumentPath)info.GetValue("Table", s);
         *                          s._rowHeaderStyle = (RowHeaderStyle)info.GetValue("RowHeaderStyle", s);
         *                          s._columnHeaderStyle = (ColumnHeaderStyle)info.GetValue("ColumnHeaderStyle", s);
         *                          s._propertyColumnHeaderStyle = (ColumnHeaderStyle)info.GetValue("PropertyColumnHeaderStyle", s);
         *
         *                          s._dataColumnStyles = (ColumnStyleDictionary)info.GetValue("DataColumnStypes", s);
         *                          s._propertyColumnStyles = (ColumnStyleDictionary)info.GetValue("PropertyColumnStyles", s);
         *                  }
         *
         *                  public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object documentRoot)
         *                  {
         *                          if (this._unresolvedPathToTable != null)
         *                          {
         *                                  object table = Main.DocumentPath.GetObject(this._unresolvedPathToTable, this._deserializedInstance, documentRoot);
         *                                  if (table is Altaxo.Data.DataTable)
         *                                  {
         *                                          this._deserializedInstance._dataTable = (Altaxo.Data.DataTable)table;
         *                                          this._unresolvedPathToTable = null;
         *                                  }
         *                          }
         *
         *                          // if the table path has been resolved, we can finish deserialization
         *                          if (this._unresolvedPathToTable == null)
         *                                  info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished);
         *                  }
         *          }
         */

        #endregion Serialization

        #region Constructors

        protected WorksheetLayout()
        {
            _guid = System.Guid.NewGuid();

            // m_ColumnStyles stores the column styles for each data column individually,
            _dataColumnStyles = new ColumnStyleDictionary()
            {
                ParentObject = this
            };

            _propertyColumnStyles = new ColumnStyleDictionary()
            {
                ParentObject = this
            };

            // The style of the row header. This is the leftmost column that shows usually the row number.
            _rowHeaderStyle = new RowHeaderStyle()
            {
                ParentObject = this
            };                                                        // holds the style of the row header (leftmost column of data grid)

            // The style of the column header. This is the upmost row that shows the name of the columns.
            _columnHeaderStyle = new ColumnHeaderStyle()
            {
                ParentObject = this
            };                                                              // the style of the column header (uppermost row of datagrid)

            // The style of the property column header. This is the leftmost column in the left of the property columns,
            _propertyColumnHeaderStyle = new ColumnHeaderStyle()
            {
                ParentObject = this
            };

            _doShowPropertyColumns = true;
        }
Ejemplo n.º 3
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                ColumnStyleDictionary s = null != o ? (ColumnStyleDictionary)o : new ColumnStyleDictionary();

                Deserialize(s, info, parent);
                return(s);
            }
Ejemplo n.º 4
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);
            }