Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ParallelEnumerable.cs
- FindCriteriaElement.cs
- ScopelessEnumAttribute.cs
- SettingsProviderCollection.cs
- MsmqReceiveParameters.cs
- FixedDocumentSequencePaginator.cs
- WorkflowHostingResponseContext.cs
- DataRowCollection.cs
- RemoteArgument.cs
- ReferenceAssemblyAttribute.cs
- DataTableReaderListener.cs
- TdsParserStateObject.cs
- StructuredProperty.cs
- MsmqMessageProperty.cs
- CompositeActivityTypeDescriptorProvider.cs
- safePerfProviderHandle.cs
- Assembly.cs
- FixedTextPointer.cs
- FileStream.cs
- ResumeStoryboard.cs
- MatrixUtil.cs
- ComEventsInfo.cs
- DbParameterCollection.cs
- TrackBar.cs
- AppDomainProtocolHandler.cs
- CategoryGridEntry.cs
- ConvertEvent.cs
- HttpWebRequest.cs
- EllipseGeometry.cs
- NativeBuffer.cs
- HtmlLink.cs
- _FtpDataStream.cs
- TemplateComponentConnector.cs
- SqlProvider.cs
- SafeBuffer.cs
- HwndHost.cs
- ControlPaint.cs
- CmsUtils.cs
- ColumnWidthChangingEvent.cs
- WindowsFormsHelpers.cs
- CompleteWizardStep.cs
- WebPartAuthorizationEventArgs.cs
- SerializationFieldInfo.cs
- TabControl.cs
- BamlRecords.cs
- DataTableMappingCollection.cs
- CodeDirectoryCompiler.cs
- TranslateTransform3D.cs
- ValuePatternIdentifiers.cs
- XmlNode.cs
- sitestring.cs
- EventListener.cs
- ParsedRoute.cs
- XmlSchema.cs
- GroupQuery.cs
- FaultFormatter.cs
- TreeNode.cs
- MimeBasePart.cs
- NameTable.cs
- EntityDataSourceDesigner.cs
- CopyNodeSetAction.cs
- AttributeEmitter.cs
- ExcludeFromCodeCoverageAttribute.cs
- RenderingEventArgs.cs
- ActivationWorker.cs
- OleStrCAMarshaler.cs
- XmlBinaryReaderSession.cs
- XamlBuildTaskServices.cs
- SwitchLevelAttribute.cs
- LinkLabel.cs
- BindStream.cs
- ColorTranslator.cs
- ConfigXmlText.cs
- AppModelKnownContentFactory.cs
- PixelShader.cs
- BitStack.cs
- EventLogTraceListener.cs
- TypeReference.cs
- ListViewGroup.cs
- BmpBitmapDecoder.cs
- MulticastNotSupportedException.cs
- IsolatedStorageSecurityState.cs
- StyleBamlTreeBuilder.cs
- PropertyEntry.cs
- LinqDataSourceValidationException.cs
- FontEmbeddingManager.cs
- _BaseOverlappedAsyncResult.cs
- SplitContainerDesigner.cs
- ResXDataNode.cs
- DesignerView.xaml.cs
- ConfigXmlComment.cs
- EntityTypeBase.cs
- AddInController.cs
- EmptyReadOnlyDictionaryInternal.cs
- FormsAuthenticationUserCollection.cs
- QilXmlReader.cs
- IndexedString.cs
- FixUpCollection.cs
- SystemFonts.cs
- TypedDatasetGenerator.cs