public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { string filename = FileDialog.ShowSave(FileDialog.Context.Document); if (string.IsNullOrEmpty(filename)) { return; } List <Page> list = new List <Page> { CurrentPage }; Document document = new Document(list); // constructs the document containing this page DatumList referenced = new DatumList(); CurrentPage.AddRequiredReferencesRecurseToContained(referenced.Add, Mapping.Ignore); foreach (Datum datum in referenced.Values) { switch (datum.TypeByteAsFileMarker) { case FileMarkers.Paper: break; case FileMarkers.SharedBitmap: document.AddSharedResource((SharedImage)datum); break; default: Debug.Fail("Unexpected external reference from page"); break; } } using (DataWriter writer = new DataWriter(filename, FileMarkers.Splash)) { writer.Write(document); } // We don't dispose the document because that would dispose the pages; we can just let the garbage collector cleanup the document }