Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / ScaleTransform.cs / 1305600 / 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
- XmlSchemaSimpleTypeList.cs
- SessionStateModule.cs
- EmptyReadOnlyDictionaryInternal.cs
- EncodingNLS.cs
- hebrewshape.cs
- RuleSetReference.cs
- RectAnimationClockResource.cs
- CssClassPropertyAttribute.cs
- SpecialNameAttribute.cs
- VisualStyleInformation.cs
- HyperLinkField.cs
- ToolStripLocationCancelEventArgs.cs
- SelectiveScrollingGrid.cs
- _ConnectStream.cs
- EnvironmentPermission.cs
- InstanceView.cs
- SerializationFieldInfo.cs
- ExpressionPrinter.cs
- Parameter.cs
- ObjectQuery_EntitySqlExtensions.cs
- TagMapCollection.cs
- backend.cs
- XamlUtilities.cs
- BuildDependencySet.cs
- WindowsSecurityToken.cs
- SourceCollection.cs
- RightsManagementErrorHandler.cs
- Blend.cs
- SymLanguageVendor.cs
- RoleServiceManager.cs
- HitTestWithPointDrawingContextWalker.cs
- SapiGrammar.cs
- SettingsAttributeDictionary.cs
- KernelTypeValidation.cs
- RotateTransform.cs
- ConfigurationElementCollection.cs
- WebPartMovingEventArgs.cs
- WebPartExportVerb.cs
- JoinCqlBlock.cs
- SQLCharsStorage.cs
- XmlNullResolver.cs
- TagMapCollection.cs
- PointIndependentAnimationStorage.cs
- CalendarAutoFormat.cs
- ReadOnlyAttribute.cs
- DecoderExceptionFallback.cs
- GeneratedContractType.cs
- HttpAsyncResult.cs
- ProgressBarRenderer.cs
- MethodCallTranslator.cs
- Compensation.cs
- __Filters.cs
- SqlConnectionManager.cs
- DBDataPermissionAttribute.cs
- SoapAttributeOverrides.cs
- FormatterServices.cs
- MultiByteCodec.cs
- WebPartTracker.cs
- QueryCursorEventArgs.cs
- PanelStyle.cs
- UserControlAutomationPeer.cs
- SyntaxCheck.cs
- TypeLoader.cs
- TypeEnumerableViewSchema.cs
- TagPrefixCollection.cs
- CodeMemberEvent.cs
- XmlSchemaComplexContentExtension.cs
- HierarchicalDataSourceControl.cs
- ImageMapEventArgs.cs
- DataException.cs
- RowUpdatedEventArgs.cs
- QueryContinueDragEvent.cs
- Unit.cs
- Highlights.cs
- ExitEventArgs.cs
- WebPartCloseVerb.cs
- DataGridViewRowCollection.cs
- PopupEventArgs.cs
- PathGeometry.cs
- XmlTextReaderImpl.cs
- AvTraceFormat.cs
- Funcletizer.cs
- WebException.cs
- Catch.cs
- DataGridTextBoxColumn.cs
- Model3D.cs
- IPHostEntry.cs
- DispatcherEventArgs.cs
- SynchronizationContext.cs
- ColumnWidthChangedEvent.cs
- InputScopeAttribute.cs
- RolePrincipal.cs
- MethodSet.cs
- BinaryObjectReader.cs
- SqlCommandSet.cs
- UnmanagedHandle.cs
- ItemDragEvent.cs
- UserControl.cs
- DbConnectionPool.cs
- InlineCollection.cs