예제 #1
0
 protected virtual PointHitTestResult HitTestCore(PointHitTestParameters param)
 {
     if (GetHitTestBounds().Contains(param.HitPoint))
     {
         return(new PointHitTestResult(param.HitPoint, this));
     }
     return(null);
 }
예제 #2
0
        protected virtual HitTestResultBehavior HitTestOverride(PointHitTestParameters param, HitTestFilterCallback <Visual> filter, HitTestResultCallback <PointHitTestResult> resultCallback)
        {
            var hitTestResult = HitTestCore(param);

            if (hitTestResult != null)
            {
                return(resultCallback(hitTestResult));
            }
            return(HitTestResultBehavior.Continue);
        }
예제 #3
0
        private HitTestResultBehavior HitTestPoint(PointHitTestParameters param, HitTestFilterCallback <Visual> filter, HitTestResultCallback <PointHitTestResult> resultCallback)
        {
            if (_bboxSubgraph.Contains(param.HitPoint))
            {
                var hitTestFilterBehavior = HitTestFilterBehavior.Continue;
                if (filter != null)
                {
                    hitTestFilterBehavior = filter(this);
                    if (hitTestFilterBehavior == HitTestFilterBehavior.ContinueSkipSelfAndChildren)
                    {
                        return(HitTestResultBehavior.Continue);
                    }
                    if (hitTestFilterBehavior == HitTestFilterBehavior.Stop)
                    {
                        return(HitTestResultBehavior.Stop);
                    }
                }
                var hitPoint = param.HitPoint;
                var point    = hitPoint;

                if (hitTestFilterBehavior != HitTestFilterBehavior.ContinueSkipChildren)
                {
                    foreach (var child in VisualChildren)
                    {
                        var childPoint = point - child.VisualOffset;
                        param.SetHitPoint(childPoint);
                        var hitTestResultBehavior = child.HitTestPoint(param, filter, resultCallback);
                        param.SetHitPoint(hitPoint);
                        if (hitTestResultBehavior == HitTestResultBehavior.Stop)
                        {
                            return(HitTestResultBehavior.Stop);
                        }
                    }
                }

                if (hitTestFilterBehavior != HitTestFilterBehavior.ContinueSkipSelf)
                {
                    param.SetHitPoint(point);
                    var hitTestResultBehavior = this.HitTestOverride(param, filter, resultCallback);
                    param.SetHitPoint(hitPoint);
                    if (hitTestResultBehavior == HitTestResultBehavior.Stop)
                    {
                        return(HitTestResultBehavior.Stop);
                    }
                }
            }
            return(HitTestResultBehavior.Continue);
        }
예제 #4
0
 public static void HitTest(Visual visual, PointHitTestParameters param, HitTestFilterCallback <Visual> filter, HitTestResultCallback <PointHitTestResult> resultCallback)
 {
     visual.HitTest(param, filter, resultCallback);
 }
예제 #5
0
 protected virtual PointHitTestResult HitTestOverride(PointHitTestParameters param)
 {
     return(null);
 }
예제 #6
0
 internal void HitTest(PointHitTestParameters param, HitTestFilterCallback <Visual> filter, HitTestResultCallback <PointHitTestResult> resultCallback)
 {
     Precompute();
     HitTestPoint(param, filter, resultCallback);
 }