private DocumentMeta AddNewDocument(HeliosObject profileObject) { DocumentMeta meta = FindDocumentMeta(profileObject); if (meta != null) { meta.document.IsSelected = true; return(meta); } HeliosEditorDocument editor = CreateDocumentEditor(profileObject); if (editor != null) { LayoutDocument document = new LayoutDocument(); document.Title = editor.Title; document.IsSelected = true; document.ContentId = HeliosSerializer.GetReferenceName(profileObject); document.Content = CreateDocumentContent(editor); DocumentPane.Children.Add(document); document.Closed += Document_Closed; meta = AddDocumentMeta(profileObject, document, editor); profileObject.PropertyChanged += DocumentObject_PropertyChanged; } return(meta); }
void DocumentObject_PropertyChanged(object sender, PropertyChangedEventArgs e) { DocumentMeta meta = FindDocumentMeta(sender as HeliosObject); if (meta == null) { throw new InvalidOperationException("Property Changed closed called for a profile object not found in meta data."); } if (e.PropertyName.Equals("Name")) { meta.document.Title = meta.editor.Title; meta.document.ContentId = "doc:" + HeliosSerializer.GetReferenceName(meta.hobj); } }
private DocumentMeta AddNewDocument(HeliosObject profileObject) { DocumentMeta meta = FindDocumentMeta(profileObject); if (meta != null) { meta.document.IsSelected = true; return(meta); } HeliosEditorDocument editor = CreateDocumentEditor(profileObject); if (editor != null) { LayoutDocument document = new LayoutDocument(); document.Title = editor.Title; document.IsSelected = true; document.ContentId = HeliosSerializer.GetReferenceName(profileObject); document.Content = CreateDocumentContent(editor); // Since a new LayoutRoot object is created upon de-serialization, the Child LayoutDocumentPane no longer belongs to the LayoutRoot // therefore the LayoutDocumentPane 'DocumentPane' must be referred to dynamically // change added by yzfanimal LayoutDocumentPane DocumentPane = this.DockManager.Layout.Descendents().OfType <LayoutDocumentPane>().FirstOrDefault(); if (DocumentPane != null) { DocumentPane.Children.Add(document); } document.Closed += Document_Closed; meta = AddDocumentMeta(profileObject, document, editor); profileObject.PropertyChanged += DocumentObject_PropertyChanged; } return(meta); }