Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Serialization / manager / ReachDocumentPageSerializer.cs / 1 / ReachDocumentPageSerializer.cs
/*++
Copyright (C) 2004- 2005 Microsoft Corporation
All rights reserved.
Module Name:
ReachDocumentPageSerializer.cs
Abstract:
Author:
[....] ([....]) January 2005
Revision History:
--*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Xml;
using System.IO;
using System.Printing;
using System.Security;
using System.Security.Permissions;
using System.ComponentModel.Design.Serialization;
using System.Windows.Xps.Packaging;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Markup;
using System.Windows.Shapes;
namespace System.Windows.Xps.Serialization
{
///
///
///
internal class DocumentPageSerializer :
ReachSerializer
{
///
///
///
public
DocumentPageSerializer(
PackageSerializationManager manager
)
:
base(manager)
{
}
public
override
void
SerializeObject(
Object serializedObject
)
{
//
// Create the ImageTable required by the Type Converters
// The Image table at this time is shared / currentPage
//
((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = new Dictionary();
//
// Create the ColorContextTable required by the Type Converters
// The Image table at this time is shared / currentPage
//
((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = new Dictionary();
base.SerializeObject(serializedObject);
}
///
///
///
internal
override
void
SerializeObject(
SerializablePropertyContext serializedProperty
)
{
//
// Create the ImageTable required by the Type Converters
// The Image table at this time is shared / currentPage
//
((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = new Dictionary();
//
// Create the ColorContextTable required by the Type Converters
// The Image table at this time is shared / currentPage
//
((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = new Dictionary();
base.SerializeObject(serializedProperty);
}
///
///
///
internal
override
void
PersistObjectData(
SerializableObjectContext serializableObjectContext
)
{
if (SerializationManager is XpsSerializationManager)
{
(SerializationManager as XpsSerializationManager).RegisterPageStart();
}
//
// A DocumentPage is persisted as a FixedPage
//
DocumentPage dp = (DocumentPage)serializableObjectContext.TargetObject;
ReachTreeWalker treeWalker = new ReachTreeWalker(this);
treeWalker.SerializeLinksInDocumentPage(dp);
XmlWriter.WriteStartElement(XpsS0Markup.FixedPage);
String xmlnsForType = SerializationManager.GetXmlNSForType(typeof(FixedPage));
if (xmlnsForType != null)
{
XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType);
XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema);
if (SerializationManager.Language != null)
{
XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, SerializationManager.Language.ToString());
}
else
{
XmlWriter.WriteAttributeString(XpsS0Markup.XmlLang, XpsS0Markup.XmlLangValue);
}
}
XpsSerializationPrintTicketRequiredEventArgs e =
new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket,
0);
((XpsSerializationManager)SerializationManager).OnXPSSerializationPrintTicketRequired(e);
PrintTicket printTicket = null;
if(e.Modified)
{
printTicket = e.PrintTicket;
}
Size size = Toolbox.ValidateDocumentSize(dp.Size, printTicket);
((XpsSerializationManager)SerializationManager).FixedPageSize = size;
//
//write length and width elements
//
WriteAttribute(XmlWriter, XpsS0Markup.PageWidth, size.Width);
WriteAttribute(XmlWriter, XpsS0Markup.PageHeight, size.Height);
//
// Serialize the data for the PrintTicket
//
if(printTicket != null)
{
PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager);
serializer.SerializeObject(printTicket);
}
SerializeChild(dp.Visual, serializableObjectContext);
((XpsSerializationManager)SerializationManager).PackagingPolicy.PreCommitCurrentPage();
//copy hyperlinks into stream
treeWalker.CommitHyperlinks();
XmlWriter.WriteEndElement();
XmlWriter = null;
//
// Free the image table in use for this page
//
((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageImageTable = null;
//
// Free the colorContext table in use for this page
//
((XpsSerializationManager)SerializationManager).ResourcePolicy.CurrentPageColorContextTable = null;
((XpsSerializationManager)SerializationManager).VisualSerializationService.ReleaseVisualTreeFlattener();
if( SerializationManager is XpsSerializationManager)
{
(SerializationManager as XpsSerializationManager).RegisterPageEnd();
}
//
// Signal to any registered callers that the Page has been serialized
//
XpsSerializationProgressChangedEventArgs progressEvent =
new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress,
0,
0,
null);
((XpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent);
}
private void SerializeChild(Visual child, SerializableObjectContext parentContext)
{
ReachSerializer serializer = SerializationManager.GetSerializer(child);
if (serializer != null)
{
serializer.SerializeObject(child);
}
}
private void WriteAttribute(XmlWriter writer, string name, object value)
{
writer.WriteAttributeString(name, TypeDescriptor.GetConverter(value).ConvertToInvariantString(value));
}
///
///
///
public
override
XmlWriter
XmlWriter
{
get
{
if (base.XmlWriter == null)
{
base.XmlWriter = SerializationManager.AcquireXmlWriter(typeof(FixedPage));
}
return base.XmlWriter;
}
set
{
base.XmlWriter = null;
SerializationManager.ReleaseXmlWriter(typeof(FixedPage));
}
}
};
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InvokeFunc.cs
- XmlDigitalSignatureProcessor.cs
- HttpHandlerActionCollection.cs
- HttpHandlerActionCollection.cs
- TransactionFlowAttribute.cs
- basevalidator.cs
- DataGridViewCellConverter.cs
- WorkflowMarkupSerializationProvider.cs
- TreeNodeMouseHoverEvent.cs
- FormsAuthenticationEventArgs.cs
- EventMappingSettings.cs
- SqlConnection.cs
- SelectionProviderWrapper.cs
- XmlRawWriter.cs
- VolatileEnlistmentState.cs
- SubMenuStyle.cs
- HtmlWindow.cs
- DbLambda.cs
- TargetParameterCountException.cs
- ActiveXHelper.cs
- WorkflowInstanceQuery.cs
- MetadataHelper.cs
- SchemaTableOptionalColumn.cs
- PolicyUnit.cs
- VectorCollection.cs
- XmlDomTextWriter.cs
- KnownColorTable.cs
- DetailsViewModeEventArgs.cs
- BackStopAuthenticationModule.cs
- BrowserCapabilitiesCodeGenerator.cs
- SqlDesignerDataSourceView.cs
- DataGridViewCellStyleChangedEventArgs.cs
- AliasGenerator.cs
- CursorInteropHelper.cs
- ZoneButton.cs
- IndicCharClassifier.cs
- RtfControls.cs
- QilLoop.cs
- MediaScriptCommandRoutedEventArgs.cs
- UnsafeNativeMethods.cs
- SchemaCollectionPreprocessor.cs
- DispatcherHooks.cs
- HostingEnvironment.cs
- SimpleWebHandlerParser.cs
- ProcessHostFactoryHelper.cs
- CachedPathData.cs
- _NativeSSPI.cs
- WindowHideOrCloseTracker.cs
- ReflectTypeDescriptionProvider.cs
- DataBindingExpressionBuilder.cs
- ThemeDirectoryCompiler.cs
- ChannelRequirements.cs
- KnownTypesProvider.cs
- FatalException.cs
- DebuggerAttributes.cs
- ModuleConfigurationInfo.cs
- SafeNativeMethodsOther.cs
- SoapParser.cs
- SubclassTypeValidatorAttribute.cs
- RegexTree.cs
- ProviderConnectionPoint.cs
- AtomServiceDocumentSerializer.cs
- FastEncoder.cs
- KeyTimeConverter.cs
- OdbcStatementHandle.cs
- DLinqAssociationProvider.cs
- DefaultBinder.cs
- SizeAnimationUsingKeyFrames.cs
- CellNormalizer.cs
- SingleConverter.cs
- EventHandlerService.cs
- TcpStreams.cs
- NullableIntAverageAggregationOperator.cs
- DataGridViewColumnEventArgs.cs
- CompiledQueryCacheEntry.cs
- ProfileInfo.cs
- XPathAxisIterator.cs
- streamingZipPartStream.cs
- AxisAngleRotation3D.cs
- SqlUDTStorage.cs
- ColorTransform.cs
- AccessViolationException.cs
- SharedStatics.cs
- RangeBaseAutomationPeer.cs
- SessionStateItemCollection.cs
- SqlDataRecord.cs
- CopyCodeAction.cs
- ProgramPublisher.cs
- GacUtil.cs
- _TransmitFileOverlappedAsyncResult.cs
- WebServiceErrorEvent.cs
- XmlSerializerFactory.cs
- StartFileNameEditor.cs
- EnumValAlphaComparer.cs
- EntityParameter.cs
- Schema.cs
- SimpleBitVector32.cs
- InvokeDelegate.cs
- formatstringdialog.cs
- BamlResourceDeserializer.cs