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); } }
protected DocNodeProxy(Main.AbsoluteDocumentPath docNodePath) { if (null == docNodePath) { throw new ArgumentNullException(nameof(docNodePath)); } InternalDocumentPath = docNodePath; InternalCheckAbsolutePath(); }
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 } }
private static void ProvideLinkedScalesWithLinkedLayerIndex(XYPlotLayer s, Main.AbsoluteDocumentPath path, Altaxo.Serialization.Xml.IXmlDeserializationInfo info) { if (null != path && path.Count > 0) { var pathend = path[path.Count - 1]; // extract layer number int layerNum = System.Xml.XmlConvert.ToInt32(pathend.Substring(1)); foreach (var scaleAndTick in s.Scales) { if (scaleAndTick is LinkedScale) #pragma warning disable CS0612 // Type or member is obsolete { ((LinkedScale)scaleAndTick).SetLinkedLayerIndex(layerNum, info); } } #pragma warning restore CS0612 // Type or member is obsolete } }
/// <summary> /// Replaces parts of the part of the document node by another part. If the replacement was successful, the original document node is cleared. /// See <see cref="M:DocumentPath.ReplacePathParts"/> for details of the part replacement. /// </summary> /// <param name="partToReplace">Part of the path that should be replaced. This part has to match the beginning of this part. The last item of the part /// is allowed to be given only partially.</param> /// <param name="newPart">The new part to replace that piece of the path, that match the <c>partToReplace</c>.</param> /// <param name="rootNode">Any document node in the hierarchy that is used to find the root node of the hierarchy.</param> /// <returns>True if the path could be replaced. Returns false if the path does not fulfill the presumptions given above.</returns> /// <remarks> /// As stated above, the last item of the partToReplace can be given only partially. As an example, the path (here separated by space) /// <para>Tables Preexperiment1/WDaten Time</para> /// <para>should be replaced by </para> /// <para>Tables Preexperiment2\WDaten Time</para> /// <para>To make this replacement, the partToReplace should be given by</para> /// <para>Tables Preexperiment1/</para> /// <para>and the newPart should be given by</para> /// <para>Tables Preexperiment2\</para> /// <para>Note that Preexperiment1\ and Preexperiment2\ are only partially defined items of the path.</para> /// </remarks> public bool ReplacePathParts(AbsoluteDocumentPath partToReplace, AbsoluteDocumentPath newPart, IDocumentLeafNode rootNode) { if (!(_docNodePath != null || IsDisposeInProgress)) { throw new InvalidProgramException(); } if (null == rootNode) { throw new ArgumentNullException(nameof(rootNode)); } var success = _docNodePath.ReplacePathParts(partToReplace, newPart, out var newPath); if (success) { _docNodePath = newPath; ClearDocNode(); ResolveDocumentObject(rootNode); } return(success); }
/// <summary> /// Disposing this instance is special - we must not dispose the reference this instance holds. /// Instead, we remove all references to the holded document node and also all event handlers- /// </summary> /// <param name="isDisposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected override void Dispose(bool isDisposing) { if (null != _weakDocNodeChangedHandler) { _weakDocNodeChangedHandler.Remove(); _weakDocNodeChangedHandler = null; } if (null != _weakDocNodeTunneledEventHandler) { _weakDocNodeTunneledEventHandler.Remove(); _weakDocNodeTunneledEventHandler = null; } _docNodeRef = null; #if DEBUG_DOCNODEPROXYLOGGING Current.Console.WriteLine("DocNodeProxy.Dispose, path was >>>{0}<<<", _docNodePath); #endif _docNodePath = null; base.Dispose(isDisposing); }
public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { bool bAllResolved = true; if (this._xColumnPath != null) { object xColumn = Main.AbsoluteDocumentPath.GetObject(this._xColumnPath, this._plotAssociation, documentRoot); bAllResolved &= (null != xColumn); if (xColumn is Altaxo.Data.INumericColumn) { this._xColumnPath = null; this._xColumnProxy = ReadableColumnProxyBase.FromColumn((Altaxo.Data.INumericColumn)xColumn); } } if (this._yColumnPath != null) { object yColumn = Main.AbsoluteDocumentPath.GetObject(this._yColumnPath, this._plotAssociation, documentRoot); bAllResolved &= (null != yColumn); if (yColumn is Altaxo.Data.INumericColumn) { this._yColumnPath = null; this._yColumnProxy = ReadableColumnProxyBase.FromColumn((Altaxo.Data.INumericColumn)yColumn); } } for (int i = 0; i < this._vColumnPaths.Length; i++) { if (this._vColumnPaths[i] != null) { object vColumn = Main.AbsoluteDocumentPath.GetObject(this._vColumnPaths[i], this._plotAssociation, documentRoot); bAllResolved &= (null != vColumn); if (vColumn is Altaxo.Data.IReadableColumn) { this._vColumnPaths[i] = null; this._vColumnProxies[i] = ReadableColumnProxyBase.FromColumn((Altaxo.Data.IReadableColumn)vColumn); } } } if (bAllResolved || isFinallyCall) { info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished); #pragma warning disable 618 _plotAssociation._matrixProxy = new DataTableMatrixProxy(_xColumnProxy, _yColumnProxy, _vColumnProxies) { ParentObject = _plotAssociation }; #pragma warning restore 618 } }
/// <summary> /// Event handler that is called when the watched node or a parent node below has disposed or its name changed. We then try to resolve the path again. /// </summary> /// <param name="sender"></param> /// <param name="source">Source of the tunneled event.</param> /// <param name="e"></param> private void EhWatchedNode_TunneledEvent(object sender, object source, Main.TunnelingEventArgs e) { if (IsDisposeInProgress) { return; } if (!(InternalDocumentNode == null)) { throw new InvalidProgramException(); } var senderAsDocNode = sender as IDocumentLeafNode; var sourceAsDocNode = source as IDocumentLeafNode; if (!(senderAsDocNode != null)) { throw new InvalidProgramException(); } if (!(sourceAsDocNode != null)) { throw new InvalidProgramException(); } if (e is DocumentPathChangedEventArgs) // here, we activly change our stored path, if the watched node or a parent has changed its name { var watchedPath = AbsoluteDocumentPath.GetAbsolutePath(senderAsDocNode); watchedPath = watchedPath.Append(_docNodePath.SubPath(watchedPath.Count, _docNodePath.Count - watchedPath.Count)); var oldPath = _docNodePath; _docNodePath = watchedPath; #if DEBUG_DOCNODEPROXYLOGGING Current.Console.WriteLine("DocNodeProxy.EhWatchedNode_TunneledEvent: Modified path, oldpath={0}, newpath={1}", oldPath, _docNodePath); #endif } // then we try to resolve the path again if ((e is DisposeEventArgs) || (e is DocumentPathChangedEventArgs)) { #if DEBUG_DOCNODEPROXYLOGGING Current.Console.WriteLine("DocNodeProxy.EhWatchedNode_TunneledEvent"); #endif var node = AbsoluteDocumentPath.GetNodeOrLeastResolveableNode(_docNodePath, sourceAsDocNode, out var wasResolvedCompletely); if (null == node) { throw new InvalidProgramException(nameof(node) + " should always be != null, since we use absolute paths, and at least an AltaxoDocument should be resolved here."); } if (wasResolvedCompletely) { ClearWatch(); SetDocNode(node); } else // not completely resolved { if (!object.ReferenceEquals(sender, node)) { ClearWatch(); SetWatchOnNode(node); } } } }
/// <summary> /// Event handler that is called when the watched node or a parent node below has disposed or its name changed. We then try to resolve the path again. /// </summary> /// <param name="sender"></param> /// <param name="source">Source of the tunneled event.</param> /// <param name="e"></param> private void EhWatchedNode_TunneledEvent(object sender, object source, Main.TunnelingEventArgs e) { if (IsDisposeInProgress) return; if (!(InternalDocumentNode == null)) throw new InvalidProgramException(); var senderAsDocNode = sender as IDocumentLeafNode; var sourceAsDocNode = source as IDocumentLeafNode; if (!(senderAsDocNode != null)) throw new InvalidProgramException(); if (!(sourceAsDocNode != null)) throw new InvalidProgramException(); if (e is DocumentPathChangedEventArgs) // here, we activly change our stored path, if the watched node or a parent has changed its name { var watchedPath = AbsoluteDocumentPath.GetAbsolutePath(senderAsDocNode); watchedPath = watchedPath.Append(_docNodePath.SubPath(watchedPath.Count, _docNodePath.Count - watchedPath.Count)); var oldPath = _docNodePath; _docNodePath = watchedPath; #if DEBUG_DOCNODEPROXYLOGGING Current.Console.WriteLine("DocNodeProxy.EhWatchedNode_TunneledEvent: Modified path, oldpath={0}, newpath={1}", oldPath, _docNodePath); #endif } // then we try to resolve the path again if ((e is DisposeEventArgs) || (e is DocumentPathChangedEventArgs)) { #if DEBUG_DOCNODEPROXYLOGGING Current.Console.WriteLine("DocNodeProxy.EhWatchedNode_TunneledEvent"); #endif bool wasResolvedCompletely; var node = AbsoluteDocumentPath.GetNodeOrLeastResolveableNode(_docNodePath, sourceAsDocNode, out wasResolvedCompletely); if (null == node) throw new InvalidProgramException(nameof(node) + " should always be != null, since we use absolute paths, and at least an AltaxoDocument should be resolved here."); if (wasResolvedCompletely) { ClearWatch(); SetDocNode(node); } else // not completely resolved { if (!object.ReferenceEquals(sender, node)) { ClearWatch(); SetWatchOnNode(node); } } } }
/// <summary> /// Replaces parts of the part of the document node by another part. If the replacement was successful, the original document node is cleared. /// See <see cref="M:DocumentPath.ReplacePathParts"/> for details of the part replacement. /// </summary> /// <param name="partToReplace">Part of the path that should be replaced. This part has to match the beginning of this part. The last item of the part /// is allowed to be given only partially.</param> /// <param name="newPart">The new part to replace that piece of the path, that match the <c>partToReplace</c>.</param> /// <param name="rootNode">Any document node in the hierarchy that is used to find the root node of the hierarchy.</param> /// <returns>True if the path could be replaced. Returns false if the path does not fulfill the presumptions given above.</returns> /// <remarks> /// As stated above, the last item of the partToReplace can be given only partially. As an example, the path (here separated by space) /// <para>Tables Preexperiment1/WDaten Time</para> /// <para>should be replaced by </para> /// <para>Tables Preexperiment2\WDaten Time</para> /// <para>To make this replacement, the partToReplace should be given by</para> /// <para>Tables Preexperiment1/</para> /// <para>and the newPart should be given by</para> /// <para>Tables Preexperiment2\</para> /// <para>Note that Preexperiment1\ and Preexperiment2\ are only partially defined items of the path.</para> /// </remarks> public bool ReplacePathParts(AbsoluteDocumentPath partToReplace, AbsoluteDocumentPath newPart, IDocumentLeafNode rootNode) { if (!(_docNodePath != null || IsDisposeInProgress)) throw new InvalidProgramException(); if (null == rootNode) throw new ArgumentNullException(nameof(rootNode)); AbsoluteDocumentPath newPath; var success = _docNodePath.ReplacePathParts(partToReplace, newPart, out newPath); if (success) { _docNodePath = newPath; ClearDocNode(); ResolveDocumentObject(rootNode); } return success; }
public void EhDeserializationFinished(Altaxo.Serialization.Xml.IXmlDeserializationInfo info, Main.IDocumentNode documentRoot, bool isFinallyCall) { if (this._pathToTable != null && this._worksheetLayout.DataTable == null) { object table = Main.AbsoluteDocumentPath.GetObject(this._pathToTable, this._worksheetLayout, documentRoot); if (table is Altaxo.Data.DataTable) { this._worksheetLayout.DataTable = (Altaxo.Data.DataTable)table; this._pathToTable = null; } } System.Collections.ArrayList resolvedStyles = new System.Collections.ArrayList(); foreach (System.Collections.DictionaryEntry entry in this._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 && this._pathToTable == null) info.DeserializationFinished -= new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(this.EhDeserializationFinished); }