Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media / ScaleTransform.cs / 1 / ScaleTransform.cs
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2001
//
// File: ScaleTransform.cs
//-----------------------------------------------------------------------------
using System;
using System.Windows;
using System.Windows.Media;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using System.Security;
using System.Collections;
using MS.Internal;
using MS.Internal.PresentationCore;
using System.Windows.Media.Animation;
using System.Globalization;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Media.Composition;
using System.Diagnostics;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media
{
///
/// Create a scale transformation.
///
public sealed partial class ScaleTransform : Transform
{
///
/// Create a scale transformation.
///
public ScaleTransform()
{
}
///
/// Create a scale transformation.
///
public ScaleTransform(
double scaleX,
double scaleY
)
{
ScaleX = scaleX;
ScaleY = scaleY;
}
///
/// Create a scale transformation.
///
public ScaleTransform(
double scaleX,
double scaleY,
double centerX,
double centerY
) : this(scaleX, scaleY)
{
CenterX = centerX;
CenterY = centerY;
}
///
/// Return the current transformation value.
///
public override Matrix Value
{
get
{
ReadPreamble();
Matrix m = new Matrix();
m.ScaleAt(ScaleX, ScaleY, CenterX, CenterY);
return m;
}
}
///
/// Returns true if transformation matches the identity transform.
///
internal override bool IsIdentity
{
get
{
return ScaleX == 1 && ScaleY == 1 && CanFreeze;
}
}
internal override void TransformRect(ref Rect rect)
{
if (rect.IsEmpty)
{
return;
}
double scaleX = ScaleX;
double scaleY = ScaleY;
double centerX = CenterX;
double centerY = CenterY;
bool translateCenter = centerX != 0 || centerY != 0;
if (translateCenter)
{
rect.X -= centerX;
rect.Y -= centerY;
}
rect.Scale(scaleX, scaleY);
if (translateCenter)
{
rect.X += centerX;
rect.Y += centerY;
}
}
///
/// MultiplyValueByMatrix - *result is set equal to "this" * matrixToMultiplyBy.
///
/// The result is stored here.
/// The multiplicand.
internal override void MultiplyValueByMatrix(ref Matrix result, ref Matrix matrixToMultiplyBy)
{
result = Matrix.Identity;
result._m11 = ScaleX;
result._m22 = ScaleY;
double centerX = CenterX;
double centerY = CenterY;
result._type = MatrixTypes.TRANSFORM_IS_SCALING;
if (centerX != 0 || centerY != 0)
{
result._offsetX = centerX - centerX * result._m11;
result._offsetY = centerY - centerY * result._m22;
result._type |= MatrixTypes.TRANSFORM_IS_TRANSLATION;
}
MatrixUtil.MultiplyMatrix(ref result, ref matrixToMultiplyBy);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, 2001
//
// File: ScaleTransform.cs
//-----------------------------------------------------------------------------
using System;
using System.Windows;
using System.Windows.Media;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using System.Security;
using System.Collections;
using MS.Internal;
using MS.Internal.PresentationCore;
using System.Windows.Media.Animation;
using System.Globalization;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Media.Composition;
using System.Diagnostics;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
namespace System.Windows.Media
{
///
/// Create a scale transformation.
///
public sealed partial class ScaleTransform : Transform
{
///
/// Create a scale transformation.
///
public ScaleTransform()
{
}
///
/// Create a scale transformation.
///
public ScaleTransform(
double scaleX,
double scaleY
)
{
ScaleX = scaleX;
ScaleY = scaleY;
}
///
/// Create a scale transformation.
///
public ScaleTransform(
double scaleX,
double scaleY,
double centerX,
double centerY
) : this(scaleX, scaleY)
{
CenterX = centerX;
CenterY = centerY;
}
///
/// Return the current transformation value.
///
public override Matrix Value
{
get
{
ReadPreamble();
Matrix m = new Matrix();
m.ScaleAt(ScaleX, ScaleY, CenterX, CenterY);
return m;
}
}
///
/// Returns true if transformation matches the identity transform.
///
internal override bool IsIdentity
{
get
{
return ScaleX == 1 && ScaleY == 1 && CanFreeze;
}
}
internal override void TransformRect(ref Rect rect)
{
if (rect.IsEmpty)
{
return;
}
double scaleX = ScaleX;
double scaleY = ScaleY;
double centerX = CenterX;
double centerY = CenterY;
bool translateCenter = centerX != 0 || centerY != 0;
if (translateCenter)
{
rect.X -= centerX;
rect.Y -= centerY;
}
rect.Scale(scaleX, scaleY);
if (translateCenter)
{
rect.X += centerX;
rect.Y += centerY;
}
}
///
/// MultiplyValueByMatrix - *result is set equal to "this" * matrixToMultiplyBy.
///
/// The result is stored here.
/// The multiplicand.
internal override void MultiplyValueByMatrix(ref Matrix result, ref Matrix matrixToMultiplyBy)
{
result = Matrix.Identity;
result._m11 = ScaleX;
result._m22 = ScaleY;
double centerX = CenterX;
double centerY = CenterY;
result._type = MatrixTypes.TRANSFORM_IS_SCALING;
if (centerX != 0 || centerY != 0)
{
result._offsetX = centerX - centerX * result._m11;
result._offsetY = centerY - centerY * result._m22;
result._type |= MatrixTypes.TRANSFORM_IS_TRANSLATION;
}
MatrixUtil.MultiplyMatrix(ref result, ref matrixToMultiplyBy);
}
}
}
// 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
- ReturnValue.cs
- CatalogZone.cs
- XmlILIndex.cs
- WorkflowDesignerMessageFilter.cs
- GraphicsContext.cs
- ScrollProviderWrapper.cs
- MetadataUtilsSmi.cs
- NullReferenceException.cs
- XmlObjectSerializerReadContext.cs
- ProcessHostFactoryHelper.cs
- ParameterInfo.cs
- UnsafeNativeMethodsCLR.cs
- SelectionEditor.cs
- UrlAuthorizationModule.cs
- HtmlTitle.cs
- FontConverter.cs
- CodeAccessPermission.cs
- EmbeddedObject.cs
- CodeComment.cs
- EpmSourcePathSegment.cs
- SerializationHelper.cs
- LostFocusEventManager.cs
- NavigationWindow.cs
- ipaddressinformationcollection.cs
- LinkButton.cs
- ImageUrlEditor.cs
- ShellProvider.cs
- SystemIcmpV4Statistics.cs
- SaveFileDialog.cs
- CapabilitiesSection.cs
- KeyValueInternalCollection.cs
- MetaChildrenColumn.cs
- CreateParams.cs
- LocalTransaction.cs
- WmpBitmapDecoder.cs
- TimeoutConverter.cs
- HierarchicalDataBoundControl.cs
- UniqueIdentifierService.cs
- ProxySimple.cs
- NamespaceMapping.cs
- BindingManagerDataErrorEventArgs.cs
- DataError.cs
- FormClosingEvent.cs
- VerificationAttribute.cs
- ToolStripPanel.cs
- PrintControllerWithStatusDialog.cs
- ImageInfo.cs
- Html32TextWriter.cs
- ApplicationSecurityManager.cs
- ObjectIDGenerator.cs
- ProviderIncompatibleException.cs
- DllNotFoundException.cs
- Int32Animation.cs
- XmlEnumAttribute.cs
- CachedFontFace.cs
- OpenTypeCommon.cs
- SchemaCollectionCompiler.cs
- PointConverter.cs
- WebAdminConfigurationHelper.cs
- WebBrowserPermission.cs
- ETagAttribute.cs
- DataGridViewTopLeftHeaderCell.cs
- XmlValueConverter.cs
- RuntimeConfig.cs
- CollectionsUtil.cs
- XPathDocumentNavigator.cs
- TreeViewDesigner.cs
- TextBoxRenderer.cs
- ETagAttribute.cs
- WebPartConnectionsConnectVerb.cs
- PasswordPropertyTextAttribute.cs
- XmlBufferedByteStreamReader.cs
- Rule.cs
- DataGridAddNewRow.cs
- XmlDocumentFragment.cs
- ObfuscationAttribute.cs
- ValidatorCollection.cs
- DirectoryInfo.cs
- DataSourceSelectArguments.cs
- Freezable.cs
- NativeMethods.cs
- followingquery.cs
- GenericRootAutomationPeer.cs
- WebProxyScriptElement.cs
- DataServiceProcessingPipeline.cs
- Path.cs
- ResXResourceReader.cs
- FormsAuthenticationTicket.cs
- ConstNode.cs
- HostingEnvironmentWrapper.cs
- NamespaceEmitter.cs
- Classification.cs
- InfoCardHelper.cs
- SafeRightsManagementPubHandle.cs
- TextModifierScope.cs
- Schema.cs
- Propagator.cs
- DSACryptoServiceProvider.cs
- BaseParagraph.cs
- ParallelRangeManager.cs