SerializePage( SerializableObjectContext serializableObjectContext ) { FixedPage fixedPage = Toolbox.GetPageRoot(serializableObjectContext.TargetObject); if (fixedPage != null) { ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage); if (serializer != null) { NgcSerializationManagerAsync manager = SerializationManager as NgcSerializationManagerAsync; XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket, 0); manager.OnNGCSerializationPrintTicketRequired(e); Toolbox.Layout(fixedPage, manager.GetActivePrintTicket()); serializer.SerializeObject(fixedPage); } else { throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoSerializer)); } } }
SerializePage( SerializableObjectContext serializableObjectContext ) { FixedPage fixedPage = Toolbox.GetPageRoot(serializableObjectContext.TargetObject); if (fixedPage != null) { ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage); if (serializer != null) { XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket, 0); ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e); PrintTicket printTicket = null; if (e.Modified) { printTicket = e.PrintTicket; } Toolbox.Layout(fixedPage, printTicket); ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = printTicket; serializer.SerializeObject(fixedPage); } else { throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoSerializer)); } } }
BeginConfirmToXPSStructure( bool mode ) { // // In case we have a FixedPage or a Visual as a root, we have to simulate // a containing FixedDocument-FixedPage ... etc. // if ((_serializedObject.GetType() == typeof(System.Windows.Documents.FixedDocument)) || (typeof(System.Windows.Documents.DocumentPaginator).IsAssignableFrom(_serializedObject.GetType()) && (_serializedObject.GetType() != typeof(System.Windows.Documents.FixedDocumentSequence)))) { // // Build the necessary wrapper for a FixedDocument // _documentSequenceXmlWriter = SimulateBeginFixedDocumentSequence(); } else if (_serializedObject.GetType() == typeof(System.Windows.Documents.FixedPage)) { // // Build the necessary wrapper for a FixedPage // _documentSequenceXmlWriter = SimulateBeginFixedDocumentSequence(); _documentXmlWriter = SimulateBeginFixedDocument(); XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket, 0); ((IXpsSerializationManager)_serializationManager).OnXPSSerializationPrintTicketRequired(e); XpsOMSerializationManager xpsOMSerializationManager = _serializationManager as XpsOMSerializationManager; PrintTicket printTicket = null; if (e.Modified) { printTicket = e.PrintTicket; } Toolbox.Layout(_serializedObject as FixedPage, printTicket); ((IXpsSerializationManager)_serializationManager).FixedPagePrintTicket = printTicket; } else if (typeof(System.Windows.Media.Visual).IsAssignableFrom(_serializedObject.GetType())) { _documentSequenceXmlWriter = SimulateBeginFixedDocumentSequence(); _documentXmlWriter = SimulateBeginFixedDocument(); if (!mode) { _pageXmlWriter = SimulateBeginFixedPage(); } } }
PersistObjectData( SerializableObjectContext serializableObjectContext ) { if (serializableObjectContext.IsComplexValue) { //SerializeObjectCore(serializableObjectContext); FixedPage fixedPage = Toolbox.GetPageRoot(serializableObjectContext.TargetObject); if (fixedPage != null) { ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage); if (serializer != null) { //Get FixedPage Print Ticket and cache it inside of the SerializationManager //so we can get it inside of XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket, 0); ((IXpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e); PrintTicket printTicket = null; if (e.Modified) { printTicket = e.PrintTicket; } Toolbox.Layout(fixedPage, printTicket); ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket = printTicket; serializer.SerializeObject(fixedPage); } else { throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_NoSerializer)); } } } else { throw new XpsSerializationException(SR.Get(SRID.ReachSerialization_WrongPropertyTypeForPageContent)); } }
SimulateFixedPageSize( Visual visual, PrintTicket printTicket ) { Size sz = new Size(0, 0); //Try to cast the visual down to a UIElement so we can get the PreviousArrangeSize // UIElement element = visual as UIElement; if (element != null) { Rect rect = element.PreviousArrangeRect; sz = Toolbox.Layout(element, rect.Size, printTicket); } else { //If the visual is not a UIElement, call ValidateDocumentSize to assign defaults sz = Toolbox.ValidateDocumentSize(sz, printTicket); } return(sz); }