Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / textformatting / CharacterHit.cs / 1 / CharacterHit.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // Description: The CharacterHit structure represents information about a character hit // within a glyph run - the index of the first character that got hit and the information // about leading or trailing edge. // // See spec at http://team/sites/Avalon/Specs/Glyph%20Run%20hit%20testing%20and%20caret%20placement%20API.htm#CharacterHit // // // History: // 11/30/2004 : mleonov - Created // //--------------------------------------------------------------------------- #region Using directives using System; #endregion namespace System.Windows.Media.TextFormatting { ////// The CharacterHit structure represents information about a character hit within a glyph run /// - the index of the first character that got hit and the information about leading or trailing edge. /// public struct CharacterHit : IEquatable{ /// /// Constructs a new CharacterHit structure. /// /// Index of the first character that got hit. /// In case of leading edge this value is 0. /// In case of trailing edge this value is the number of codepoints until the next valid caret position. public CharacterHit(int firstCharacterIndex, int trailingLength) { _firstCharacterIndex = firstCharacterIndex; _trailingLength = trailingLength; } ////// Index of the first character that got hit. /// public int FirstCharacterIndex { get { return _firstCharacterIndex; } } ////// In case of leading edge this value is 0. /// In case of trailing edge this value is the number of codepoints until the next valid caret position. /// public int TrailingLength { get { return _trailingLength; } } ////// Checks whether two character hit objects are equal. /// /// First object to compare. /// Second object to compare. ///Returns true when the values of FirstCharacterIndex and TrailingLength are equal for both objects, /// and false otherwise. public static bool operator==(CharacterHit left, CharacterHit right) { return left._firstCharacterIndex == right._firstCharacterIndex && left._trailingLength == right._trailingLength; } ////// Checks whether two character hit objects are not equal. /// /// First object to compare. /// Second object to compare. ///Returns false when the values of FirstCharacterIndex and TrailingLength are equal for both objects, /// and true otherwise. public static bool operator!=(CharacterHit left, CharacterHit right) { return !(left == right); } ////// Checks whether an object is equal to another character hit object. /// /// CharacterHit object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public bool Equals(CharacterHit obj) { return this == obj; } ////// Checks whether an object is equal to another character hit object. /// /// CharacterHit object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public override bool Equals(object obj) { if (!(obj is CharacterHit)) return false; return this == (CharacterHit)obj; } ////// Compute hash code for this object. /// ///A 32-bit signed integer hash code. public override int GetHashCode() { return _firstCharacterIndex.GetHashCode() ^ _trailingLength.GetHashCode(); } private int _firstCharacterIndex; private int _trailingLength; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // Description: The CharacterHit structure represents information about a character hit // within a glyph run - the index of the first character that got hit and the information // about leading or trailing edge. // // See spec at http://team/sites/Avalon/Specs/Glyph%20Run%20hit%20testing%20and%20caret%20placement%20API.htm#CharacterHit // // // History: // 11/30/2004 : mleonov - Created // //--------------------------------------------------------------------------- #region Using directives using System; #endregion namespace System.Windows.Media.TextFormatting { ////// The CharacterHit structure represents information about a character hit within a glyph run /// - the index of the first character that got hit and the information about leading or trailing edge. /// public struct CharacterHit : IEquatable{ /// /// Constructs a new CharacterHit structure. /// /// Index of the first character that got hit. /// In case of leading edge this value is 0. /// In case of trailing edge this value is the number of codepoints until the next valid caret position. public CharacterHit(int firstCharacterIndex, int trailingLength) { _firstCharacterIndex = firstCharacterIndex; _trailingLength = trailingLength; } ////// Index of the first character that got hit. /// public int FirstCharacterIndex { get { return _firstCharacterIndex; } } ////// In case of leading edge this value is 0. /// In case of trailing edge this value is the number of codepoints until the next valid caret position. /// public int TrailingLength { get { return _trailingLength; } } ////// Checks whether two character hit objects are equal. /// /// First object to compare. /// Second object to compare. ///Returns true when the values of FirstCharacterIndex and TrailingLength are equal for both objects, /// and false otherwise. public static bool operator==(CharacterHit left, CharacterHit right) { return left._firstCharacterIndex == right._firstCharacterIndex && left._trailingLength == right._trailingLength; } ////// Checks whether two character hit objects are not equal. /// /// First object to compare. /// Second object to compare. ///Returns false when the values of FirstCharacterIndex and TrailingLength are equal for both objects, /// and true otherwise. public static bool operator!=(CharacterHit left, CharacterHit right) { return !(left == right); } ////// Checks whether an object is equal to another character hit object. /// /// CharacterHit object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public bool Equals(CharacterHit obj) { return this == obj; } ////// Checks whether an object is equal to another character hit object. /// /// CharacterHit object to compare with. ///Returns true when the object is equal to the input object, /// and false otherwise. public override bool Equals(object obj) { if (!(obj is CharacterHit)) return false; return this == (CharacterHit)obj; } ////// Compute hash code for this object. /// ///A 32-bit signed integer hash code. public override int GetHashCode() { return _firstCharacterIndex.GetHashCode() ^ _trailingLength.GetHashCode(); } private int _firstCharacterIndex; private int _trailingLength; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PenContext.cs
- WebBrowser.cs
- DesignColumn.cs
- FieldBuilder.cs
- GridItemProviderWrapper.cs
- XmlToDatasetMap.cs
- ServiceMetadataContractBehavior.cs
- AnnotationService.cs
- JavaScriptObjectDeserializer.cs
- MultiBinding.cs
- CompatibleIComparer.cs
- NavigationWindow.cs
- UnsafeNativeMethodsPenimc.cs
- BidOverLoads.cs
- UpdatableWrapper.cs
- AuthorizationRule.cs
- ValidationHelpers.cs
- Double.cs
- TraversalRequest.cs
- _Rfc2616CacheValidators.cs
- DataTableReader.cs
- TdsParameterSetter.cs
- HttpEncoderUtility.cs
- XsdCachingReader.cs
- BodyGlyph.cs
- oledbmetadatacolumnnames.cs
- ManualResetEventSlim.cs
- ListBindingConverter.cs
- CodeAttributeDeclaration.cs
- InstanceCompleteException.cs
- MatrixTransform3D.cs
- Logging.cs
- CodeTypeParameter.cs
- ToolStripItemDesigner.cs
- EndPoint.cs
- ThreadExceptionEvent.cs
- SessionStateUtil.cs
- HtmlElementCollection.cs
- SimplePropertyEntry.cs
- MergeFailedEvent.cs
- Rectangle.cs
- NameSpaceExtractor.cs
- Interlocked.cs
- ConsoleKeyInfo.cs
- PauseStoryboard.cs
- SmiEventSink.cs
- TileBrush.cs
- StylusCollection.cs
- LinqDataSourceValidationException.cs
- FieldTemplateFactory.cs
- HotSpotCollection.cs
- ScaleTransform3D.cs
- RepeatBehavior.cs
- CaseInsensitiveComparer.cs
- HttpGetServerProtocol.cs
- ClientEventManager.cs
- GC.cs
- ElementNotEnabledException.cs
- ConfigXmlCDataSection.cs
- BufferAllocator.cs
- CompModSwitches.cs
- ClaimComparer.cs
- InternalsVisibleToAttribute.cs
- MultipleViewProviderWrapper.cs
- TabControlEvent.cs
- DataList.cs
- XmlSchemaImporter.cs
- RequestCache.cs
- XmlSchemaAttribute.cs
- DesignTimeTemplateParser.cs
- HyperLinkField.cs
- UIElementCollection.cs
- KeyValuePair.cs
- SqlCacheDependencySection.cs
- LogEntryDeserializer.cs
- ZipIOCentralDirectoryFileHeader.cs
- RightNameExpirationInfoPair.cs
- SByteConverter.cs
- Connector.cs
- DataBoundControlHelper.cs
- VisualBrush.cs
- FactoryRecord.cs
- Parsers.cs
- EmptyElement.cs
- MouseActionConverter.cs
- SqlIdentifier.cs
- InvalidOleVariantTypeException.cs
- FileFormatException.cs
- EditingCommands.cs
- PageAsyncTaskManager.cs
- CustomAttribute.cs
- HtmlToClrEventProxy.cs
- GPPOINT.cs
- PropertyMetadata.cs
- ObjectDataSourceSelectingEventArgs.cs
- SmiRequestExecutor.cs
- CommandHelpers.cs
- ErrorEventArgs.cs
- AnalyzedTree.cs
- SafeRegistryHandle.cs