Пример #1
0
        void HitTest(Point hitPoint)
        {
            if (_spriteTarget != null)
            {
                _spriteTarget.IsDragConnectionOver = false;
                _spriteTarget = null;
            }

            if (_jackTarget != null)
            {
                _jackTarget.IsConnectionOver = false;
                _jackTarget = null;
            }

            VisualTreeHelper.HitTest(_adornedElement,
                                     new HitTestFilterCallback(HitTestFilter),
                                     result => HitTestResultBehavior.Continue,
                                     new PointHitTestParameters(hitPoint));

            if (_adornedElement.InputHitTest(hitPoint) is DependencyObject inputElement)
            {
                var contentControl = VisualFinder.GetAncestor <ContentControl>(inputElement);
                if (contentControl != null)
                {
                    _spriteTarget = contentControl.DataContext as ISpriteVM;
                    if (_spriteTarget != null)
                    {
                        _spriteTarget.IsDragConnectionOver = true;
                    }
                }
            }
        }
Пример #2
0
        public ConnectorAdorner(UIElement adornedElement, Point?startPoint, Jack jackSource, ISpriteVM spriteSource)
            : base(adornedElement)
        {
            _adornedElement = adornedElement;
            _startPoint     = startPoint;
            _jackSource     = jackSource;
            _spriteSource   = spriteSource;

            Cursor = Cursors.Cross;

            _jackSource.IsConnectionOver = true;
        }
Пример #3
0
        HitTestFilterBehavior HitTestFilter(DependencyObject o)
        {
            if (o.GetType() == typeof(Jack))
            {
                _jackTarget = (Jack)o;
                if (ReferenceEquals(_jackTarget, _jackSource))
                {
                    return(HitTestFilterBehavior.ContinueSkipSelfAndChildren);
                }
                _jackTarget.IsConnectionOver = true;

                var contentControl = VisualFinder.GetAncestor <ContentControl>(_jackTarget);
                _spriteTarget = contentControl.DataContext as ISpriteVM;
                if (_spriteTarget != null)
                {
                    _spriteTarget.IsDragConnectionOver = true;
                }

                return(HitTestFilterBehavior.ContinueSkipSelfAndChildren);
            }

            return(HitTestFilterBehavior.Continue);
        }