Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / textformatting / CharacterHit.cs / 1305600 / 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
- HttpListenerRequest.cs
- DiscoveryMessageSequence11.cs
- SettingsPropertyIsReadOnlyException.cs
- Content.cs
- FixedSOMTableRow.cs
- InkCanvasSelection.cs
- ScriptingSectionGroup.cs
- FileStream.cs
- NativeObjectSecurity.cs
- ListViewGroupConverter.cs
- DataControlField.cs
- ObjectContext.cs
- OrderPreservingSpoolingTask.cs
- RoutedEventConverter.cs
- SimpleMailWebEventProvider.cs
- SendDesigner.xaml.cs
- ConditionBrowserDialog.cs
- OracleInfoMessageEventArgs.cs
- TextDecorationCollectionConverter.cs
- FakeModelItemImpl.cs
- SqlXml.cs
- SourceLocationProvider.cs
- wmiprovider.cs
- CfgSemanticTag.cs
- CfgParser.cs
- RenderCapability.cs
- DLinqColumnProvider.cs
- PageCache.cs
- Brush.cs
- DBAsyncResult.cs
- WebUtil.cs
- EventSetter.cs
- SqlDataRecord.cs
- DelayLoadType.cs
- ActivityStatusChangeEventArgs.cs
- DBDataPermissionAttribute.cs
- EntityCollectionChangedParams.cs
- SoapClientMessage.cs
- EtwTrace.cs
- SuppressMessageAttribute.cs
- BinHexDecoder.cs
- XmlBinaryReaderSession.cs
- Int32Animation.cs
- HtmlInputFile.cs
- RuntimeWrappedException.cs
- WebRequestModuleElementCollection.cs
- Calendar.cs
- CommandHelper.cs
- NGCPageContentSerializerAsync.cs
- DocumentViewerHelper.cs
- ParserContext.cs
- NullableDecimalSumAggregationOperator.cs
- Int32CollectionConverter.cs
- ObjectContext.cs
- ButtonAutomationPeer.cs
- SqlConnectionPoolGroupProviderInfo.cs
- EntityStoreSchemaGenerator.cs
- DictionarySectionHandler.cs
- Stack.cs
- HttpListenerPrefixCollection.cs
- PackageProperties.cs
- MouseButton.cs
- DataServiceHost.cs
- SerializableTypeCodeDomSerializer.cs
- SqlConnectionPoolGroupProviderInfo.cs
- DbProviderConfigurationHandler.cs
- GeneralTransformGroup.cs
- SoapHeaderAttribute.cs
- ResourceDefaultValueAttribute.cs
- ListComponentEditor.cs
- MessageQueueException.cs
- handlecollector.cs
- LinkUtilities.cs
- MdiWindowListStrip.cs
- ListBindingHelper.cs
- EventLogger.cs
- FixedPageStructure.cs
- LocalizationParserHooks.cs
- DataGridRowEventArgs.cs
- SqlComparer.cs
- BaseParagraph.cs
- RoleManagerEventArgs.cs
- BrowserDefinitionCollection.cs
- Validator.cs
- TypedRowHandler.cs
- TableCell.cs
- TransactionalPackage.cs
- WebResourceAttribute.cs
- RelationshipConverter.cs
- Timer.cs
- ProxyWebPart.cs
- IndentedWriter.cs
- formatter.cs
- TypeUsageBuilder.cs
- AssemblyUtil.cs
- ResourceExpressionBuilder.cs
- ColorAnimation.cs
- SystemIcmpV4Statistics.cs
- SQLByte.cs
- Ipv6Element.cs