Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Serialization / manager / ReachVisualSerializerAsync.cs / 1 / ReachVisualSerializerAsync.cs
/*++ Copyright (C) 2004- 2005 Microsoft Corporation All rights reserved. Module Name: ReachVisualSerializerAsync.cs Abstract: Author: [....] ([....]) 25-May-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.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; namespace System.Windows.Xps.Serialization { ////// /// internal class ReachVisualSerializerAsync : ReachSerializerAsync { ////// /// public ReachVisualSerializerAsync( PackageSerializationManager manager ): base(manager) { } public override void AsyncOperation( ReachSerializerContext context ) { if(context == null) { } switch (context.Action) { case SerializerAction.serializeNextTreeNode: { ReachVisualSerializerContext thisContext = context as ReachVisualSerializerContext; if(thisContext != null) { SerializeNextTreeNode(thisContext); } break; } default: { base.AsyncOperation(context); break; } } } ////// /// public override void SerializeObject( object serializedObject ) { Visual v = serializedObject as Visual; if (v == null) { throw new ArgumentException(ReachSR.Get(ReachSRID.MustBeOfType, "serializedObject", typeof(Visual))); } XmlWriter pageWriter = ((XpsSerializationManagerAsync)SerializationManager). PackagingPolicy.AcquireXmlWriterForPage(); XmlWriter resWriter = ((XpsSerializationManagerAsync)SerializationManager). PackagingPolicy.AcquireXmlWriterForResourceDictionary(); SerializeTree(v, resWriter, pageWriter); } ////// /// internal override void SerializeObject( SerializablePropertyContext serializedProperty ) { // // Do nothing here. // We do not support serializing visuals that come in as // properties out of context of a FixedPage or a DocumentPage // } private void SerializeTree( Visual visual, XmlWriter resWriter, XmlWriter bodyWriter ) { Size fixedPageSize = ((XpsSerializationManager)SerializationManager).FixedPageSize; VisualTreeFlattener flattener = ((XpsSerializationManagerAsync)SerializationManager). VisualSerializationService.AcquireVisualTreeFlattener(resWriter, bodyWriter, fixedPageSize); if (flattener.StartVisual(visual)) { StackcontextStack = new Stack (); contextStack.Push(new NodeContext(visual)); ReachVisualSerializerContext context = new ReachVisualSerializerContext(this, contextStack, flattener, SerializerAction.serializeNextTreeNode); ((XpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context); } } private void SerializeNextTreeNode( ReachVisualSerializerContext context ) { if(context.ContextStack.Count > 0) { Stack contextStack = context.ContextStack; VisualTreeFlattener flattener = context.VisualFlattener; ReachVisualSerializerContext nextContext = new ReachVisualSerializerContext(this, contextStack, flattener, SerializerAction.serializeNextTreeNode); ((XpsSerializationManagerAsync)SerializationManager).OperationStack.Push(nextContext); NodeContext ctx = contextStack.Peek(); Visual v = ctx.GetNextChild(); if (v != null) { if (flattener.StartVisual(v)) { contextStack.Push(new NodeContext(v)); } } else { contextStack.Pop(); flattener.EndVisual(); } } } /// /// /// internal override void PersistObjectData( SerializableObjectContext serializableObjectContext ) { // // Do nothing here // } ////// /// 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)); } } #region Internal Methods ////// /// internal bool SerializeDisguisedVisual( object serializedObject ) { Visual v = serializedObject as Visual; if (v == null) { throw new ArgumentException(ReachSR.Get(ReachSRID.MustBeOfType, "serializedObject", typeof(Visual))); } XmlWriter pageWriter = ((XpsSerializationManagerAsync)SerializationManager). PackagingPolicy.AcquireXmlWriterForPage(); XmlWriter resWriter = ((XpsSerializationManagerAsync)SerializationManager). PackagingPolicy.AcquireXmlWriterForResourceDictionary(); Size fixedPageSize = ((XpsSerializationManager)SerializationManager).FixedPageSize; VisualTreeFlattener flattener = ((XpsSerializationManagerAsync)SerializationManager). VisualSerializationService.AcquireVisualTreeFlattener(resWriter, pageWriter, fixedPageSize); return flattener.StartVisual(v); } #endregion Internal Methods }; internal class ReachVisualSerializerContext : ReachSerializerContext { public ReachVisualSerializerContext( ReachSerializerAsync serializer, StackcontextStack, VisualTreeFlattener flattener, SerializerAction action ): base(serializer,action) { this._contextStack = contextStack; this._flattener = flattener; } public Stack ContextStack { get { return _contextStack; } } public VisualTreeFlattener VisualFlattener { get { return _flattener; } } private Stack _contextStack; VisualTreeFlattener _flattener; }; } // 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
- DateTimeStorage.cs
- ThrowHelper.cs
- QilXmlWriter.cs
- ReflectTypeDescriptionProvider.cs
- Underline.cs
- EventLogLink.cs
- ToolTipAutomationPeer.cs
- PointIndependentAnimationStorage.cs
- FontSourceCollection.cs
- XPathDocumentBuilder.cs
- PrintController.cs
- ObjectListCommandEventArgs.cs
- MobileListItem.cs
- CheckoutException.cs
- ColorConvertedBitmapExtension.cs
- MetaTableHelper.cs
- TriggerAction.cs
- Bits.cs
- LiteralDesigner.cs
- ValueTypePropertyReference.cs
- SqlRetyper.cs
- TypeUtils.cs
- SequentialWorkflowHeaderFooter.cs
- NegotiateStream.cs
- TagMapCollection.cs
- SettingsSection.cs
- ServiceDurableInstance.cs
- login.cs
- SessionStateUtil.cs
- EndpointAddressMessageFilterTable.cs
- DependencyPropertyAttribute.cs
- DocobjHost.cs
- Int64Converter.cs
- NamedElement.cs
- IntSumAggregationOperator.cs
- TreeViewHitTestInfo.cs
- ExtensibleClassFactory.cs
- BrowserDefinition.cs
- SqlDataSourceTableQuery.cs
- WebPartUtil.cs
- StringArrayEditor.cs
- CounterSample.cs
- CharUnicodeInfo.cs
- PermissionToken.cs
- SerializationEventsCache.cs
- Peer.cs
- DoubleAnimationClockResource.cs
- IncrementalReadDecoders.cs
- TreeViewImageKeyConverter.cs
- Events.cs
- RootBuilder.cs
- TextTreeRootNode.cs
- BaseHashHelper.cs
- SmtpTransport.cs
- EUCJPEncoding.cs
- ClientSettingsSection.cs
- WebPartConnection.cs
- CalendarDayButton.cs
- VariableQuery.cs
- ActivityWithResultConverter.cs
- MissingMemberException.cs
- RSACryptoServiceProvider.cs
- TextCompositionEventArgs.cs
- PackageDocument.cs
- SmiEventSink_Default.cs
- ChannelTokenTypeConverter.cs
- GenericArgumentsUpdater.cs
- Event.cs
- CacheEntry.cs
- SoapObjectInfo.cs
- DelegateSerializationHolder.cs
- SqlError.cs
- StandardBindingReliableSessionElement.cs
- HttpRuntimeSection.cs
- BaseContextMenu.cs
- SHA1CryptoServiceProvider.cs
- ToolStripLocationCancelEventArgs.cs
- RoutedUICommand.cs
- ServiceBuildProvider.cs
- CachedPathData.cs
- MeshGeometry3D.cs
- ListenDesigner.cs
- RawStylusInputReport.cs
- OpenTypeLayoutCache.cs
- WSDualHttpSecurityMode.cs
- BidPrivateBase.cs
- _LocalDataStore.cs
- BitmapVisualManager.cs
- TextTreeUndoUnit.cs
- SimpleHandlerFactory.cs
- Soap.cs
- TextTreeRootNode.cs
- CookieParameter.cs
- CollectionsUtil.cs
- SessionEndedEventArgs.cs
- ReceiveErrorHandling.cs
- TypeDelegator.cs
- IsolationInterop.cs
- ValidateNames.cs
- PresentationSource.cs