Beispiel #1
0
        private IDropTarget findDropTarget(AbstractBlock draggedData)
        {
            if (draggedData == null)
                return null;

            foreach (AbstractBlock target in _lDropTarget)
            {
                if (draggedData == target)
                    continue;
                if (!target.IsAllowBlockType(draggedData))
                    continue;

                Rect bigBlockRect;
                AbstractBlock smallBlock = null;
                if (target.Width < draggedData.Width)
                {
                    bigBlockRect = draggedData.GetRect();
                    smallBlock = target;
                }
                else
                {
                    bigBlockRect = target.GetRect();
                    smallBlock = draggedData;
                }

                if (bigBlockRect.Contains(smallBlock.GetLeftTop())
                    || bigBlockRect.Contains(smallBlock.GetRightTop())
                    || bigBlockRect.Contains(smallBlock.GetLeftBottom())
                    || bigBlockRect.Contains(smallBlock.GetRightBottom()))
                {
                    return target as IDropTarget;
                }
            }
            return null;
        }