Пример #1
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     var result = new GeneralTransformGroup();
     result.Children.Add(base.GetDesiredTransform(transform));
     result.Children.Add(new TranslateTransform(_offsetLeft, _offsetTop));
     return result;
 }
Пример #2
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup result = new GeneralTransformGroup();
     result.Children.Add(base.GetDesiredTransform(transform));
     result.Children.Add(new TranslateTransform(_leftOffset, _topOffset));
     return result;
 }
Пример #3
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup result = new GeneralTransformGroup();
     result.Children.Add (transform);
     result.Children.Add (new TranslateTransform (this.offset.X, this.offset.Y));
     return result;
 }
Пример #4
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     var transformGroup = new GeneralTransformGroup();
     transformGroup.Children.Add(base.GetDesiredTransform(transform));
     transformGroup.Children.Add(new TranslateTransform(_currentPoint.X - _startPoint.X, _currentPoint.Y - _startPoint.Y));
     return transformGroup;
 }
Пример #5
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup result = new GeneralTransformGroup();
     result.Children.Add(base.GetDesiredTransform(transform));
     result.Children.Add(new TranslateTransform(position.X, position.Y));
     return result;
 }
Пример #6
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup newTransform = new GeneralTransformGroup();
     newTransform.Children.Add(base.GetDesiredTransform(transform));
     newTransform.Children.Add(new TranslateTransform(this._adornerOffset.X, this._adornerOffset.Y));
     return newTransform;
 }
Пример #7
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup result = new GeneralTransformGroup();
     result.Children.Add(base.GetDesiredTransform(transform));
     result.Children.Add(new TranslateTransform(this.left, this.top));
     return result;
 }
Пример #8
0
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup group = new GeneralTransformGroup();
     group.Children.Add(base.GetDesiredTransform(transform));
     group.Children.Add(translate);
     return group;
 }
    public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
    {
      var result = new GeneralTransformGroup();
      result.Children.Add(base.GetDesiredTransform(transform));
      result.Children.Add(new TranslateTransform(this.MousePosition.X - 4, this.MousePosition.Y - 4));

      return result;
    }
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     GeneralTransformGroup result = new GeneralTransformGroup();
     result.Children.Add(base.GetDesiredTransform(transform));
     result.Children.Add(new TranslateTransform(
         position.X - treeViewEx.ScrollViewer.ContentHorizontalOffset, position.Y - treeViewEx.ScrollViewer.ContentVerticalOffset));
     return result;
 }
Пример #11
0
 /// <summary>
 ///     Override.
 /// </summary>
 /// <param name="transform"></param>
 /// <returns></returns>
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     var result = new GeneralTransformGroup();
     // ReSharper disable AssignNullToNotNullAttribute
     result.Children.Add(base.GetDesiredTransform(transform));
     // ReSharper restore AssignNullToNotNullAttribute
     result.Children.Add(new TranslateTransform(offsetLeft, offsetTop));
     return result;
 }
Пример #12
0
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            GeneralTransformGroup result = new GeneralTransformGroup();
            result.Children.Add(new TranslateTransform(Left, Top));
            if (Left > 0) this.Visibility = Visibility.Visible;
            result.Children.Add(base.GetDesiredTransform(transform));

            return result;
        }
Пример #13
0
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform) {
            var result = new GeneralTransformGroup();
            var desired = base.GetDesiredTransform(transform);
            if (desired != null) {
                result.Children.Add(desired);
            }

            result.Children.Add(new TranslateTransform(_offsetLeft, _offsetTop));
            return result;
        }
Пример #14
0
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            var result = new GeneralTransformGroup();
            var tf = base.GetDesiredTransform(transform);
            Debug.Assert(tf != null);
            result.Children.Add(tf);
            result.Children.Add(new TranslateTransform(_left, _top));

            return result;
        }
Пример #15
0
    public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
    {
      var baseTransform = base.GetDesiredTransform(transform);
      var translateTransform = new TranslateTransform(MousePosition.X - 4, MousePosition.Y - 4);
      
      var result = new GeneralTransformGroup();
      if (baseTransform != null)
        result.Children.Add(baseTransform);
      result.Children.Add(translateTransform);

      return result;
    }
Пример #16
0
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            var result = new GeneralTransformGroup();

            result.Children.Add(base.GetDesiredTransform(transform));

            var mousePositionTransform = new TranslateTransform(MousePosition.X, MousePosition.Y);
            result.Children.Add(mousePositionTransform);

            var mousePositionOffsetTransform = new TranslateTransform(-4, -4);
            result.Children.Add(mousePositionOffsetTransform);

            return result;
        }
        /// <summary>
        /// Adorners don't always want to be transformed in the same way as the elements they
        /// adorn.  Adorners which adorn points, such as resize handles, want to be translated
        /// and rotated but not scaled.  Adorners adorning an object, like a marquee, may want
        /// all transforms.  This method is called by AdornerLayer to allow the adorner to
        /// filter out the transforms it doesn't want and return a new transform with just the
        /// transforms it wants applied.  An adorner can also add an additional translation
        /// transform at this time, allowing it to be positioned somewhere other than the upper
        /// left corner of its adorned element.
        /// </summary>
        /// <param name="transform">The transform applied to the object the adorner adorns</param>
        /// <returns>Transform to apply to the adorner</returns>
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            if (ReferenceElement == null)
                return transform;

            GeneralTransformGroup group = new GeneralTransformGroup();
            group.Children.Add(transform);

            GeneralTransform t = this.TransformToDescendant(ReferenceElement);
            if (t != null)
            {
                group.Children.Add(t);
            }
            return group;
        }
Пример #18
0
 /// <summary>
 /// Returns a <see cref="T:System.Windows.Media.Transform"/> for the adorner, based on the transform that is currently applied to the adorned element.
 /// </summary>
 /// <param name="transform">The transform that is currently applied to the adorned element.</param>
 /// <returns>A transform to apply to the adorner.</returns>
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     if (PlaceholderReferenceElement == null)
     {
         return transform;
     }
     var group = new GeneralTransformGroup();
     group.Children.Add(transform);
     var transform2 = TransformToDescendant(PlaceholderReferenceElement);
     if (transform2 != null)
     {
         group.Children.Add(transform2);
     }
     return group;
 }
Пример #19
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------
 
        #region Public Methods

        /// <summary>
        /// Add a transform so that the adorner is in right spot.
        /// </summary>
        /// <param name="transform">
        /// The transform applied to the object the adorner adorns
        /// </param>
        /// <returns>
        /// Transform to apply to the adorner
        /// </returns>
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            GeneralTransformGroup group;            
            TranslateTransform translation;

            group = new GeneralTransformGroup();            
            translation = new TranslateTransform(_x, _top);

            group.Children.Add(translation);

            if (transform != null)
            {
                group.Children.Add(transform);
            }

            return group;
        }
Пример #20
0
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            Rect adornedElementRect = new Rect(this.AdornedElement.RenderSize);
            double positionX = adornedElementRect.Left;
            double positionY;
            if (Content.Before)
            {
                positionY = adornedElementRect.Top;
            }
            else
            {
                positionY = adornedElementRect.Bottom;
            }

            GeneralTransformGroup result = new GeneralTransformGroup();
            result.Children.Add(base.GetDesiredTransform(transform));
            result.Children.Add(new TranslateTransform(positionX, positionY - contentPresenter.ActualHeight/2));
            return result;
        }
Пример #21
0
        /// <summary>
        /// The overridden GetDesiredTransform method
        /// </summary>
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            if ( transform == null )
            {
                throw new ArgumentNullException("transform");
            }

            VerifyAccess();
            GeneralTransformGroup desiredTransform = new GeneralTransformGroup();
            desiredTransform.Children.Add(transform);

            // Check if we need translate the adorner.
            if ( !DoubleUtil.AreClose(_offsetX, 0) || !DoubleUtil.AreClose(_offsetY, 0) )
            {                
                desiredTransform.Children.Add(new TranslateTransform(_offsetX, _offsetY));
            }

            return desiredTransform;
        }
Пример #22
0
        internal GeneralTransform2DTo3D(GeneralTransform transform2D, 
                                        Viewport2DVisual3D containingVisual3D, 
                                        GeneralTransform3D transform3D)
        {            
            Visual child = containingVisual3D.Visual;

            Debug.Assert(child != null, "Going from 2D to 3D containingVisual3D.Visual should not be null");
            
            _transform3D = (GeneralTransform3D)transform3D.GetCurrentValueAsFrozen();

            // we also need to go one more level up to handle a transform being placed
            // on the Viewport2DVisual3D's child
            GeneralTransformGroup transformGroup = new GeneralTransformGroup();
            transformGroup.Children.Add((GeneralTransform)transform2D.GetCurrentValueAsFrozen());
            transformGroup.Children.Add((GeneralTransform)child.TransformToOuterSpace().GetCurrentValueAsFrozen());
            transformGroup.Freeze();
            _transform2D = transformGroup;

            _positions = containingVisual3D.InternalPositionsCache;
            _textureCoords = containingVisual3D.InternalTextureCoordinatesCache;
            _triIndices = containingVisual3D.InternalTriangleIndicesCache;

            _childBounds = child.CalculateSubgraphRenderBoundsOuterSpace();
        }
Пример #23
0
        /// <summary>
        /// Provides the transform or the inverse transform between this visual and the specified ancestor.
        /// Returns true if the transform is "simple" - in which case the GeneralTransform is null
        /// and the caller should use the Matrix.
        /// Otherwise, returns false - use the GeneralTransform and ignore the Matrix.
        /// If inverse is requested but not available (if the transform is not invertible), false is
        /// returned and the GeneralTransform is null.
        /// </summary>
        /// <param name="ancestor">Ancestor visual.</param>
        /// <param name="inverse">Returns inverse if this argument is true.</param>
        /// <param name="generalTransform">The GeneralTransform if this method returns false.</param>
        /// <param name="simpleTransform">The Matrix if this method returns true.</param>
        internal bool TrySimpleTransformToAncestor(Visual ancestor,
                                                   bool inverse,
                                                   out GeneralTransform generalTransform,
                                                   out Matrix simpleTransform)
        {
            Debug.Assert(ancestor != null);

            // flag to indicate if we have a case where we do multile 2D->3D->2D transitions
            bool embedded2Don3D = false;

            DependencyObject g = this;
            Matrix m = Matrix.Identity;

            // Keep this null until it's needed
            GeneralTransformGroup group = null;

            // This while loop will walk up the visual tree until we encounter the ancestor.
            // As it does so, it will accumulate the descendent->ancestor transform.
            // In most cases, this is simply a matrix, though if we encounter a bitmap effect we
            // will need to use a general transform group to store the transform.
            // We will accumulate the current transform in a matrix until we encounter a bitmap effect,
            // at which point we will add the matrix's current value and the bitmap effect's transforms
            // to the GeneralTransformGroup and continue to accumulate further transforms in the matrix again.
            // At the end of this loop, we will have 0 or more transforms in the GeneralTransformGroup
            // and the matrix which, if not identity, should be appended to the GeneralTransformGroup.
            // If, as is commonly the case, this loop terminates without encountering a bitmap effect
            // we will simply use the Matrix.

            while ((VisualTreeHelper.GetParent(g) != null) && (g != ancestor))
            {
                Visual gAsVisual = g as Visual;
                if (gAsVisual != null)
                {
                    if (gAsVisual.CheckFlagsAnd(VisualFlags.NodeHasEffect))
                    {
                        // Only check for Effect, not legacy BitmapEffect.  Previous
                        // version had an incorrect BitmapEffect implementation
                        // here, and there's no need to improve on our
                        // BitmapEffect implementation if it didn't work
                        // before.
                        
                        Effect imageEffect = EffectField.GetValue(gAsVisual);
                        if (imageEffect != null)
                        {
                            GeneralTransform gt = imageEffect.CoerceToUnitSpaceGeneralTransform(
                                imageEffect.EffectMapping,
                                gAsVisual.VisualDescendantBounds);
                        
                            Transform affineTransform = gt.AffineTransform;
                            if (affineTransform != null)
                            {
                                Matrix cm = affineTransform.Value;
                                MatrixUtil.MultiplyMatrix(ref m, ref cm);
                            }
                            else
                            {
                                if (group == null)
                                {
                                    group = new GeneralTransformGroup();
                                }

                                group.Children.Add(new MatrixTransform(m));
                                m = Matrix.Identity;

                                group.Children.Add(gt);
                            }
                        }
                    }

                    Transform transform = TransformField.GetValue(gAsVisual);
                    if (transform != null)
                    {
                        Matrix cm = transform.Value;
                        MatrixUtil.MultiplyMatrix(ref m, ref cm);
                    }
                    m.Translate(gAsVisual._offset.X, gAsVisual._offset.Y); // Consider having a bit that indicates that we have a non-null offset.
                    g = gAsVisual._parent;
                }
                else
                {
                    // we just hit a Visual3D - use a GeneralTransform to go from 2D -> 3D -> 2D
                    // and then return to the tree using the 2D parent - the general transform will deal with the 
                    // actual transformation.  This Visual3D also must be a Viewport2DVisual3D since this is the only
                    // Visual3D that can have a 2D child.
                    Viewport2DVisual3D gAsVisual3D = g as Viewport2DVisual3D;
                    
                    if (group == null)
                    {
                        group = new GeneralTransformGroup();                        
                    }

                    group.Children.Add(new MatrixTransform(m));
                    m = Matrix.Identity;

                    Visual visualForGenTransform = null;
                    if (embedded2Don3D)
                    {
                        visualForGenTransform = gAsVisual3D.Visual;
                    }
                    else
                    {
                        visualForGenTransform = this;
                        embedded2Don3D = true;
                    }
                    
                    group.Children.Add(new GeneralTransform2DTo3DTo2D(gAsVisual3D, visualForGenTransform));

                    g = VisualTreeHelper.GetContainingVisual2D(gAsVisual3D);
                }
            }

            if (g != ancestor)
            {
                throw new System.InvalidOperationException(SR.Get(inverse ? SRID.Visual_NotADescendant : SRID.Visual_NotAnAncestor));
            }

            // At this point, we will have 0 or more transforms in the GeneralTransformGroup
            // and the matrix which, if not identity, should be appended to the GeneralTransformGroup.
            // If, as is commonly the case, this loop terminates without encountering a bitmap effect
            // we will simply use the Matrix.

            // Assert that a non-null group implies at least one child
            Debug.Assert((group == null) || (group.Children.Count > 0));

            // Do we have a group?
            if (group != null)
            {
                if (!m.IsIdentity)
                {
                    group.Children.Add(new MatrixTransform(m));
                }

                if (inverse)
                {
                    group = (GeneralTransformGroup)group.Inverse;
                }

                // group can be null if it does not have an inverse
                if (group != null)
                {
                    group.Freeze();
                }

                // Initialize out params
                generalTransform = group;
                simpleTransform = new Matrix();
                return false; // simple transform failed
            }
            // If not, the entire transform is stored in the matrix
            else
            {
                // Initialize out params
                generalTransform = null;

                if (inverse)
                {
                    if (!m.HasInverse)
                    {
                        simpleTransform = new Matrix();
                        return false; // inversion failed, so simple transform failed.
                    }

                    m.Invert();
                }

                simpleTransform = m;
                return true; // simple transform succeeded
            }
        }
 public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
 {
     try
     {
         GeneralTransformGroup result = new GeneralTransformGroup();
         result.Children.Add(base.GetDesiredTransform(transform));
         result.Children.Add(new TranslateTransform(_leftOffset, _topOffset));
         return result;
     }
     catch (Exception ex)
     {
         VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "GetDesiredTransform", "VMukti.Presentation.Controls.ModuleExplorer.DragDropAdorner");
         return null;
     }
 }
Пример #25
0
        // provides a transform that goes between the Visual's coordinate space
        // and that after applying the transforms that bring it to outer space.        
        internal GeneralTransform TransformToOuterSpace()
        {
            Matrix m = Matrix.Identity;
            GeneralTransformGroup group = null;
            GeneralTransform result = null;
            
            if (CheckFlagsAnd(VisualFlags.NodeHasEffect))
            {
                Effect effect = EffectField.GetValue(this);
                if (effect != null)
                {
                    GeneralTransform gt = effect.CoerceToUnitSpaceGeneralTransform(
                        effect.EffectMapping,
                        VisualDescendantBounds);

                    Transform affineTransform = gt.AffineTransform;
                    if (affineTransform != null)
                    {
                        Matrix cm = affineTransform.Value;
                        MatrixUtil.MultiplyMatrix(ref m, ref cm);
                    }
                    else
                    {
                        group = new GeneralTransformGroup();
                        group.Children.Add(gt);
                    }
                }
                else
                {
                    BitmapEffectState bitmapEffectState = BitmapEffectStateField.GetValue(this);
                    // If we have an effect on this node and it isn't an Effect, it must be a BitmapEffect.
                    // Since BitmapEffects are deprecated and ignored, they do not change a Visual's transform.
                    Debug.Assert(bitmapEffectState != null);
                }
            }

            Transform transform = TransformField.GetValue(this);
            if (transform != null)
            {
                Matrix cm = transform.Value;
                MatrixUtil.MultiplyMatrix(ref m, ref cm);
            }
            m.Translate(_offset.X, _offset.Y); // Consider having a bit that indicates that we have a non-null offset.

            if (group == null)
            {
                result = new MatrixTransform(m);
            }
            else
            {
                group.Children.Add(new MatrixTransform(m));
                result = group;
            }

            result.Freeze();
            return result;
        }
Пример #26
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        /// <summary>
        /// Add a transform so that the composition adorner gets positioned at the correct spot within the text being edited
        /// </summary>
        /// <param name="transform">
        /// The transform applied to the object the adorner adorns
        /// </param>
        /// <returns>
        /// Transform to apply to the adorner
        /// </returns>
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {            
            TranslateTransform translation;
            GeneralTransformGroup group = new GeneralTransformGroup();

            // Get the matrix transform out, skip all non affine transforms
            Transform t = transform.AffineTransform;
            if (t == null)
            {                
                t = Transform.Identity;                
            }

            // Translate the adorner to (0, 0) point
            translation = new TranslateTransform(-(t.Value.OffsetX), -(t.Value.OffsetY));

            group.Children.Add(translation);

            if (transform != null)
            {
                group.Children.Add(transform);
            }

            return group;
        }
        /// <summary> 
        /// Constructor
        /// </summary> 
        /// <param name="visual3D">The Visual3D that contains the 2D visual</param> 
        /// <param name="fromVisual">The visual on the Visual3D</param>
        internal GeneralTransform2DTo3DTo2D(Viewport2DVisual3D visual3D, Visual fromVisual) 
        {
            IsInverse = false;

            // get a copy of the geometry information - we store our own model to reuse hit 
            // test code on the GeometryModel3D
            _geometry = new MeshGeometry3D(); 
            _geometry.Positions = visual3D.InternalPositionsCache; 
            _geometry.TextureCoordinates = visual3D.InternalTextureCoordinatesCache;
            _geometry.TriangleIndices = visual3D.InternalTriangleIndicesCache; 
            _geometry.Freeze();

            Visual visual3Dchild = visual3D.Visual;
 
            // Special case - Setting CacheMode on V2DV3D causes an internal switch from using a VisualBrush
            // to using a BitmapCacheBrush.  It also introduces an extra 2D Visual in the Visual tree above 
            // the V2DV3D.Visual, but this extra node has no effect on transforms and can safely be ignored. 
            // The transform returned will be identical to the one created for calling TransformTo* with
            // the V2DV3D.Visual itself. 
            Visual descendentVisual = (fromVisual == visual3Dchild._parent) ? visual3Dchild : fromVisual;

            // get a copy of the size of the visual brush and the rect on the
            // visual that the transform is going to/from 

            _visualBrushBounds = visual3Dchild.CalculateSubgraphRenderBoundsOuterSpace(); 
            _visualBounds = descendentVisual.CalculateSubgraphRenderBoundsInnerSpace(); 

            // get the transform that will let us go from the fromVisual to its last 2D 
            // parent before it reaches the 3D part of the graph (i.e. visual3D.Child)
            GeneralTransformGroup transformGroup = new GeneralTransformGroup();
            transformGroup.Children.Add(descendentVisual.TransformToAncestor(visual3Dchild));
            transformGroup.Children.Add(visual3Dchild.TransformToOuterSpace()); 
            transformGroup.Freeze();
            _transform2D = transformGroup; 
 
            // store the inverse as well
            _transform2DInverse = (GeneralTransform)_transform2D.Inverse; 
            if (_transform2DInverse != null)
            {
                _transform2DInverse.Freeze();
            } 

            // make a copy of the camera and other values on the Viewport3D 
            Viewport3DVisual viewport3D = (Viewport3DVisual)VisualTreeHelper.GetContainingVisual2D(visual3D); 

            _camera = viewport3D.Camera; 
            if (_camera != null)
            {
                _camera = (Camera)viewport3D.Camera.GetCurrentValueAsFrozen();
            } 

            _viewSize = viewport3D.Viewport.Size; 
            _boundingRect = viewport3D.ComputeSubgraphBounds3D(); 
            _objectToViewport = visual3D.TransformToAncestor(viewport3D);
 
            // if the transform was not possible, it could be null - check before freezing
            if (_objectToViewport != null)
            {
                _objectToViewport.Freeze(); 
            }
 
            // store the needed transformations for the various operations 
            _worldTransformation = M3DUtil.GetWorldTransformationMatrix(visual3D);
 
            _validEdgesCache = null;
        }
Пример #28
0
        /// <summary>
        /// The returned matrix can be used to transform coordinates from this Visual to
        /// the specified Visual.
        /// Returns null if no such transform exists due to a non-invertible Transform.
        /// </summary>
        /// <exception cref="ArgumentNullException">If visual is null.</exception>
        /// <exception cref="InvalidOperationException">If the Visuals are not connected.</exception>
        public GeneralTransform TransformToVisual(Visual visual)
        {
            DependencyObject ancestor = FindCommonVisualAncestor(visual);
            Visual ancestorAsVisual = ancestor as Visual;

            if (ancestorAsVisual == null)
            {
                throw new System.InvalidOperationException(SR.Get(SRID.Visual_NoCommonAncestor));
            }

            GeneralTransform g0;
            Matrix m0;

            bool isSimple0 = this.TrySimpleTransformToAncestor(ancestorAsVisual,
                                                               false,
                                                               out g0,
                                                               out m0);

            GeneralTransform g1;
            Matrix m1;

            bool isSimple1 = visual.TrySimpleTransformToAncestor(ancestorAsVisual,
                                                                 true,
                                                                 out g1,
                                                                 out m1);

            // combine the transforms
            // if both transforms are simple Matrix transforms, just multiply them and
            // return the result.
            if (isSimple0 && isSimple1)
            {
                MatrixUtil.MultiplyMatrix(ref m0, ref m1);
                MatrixTransform m = new MatrixTransform(m0);
                m.Freeze();
                return m;
            }

            // Handle the case where 0 is simple and 1 is complex.
            if (isSimple0)
            {
                g0 = new MatrixTransform(m0);
                g0.Freeze();
            }
            else if (isSimple1)
            {
                g1 = new MatrixTransform(m1);
                g1.Freeze();
            }

            // If inverse was requested, TrySimpleTransformToAncestor can return null
            // add the transform only if it is not null
            if (g1 != null)
            {
                GeneralTransformGroup group = new GeneralTransformGroup();
                group.Children.Add(g0);
                group.Children.Add(g1);
                group.Freeze();
                return group;
            }

            return g0;
        }
Пример #29
0
 private GeneralTransform GetTabletToElementTransform(IInputElement relativeTo)
 {
     GeneralTransformGroup group = new GeneralTransformGroup();
     group.Children.Add(new MatrixTransform(_stylusLogic.GetTabletToViewTransform(TabletDevice)));
     group.Children.Add(GetElementTransform(relativeTo));
     return group;
 }
Пример #30
0
        //--------------------------------------------------------------
        /// <summary>
        /// Returns a <see cref="Transform"/> for the adorner, based on the transform that is
        /// currently applied to the adorned element.
        /// </summary>
        /// <param name="transform">
        /// The transform that is currently applied to the adorned element.
        /// </param>
        /// <returns>A transform to apply to the adorner.</returns>
        public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
        {
            var baseTransform = base.GetDesiredTransform(transform);
            var localTransform = new TranslateTransform(_horizontalOffset, _verticalOffset);

            if (baseTransform != null)
            {
                // Add translation to original transform.
                var result = new GeneralTransformGroup();
                result.Children.Add(baseTransform);
                result.Children.Add(localTransform);
                return result;
            }

            return localTransform;
        }