Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / Transform.cs / 1 / Transform.cs
/****************************************************************************\
*
* File: Transform.cs
*
* Description:
* Transform.cs defines the "Transform" object, translate, rotate and scale.
*
* Copyright (C) 2002 by Microsoft Corporation. All rights reserved.
*
\***************************************************************************/
using MS.Internal;
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using MS.Internal.Serialization;
using MS.Internal.PresentationCore;
namespace System.Windows.Media
{
#region Transform
///
/// Transform provides a base for all types of transformations, including matrix and list type.
///
[Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
public abstract partial class Transform : GeneralTransform
{
internal Transform()
{
}
///
/// Identity transformation.
///
public static Transform Identity
{
get
{
return s_identity;
}
}
private static Transform MakeIdentityTransform()
{
Transform identity = new MatrixTransform(Matrix.Identity);
identity.Freeze();
return identity;
}
private static Transform s_identity = MakeIdentityTransform();
///
/// Return the current transformation value.
///
public abstract Matrix Value { get; }
///
/// Returns true if transformation if the transformation is definitely an identity. There are cases where it will
/// return false because of computational error or presence of animations (And we're interpolating through a
/// transient identity) -- this is intentional. This property is used internally only. If you need to check the
/// current matrix value for identity, use Transform.Value.Identity.
///
internal abstract bool IsIdentity {get;}
internal virtual bool CanSerializeToString() { return false; }
#region Perf Helpers
internal virtual void TransformRect(ref Rect rect)
{
Matrix matrix = Value;
MatrixUtil.TransformRect(ref rect, ref matrix);
}
///
/// MultiplyValueByMatrix - result is set equal to "this" * matrixToMultiplyBy.
///
/// The result is stored here.
/// The multiplicand.
internal virtual void MultiplyValueByMatrix(ref Matrix result, ref Matrix matrixToMultiplyBy)
{
result = Value;
MatrixUtil.MultiplyMatrix(ref result, ref matrixToMultiplyBy);
}
///
/// Critical -- references and writes out to memory addresses. The
/// caller is safe if the pointer points to a D3DMATRIX
/// value.
///
[SecurityCritical]
internal unsafe virtual void ConvertToD3DMATRIX(/* out */ D3DMATRIX* milMatrix)
{
Matrix matrix = Value;
MILUtilities.ConvertToD3DMATRIX(&matrix, milMatrix);
}
#endregion
///
/// Consolidates the common logic of obtain the value of a
/// Transform, after checking the transform for null.
///
/// Transform to obtain value of.
///
/// Current value of 'transform'. Matrix.Identity if
/// the 'transform' parameter is null.
///
internal static void GetTransformValue(
Transform transform,
out Matrix currentTransformValue
)
{
if (transform != null)
{
currentTransformValue = transform.Value;
}
else
{
currentTransformValue = Matrix.Identity;
}
}
///
/// Transforms a point
///
/// Input point
/// Output point
/// True if the point was successfully transformed
public override bool TryTransform(Point inPoint, out Point result)
{
Matrix m = Value;
result = m.Transform(inPoint);
return true;
}
///
/// Transforms the bounding box to the smallest axis aligned bounding box
/// that contains all the points in the original bounding box
///
/// Bounding box
/// The transformed bounding box
public override Rect TransformBounds(Rect rect)
{
TransformRect(ref rect);
return rect;
}
///
/// Returns the inverse transform if it has an inverse, null otherwise
///
public override GeneralTransform Inverse
{
get
{
ReadPreamble();
Matrix matrix = Value;
if (!matrix.HasInverse)
{
return null;
}
matrix.Invert();
return new MatrixTransform(matrix);
}
}
///
/// Returns a best effort affine transform
///
internal override Transform AffineTransform
{
[FriendAccessAllowed] // Built into Core, also used by Framework.
get
{
return this;
}
}
}
#endregion
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
/****************************************************************************\
*
* File: Transform.cs
*
* Description:
* Transform.cs defines the "Transform" object, translate, rotate and scale.
*
* Copyright (C) 2002 by Microsoft Corporation. All rights reserved.
*
\***************************************************************************/
using MS.Internal;
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Markup;
using MS.Internal.Serialization;
using MS.Internal.PresentationCore;
namespace System.Windows.Media
{
#region Transform
///
/// Transform provides a base for all types of transformations, including matrix and list type.
///
[Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
public abstract partial class Transform : GeneralTransform
{
internal Transform()
{
}
///
/// Identity transformation.
///
public static Transform Identity
{
get
{
return s_identity;
}
}
private static Transform MakeIdentityTransform()
{
Transform identity = new MatrixTransform(Matrix.Identity);
identity.Freeze();
return identity;
}
private static Transform s_identity = MakeIdentityTransform();
///
/// Return the current transformation value.
///
public abstract Matrix Value { get; }
///
/// Returns true if transformation if the transformation is definitely an identity. There are cases where it will
/// return false because of computational error or presence of animations (And we're interpolating through a
/// transient identity) -- this is intentional. This property is used internally only. If you need to check the
/// current matrix value for identity, use Transform.Value.Identity.
///
internal abstract bool IsIdentity {get;}
internal virtual bool CanSerializeToString() { return false; }
#region Perf Helpers
internal virtual void TransformRect(ref Rect rect)
{
Matrix matrix = Value;
MatrixUtil.TransformRect(ref rect, ref matrix);
}
///
/// MultiplyValueByMatrix - result is set equal to "this" * matrixToMultiplyBy.
///
/// The result is stored here.
/// The multiplicand.
internal virtual void MultiplyValueByMatrix(ref Matrix result, ref Matrix matrixToMultiplyBy)
{
result = Value;
MatrixUtil.MultiplyMatrix(ref result, ref matrixToMultiplyBy);
}
///
/// Critical -- references and writes out to memory addresses. The
/// caller is safe if the pointer points to a D3DMATRIX
/// value.
///
[SecurityCritical]
internal unsafe virtual void ConvertToD3DMATRIX(/* out */ D3DMATRIX* milMatrix)
{
Matrix matrix = Value;
MILUtilities.ConvertToD3DMATRIX(&matrix, milMatrix);
}
#endregion
///
/// Consolidates the common logic of obtain the value of a
/// Transform, after checking the transform for null.
///
/// Transform to obtain value of.
///
/// Current value of 'transform'. Matrix.Identity if
/// the 'transform' parameter is null.
///
internal static void GetTransformValue(
Transform transform,
out Matrix currentTransformValue
)
{
if (transform != null)
{
currentTransformValue = transform.Value;
}
else
{
currentTransformValue = Matrix.Identity;
}
}
///
/// Transforms a point
///
/// Input point
/// Output point
/// True if the point was successfully transformed
public override bool TryTransform(Point inPoint, out Point result)
{
Matrix m = Value;
result = m.Transform(inPoint);
return true;
}
///
/// Transforms the bounding box to the smallest axis aligned bounding box
/// that contains all the points in the original bounding box
///
/// Bounding box
/// The transformed bounding box
public override Rect TransformBounds(Rect rect)
{
TransformRect(ref rect);
return rect;
}
///
/// Returns the inverse transform if it has an inverse, null otherwise
///
public override GeneralTransform Inverse
{
get
{
ReadPreamble();
Matrix matrix = Value;
if (!matrix.HasInverse)
{
return null;
}
matrix.Invert();
return new MatrixTransform(matrix);
}
}
///
/// Returns a best effort affine transform
///
internal override Transform AffineTransform
{
[FriendAccessAllowed] // Built into Core, also used by Framework.
get
{
return this;
}
}
}
#endregion
}
// 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
- NullableIntSumAggregationOperator.cs
- XpsSerializationManager.cs
- CommandID.cs
- Axis.cs
- Screen.cs
- LogicalExpr.cs
- ClientSession.cs
- ServiceObjectContainer.cs
- LayoutTable.cs
- httpserverutility.cs
- XmlSchemaImport.cs
- WebBrowserEvent.cs
- DbInsertCommandTree.cs
- ReliableReplySessionChannel.cs
- HtmlForm.cs
- DbCommandDefinition.cs
- BatchParser.cs
- IntegerFacetDescriptionElement.cs
- TraceProvider.cs
- ToolStrip.cs
- Label.cs
- ContainerSelectorActiveEvent.cs
- ButtonBaseAdapter.cs
- RichTextBox.cs
- CompressionTransform.cs
- PenLineJoinValidation.cs
- _CommandStream.cs
- FormsAuthenticationModule.cs
- StandardToolWindows.cs
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- MessageHeaderDescription.cs
- ProfileEventArgs.cs
- PresentationTraceSources.cs
- PenThreadPool.cs
- ObjectParameterCollection.cs
- HttpsChannelListener.cs
- MetafileHeaderWmf.cs
- UserControlBuildProvider.cs
- Not.cs
- MorphHelper.cs
- ParentControlDesigner.cs
- ASCIIEncoding.cs
- MDIClient.cs
- TextMetrics.cs
- LineSegment.cs
- PeerNameRecordCollection.cs
- EditBehavior.cs
- ContainerControl.cs
- FileSystemInfo.cs
- RowBinding.cs
- UrlRoutingHandler.cs
- ActivationServices.cs
- GPPOINTF.cs
- SystemInfo.cs
- FixUpCollection.cs
- EntryPointNotFoundException.cs
- MatrixAnimationUsingKeyFrames.cs
- NameValueCollection.cs
- _IPv6Address.cs
- DataRelationCollection.cs
- TraceContextEventArgs.cs
- DeleteMemberBinder.cs
- IsolationInterop.cs
- IPipelineRuntime.cs
- LogicalExpr.cs
- DataSvcMapFileSerializer.cs
- WebPartVerbCollection.cs
- HtmlInputHidden.cs
- XmlSchemaSequence.cs
- XPathNodeInfoAtom.cs
- ImageInfo.cs
- DisplayClaim.cs
- Variant.cs
- CompilerWrapper.cs
- SchemaTableOptionalColumn.cs
- InsufficientMemoryException.cs
- HttpApplicationFactory.cs
- Monitor.cs
- SqlDependencyListener.cs
- FontConverter.cs
- BooleanAnimationBase.cs
- CssTextWriter.cs
- __FastResourceComparer.cs
- MULTI_QI.cs
- RtfFormatStack.cs
- FontEditor.cs
- FigureParagraph.cs
- RightsManagementInformation.cs
- Authorization.cs
- InstanceHandleConflictException.cs
- ObjectListDataBindEventArgs.cs
- TableSectionStyle.cs
- DependencyProperty.cs
- FolderBrowserDialog.cs
- DeadCharTextComposition.cs
- ZipArchive.cs
- DBCSCodePageEncoding.cs
- SharedPersonalizationStateInfo.cs
- QuaternionRotation3D.cs
- LinqDataSourceDeleteEventArgs.cs