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 / 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 Freezable.CloneCore .
///
///
protected override void CloneCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.CloneCore(sourceFreezable);
CopyCommon(transform);
}
///
/// Implementation of Freezable.CloneCurrentValueCore .
///
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.CloneCurrentValueCore(sourceFreezable);
CopyCommon(transform);
}
///
/// Implementation of Freezable.GetAsFrozenCore .
///
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.GetAsFrozenCore(sourceFreezable);
CopyCommon(transform);
}
///
/// Implementation of Freezable.GetCurrentValueAsFrozenCore .
///
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.GetCurrentValueAsFrozenCore(sourceFreezable);
CopyCommon(transform);
}
///
/// 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 Freezable.CloneCore .
///
///
protected override void CloneCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.CloneCore(sourceFreezable);
CopyCommon(transform);
}
///
/// Implementation of Freezable.CloneCurrentValueCore .
///
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.CloneCurrentValueCore(sourceFreezable);
CopyCommon(transform);
}
///
/// Implementation of Freezable.GetAsFrozenCore .
///
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.GetAsFrozenCore(sourceFreezable);
CopyCommon(transform);
}
///
/// Implementation of Freezable.GetCurrentValueAsFrozenCore .
///
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
GeneralTransform3DTo2D transform = (GeneralTransform3DTo2D)sourceFreezable;
base.GetCurrentValueAsFrozenCore(sourceFreezable);
CopyCommon(transform);
}
///
/// 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
- xmlglyphRunInfo.cs
- SessionStateUtil.cs
- ButtonPopupAdapter.cs
- HtmlSelectionListAdapter.cs
- X509Extension.cs
- ResourceWriter.cs
- JapaneseLunisolarCalendar.cs
- DashStyle.cs
- TabletDeviceInfo.cs
- StaticExtension.cs
- ObjectContextServiceProvider.cs
- ScrollViewer.cs
- Label.cs
- XmlDocumentFragment.cs
- ServiceHandle.cs
- BindValidationContext.cs
- FilterQuery.cs
- ToolstripProfessionalRenderer.cs
- ManagementClass.cs
- SrgsElementFactory.cs
- BuiltInExpr.cs
- Point3DAnimationBase.cs
- controlskin.cs
- RemoteWebConfigurationHost.cs
- BrushValueSerializer.cs
- AccessViolationException.cs
- SerializableAttribute.cs
- securitycriticaldataformultiplegetandset.cs
- ViewStateChangedEventArgs.cs
- SimpleMailWebEventProvider.cs
- Console.cs
- ClientData.cs
- ByteAnimationUsingKeyFrames.cs
- CommandDevice.cs
- TextSelection.cs
- CurrencyManager.cs
- DecimalStorage.cs
- CodeDomSerializer.cs
- SweepDirectionValidation.cs
- WebPartConnectionsConfigureVerb.cs
- CustomActivityDesigner.cs
- SelectedCellsCollection.cs
- NavigationService.cs
- DifferencingCollection.cs
- GlyphRunDrawing.cs
- SafePointer.cs
- OutputScope.cs
- DataKeyCollection.cs
- XmlSchemaAny.cs
- TypeBrowser.xaml.cs
- CodeDomConfigurationHandler.cs
- Delegate.cs
- InputLangChangeEvent.cs
- CodeVariableDeclarationStatement.cs
- InternalConfirm.cs
- XmlReflectionMember.cs
- AlphabeticalEnumConverter.cs
- EventBuilder.cs
- SafeFindHandle.cs
- WebBrowserEvent.cs
- GridViewPageEventArgs.cs
- BitmapScalingModeValidation.cs
- Constraint.cs
- DragDeltaEventArgs.cs
- WindowsFormsSectionHandler.cs
- PageTextBox.cs
- ListViewInsertEventArgs.cs
- CodeParameterDeclarationExpression.cs
- WriteableBitmap.cs
- activationcontext.cs
- DataControlFieldTypeEditor.cs
- ImagingCache.cs
- DesignerExtenders.cs
- FunctionUpdateCommand.cs
- TypeTypeConverter.cs
- NameTable.cs
- X509ChainPolicy.cs
- RotateTransform3D.cs
- TableItemPattern.cs
- Source.cs
- EmptyStringExpandableObjectConverter.cs
- XmlDeclaration.cs
- CommandTreeTypeHelper.cs
- JsonEnumDataContract.cs
- xmlfixedPageInfo.cs
- _NtlmClient.cs
- ExceptionCollection.cs
- RedirectionProxy.cs
- RuntimeVariableList.cs
- Point4D.cs
- SafeNativeMethodsCLR.cs
- ComponentResourceManager.cs
- GcSettings.cs
- NamedElement.cs
- recordstate.cs
- Floater.cs
- HotSpotCollectionEditor.cs
- XmlSchemaAny.cs
- WebConfigurationFileMap.cs
- XmlSchemaAnnotated.cs