protected virtual void OnDocumentInstanceChanged(Main.IDocumentNode oldvalue, Main.IDocumentNode newvalue) { if (null != DocumentInstanceChanged) { DocumentInstanceChanged(this, oldvalue, newvalue); } }
public RelDocNodeProxy(Main.IDocumentLeafNode docNode, Main.IDocumentNode parentNode) { if (null == docNode) { throw new ArgumentNullException(nameof(docNode)); } if (null == parentNode) { throw new ArgumentNullException(nameof(parentNode)); } var docNodeRoot = Main.AbsoluteDocumentPath.GetRootNode(docNode); var parentNodeRoot = Main.AbsoluteDocumentPath.GetRootNode(parentNode); if (!object.ReferenceEquals(docNodeRoot, parentNodeRoot)) { throw new ArgumentException(string.Format("parentNode (type: {0}) and docNode (type: {1}) have no common root. This suggests that one of the items is not rooted. Please report this error! The type of the parent node's root is {2}. The type of the docNode's root is {3}.", parentNode.GetType(), docNode.GetType(), parentNodeRoot.GetType(), docNodeRoot.GetType())); } InternalSetDocNode(docNode, parentNode); if (!(_docNodePath != null)) { throw new InvalidProgramException(); // because we tested above that both nodes have a common root } _parent = parentNode; }
public virtual void Serialize(object obj, Altaxo.Serialization.Xml.IXmlSerializationInfo info) { WorksheetLayout s = (WorksheetLayout)obj; info.AddValue("Guid", System.Xml.XmlConvert.ToString(s.m_Guid)); info.AddValue("Table", Main.DocumentPath.GetAbsolutePath(s.m_DataTable)); info.AddValue("RowHeaderStyle", s.m_RowHeaderStyle); info.AddValue("ColumnHeaderStyle", s.m_ColumnHeaderStyle); info.AddValue("PropertyColumnHeaderStyle", s.m_PropertyColumnHeaderStyle); info.CreateArray("DefaultColumnStyles", s.m_DefaultColumnStyles.Values.Count); foreach (object style in s.m_DefaultColumnStyles.Values) { info.AddValue("DefaultColumnStyle", style); } info.CommitArray(); info.CreateArray("ColumnStyles", s.m_ColumnStyles.Count); foreach (System.Collections.DictionaryEntry dictentry in s.m_ColumnStyles) { info.CreateElement("e"); Main.IDocumentNode col = (Main.IDocumentNode)dictentry.Key; info.AddValue("Column", Main.DocumentPath.GetAbsolutePath(col)); info.AddValue("Style", dictentry.Value); info.CommitElement(); // "e" } info.CommitArray(); }
public RelDocNodeProxy ClonePathOnly(Main.IDocumentNode newparent) { RelDocNodeProxy result = new RelDocNodeProxy(); result.CopyPathOnlyFrom(this, newparent); return(result); }
/// <summary> /// Gets the parent data table of a child object. /// </summary> /// <param name="child">The child object for which the parent table should be found.</param> public static Altaxo.Data.DataTable GetParentDataTableOf(Main.IDocumentNode child) { if (child == null) { return(null); } else { return((DataTable)Main.DocumentPath.GetRootNodeImplementing(child, typeof(DataTable))); } }
/// <summary> /// Creates a copy of a docnode proxy /// </summary> /// <param name="from"></param> /// <param name="copyPathOnly">If true, only the path is copied, and the document is then resolved using the provided <paramref name="parentNode"/> as start point of the path. /// If <c>false</c>, and the proxy to copy from has a valid document, that document is used also for this instance, and a new relative path from <paramref name="parentNode"/> to the document is calculated.</param> /// <param name="parentNode">The parent node of this proxy.</param> public RelDocNodeProxy(RelDocNodeProxy from, bool copyPathOnly, Main.IDocumentNode parentNode) { _parent = parentNode; _docNodePath = from._docNodePath.Clone(); if (!copyPathOnly && null != from.Document) { InternalSetDocNode(from.Document, parentNode); } ResolveDocumentObject(); }
/// <summary> /// For deserialization purposes only. /// </summary> /// <param name="docNodePath">The document node path.</param> /// <param name="parentNode">The parent node of this proxy. This is also the start node for resolution of the path.</param> /// <exception cref="System.ArgumentNullException"> /// docNodePath /// or /// parentNode /// </exception> protected RelDocNodeProxy(Main.RelativeDocumentPath docNodePath, Main.IDocumentNode parentNode) { if (null == docNodePath) { throw new ArgumentNullException(nameof(docNodePath)); } if (null == parentNode) { throw new ArgumentNullException(nameof(parentNode)); } _parent = parentNode; _docNodePath = docNodePath; }
/// <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(); }
/// <summary> /// Sets the document node to null, but keeps the doc node path. /// </summary> protected void ClearDocNode() { if (_docNode == null) { return; } OnBeforeClearDocNode(); 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); } Main.IDocumentNode oldvalue = _docNode; _docNode = null; OnDocumentInstanceChanged(oldvalue, _docNode); }
public void AnnounceDeserializationEnd(Main.IDocumentNode documentRoot, bool isFinalCall) { DeserializationFinished?.Invoke(this, documentRoot, isFinalCall); }
private void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { object o = AbsoluteDocumentPath.GetObject(_pathToDocument, documentRoot); if (o is TextDocument textDoc) { _deserializedInstance.Document = textDoc; info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhDeserializationFinished); } }
void Main.IParentOfINameOwnerChildNodes.EhChild_ParentChanged(Main.INameOwner childNode, Main.IDocumentNode oldParent) { if (object.ReferenceEquals(this, oldParent) && _itemsByName.ContainsKey(childNode.Name)) { throw new InvalidProgramException(string.Format("Unauthorized change of the {0}'s parent", typeof(TItem).Name)); } }
/// <summary> /// Sets the document node to null, but keeps the doc node path. /// </summary> protected void ClearDocNode() { if (_docNode == null) return; OnBeforeClearDocNode(); 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); Main.IDocumentNode oldvalue = _docNode; _docNode = null; OnDocumentInstanceChanged(oldvalue,_docNode); }
/// <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(); }
/// <summary> /// Gets the parent DataTableCollection of a child table, a child ColumnCollection, or a child column. /// </summary> /// <param name="child">Can be a DataTable, a DataColumnCollection, or a DataColumn for which the parent table collection is searched.</param> /// <returns>The parent DataTableCollection, if it exists, or null otherwise.</returns> public static Altaxo.Data.DataTableCollection GetParentDataTableCollectionOf(Main.IDocumentNode child) { return((DataTableCollection)Main.DocumentPath.GetRootNodeImplementing(child, typeof(DataTableCollection))); }
public WorksheetLayoutCollection(Main.IDocumentNode documentParent) { _items = new Dictionary <string, WorksheetLayout>(); _parent = documentParent; }
/// <summary> /// Takes final measures after the deserialization has finished, but before the dirty flag is cleared. Here, the scale bounds are updated with /// the data from the project. /// </summary> /// <param name="info">The deserialization information.</param> /// <param name="documentRoot">The document root of the current document.</param> /// <param name="isFinallyCall">If set to <c>true</c> this is the last callback before the dirty flag is cleared for the document.</param> protected virtual void EhDeserializationFinished(Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { if (isFinallyCall) { // after deserialisation the data bounds object of the scale is empty: // then we have to rescale the axis if (Scales.X.DataBoundsObject.IsEmpty) { InitializeXScaleDataBounds(); } if (Scales.Y.DataBoundsObject.IsEmpty) { InitializeYScaleDataBounds(); } } }
/// <summary> /// Copying constructor. /// </summary> /// <param name="from">Object to clone from.</param> /// <param name="newparent"></param> public void CopyFrom(RelDocNodeProxy from, Main.IDocumentNode newparent) { this.SetDocNode(from._docNode, newparent); // than the new Proxy refers to the same document node }
public RelDocNodeProxy(Main.IDocumentNode docNode, Main.IDocumentNode parentNode) { SetDocNode(docNode, parentNode); }
public void CopyPathOnlyFrom(RelDocNodeProxy from, Main.IDocumentNode newparent) { this.ClearDocNode(); this._parentNode = newparent; this._docNodePath = from._docNodePath == null ? null : (Main.DocumentPath)from._docNodePath.Clone(); }
public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { bool bAllResolved = true; if (_xColumnPath != null) { object xColumn = Main.AbsoluteDocumentPath.GetObject(_xColumnPath, _plotAssociation, documentRoot); bAllResolved &= (null != xColumn); if (xColumn is Altaxo.Data.INumericColumn) { _xColumnPath = null; _xColumnProxy = ReadableColumnProxyBase.FromColumn((Altaxo.Data.INumericColumn)xColumn); } } if (_yColumnPath != null) { object yColumn = Main.AbsoluteDocumentPath.GetObject(_yColumnPath, _plotAssociation, documentRoot); bAllResolved &= (null != yColumn); if (yColumn is Altaxo.Data.INumericColumn) { _yColumnPath = null; _yColumnProxy = ReadableColumnProxyBase.FromColumn((Altaxo.Data.INumericColumn)yColumn); } } for (int i = 0; i < _vColumnPaths.Length; i++) { if (_vColumnPaths[i] != null) { object vColumn = Main.AbsoluteDocumentPath.GetObject(_vColumnPaths[i], _plotAssociation, documentRoot); bAllResolved &= (null != vColumn); if (vColumn is Altaxo.Data.IReadableColumn) { _vColumnPaths[i] = null; _vColumnProxies[i] = ReadableColumnProxyBase.FromColumn((Altaxo.Data.IReadableColumn)vColumn); } } } if (bAllResolved || isFinallyCall) { info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhDeserializationFinished); #pragma warning disable 618 _plotAssociation._matrixProxy = new DataTableMatrixProxy(_xColumnProxy, _yColumnProxy, _vColumnProxies) { ParentObject = _plotAssociation }; #pragma warning restore 618 } }
public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { if (_pathToTable != null && _worksheetLayout.DataTable == null) { object table = Main.AbsoluteDocumentPath.GetObject(_pathToTable, _worksheetLayout, documentRoot); if (table is Altaxo.Data.DataTable) { _worksheetLayout.DataTable = (Altaxo.Data.DataTable)table; _pathToTable = null; } } var resolvedStyles = new System.Collections.ArrayList(); foreach (System.Collections.DictionaryEntry entry in _colStyles) { object resolvedobj = Main.AbsoluteDocumentPath.GetObject((Main.AbsoluteDocumentPath)entry.Key, _worksheetLayout, documentRoot); if (null != resolvedobj) { _worksheetLayout.DataColumnStyles.Add((DataColumn)resolvedobj, (ColumnStyle)entry.Value); resolvedStyles.Add(entry.Key); } } foreach (object resstyle in resolvedStyles) { _colStyles.Remove(resstyle); } // if all columns have resolved, we can close the event link if (_colStyles.Count == 0 && _pathToTable == null) { info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhDeserializationFinished); } }
public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { var resolvedStyles = new List <Main.AbsoluteDocumentPath>(); foreach (var entry in _unresolvedColumns) { object resolvedobj = Main.AbsoluteDocumentPath.GetObject(entry.Key, _deserializedInstance, documentRoot); if (null != resolvedobj) { _deserializedInstance._columnStyles.Add((DataColumn)resolvedobj, entry.Value); resolvedStyles.Add(entry.Key); } } foreach (var resstyle in resolvedStyles) { _unresolvedColumns.Remove(resstyle); } // if all columns have resolved, we can close the event link if (_unresolvedColumns.Count == 0) { info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhDeserializationFinished); } }
/// <summary> /// Gets the parent GraphDocumentCollection of a child graph. /// </summary> /// <param name="child">A graph for which the parent collection is searched.</param> /// <returns>The parent GraphDocumentCollection, if it exists, or null otherwise.</returns> public static GraphDocumentCollection GetParentGraphDocumentCollectionOf(Main.IDocumentNode child) { return((GraphDocumentCollection)Main.DocumentPath.GetRootNodeImplementing(child, typeof(GraphDocumentCollection))); }
private void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { var o = AbsoluteDocumentPath.GetObject(_PathToGraph, documentRoot); if (o is GraphDocument) { _GraphController._graphDocument = (GraphDocument)o; info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhDeserializationFinished); } }
public FitFunctionScriptCollection(Main.IDocumentNode parent) { _parent = parent; }
protected void EhXmlDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { if (null != ResolveDocumentObject(documentRoot) || isFinallyCall) { info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhXmlDeserializationFinished); } }
public DensityImageLegend(DensityImagePlotItem plotItem, Main.IDocumentNode futureParentObject, PointD2D initialLocation, PointD2D graphicSize, Main.Properties.IReadOnlyPropertyBag context) : base(new ItemLocationDirect()) { if (null == plotItem) { throw new ArgumentNullException("plotItem"); } if (null == futureParentObject) { throw new ArgumentNullException("futureParentObject"); } ParentObject = futureParentObject; PlotItem = plotItem; if (null == _plotItemProxy.DocumentPath) { throw new ArgumentException("No path could be found between plotItem and futureParentObject. This is an indication that one of the objects is not rooted."); } SetSize(graphicSize.X, graphicSize.Y, Main.EventFiring.Suppressed); SetPosition(initialLocation, Main.EventFiring.Suppressed); // _orientationIsVertical = true; // _scaleIsReversed = false; var cachedScale = (NumericalScale)PlotItem.Style.Scale.Clone(); var scaleTickSpacing = Altaxo.Graph.Scales.Scale.CreateDefaultTicks(cachedScale.GetType()); _cachedArea = new DensityLegendArea(Size, true, false, cachedScale, scaleTickSpacing); //_cachedArea.ParentObject = this; // --> moved to the end of this function _axisStyles = new AxisStyleCollection(); _axisStyles.UpdateCoordinateSystem(_cachedArea.CoordinateSystem); // _axisStyles.ParentObject = this; --> see below var sx0 = new AxisStyle(CSLineID.X0, true, true, false, "Z values", context); sx0.AxisLineStyle.FirstDownMajorTicks = true; sx0.AxisLineStyle.FirstUpMajorTicks = false; sx0.AxisLineStyle.FirstDownMinorTicks = true; sx0.AxisLineStyle.FirstUpMinorTicks = false; var sx1 = new AxisStyle(CSLineID.X1, true, false, false, null, context); sx1.AxisLineStyle.FirstDownMajorTicks = false; sx1.AxisLineStyle.FirstUpMajorTicks = false; sx1.AxisLineStyle.FirstDownMinorTicks = false; sx1.AxisLineStyle.FirstUpMinorTicks = false; var sy0 = new AxisStyle(CSLineID.Y0, true, false, false, "Color map", context); var sy1 = new AxisStyle(CSLineID.Y1, true, false, false, null, context); _axisStyles.Add(sx0); _axisStyles.Add(sx1); _axisStyles.Add(sy0); _axisStyles.Add(sy1); sx0.Title.Rotation = 90; sx0.Title.Location.ParentAnchorX = RADouble.NewRel(0); // Left sx0.Title.Location.ParentAnchorY = RADouble.NewRel(0.5); // Center sx0.Title.Location.LocalAnchorX = RADouble.NewRel(0.5); // Center sx0.Title.Location.LocalAnchorY = RADouble.NewRel(1); // Bottom sx0.Title.X = -Width / 3; sx0.Title.Y = 0; sy0.Title.Location.ParentAnchorX = RADouble.NewRel(0.5); // Center sy0.Title.Location.ParentAnchorY = RADouble.NewRel(0); // Top sy0.Title.Location.LocalAnchorX = RADouble.NewRel(0.5); // Center sy0.Title.Location.LocalAnchorY = RADouble.NewRel(1); // Bottom sy0.Title.X = 0; sy0.Title.Y = sy0.Title.Height / 2; // set the parent objects _axisStyles.ParentObject = this; _cachedArea.ParentObject = this; UpdateTransformationMatrix(); }
private void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { if (null != _PathToLayout) { var o = AbsoluteDocumentPath.GetObject(_PathToLayout, documentRoot); if (o is Altaxo.Worksheet.WorksheetLayout) { _TableController._worksheetLayout = (Altaxo.Worksheet.WorksheetLayout)o; _PathToLayout = null; } } if (null == _PathToLayout) { info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(EhDeserializationFinished); } }