Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Documents / TextSegment.cs / 1305600 / 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
- ToolboxDataAttribute.cs
- RightsManagementEncryptedStream.cs
- TextRunProperties.cs
- TargetConverter.cs
- Math.cs
- LinkTarget.cs
- UriTemplatePathPartiallyEquivalentSet.cs
- FontSizeConverter.cs
- SafeTokenHandle.cs
- ImageMap.cs
- SoapReflectionImporter.cs
- QilList.cs
- PeerApplication.cs
- TaiwanLunisolarCalendar.cs
- UnsafeNativeMethodsCLR.cs
- WindowsFormsSectionHandler.cs
- ListBoxChrome.cs
- WindowsSlider.cs
- Range.cs
- OdbcConnectionString.cs
- ObsoleteAttribute.cs
- CollaborationHelperFunctions.cs
- PageAsyncTask.cs
- ListBindingConverter.cs
- BinaryUtilClasses.cs
- CryptoStream.cs
- GcHandle.cs
- TextEditorDragDrop.cs
- Quaternion.cs
- XmlSerializer.cs
- FixedSOMGroup.cs
- AuthenticationManager.cs
- AQNBuilder.cs
- AudienceUriMode.cs
- ResourceSet.cs
- Calendar.cs
- HttpConfigurationContext.cs
- TemplateBindingExpression.cs
- SystemDropShadowChrome.cs
- RepeatBehavior.cs
- CultureMapper.cs
- ToolStripDropDownMenu.cs
- Point3DAnimationUsingKeyFrames.cs
- Function.cs
- StateRuntime.cs
- ExpandoObject.cs
- ConfigurationConverterBase.cs
- XmlCodeExporter.cs
- GraphicsPath.cs
- EntityDataSourceUtil.cs
- WeakEventManager.cs
- InteropExecutor.cs
- SchemaTableColumn.cs
- Label.cs
- ColorBlend.cs
- TransactionBridge.cs
- OdbcConnectionPoolProviderInfo.cs
- Overlapped.cs
- CacheManager.cs
- LinkButton.cs
- HighlightVisual.cs
- XmlAttributeOverrides.cs
- ListViewEditEventArgs.cs
- BamlRecordWriter.cs
- FontResourceCache.cs
- TypeTypeConverter.cs
- _SecureChannel.cs
- DocumentGridPage.cs
- RenderingEventArgs.cs
- DateRangeEvent.cs
- CommentAction.cs
- EntityCommand.cs
- recordstatefactory.cs
- WebPartAddingEventArgs.cs
- PartitionerStatic.cs
- TextCollapsingProperties.cs
- Expression.cs
- Inflater.cs
- QilReplaceVisitor.cs
- SmtpReplyReader.cs
- Authorization.cs
- KnownTypesHelper.cs
- InstanceData.cs
- ComponentEvent.cs
- SaveFileDialog.cs
- ConfigurationLocation.cs
- ThemeDictionaryExtension.cs
- XmlSignatureManifest.cs
- UncommonField.cs
- TabPage.cs
- querybuilder.cs
- ScanQueryOperator.cs
- DesignerActionMethodItem.cs
- Empty.cs
- ControlDesignerState.cs
- Viewport3DVisual.cs
- DoubleLinkListEnumerator.cs
- DeflateEmulationStream.cs
- DataGridViewCellStyleChangedEventArgs.cs
- MetadataCollection.cs