Пример #1
0
        public override IDropLocation GetDropLocation(Point cursor)
        {
            StackPanelDropLocation dropTarget = GetDropLocationCore(cursor);

            if (dropTarget != null && dropTarget.IsNearby())
            {
                dropTarget = null;
            }

            return(dropTarget);
        }
Пример #2
0
        private StackPanelDropLocation GetDropLocationCore(Point cursor)
        {
            StackPanelDropLocation dropTarget = null;

            if (DragManager.DraggedElement.IsElementInSubtree(this))
            {
                return(null);
            }

            if (Children.Count == 0)
            {
                dropTarget = new StackPanelDropLocation(
                    this,
                    0,
                    PointSituationRelativeToRect.Fill,
                    GetMarkerCoordinates(new Rect(), true));
            }

            int i = 0;

            foreach (FrameworkElement child in Children)
            {
                var classification = ClassifyPoint(cursor, childPositions[i]);
                if (classification == PointSituationRelativeToRect.Before)
                {
                    dropTarget = new StackPanelDropLocation(this, i, classification, GetMarkerCoordinates(childPositions[i], true));
                    return(dropTarget);
                }
                if (i == Children.Count - 1 && classification == PointSituationRelativeToRect.After)
                {
                    dropTarget = new StackPanelDropLocation(this, i, classification, GetMarkerCoordinates(childPositions[i], false));
                    return(dropTarget);
                }
                i++;
            }
            return(dropTarget);
        }