Пример #1
0
        bool TryGetInvertedTransform(CompositionVisual visual, out Matrix matrix)
        {
            var m = visual.TryGetServerGlobalTransform();

            if (m == null)
            {
                matrix = default;
                return(false);
            }

            var m33 = MatrixUtils.ToMatrix(m.Value);

            return(m33.TryInvert(out matrix));
        }
Пример #2
0
        /// <summary>
        /// Attempts to transform a point to a particular CompositionVisual coordinate space
        /// </summary>
        /// <returns></returns>
        public Point?TryTransformToVisual(CompositionVisual visual, Point point)
        {
            if (visual.Root != this)
            {
                return(null);
            }
            var v = visual;
            var m = Matrix.Identity;

            while (v != null)
            {
                if (!TryGetInvertedTransform(v, out var cm))
                {
                    return(null);
                }
                m = m * cm;
                v = v.Parent;
            }

            return(point * m);
        }
Пример #3
0
        void HitTestCore(CompositionVisual visual, Point globalPoint, PooledList <CompositionVisual> result,
                         Func <IVisual, bool>?filter)
        {
            if (visual.Visible == false)
            {
                return;
            }
            if (!TryTransformTo(visual, globalPoint, out var point))
            {
                return;
            }

            if (visual.ClipToBounds &&
                (point.X < 0 || point.Y < 0 || point.X > visual.Size.X || point.Y > visual.Size.Y))
            {
                return;
            }

            if (visual.Clip?.FillContains(point) == false)
            {
                return;
            }

            // Inspect children
            if (visual is CompositionContainerVisual cv)
            {
                for (var c = cv.Children.Count - 1; c >= 0; c--)
                {
                    var ch = cv.Children[c];
                    HitTestCore(ch, globalPoint, result, filter);
                }
            }

            // Hit-test the current node
            if (visual.HitTest(point, filter))
            {
                result.Add(visual);
            }
        }
Пример #4
0
 partial void OnRemoved(CompositionVisual item) => item.Parent = null;
Пример #5
0
 partial void OnAdded(CompositionVisual item) => item.Parent = _owner;
Пример #6
0
 public void InsertAtBottom(CompositionVisual newChild) => Insert(0, newChild);
Пример #7
0
 public void InsertAtTop(CompositionVisual newChild) => Insert(_list.Count, newChild);
Пример #8
0
 internal CompositionVisualCollection(CompositionVisual parent, ServerCompositionVisualCollection server) : base(parent.Compositor, server)
 {
     _owner = parent;
     InitializeDefaults();
 }