Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Documents / ChildDocumentBlock.cs / 1 / ChildDocumentBlock.cs
//---------------------------------------------------------------------------- //// Copyright (C) 2004 by Microsoft Corporation. All rights reserved. // // // Description: // Represent a node in the doubly linked list a DocumentSequenceTextContainer // maintains for the child-TextContainers it aggregates. Each child-TextContainer // would have a corresponding entry in the list. // // History: // 07/14/2004 - Zhenbin Xu (ZhenbinX) - Created. // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using MS.Internal.Documents; using System; using System.Diagnostics; //===================================================================== ////// Represent a node in the doubly linked list a DocumentSequenceTextContainer /// maintains for the child-TextContainers it aggregates. Each child-TextContainer /// would have a corresponding entry in the list. /// internal sealed class ChildDocumentBlock { //------------------------------------------------------------------- // // Enum // //---------------------------------------------------------------------- [Flags()] internal enum BlockStatus { None = 0, UnloadedBlock = 1, // Child block has not been loaded } //------------------------------------------------------------------- // // Connstructors // //---------------------------------------------------------------------- #region Ctors internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, ITextContainer childContainer) { Debug.Assert(childContainer != null); _aggregatedContainer = aggregatedContainer; _container = childContainer; } internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, DocumentReference docRef) { Debug.Assert(docRef != null); _aggregatedContainer = aggregatedContainer; _docRef = docRef; _SetStatus(BlockStatus.UnloadedBlock); } #endregion Ctors //-------------------------------------------------------------------- // // Internal Properties // //--------------------------------------------------------------------- #region Internal Methods // Insert a new node into this list. internal ChildDocumentBlock InsertNextBlock(ChildDocumentBlock newBlock) { Debug.Assert(newBlock != null); // Setup the new block correctly newBlock._nextBlock = this._nextBlock; newBlock._previousBlock = this; // Link old next block to the new block if (this._nextBlock != null) { this._nextBlock._previousBlock = newBlock; } // Link this block to new block this._nextBlock = newBlock; return newBlock; } #endregion Internal Methods //-------------------------------------------------------------------- // // Internal Properties // //--------------------------------------------------------------------- #region Internal Properties // The AggregatedContainer that holds the list of ChildDocumentBlock. internal DocumentSequenceTextContainer AggregatedContainer { get { return _aggregatedContainer; } } // Reference to the child TextContainer internal ITextContainer ChildContainer { get { _EnsureBlockLoaded(); return _container; } } // The highlight layer used to notify child TextContainer // about TextSelection highlight change. internal DocumentSequenceHighlightLayer ChildHighlightLayer { get { if (_highlightLayer == null) { _highlightLayer = new DocumentSequenceHighlightLayer(_aggregatedContainer); Debug.Assert(ChildContainer.Highlights.GetLayer(typeof(TextSelection)) == null); ChildContainer.Highlights.AddLayer(_highlightLayer); } return _highlightLayer; } } // Reference to the DocumentReference internal DocumentReference DocRef { get { return _docRef; } } // End TextPointer of the child container internal ITextPointer End { get { return ChildContainer.End; } } #if DEBUG // Get if this entry is non-head/tail block in the linked list internal bool IsInsideBlock { get { return (this._previousBlock != null && this._nextBlock != null); } } #endif // Get if this entry is Head of list internal bool IsHead { get { return (this._previousBlock == null); } } // Get if this entry is Tail of list internal bool IsTail { get { return (this._nextBlock == null); } } // Previous container entry in the link list internal ChildDocumentBlock PreviousBlock { get { return _previousBlock; } } // Next container entry in the link list internal ChildDocumentBlock NextBlock { get { return _nextBlock; } } #if DEBUG internal uint DebugId { get { return _debugId; } } #endif #endregion Internal Properties //------------------------------------------------------------------- // // Private Methods // //--------------------------------------------------------------------- #region Private Methods private void _EnsureBlockLoaded() { if (_HasStatus(BlockStatus.UnloadedBlock)) { _ClearStatus(BlockStatus.UnloadedBlock); DocumentsTrace.FixedDocumentSequence.TextOM.Trace("Loading TextContainer " + _docRef.ToString()); // Load the TextContainer IDocumentPaginatorSource idp = _docRef.GetDocument(false /*forceReload*/); IServiceProvider isp = idp as IServiceProvider; if (isp != null) { ITextContainer tc = isp.GetService(typeof(ITextContainer)) as ITextContainer; if (tc != null) { _container = tc; DocumentsTrace.FixedDocumentSequence.TextOM.Trace("Got ITextContainer"); } } if (_container == null) { _container = new NullTextContainer(); } } } private bool _HasStatus(BlockStatus flags) { return ((_status & flags) == flags); } private void _SetStatus(BlockStatus flags) { _status |= flags; } private void _ClearStatus(BlockStatus flags) { _status &= (~flags); } #endregion Private Methods //-------------------------------------------------------------------- // // Private Fields // //--------------------------------------------------------------------- #region Private Fields private readonly DocumentSequenceTextContainer _aggregatedContainer; private readonly DocumentReference _docRef; // Reference to the sub-document private ITextContainer _container; // Child TextContainer private DocumentSequenceHighlightLayer _highlightLayer; // Highlight layer used to notify child TextContainer highlight changes. private BlockStatus _status; // Status of this block, such as Loaded, etc. private ChildDocumentBlock _previousBlock; // Link to previous block private ChildDocumentBlock _nextBlock; // Link to next block #if DEBUG private uint _debugId = (_debugIdCounter++); private static uint _debugIdCounter = 0; #endif #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- //// Copyright (C) 2004 by Microsoft Corporation. All rights reserved. // // // Description: // Represent a node in the doubly linked list a DocumentSequenceTextContainer // maintains for the child-TextContainers it aggregates. Each child-TextContainer // would have a corresponding entry in the list. // // History: // 07/14/2004 - Zhenbin Xu (ZhenbinX) - Created. // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using MS.Internal.Documents; using System; using System.Diagnostics; //===================================================================== ////// Represent a node in the doubly linked list a DocumentSequenceTextContainer /// maintains for the child-TextContainers it aggregates. Each child-TextContainer /// would have a corresponding entry in the list. /// internal sealed class ChildDocumentBlock { //------------------------------------------------------------------- // // Enum // //---------------------------------------------------------------------- [Flags()] internal enum BlockStatus { None = 0, UnloadedBlock = 1, // Child block has not been loaded } //------------------------------------------------------------------- // // Connstructors // //---------------------------------------------------------------------- #region Ctors internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, ITextContainer childContainer) { Debug.Assert(childContainer != null); _aggregatedContainer = aggregatedContainer; _container = childContainer; } internal ChildDocumentBlock(DocumentSequenceTextContainer aggregatedContainer, DocumentReference docRef) { Debug.Assert(docRef != null); _aggregatedContainer = aggregatedContainer; _docRef = docRef; _SetStatus(BlockStatus.UnloadedBlock); } #endregion Ctors //-------------------------------------------------------------------- // // Internal Properties // //--------------------------------------------------------------------- #region Internal Methods // Insert a new node into this list. internal ChildDocumentBlock InsertNextBlock(ChildDocumentBlock newBlock) { Debug.Assert(newBlock != null); // Setup the new block correctly newBlock._nextBlock = this._nextBlock; newBlock._previousBlock = this; // Link old next block to the new block if (this._nextBlock != null) { this._nextBlock._previousBlock = newBlock; } // Link this block to new block this._nextBlock = newBlock; return newBlock; } #endregion Internal Methods //-------------------------------------------------------------------- // // Internal Properties // //--------------------------------------------------------------------- #region Internal Properties // The AggregatedContainer that holds the list of ChildDocumentBlock. internal DocumentSequenceTextContainer AggregatedContainer { get { return _aggregatedContainer; } } // Reference to the child TextContainer internal ITextContainer ChildContainer { get { _EnsureBlockLoaded(); return _container; } } // The highlight layer used to notify child TextContainer // about TextSelection highlight change. internal DocumentSequenceHighlightLayer ChildHighlightLayer { get { if (_highlightLayer == null) { _highlightLayer = new DocumentSequenceHighlightLayer(_aggregatedContainer); Debug.Assert(ChildContainer.Highlights.GetLayer(typeof(TextSelection)) == null); ChildContainer.Highlights.AddLayer(_highlightLayer); } return _highlightLayer; } } // Reference to the DocumentReference internal DocumentReference DocRef { get { return _docRef; } } // End TextPointer of the child container internal ITextPointer End { get { return ChildContainer.End; } } #if DEBUG // Get if this entry is non-head/tail block in the linked list internal bool IsInsideBlock { get { return (this._previousBlock != null && this._nextBlock != null); } } #endif // Get if this entry is Head of list internal bool IsHead { get { return (this._previousBlock == null); } } // Get if this entry is Tail of list internal bool IsTail { get { return (this._nextBlock == null); } } // Previous container entry in the link list internal ChildDocumentBlock PreviousBlock { get { return _previousBlock; } } // Next container entry in the link list internal ChildDocumentBlock NextBlock { get { return _nextBlock; } } #if DEBUG internal uint DebugId { get { return _debugId; } } #endif #endregion Internal Properties //------------------------------------------------------------------- // // Private Methods // //--------------------------------------------------------------------- #region Private Methods private void _EnsureBlockLoaded() { if (_HasStatus(BlockStatus.UnloadedBlock)) { _ClearStatus(BlockStatus.UnloadedBlock); DocumentsTrace.FixedDocumentSequence.TextOM.Trace("Loading TextContainer " + _docRef.ToString()); // Load the TextContainer IDocumentPaginatorSource idp = _docRef.GetDocument(false /*forceReload*/); IServiceProvider isp = idp as IServiceProvider; if (isp != null) { ITextContainer tc = isp.GetService(typeof(ITextContainer)) as ITextContainer; if (tc != null) { _container = tc; DocumentsTrace.FixedDocumentSequence.TextOM.Trace("Got ITextContainer"); } } if (_container == null) { _container = new NullTextContainer(); } } } private bool _HasStatus(BlockStatus flags) { return ((_status & flags) == flags); } private void _SetStatus(BlockStatus flags) { _status |= flags; } private void _ClearStatus(BlockStatus flags) { _status &= (~flags); } #endregion Private Methods //-------------------------------------------------------------------- // // Private Fields // //--------------------------------------------------------------------- #region Private Fields private readonly DocumentSequenceTextContainer _aggregatedContainer; private readonly DocumentReference _docRef; // Reference to the sub-document private ITextContainer _container; // Child TextContainer private DocumentSequenceHighlightLayer _highlightLayer; // Highlight layer used to notify child TextContainer highlight changes. private BlockStatus _status; // Status of this block, such as Loaded, etc. private ChildDocumentBlock _previousBlock; // Link to previous block private ChildDocumentBlock _nextBlock; // Link to next block #if DEBUG private uint _debugId = (_debugIdCounter++); private static uint _debugIdCounter = 0; #endif #endregion Private Fields } } // 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
- ParseChildrenAsPropertiesAttribute.cs
- SiblingIterators.cs
- PersonalizationProviderCollection.cs
- ServiceHttpModule.cs
- BufferModeSettings.cs
- StateMachineWorkflow.cs
- _TLSstream.cs
- RegistryPermission.cs
- StatusStrip.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- TypeExtension.cs
- ClonableStack.cs
- RangeBase.cs
- CommandField.cs
- Deflater.cs
- ApplicationInterop.cs
- CallbackValidator.cs
- updateconfighost.cs
- HostingEnvironmentWrapper.cs
- RuntimeConfig.cs
- SchemaHelper.cs
- HorizontalAlignConverter.cs
- TextServicesCompartmentEventSink.cs
- RowBinding.cs
- TraceInternal.cs
- storepermissionattribute.cs
- RecognizedAudio.cs
- ToolStripButton.cs
- AssemblyNameUtility.cs
- Hashtable.cs
- GraphicsContext.cs
- ScrollEventArgs.cs
- SspiHelper.cs
- DBConnection.cs
- NumericPagerField.cs
- mactripleDES.cs
- AdornerDecorator.cs
- BindingBase.cs
- SequentialWorkflowHeaderFooter.cs
- ExpressionPrinter.cs
- BrowserCapabilitiesCodeGenerator.cs
- ImageBrush.cs
- ManifestBasedResourceGroveler.cs
- ContentWrapperAttribute.cs
- _ContextAwareResult.cs
- CriticalExceptions.cs
- RedirectionProxy.cs
- Select.cs
- ContractMethodParameterInfo.cs
- DataGrid.cs
- ConfigurationLocation.cs
- IgnoreFlushAndCloseStream.cs
- OleDragDropHandler.cs
- ServiceKnownTypeAttribute.cs
- WorkflowViewManager.cs
- DataGridViewColumnHeaderCell.cs
- SwitchExpression.cs
- ContentWrapperAttribute.cs
- BooleanFunctions.cs
- WinEventTracker.cs
- NewItemsContextMenuStrip.cs
- SID.cs
- Vector3dCollection.cs
- DataGridComponentEditor.cs
- CacheSection.cs
- FormViewInsertedEventArgs.cs
- XmlNode.cs
- EntityDataSourceUtil.cs
- SerializationEventsCache.cs
- XamlParser.cs
- QilLoop.cs
- DataControlFieldCollection.cs
- NegotiationTokenAuthenticatorStateCache.cs
- StylusButtonEventArgs.cs
- ClaimTypeElement.cs
- Pair.cs
- UnmanagedMemoryStream.cs
- RequestSecurityTokenResponse.cs
- _LoggingObject.cs
- LinkDescriptor.cs
- SubpageParagraph.cs
- TextFormatter.cs
- SecurityElement.cs
- SqlDataSourceSelectingEventArgs.cs
- XmlMapping.cs
- XmlConvert.cs
- Descriptor.cs
- QueryAccessibilityHelpEvent.cs
- ToolTipAutomationPeer.cs
- ServiceMetadataPublishingElement.cs
- AutomationPropertyInfo.cs
- ConstNode.cs
- SoapEnumAttribute.cs
- RtfToken.cs
- StyleCollection.cs
- WsiProfilesElementCollection.cs
- ProviderIncompatibleException.cs
- UserValidatedEventArgs.cs
- XamlReaderConstants.cs
- LinkedResource.cs