protected void InternalInitializeDocument(TextDocumentViewOptions options) { if (null == options?.Document) { throw new ArgumentNullException("No document stored inside options"); } _options = options; Title = GetTitleFromDocumentName(TextDocument); TextDocument.TunneledEvent += new WeakActionHandler <object, object, Altaxo.Main.TunnelingEventArgs>(EhDocumentTunneledEvent, (handler) => TextDocument.TunneledEvent -= handler); }
public bool InitializeDocument(params object[] args) { if (null == args || args.Length == 0) { return(false); } TextDocumentViewOptions newOptions = null; if (args[0] is TextDocumentViewOptions notesViewOptions) { newOptions = notesViewOptions; } else if (args[0] is TextDocument notesDoc) { newOptions = new TextDocumentViewOptions(notesDoc); } if (newOptions == null) { return(false); // not successfull } if (newOptions.Document == null) { throw new InvalidProgramException("The provided options do not contain any document"); } if (_options?.Document != null && !object.ReferenceEquals(TextDocument, _options.Document)) { throw new InvalidProgramException("The already initialized document and the document in the option class are not identical"); } InternalInitializeDocument(newOptions); return(true); }