Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / System / Windows / Documents / TextSegment.cs / 1 / TextSegment.cs
//---------------------------------------------------------------------------- // // File: TextSegment.cs // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: A pair of TextPositions used to denote a run of TextContainer content. // //--------------------------------------------------------------------------- namespace System.Windows.Documents { using MS.Internal; using System.Collections; ////// A pair of TextPositions used to denote a run of TextContainer content. /// // internal struct TextSegment { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Constructor. /// /// /// Position preceeding the TextSegment's content. /// /// /// Position following the TextSegment's content. /// ////// If startPosition or endPosition are TextNavigators (derived from /// TextPointer), the TextSegment constructor will store new TextPointer /// instances internally. The values returned by the Start and End /// properties are always immutable TextPositions. /// internal TextSegment(ITextPointer startPosition, ITextPointer endPosition) : this(startPosition, endPosition, false) { } ////// Constructor. /// /// /// Position preceeding the TextSegment's content. /// /// /// Position following the TextSegment's content. /// /// /// Whether preserves LogicalDirection of start and end positions. /// internal TextSegment(ITextPointer startPosition, ITextPointer endPosition, bool preserveLogicalDirection) { ValidationHelper.VerifyPositionPair(startPosition, endPosition); if (startPosition.CompareTo(endPosition) == 0) { // To preserve segment emptiness // we use the same instance of a pointer // for both segment ends. _start = startPosition.GetFrozenPointer(startPosition.LogicalDirection); _end = _start; } else { Invariant.Assert(startPosition.CompareTo(endPosition) < 0); _start = startPosition.GetFrozenPointer(preserveLogicalDirection ? startPosition.LogicalDirection : LogicalDirection.Backward); _end = endPosition.GetFrozenPointer(preserveLogicalDirection ? endPosition.LogicalDirection : LogicalDirection.Forward); } } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods ////// returns true if the segment contains a given position /// // internal bool Contains(ITextPointer position) { return (!this.IsNull && this._start.CompareTo(position) <= 0 && position.CompareTo(this._end) <= 0); } #endregion Internal Methods //------------------------------------------------------ // // Internal Properties // //------------------------------------------------------ #region Internal Properties ////// Position preceeding the TextSegment's content. /// internal ITextPointer Start { get { return _start; } } ////// Position following the TextSegment's content. /// internal ITextPointer End { get { return _end; } } internal bool IsNull { get { return _start == null || _end == null; } } #endregion Internal Properties ////// The "TextSegment.Null" value. /// ////// TextSegtemt.Null is used in contexts where text segment is missing. /// internal static readonly TextSegment Null = new TextSegment(); //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields // Position preceeding the TextSegment's content. private readonly ITextPointer _start; // Position following the TextSegment's content. private readonly ITextPointer _end; #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
- IOThreadScheduler.cs
- CFStream.cs
- Wizard.cs
- BlockUIContainer.cs
- XmlReaderDelegator.cs
- CurrentChangingEventArgs.cs
- ThreadPool.cs
- NullableLongAverageAggregationOperator.cs
- XmlSchemaType.cs
- BamlBinaryReader.cs
- BamlTreeUpdater.cs
- RotationValidation.cs
- SmtpMail.cs
- CompiledQueryCacheEntry.cs
- StreamWriter.cs
- EdmMember.cs
- Application.cs
- InputReportEventArgs.cs
- CloudCollection.cs
- EditingCommands.cs
- Script.cs
- TableCellsCollectionEditor.cs
- TraceUtility.cs
- ConfigurationFileMap.cs
- SqlDataRecord.cs
- UnmanagedBitmapWrapper.cs
- DataGridViewDataConnection.cs
- TiffBitmapDecoder.cs
- MessagePropertyFilter.cs
- SortedList.cs
- StorageMappingFragment.cs
- SplayTreeNode.cs
- TextCollapsingProperties.cs
- basevalidator.cs
- DNS.cs
- NamedPipeConnectionPool.cs
- HtmlString.cs
- HwndHostAutomationPeer.cs
- DoubleAnimationUsingKeyFrames.cs
- AddingNewEventArgs.cs
- SchemaSetCompiler.cs
- RadioButtonStandardAdapter.cs
- LabelAutomationPeer.cs
- ListItemCollection.cs
- FormatConvertedBitmap.cs
- DriveInfo.cs
- TransformerInfo.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- OLEDB_Enum.cs
- AutomationPropertyChangedEventArgs.cs
- DataGridViewCellStyleChangedEventArgs.cs
- TextCollapsingProperties.cs
- AggregateNode.cs
- NavigationProperty.cs
- VisualTreeUtils.cs
- MenuItemCollection.cs
- _BaseOverlappedAsyncResult.cs
- ScopelessEnumAttribute.cs
- UriParserTemplates.cs
- BasePattern.cs
- WasAdminWrapper.cs
- XPathAncestorIterator.cs
- HierarchicalDataSourceIDConverter.cs
- TemplateKeyConverter.cs
- DataGridViewCellStateChangedEventArgs.cs
- EventHandlersStore.cs
- CompoundFileStorageReference.cs
- EventMap.cs
- DataStreams.cs
- HtmlInputText.cs
- ImportContext.cs
- ByteAnimationBase.cs
- DataRelationCollection.cs
- X509Certificate2.cs
- ReadOnlyCollection.cs
- EtwProvider.cs
- ValidationManager.cs
- XmlRawWriterWrapper.cs
- LocatorPart.cs
- WebPartsPersonalizationAuthorization.cs
- StateValidator.cs
- ListViewItemMouseHoverEvent.cs
- SimpleType.cs
- Pts.cs
- MemberPath.cs
- AttachedPropertyMethodSelector.cs
- PrintPreviewDialog.cs
- DetailsViewModeEventArgs.cs
- ExpressionEditorAttribute.cs
- ListBox.cs
- IgnoreSectionHandler.cs
- CultureTableRecord.cs
- OdbcTransaction.cs
- InternalSafeNativeMethods.cs
- GridViewHeaderRowPresenter.cs
- TreeNodeCollection.cs
- LinqDataSourceHelper.cs
- CodeBlockBuilder.cs
- ObjectIDGenerator.cs
- ApplicationInfo.cs