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 / 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
- FormatterServices.cs
- CodeMethodReturnStatement.cs
- NavigationPropertyEmitter.cs
- TableStyle.cs
- ActivityIdHeader.cs
- Timer.cs
- RsaKeyGen.cs
- AspCompat.cs
- SqlSupersetValidator.cs
- SQLDoubleStorage.cs
- ConfigurationErrorsException.cs
- HeaderUtility.cs
- MimeMultiPart.cs
- HighlightVisual.cs
- ManagementBaseObject.cs
- AttributeUsageAttribute.cs
- WpfMemberInvoker.cs
- xml.cs
- CommandDevice.cs
- DynamicPropertyHolder.cs
- ContextProperty.cs
- SqlCachedBuffer.cs
- assemblycache.cs
- Types.cs
- NativeMethods.cs
- ComponentResourceKey.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- MetafileHeaderWmf.cs
- TagNameToTypeMapper.cs
- BlurEffect.cs
- MatrixIndependentAnimationStorage.cs
- DesignTimeHTMLTextWriter.cs
- DynamicDiscoveryDocument.cs
- _ProxyChain.cs
- TraceUtils.cs
- ScopelessEnumAttribute.cs
- KeyEvent.cs
- MethodMessage.cs
- TypeToStringValueConverter.cs
- PersonalizationProviderHelper.cs
- ScrollProviderWrapper.cs
- Logging.cs
- InvalidOleVariantTypeException.cs
- Timer.cs
- DecimalAnimationUsingKeyFrames.cs
- ScrollData.cs
- DataGridAddNewRow.cs
- InfocardExtendedInformationCollection.cs
- NodeCounter.cs
- ComplexLine.cs
- MultiTrigger.cs
- AssociationEndMember.cs
- DeadCharTextComposition.cs
- XmlTextReader.cs
- TreeNodeBindingCollection.cs
- XPathArrayIterator.cs
- UIElement3D.cs
- Identifier.cs
- WebServiceHost.cs
- ResourceDescriptionAttribute.cs
- UrlAuthFailedErrorFormatter.cs
- StatusBarPanel.cs
- UncommonField.cs
- DrawingCollection.cs
- XPathDocumentNavigator.cs
- FixedLineResult.cs
- NetNamedPipeSecurityMode.cs
- UserControlParser.cs
- ContractSearchPattern.cs
- DataListItemCollection.cs
- CTreeGenerator.cs
- SettingsProviderCollection.cs
- ProgressBar.cs
- KeyTime.cs
- SqlNotificationEventArgs.cs
- RelationshipDetailsRow.cs
- WSFederationHttpBindingElement.cs
- HTTPRemotingHandler.cs
- PolyLineSegment.cs
- WebControlParameterProxy.cs
- PnrpPermission.cs
- _BasicClient.cs
- ToolStripButton.cs
- ChtmlTextWriter.cs
- BitStack.cs
- DashStyle.cs
- ObjectContext.cs
- XmlRawWriter.cs
- Binding.cs
- StorageConditionPropertyMapping.cs
- JavascriptXmlWriterWrapper.cs
- IdentityModelDictionary.cs
- MessageSecurityOverHttp.cs
- SortedList.cs
- _HeaderInfo.cs
- EmptyCollection.cs
- HorizontalAlignConverter.cs
- DataViewSettingCollection.cs
- RowSpanVector.cs
- EditingCommands.cs