Example #1
0
            public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object documentRoot)
            {
                if (this.m_PathToTable != null)
                {
                    object table = Main.DocumentPath.GetObject(this.m_PathToTable, this.m_TableLayout, documentRoot);
                    if (table is Altaxo.Data.DataTable)
                    {
                        this.m_TableLayout.m_DataTable = (Altaxo.Data.DataTable)table;
                        this.m_PathToTable             = null;
                    }
                }

                System.Collections.ArrayList resolvedStyles = new System.Collections.ArrayList();
                foreach (System.Collections.DictionaryEntry entry in this.m_ColStyles)
                {
                    object resolvedobj = Main.DocumentPath.GetObject((Main.DocumentPath)entry.Key, m_TableLayout, documentRoot);
                    if (null != resolvedobj)
                    {
                        m_TableLayout.ColumnStyles.Add(resolvedobj, entry.Value);
                        resolvedStyles.Add(entry.Key);
                    }
                }

                foreach (object resstyle in resolvedStyles)
                {
                    m_ColStyles.Remove(resstyle);
                }


                // if all columns have resolved, we can close the event link
                if (m_ColStyles.Count == 0 && this.m_PathToTable == null)
                {
                    info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished);
                }
            }
Example #2
0
            public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info)
            {
                RelDocNodeProxy s = (RelDocNodeProxy)obj;

                System.Diagnostics.Debug.Assert(s._parentNode != null);
                Main.DocumentPath path = Main.DocumentPath.GetRelativePathFromTo(s._parentNode, (Main.IDocumentNode)s._docNode);
                info.AddValue("Node", path);
            }
            public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object documentRoot)
            {
                bool bAllResolved = true;

                if (this._xColumn != null)
                {
                    object xColumn = Main.DocumentPath.GetObject(this._xColumn, this._plotAssociation, documentRoot);
                    bAllResolved &= (null != xColumn);
                    if (xColumn is Altaxo.Data.INumericColumn)
                    {
                        this._xColumn = null;
                        _plotAssociation.m_XColumn = (Altaxo.Data.INumericColumn)xColumn;
                        if (xColumn is Altaxo.Data.DataColumn)
                        {
                            ((Altaxo.Data.DataColumn)xColumn).Changed += new EventHandler(_plotAssociation.EhColumnDataChangedEventHandler);
                        }
                    }
                }

                if (this._yColumn != null)
                {
                    object yColumn = Main.DocumentPath.GetObject(this._yColumn, this._plotAssociation, documentRoot);
                    bAllResolved &= (null != yColumn);
                    if (yColumn is Altaxo.Data.INumericColumn)
                    {
                        this._yColumn = null;
                        _plotAssociation.m_YColumn = (Altaxo.Data.INumericColumn)yColumn;
                        if (yColumn is Altaxo.Data.DataColumn)
                        {
                            ((Altaxo.Data.DataColumn)yColumn).Changed += new EventHandler(_plotAssociation.EhColumnDataChangedEventHandler);
                        }
                    }
                }

                for (int i = 0; i < this._vColumns.Length; i++)
                {
                    if (this._vColumns[i] != null)
                    {
                        object vColumn = Main.DocumentPath.GetObject(this._vColumns[i], this._plotAssociation, documentRoot);
                        bAllResolved &= (null != vColumn);
                        if (vColumn is Altaxo.Data.IReadableColumn)
                        {
                            this._vColumns[i] = null;
                            _plotAssociation.m_DataColumns[i] = (Altaxo.Data.IReadableColumn)vColumn;
                            if (vColumn is Altaxo.Data.DataColumn)
                            {
                                ((Altaxo.Data.DataColumn)vColumn).Changed += new EventHandler(_plotAssociation.EhColumnDataChangedEventHandler);
                            }
                        }
                    }
                }

                if (bAllResolved)
                {
                    info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished);
                }
            }
Example #4
0
        /// <summary>
        /// Event handler that is called when the document node has changed. Because the path to the node can have changed too,
        /// the path is renewed in this case. The <see cref="OnChanged" /> method is called then for the proxy itself.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void EhDocNode_Changed(object sender, EventArgs e)
        {
            if (_docNode is Main.IDocumentNode)
            {
                _docNodePath = Main.DocumentPath.GetRelativePathFromTo(_parentNode, (Main.IDocumentNode)_docNode);
            }
            else
            {
                _docNodePath = null;
            }

            OnChanged();
        }
Example #5
0
        /// <summary>
        /// Event handler that is called when the document node has changed. Because the path to the node can have changed too,
        /// the path is renewed in this case. The <see cref="OnChanged" /> method is called then for the proxy itself.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void EhDocNode_Changed(object sender, EventArgs e)
        {
            if (_docNode is Main.IDocumentNode)
            {
                _docNodePath = Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)_docNode);
            }
            else
            {
                _docNodePath = null;
            }

            OnChanged();
        }
Example #6
0
        /// <summary>
        /// Sets the document node that is held by this proxy.
        /// </summary>
        /// <param name="docNode">The document node. If <c>docNode</c> implements <see cref="Main.IDocumentNode" />,
        /// the document path is stored for this object in addition to the object itself.</param>
        /// <param name="parentNode"></param>
        public void SetDocNode(Main.IDocumentNode docNode, Main.IDocumentNode parentNode)
        {
            if (!IsValidDocument(docNode))
            {
                throw new ArgumentException("This type of document is not allowed for the proxy of type " + this.GetType().ToString());
            }
            if (parentNode == null)
            {
                throw new ArgumentNullException("parentNode");
            }

            bool docNodeInstanceChanged = !object.ReferenceEquals(_docNode, docNode) || !object.ReferenceEquals(_parentNode, parentNode);

            if (!docNodeInstanceChanged)
            {
                return;
            }
            Main.IDocumentNode oldvalue = _docNode;

            if (_docNode != null)
            {
                ClearDocNode();
                this._docNodePath = null;
            }

            _docNode    = docNode;
            _parentNode = parentNode;

            if (_docNode != null)
            {
                _docNodePath = Main.DocumentPath.GetRelativePathFromTo(parentNode, _docNode);
            }

            if (_docNode is Main.IEventIndicatedDisposable)
            {
                ((Main.IEventIndicatedDisposable)_docNode).Disposed += new EventHandler(EhDocNode_Disposed);
            }

            if (_docNode is Main.IChangedEventSource)
            {
                ((Main.IChangedEventSource)_docNode).Changed += new EventHandler(EhDocNode_Changed);
            }

            OnAfterSetDocNode();

            this.OnDocumentInstanceChanged(oldvalue, _docNode);

            OnChanged();
        }
Example #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);
            }
Example #8
0
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 /// <param name="from">Object to clone from.</param>
 public DocNodeProxy(DocNodeProxy from)
 {
     if (from._docNode is Main.IDocumentNode)
     {
         this.SetDocNode(from._docNode); // than the new Proxy refers to the same document node
     }
     else if (from._docNode is ICloneable)
     {
         this.SetDocNode(((System.ICloneable)from._docNode).Clone()); // clone the underlying object
     }
     else if (from._docNode != null)
     {
         this.SetDocNode(from._docNode); // the underlying object is not cloneable, so refer directly to it
     }
     else if (from._docNodePath != null)
     {
         this._docNodePath = from._docNodePath.Clone(); // if no current document available, clone only the path
     }
 }
Example #9
0
        /// <summary>
        /// Sets the document node that is held by this proxy.
        /// </summary>
        /// <param name="docNode">The document node. If <c>docNode</c> implements <see cref="Main.IDocumentNode" />,
        /// the document path is stored for this object in addition to the object itself.</param>
        public void SetDocNode(object docNode)
        {
            if (!IsValidDocument(docNode))
            {
                throw new ArgumentException("This type of document is not allowed for the proxy of type " + this.GetType().ToString());
            }

            if (_docNode != null)
            {
                ClearDocNode();
                this._docNodePath = null;
            }

            _docNode = docNode;

            if (_docNode is Main.IDocumentNode)
            {
                _docNodePath = Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)_docNode);
            }
            else
            {
                _docNodePath = null;
            }

            if (_docNode is Main.IEventIndicatedDisposable)
            {
                ((Main.IEventIndicatedDisposable)_docNode).Disposed += new EventHandler(EhDocNode_Disposed);
            }

            if (_docNode is Main.IChangedEventSource)
            {
                ((Main.IChangedEventSource)_docNode).Changed += new EventHandler(EhDocNode_Changed);
            }

            OnAfterSetDocNode();

            OnChanged();
        }
 private RelDocNodeProxy(Main.DocumentPath relDocNodePath)
 {
   _docNodePath = relDocNodePath;
 }
    /// <summary>
    /// Event handler that is called when the document node has changed. Because the path to the node can have changed too,
    /// the path is renewed in this case. The <see cref="OnChanged" /> method is called then for the proxy itself.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void EhDocNode_Changed(object sender, EventArgs e)
    {
      if (_docNode is Main.IDocumentNode)
        _docNodePath = Main.DocumentPath.GetRelativePathFromTo(_parentNode,(Main.IDocumentNode)_docNode);
      else
        _docNodePath = null;

      OnChanged();
    }
    /// <summary>
    /// Sets the document node that is held by this proxy.
    /// </summary>
    /// <param name="docNode">The document node. If <c>docNode</c> implements <see cref="Main.IDocumentNode" />,
    /// the document path is stored for this object in addition to the object itself.</param>
    /// <param name="parentNode"></param>
    public void SetDocNode(Main.IDocumentNode docNode, Main.IDocumentNode parentNode)
    {
      if (!IsValidDocument(docNode))
        throw new ArgumentException("This type of document is not allowed for the proxy of type " + this.GetType().ToString());
      if (parentNode == null)
        throw new ArgumentNullException("parentNode");

      bool docNodeInstanceChanged = !object.ReferenceEquals(_docNode, docNode) || !object.ReferenceEquals(_parentNode, parentNode);
      if (!docNodeInstanceChanged)
        return;
      Main.IDocumentNode oldvalue = _docNode;

      if (_docNode != null)
      {
        ClearDocNode();
        this._docNodePath = null;
      }

      _docNode = docNode;
      _parentNode = parentNode;
      
      if (_docNode != null)
        _docNodePath = Main.DocumentPath.GetRelativePathFromTo(parentNode, _docNode);

      if (_docNode is Main.IEventIndicatedDisposable)
        ((Main.IEventIndicatedDisposable)_docNode).Disposed += new EventHandler(EhDocNode_Disposed);

      if (_docNode is Main.IChangedEventSource)
        ((Main.IChangedEventSource)_docNode).Changed += new EventHandler(EhDocNode_Changed);

      OnAfterSetDocNode();

      this.OnDocumentInstanceChanged(oldvalue,_docNode);

      OnChanged();
    }
 public void CopyPathOnlyFrom(RelDocNodeProxy from, Main.IDocumentNode newparent)
 {
   this.ClearDocNode();
   this._parentNode = newparent;
   this._docNodePath = from._docNodePath==null ? null : (Main.DocumentPath)from._docNodePath.Clone();
 }
      private void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object documentRoot)
      {

        if(null!=_PathToLayout)
        {
          object o = Main.DocumentPath.GetObject(_PathToLayout,documentRoot,_TableController);
          if(o is Altaxo.Worksheet.WorksheetLayout)
          {
            _TableController.WorksheetLayout = o as Altaxo.Worksheet.WorksheetLayout;
            _PathToLayout=null;
          }
        }
        
        if(null==_PathToLayout)
        {
          info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished);
        }
      }
Example #15
0
 private RelDocNodeProxy(Main.DocumentPath relDocNodePath)
 {
     _docNodePath = relDocNodePath;
 }
Example #16
0
 private DocNodeProxy(Main.DocumentPath docNodePath)
 {
     _docNodePath = docNodePath;
 }
Example #17
0
    /// <summary>
    /// Sets the document node that is held by this proxy.
    /// </summary>
    /// <param name="docNode">The document node. If <c>docNode</c> implements <see cref="Main.IDocumentNode" />,
    /// the document path is stored for this object in addition to the object itself.</param>
    public void SetDocNode(object docNode)
    {
      if(!IsValidDocument(docNode))
        throw new ArgumentException("This type of document is not allowed for the proxy of type " + this.GetType().ToString());

      if (_docNode != null)
      {
        ClearDocNode();
        this._docNodePath = null;
      }

      _docNode = docNode;

      if(_docNode is Main.IDocumentNode)
        _docNodePath = Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)_docNode);
      else
        _docNodePath = null;

      if(_docNode is Main.IEventIndicatedDisposable)
        ((Main.IEventIndicatedDisposable)_docNode).Disposed += new EventHandler(EhDocNode_Disposed);

      if (_docNode is Main.IChangedEventSource)
        ((Main.IChangedEventSource)_docNode).Changed += new EventHandler(EhDocNode_Changed);

      OnAfterSetDocNode();

      OnChanged();
    }
Example #18
0
    /// <summary>
    /// Event handler that is called when the document node has changed. Because the path to the node can have changed too,
    /// the path is renewed in this case. The <see cref="OnChanged" /> method is called then for the proxy itself.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void EhDocNode_Changed(object sender, EventArgs e)
    {
      if (_docNode is Main.IDocumentNode)
        _docNodePath = Main.DocumentPath.GetAbsolutePath((Main.IDocumentNode)_docNode);
      else
        _docNodePath = null;

      OnChanged();
    }
      public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object documentRoot)
      {
        if(this.m_PathToTable!=null)
        {
          object table = Main.DocumentPath.GetObject(this.m_PathToTable,this.m_TableLayout,documentRoot);
          if(table is Altaxo.Data.DataTable)
          {
            this.m_TableLayout.m_DataTable = (Altaxo.Data.DataTable)table;
            this.m_PathToTable = null;
          }
        }

        System.Collections.ArrayList resolvedStyles = new System.Collections.ArrayList();
        foreach(System.Collections.DictionaryEntry entry in this.m_ColStyles)
        {
          object resolvedobj = Main.DocumentPath.GetObject((Main.DocumentPath)entry.Key,m_TableLayout, documentRoot);
          if(null!=resolvedobj)
          {
            m_TableLayout.ColumnStyles.Add(resolvedobj,entry.Value);
            resolvedStyles.Add(entry.Key);
          }
        }

        foreach(object resstyle in resolvedStyles)
          m_ColStyles.Remove(resstyle);


        // if all columns have resolved, we can close the event link
        if(m_ColStyles.Count==0 && this.m_PathToTable==null)
          info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished);
      }
Example #20
0
 private DocNodeProxy(Main.DocumentPath docNodePath)
 {
   _docNodePath = docNodePath;
 }
Example #21
0
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 /// <param name="from">Object to clone from.</param>
 public DocNodeProxy(DocNodeProxy from)
 {
   if (from._docNode is Main.IDocumentNode)
     this.SetDocNode(from._docNode); // than the new Proxy refers to the same document node
   else if (from._docNode is ICloneable)
     this.SetDocNode(((System.ICloneable)from._docNode).Clone()); // clone the underlying object
   else if (from._docNode != null)
     this.SetDocNode(from._docNode); // the underlying object is not cloneable, so refer directly to it
   else if(from._docNodePath != null)
     this._docNodePath= from._docNodePath.Clone(); // if no current document available, clone only the path
 }
Example #22
0
      public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object documentRoot)
      {
        bool bAllResolved = true;

        object linkedLayer = Main.DocumentPath.GetObject(this._LinkedLayerPath, this._Layer, documentRoot);

        if (linkedLayer is XYPlotLayer)
        {
          this._Layer.LinkedLayer = (XYPlotLayer)linkedLayer;
          this._LinkedLayerPath = null;
        }
        else
        {
          bAllResolved = false;
        }

        if (bAllResolved)
          info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished);

      }
Example #23
0
 public void CopyPathOnlyFrom(RelDocNodeProxy from, Main.IDocumentNode newparent)
 {
     this.ClearDocNode();
     this._parentNode  = newparent;
     this._docNodePath = from._docNodePath == null ? null : (Main.DocumentPath)from._docNodePath.Clone();
 }