Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / 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. //---------------------------------------------------------------------------- // // 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
- PathSegmentCollection.cs
- RecipientServiceModelSecurityTokenRequirement.cs
- FixedSOMTextRun.cs
- FileSystemEventArgs.cs
- KnownColorTable.cs
- OutputCacheModule.cs
- SignedXml.cs
- DataGridViewCellStyleChangedEventArgs.cs
- MemberPath.cs
- HostDesigntimeLicenseContext.cs
- LineServicesCallbacks.cs
- AssociationSet.cs
- RubberbandSelector.cs
- Part.cs
- MatchAttribute.cs
- WS2007HttpBinding.cs
- XmlDocumentType.cs
- BaseParaClient.cs
- SelectionRange.cs
- Hash.cs
- SmtpDigestAuthenticationModule.cs
- DispatchWrapper.cs
- Utils.cs
- DrawingContextWalker.cs
- ApplicationSecurityManager.cs
- AdornerHitTestResult.cs
- ReliableChannelBinder.cs
- SqlException.cs
- BlurBitmapEffect.cs
- UnknownBitmapDecoder.cs
- SpotLight.cs
- TypeName.cs
- AuthenticateEventArgs.cs
- ContextMenu.cs
- MappedMetaModel.cs
- GuidTagList.cs
- SingleStorage.cs
- CircleHotSpot.cs
- BindToObject.cs
- TraceLevelStore.cs
- PreservationFileWriter.cs
- HttpRequestCacheValidator.cs
- CallbackValidator.cs
- WebPartCollection.cs
- PermissionToken.cs
- Memoizer.cs
- TextMessageEncoder.cs
- ItemCheckedEvent.cs
- UnsafeNativeMethods.cs
- CodeIdentifiers.cs
- TableRow.cs
- ImpersonationContext.cs
- ApplicationFileCodeDomTreeGenerator.cs
- SQLSingle.cs
- SafeNativeMethods.cs
- ChannelServices.cs
- ILGenerator.cs
- elementinformation.cs
- TypographyProperties.cs
- PointHitTestParameters.cs
- AsymmetricKeyExchangeFormatter.cs
- CheckPair.cs
- TypefaceMetricsCache.cs
- AttributeCollection.cs
- WindowsRebar.cs
- OracleBFile.cs
- QuadraticBezierSegment.cs
- ProfilePropertyNameValidator.cs
- SafeEventLogReadHandle.cs
- FieldNameLookup.cs
- RectangleConverter.cs
- UnsettableComboBox.cs
- ScrollEventArgs.cs
- ChildrenQuery.cs
- Vector3DKeyFrameCollection.cs
- TextEditorSelection.cs
- CapacityStreamGeometryContext.cs
- SmtpMail.cs
- DesignerActionMethodItem.cs
- ManagementScope.cs
- ShaderEffect.cs
- ExportOptions.cs
- ProjectionCamera.cs
- TextServicesProperty.cs
- CompModSwitches.cs
- DataBinding.cs
- HtmlSelect.cs
- WebPartDisplayMode.cs
- XmlAttributeOverrides.cs
- TraceListeners.cs
- HttpListener.cs
- FileLogRecordEnumerator.cs
- ViewStateException.cs
- ScriptBehaviorDescriptor.cs
- ExceptionValidationRule.cs
- FactoryGenerator.cs
- SpecialNameAttribute.cs
- X509CertificateValidator.cs
- oledbmetadatacollectionnames.cs
- QilStrConcat.cs