Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / MS / Internal / TextFormatting / ThousandthOfEmRealPoints.cs / 1305600 / ThousandthOfEmRealPoints.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: ThousandthOfEmRealPoints class
//
// History:
// 1/13/2005: Garyyang Created the file
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Windows;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace MS.Internal.TextFormatting
{
///
/// This is a fixed-size implementation of IList<Point>. It is aimed to reduce the double values storage
/// while providing enough precision for glyph run operations. Current usage pattern suggests that there is no
/// need to support resizing functionality (i.e. Add(), Insert(), Remove(), RemoveAt()).
///
/// For each point being stored, it will store the X and Y coordinates of the point into two seperate ThousandthOfEmRealDoubles,
/// which scales double to 16-bit integer if possible.
///
///
internal sealed class ThousandthOfEmRealPoints : IList
{
//----------------------------------
// Constructor
//----------------------------------
internal ThousandthOfEmRealPoints(
double emSize,
int capacity
)
{
Debug.Assert(capacity >= 0);
InitArrays(emSize, capacity);
}
internal ThousandthOfEmRealPoints(
double emSize,
IList pointValues
)
{
Debug.Assert(pointValues != null);
InitArrays(emSize, pointValues.Count);
// do the setting
for (int i = 0; i < Count; i++)
{
_xArray[i] = pointValues[i].X;
_yArray[i] = pointValues[i].Y;
}
}
//-------------------------------------
// Internal properties
//-------------------------------------
public int Count
{
get
{
return _xArray.Count;
}
}
public bool IsReadOnly
{
get { return false; }
}
public Point this[int index]
{
get
{
// underlying array does boundary check
return new Point(_xArray[index], _yArray[index]);
}
set
{
// underlying array does boundary check
_xArray[index] = value.X;
_yArray[index] = value.Y;
}
}
//------------------------------------
// internal methods
//------------------------------------
public int IndexOf(Point item)
{
// linear search
for (int i = 0; i < Count; i++)
{
if (_xArray[i] == item.X && _yArray[i] == item.Y)
{
return i;
}
}
return -1;
}
public void Clear()
{
_xArray.Clear();
_yArray.Clear();
}
public bool Contains(Point item)
{
return IndexOf(item) >= 0;
}
public void CopyTo(Point[] array, int arrayIndex)
{
// parameter validations
if (array == null)
{
throw new ArgumentNullException("array");
}
if (array.Rank != 1)
{
throw new ArgumentException(
SR.Get(SRID.Collection_CopyTo_ArrayCannotBeMultidimensional),
"array");
}
if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
if (arrayIndex >= array.Length)
{
throw new ArgumentException(
SR.Get(
SRID.Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength,
"arrayIndex",
"array"),
"arrayIndex");
}
if ((array.Length - Count - arrayIndex) < 0)
{
throw new ArgumentException(
SR.Get(
SRID.Collection_CopyTo_NumberOfElementsExceedsArrayLength,
"arrayIndex",
"array"));
}
// do the copying here
for (int i = 0; i < Count; i++)
{
array[arrayIndex + i] = this[i];
}
}
public IEnumerator GetEnumerator()
{
for (int i = 0; i < Count; i++)
{
yield return this[i];
}
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return ((IEnumerable)this).GetEnumerator();
}
public void Add(Point value)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
public void Insert(int index, Point item)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
public bool Remove(Point item)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
public void RemoveAt(int index)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
//---------------------------------------------
// Private methods
//---------------------------------------------
private void InitArrays(double emSize, int capacity)
{
_xArray = new ThousandthOfEmRealDoubles(emSize, capacity);
_yArray = new ThousandthOfEmRealDoubles(emSize, capacity);
}
//----------------------------------------
// Private members
//----------------------------------------
private ThousandthOfEmRealDoubles _xArray; // scaled double array for X coordinates
private ThousandthOfEmRealDoubles _yArray; // scaled double array for Y coordinates
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: ThousandthOfEmRealPoints class
//
// History:
// 1/13/2005: Garyyang Created the file
//
//---------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Windows;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace MS.Internal.TextFormatting
{
///
/// This is a fixed-size implementation of IList<Point>. It is aimed to reduce the double values storage
/// while providing enough precision for glyph run operations. Current usage pattern suggests that there is no
/// need to support resizing functionality (i.e. Add(), Insert(), Remove(), RemoveAt()).
///
/// For each point being stored, it will store the X and Y coordinates of the point into two seperate ThousandthOfEmRealDoubles,
/// which scales double to 16-bit integer if possible.
///
///
internal sealed class ThousandthOfEmRealPoints : IList
{
//----------------------------------
// Constructor
//----------------------------------
internal ThousandthOfEmRealPoints(
double emSize,
int capacity
)
{
Debug.Assert(capacity >= 0);
InitArrays(emSize, capacity);
}
internal ThousandthOfEmRealPoints(
double emSize,
IList pointValues
)
{
Debug.Assert(pointValues != null);
InitArrays(emSize, pointValues.Count);
// do the setting
for (int i = 0; i < Count; i++)
{
_xArray[i] = pointValues[i].X;
_yArray[i] = pointValues[i].Y;
}
}
//-------------------------------------
// Internal properties
//-------------------------------------
public int Count
{
get
{
return _xArray.Count;
}
}
public bool IsReadOnly
{
get { return false; }
}
public Point this[int index]
{
get
{
// underlying array does boundary check
return new Point(_xArray[index], _yArray[index]);
}
set
{
// underlying array does boundary check
_xArray[index] = value.X;
_yArray[index] = value.Y;
}
}
//------------------------------------
// internal methods
//------------------------------------
public int IndexOf(Point item)
{
// linear search
for (int i = 0; i < Count; i++)
{
if (_xArray[i] == item.X && _yArray[i] == item.Y)
{
return i;
}
}
return -1;
}
public void Clear()
{
_xArray.Clear();
_yArray.Clear();
}
public bool Contains(Point item)
{
return IndexOf(item) >= 0;
}
public void CopyTo(Point[] array, int arrayIndex)
{
// parameter validations
if (array == null)
{
throw new ArgumentNullException("array");
}
if (array.Rank != 1)
{
throw new ArgumentException(
SR.Get(SRID.Collection_CopyTo_ArrayCannotBeMultidimensional),
"array");
}
if (arrayIndex < 0)
{
throw new ArgumentOutOfRangeException("arrayIndex");
}
if (arrayIndex >= array.Length)
{
throw new ArgumentException(
SR.Get(
SRID.Collection_CopyTo_IndexGreaterThanOrEqualToArrayLength,
"arrayIndex",
"array"),
"arrayIndex");
}
if ((array.Length - Count - arrayIndex) < 0)
{
throw new ArgumentException(
SR.Get(
SRID.Collection_CopyTo_NumberOfElementsExceedsArrayLength,
"arrayIndex",
"array"));
}
// do the copying here
for (int i = 0; i < Count; i++)
{
array[arrayIndex + i] = this[i];
}
}
public IEnumerator GetEnumerator()
{
for (int i = 0; i < Count; i++)
{
yield return this[i];
}
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return ((IEnumerable)this).GetEnumerator();
}
public void Add(Point value)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
public void Insert(int index, Point item)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
public bool Remove(Point item)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
public void RemoveAt(int index)
{
// not supported, same as Point[]
throw new NotSupportedException(SR.Get(SRID.CollectionIsFixedSize));
}
//---------------------------------------------
// Private methods
//---------------------------------------------
private void InitArrays(double emSize, int capacity)
{
_xArray = new ThousandthOfEmRealDoubles(emSize, capacity);
_yArray = new ThousandthOfEmRealDoubles(emSize, capacity);
}
//----------------------------------------
// Private members
//----------------------------------------
private ThousandthOfEmRealDoubles _xArray; // scaled double array for X coordinates
private ThousandthOfEmRealDoubles _yArray; // scaled double array for Y coordinates
}
}
// 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
- DataControlImageButton.cs
- XPathException.cs
- HostedHttpTransportManager.cs
- OrCondition.cs
- EmbeddedObject.cs
- ValidatorCollection.cs
- UniqueSet.cs
- TdsParserSafeHandles.cs
- SecuritySessionSecurityTokenProvider.cs
- ClientConvert.cs
- MarkupCompilePass2.cs
- QueryPageSettingsEventArgs.cs
- XmlTextReaderImpl.cs
- SystemIPInterfaceStatistics.cs
- JsonQNameDataContract.cs
- ColumnCollection.cs
- XmlStringTable.cs
- ListViewUpdateEventArgs.cs
- SpellerHighlightLayer.cs
- CodeIdentifiers.cs
- CatalogPart.cs
- EventLogPermission.cs
- LogLogRecord.cs
- TripleDESCryptoServiceProvider.cs
- MessageContractAttribute.cs
- MimeMapping.cs
- ValidationHelpers.cs
- FileIOPermission.cs
- ManagementObject.cs
- XmlSchemaAny.cs
- PriorityBinding.cs
- ItemCollection.cs
- TextAction.cs
- IERequestCache.cs
- CheckBoxBaseAdapter.cs
- SoapSchemaImporter.cs
- LogLogRecordEnumerator.cs
- ContentPosition.cs
- Baml2006Reader.cs
- UpnEndpointIdentityExtension.cs
- WebPermission.cs
- ProtocolsConfigurationHandler.cs
- GraphicsContext.cs
- PerformanceCounterPermissionAttribute.cs
- BaseAsyncResult.cs
- EditCommandColumn.cs
- XmlKeywords.cs
- TemplateBamlTreeBuilder.cs
- ParserHooks.cs
- HitTestWithPointDrawingContextWalker.cs
- CollectionConverter.cs
- dataprotectionpermission.cs
- WindowsListViewGroupHelper.cs
- DynamicUpdateCommand.cs
- BinHexDecoder.cs
- ListControl.cs
- EntitySqlQueryBuilder.cs
- KeyValueSerializer.cs
- VectorCollection.cs
- WebPartAuthorizationEventArgs.cs
- UriExt.cs
- DataListComponentEditor.cs
- ZipPackage.cs
- SmtpNegotiateAuthenticationModule.cs
- RepeaterItem.cs
- UriParserTemplates.cs
- SAPICategories.cs
- PeerEndPoint.cs
- TransactionState.cs
- PageAsyncTask.cs
- ThreadExceptionEvent.cs
- ButtonFieldBase.cs
- __Filters.cs
- PropertyMetadata.cs
- WebPartConnectionsEventArgs.cs
- XmlExceptionHelper.cs
- X509CertificateTrustedIssuerElementCollection.cs
- ProvideValueServiceProvider.cs
- SafeMILHandleMemoryPressure.cs
- WorkflowServiceHost.cs
- TypedServiceOperationListItem.cs
- ObjectDataProvider.cs
- SafeProcessHandle.cs
- ListBindableAttribute.cs
- TimeBoundedCache.cs
- XmlNodeChangedEventArgs.cs
- ArithmeticException.cs
- ServiceDesigner.cs
- ErrorRuntimeConfig.cs
- CodeGotoStatement.cs
- PenLineJoinValidation.cs
- Cell.cs
- RegexCode.cs
- IdentitySection.cs
- FontUnitConverter.cs
- xamlnodes.cs
- SubtreeProcessor.cs
- PackageDigitalSignature.cs
- QueueProcessor.cs
- util.cs