/// <summary> /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>. /// </summary> /// <param name="sourceFreezable"></param> protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable) { GeneralTransform2DTo3D transform = (GeneralTransform2DTo3D)sourceFreezable; base.GetCurrentValueAsFrozenCore(sourceFreezable); CopyCommon(transform); }
/// <summary> /// Implementation of <see cref="System.Windows.Freezable.CloneCurrentValueCore(Freezable)">Freezable.CloneCurrentValueCore</see>. /// </summary> /// <param name="sourceFreezable"></param> protected override void CloneCurrentValueCore(Freezable sourceFreezable) { GeneralTransform2DTo3D transform = (GeneralTransform2DTo3D)sourceFreezable; base.CloneCurrentValueCore(sourceFreezable); CopyCommon(transform); }
internal GeneralTransform3DTo2DTo3D(GeneralTransform3DTo2D transform3DTo2D, GeneralTransform2DTo3D transform2DTo3D) { Debug.Assert(transform3DTo2D != null && transform2DTo3D != null); _transform3DTo2D = (GeneralTransform3DTo2D)transform3DTo2D.GetAsFrozen(); _transform2DTo3D = (GeneralTransform2DTo3D)transform2DTo3D.GetAsFrozen(); }
/// <summary> /// Clones values that do not have corresponding DPs /// </summary> /// <param name="transform"></param> private void CopyCommon(GeneralTransform2DTo3D transform) { _transform2D = transform._transform2D; _transform3D = transform._transform3D; _positions = transform._positions; _textureCoords = transform._textureCoords; _triIndices = transform._triIndices; _childBounds = transform._childBounds; }
/// <summary> /// Provides the transform to go from 2D to 3D. /// </summary> /// <param name="ancestor">Ancestor visual.</param> /// <param name="transformTo3D">The transform to use to go to 3D</param> internal bool TrySimpleTransformToAncestor(Visual3D ancestor, out GeneralTransform2DTo3D transformTo3D) { Debug.Assert(ancestor != null); // get the 3D object that contains this visual // this must be a Viewport2DVisual3D since this is the only 3D class that can contain 2D content as a child Viewport2DVisual3D containingVisual3D = VisualTreeHelper.GetContainingVisual3D(this) as Viewport2DVisual3D; // if containingVisual3D is null then ancestor is not the ancestor if (containingVisual3D == null) { throw new System.InvalidOperationException(SR.Get(SRID.Visual_NotAnAncestor)); } GeneralTransform transform2D = this.TransformToAncestor(containingVisual3D.Visual); GeneralTransform3D transform3D = containingVisual3D.TransformToAncestor(ancestor); transformTo3D = new GeneralTransform2DTo3D(transform2D, containingVisual3D, transform3D); return true; }