Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media3D / GeneralTransform3DTo2D.cs / 1 / GeneralTransform3DTo2D.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Declaration of the GeneralTransform3DTo2D class. // //--------------------------------------------------------------------------- using System.Windows.Media; using System.Windows.Media.Animation; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; namespace System.Windows.Media.Media3D { ////// GeneralTransform3DTo2D class provides services to transform points and rects in 3D to 2D /// public class GeneralTransform3DTo2D : Freezable { internal GeneralTransform3DTo2D() { _transformBetween2D = null; } internal GeneralTransform3DTo2D(Matrix3D projectionTransform, GeneralTransform transformBetween2D) { _projectionTransform = projectionTransform; _transformBetween2D = (GeneralTransform)transformBetween2D.GetAsFrozen(); } ////// Transform a point /// /// Input point /// Output point ///True if the point was transformed successfuly, false otherwise public bool TryTransform(Point3D inPoint, out Point result) { bool success = false; result = new Point(); // project the point if (_projectionTransform != null) { Point3D projectedPoint = _projectionTransform.Transform(inPoint); if (_transformBetween2D != null) { result = _transformBetween2D.Transform(new Point(projectedPoint.X, projectedPoint.Y)); success = true; } } return success; } ////// Transform a point from 3D in to 2D /// /// If the transformation does not succeed, this will throw an InvalidOperationException. /// If you don't want to try/catch, call TryTransform instead and check the boolean it /// returns. /// /// /// Input point ///The transformed point public Point Transform(Point3D point) { Point transformedPoint; if (!TryTransform(point, out transformedPoint)) { throw new InvalidOperationException(SR.Get(SRID.GeneralTransform_TransformFailed, null)); } return transformedPoint; } ////// Transform a Rect3D to a Rect. If this transformation cannot be completed Rect.Empty is returned. /// /// Input 3D bounding box ///The 2D bounding box of the projection of these points public Rect TransformBounds(Rect3D rect3D) { if (_transformBetween2D != null) { return _transformBetween2D.TransformBounds(MILUtilities.ProjectBounds(ref _projectionTransform, ref rect3D)); } else { return Rect.Empty; } } ////// Implementation of ///Freezable.CreateInstanceCore . ///The new Freezable. protected override Freezable CreateInstanceCore() { return new GeneralTransform3DTo2D(); } ////// Implementation of /// protected override void CloneCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.CloneCore(sourceFreezable); CopyCommon(transform); } ///Freezable.CloneCore . ////// Implementation of /// protected override void CloneCurrentValueCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(transform); } ///Freezable.CloneCurrentValueCore . ////// Implementation of /// protected override void GetAsFrozenCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(transform); } ///Freezable.GetAsFrozenCore . ////// Implementation of /// protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(transform); } ///Freezable.GetCurrentValueAsFrozenCore . ////// Clones values that do not have corresponding DPs /// /// private void CopyCommon(GeneralTransform3DTo2D transform) { _projectionTransform = transform._projectionTransform; _transformBetween2D = transform._transformBetween2D; } private Matrix3D _projectionTransform; private GeneralTransform _transformBetween2D; } } // 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: Declaration of the GeneralTransform3DTo2D class. // //--------------------------------------------------------------------------- using System.Windows.Media; using System.Windows.Media.Animation; using SR = MS.Internal.PresentationCore.SR; using SRID = MS.Internal.PresentationCore.SRID; namespace System.Windows.Media.Media3D { ////// GeneralTransform3DTo2D class provides services to transform points and rects in 3D to 2D /// public class GeneralTransform3DTo2D : Freezable { internal GeneralTransform3DTo2D() { _transformBetween2D = null; } internal GeneralTransform3DTo2D(Matrix3D projectionTransform, GeneralTransform transformBetween2D) { _projectionTransform = projectionTransform; _transformBetween2D = (GeneralTransform)transformBetween2D.GetAsFrozen(); } ////// Transform a point /// /// Input point /// Output point ///True if the point was transformed successfuly, false otherwise public bool TryTransform(Point3D inPoint, out Point result) { bool success = false; result = new Point(); // project the point if (_projectionTransform != null) { Point3D projectedPoint = _projectionTransform.Transform(inPoint); if (_transformBetween2D != null) { result = _transformBetween2D.Transform(new Point(projectedPoint.X, projectedPoint.Y)); success = true; } } return success; } ////// Transform a point from 3D in to 2D /// /// If the transformation does not succeed, this will throw an InvalidOperationException. /// If you don't want to try/catch, call TryTransform instead and check the boolean it /// returns. /// /// /// Input point ///The transformed point public Point Transform(Point3D point) { Point transformedPoint; if (!TryTransform(point, out transformedPoint)) { throw new InvalidOperationException(SR.Get(SRID.GeneralTransform_TransformFailed, null)); } return transformedPoint; } ////// Transform a Rect3D to a Rect. If this transformation cannot be completed Rect.Empty is returned. /// /// Input 3D bounding box ///The 2D bounding box of the projection of these points public Rect TransformBounds(Rect3D rect3D) { if (_transformBetween2D != null) { return _transformBetween2D.TransformBounds(MILUtilities.ProjectBounds(ref _projectionTransform, ref rect3D)); } else { return Rect.Empty; } } ////// Implementation of ///Freezable.CreateInstanceCore . ///The new Freezable. protected override Freezable CreateInstanceCore() { return new GeneralTransform3DTo2D(); } ////// Implementation of /// protected override void CloneCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.CloneCore(sourceFreezable); CopyCommon(transform); } ///Freezable.CloneCore . ////// Implementation of /// protected override void CloneCurrentValueCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(transform); } ///Freezable.CloneCurrentValueCore . ////// Implementation of /// protected override void GetAsFrozenCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.GetAsFrozenCore(sourceFreezable); CopyCommon(transform); } ///Freezable.GetAsFrozenCore . ////// Implementation of /// protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(transform); } ///Freezable.GetCurrentValueAsFrozenCore . ////// Clones values that do not have corresponding DPs /// /// private void CopyCommon(GeneralTransform3DTo2D transform) { _projectionTransform = transform._projectionTransform; _transformBetween2D = transform._transformBetween2D; } private Matrix3D _projectionTransform; private GeneralTransform _transformBetween2D; } } // 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
- ChtmlFormAdapter.cs
- AdapterUtil.cs
- AuthorizationRule.cs
- Padding.cs
- IpcServerChannel.cs
- SecurityProtocolFactory.cs
- PaintValueEventArgs.cs
- ListViewCommandEventArgs.cs
- DataTableMapping.cs
- ListChangedEventArgs.cs
- DataServiceEntityAttribute.cs
- XmlSerializerSection.cs
- KnownTypesProvider.cs
- infer.cs
- FileDataSourceCache.cs
- QueryCreatedEventArgs.cs
- _AuthenticationState.cs
- XmlArrayItemAttribute.cs
- ScrollItemProviderWrapper.cs
- InterleavedZipPartStream.cs
- Label.cs
- ApplicationCommands.cs
- StrokeNodeData.cs
- WebPartDescriptionCollection.cs
- XmlNodeChangedEventManager.cs
- AxHost.cs
- SQLInt64.cs
- HiddenField.cs
- EmptyStringExpandableObjectConverter.cs
- Base64Decoder.cs
- RoleGroup.cs
- ProxyAttribute.cs
- _DomainName.cs
- ListViewItem.cs
- EmptyElement.cs
- ProcessModule.cs
- HwndKeyboardInputProvider.cs
- ChildChangedEventArgs.cs
- CustomErrorCollection.cs
- SecurityTokenTypes.cs
- WindowsGraphicsCacheManager.cs
- ObjectNavigationPropertyMapping.cs
- ResourcePermissionBaseEntry.cs
- NamespaceInfo.cs
- PrinterResolution.cs
- ServiceDescription.cs
- CreateUserWizard.cs
- CaseInsensitiveOrdinalStringComparer.cs
- ListViewEditEventArgs.cs
- ForeignKeyFactory.cs
- ElementUtil.cs
- FunctionDescription.cs
- XPathPatternParser.cs
- DefaultAssemblyResolver.cs
- Line.cs
- SuppressMessageAttribute.cs
- TextEndOfSegment.cs
- DrawingServices.cs
- ChangeDirector.cs
- TdsParserSessionPool.cs
- XmlSerializationGeneratedCode.cs
- SByteConverter.cs
- WCFModelStrings.Designer.cs
- JournalNavigationScope.cs
- IISMapPath.cs
- XsltException.cs
- MissingManifestResourceException.cs
- Choices.cs
- XmlLanguage.cs
- _ProxyChain.cs
- NativeMethods.cs
- RuleProcessor.cs
- FileDataSourceCache.cs
- XmlStringTable.cs
- StreamMarshaler.cs
- HashAlgorithm.cs
- GPRECT.cs
- SiblingIterators.cs
- relpropertyhelper.cs
- PropertyRecord.cs
- SplashScreen.cs
- PortCache.cs
- GlyphTypeface.cs
- StrokeCollectionDefaultValueFactory.cs
- ConfigurationProperty.cs
- PageEventArgs.cs
- FixedTextView.cs
- ReferenceEqualityComparer.cs
- Grid.cs
- wgx_sdk_version.cs
- TextBounds.cs
- ConfigXmlCDataSection.cs
- HostedHttpTransportManager.cs
- WindowsFormsLinkLabel.cs
- FileSystemInfo.cs
- WindowsStatusBar.cs
- LicenseContext.cs
- SpellerInterop.cs
- EmptyCollection.cs
- SqlClientMetaDataCollectionNames.cs