コード例 #1
0
        public static bool AllowMoving(BaseLayoutItem item, BaseLayoutItem target)
        {
            bool result = false;

            if (target == null)
            {
                return(false);
            }
            if (DragHelper.IsItemInGroup(item) && DragHelper.IsTargetInGroup(target) && (target is LayoutControlItem))
            {
                return(true);
            }
            BaseLayoutItem draggedItem = null, targetItem = null;

            if (item is LayoutControlItem)
            {
                draggedItem = item as LayoutControlItem;
                if (target is LayoutControlItem)
                {
                    targetItem = target as LayoutControlItem;
                    if (targetItem.Parent == draggedItem.Parent)
                    {
                        result = true;
                    }
                }
                if (target is LayoutGroup)
                {
                    targetItem = target as LayoutGroup;
                    if (targetItem.Parent == draggedItem.Parent)
                    {
                        result = true;
                    }
                }
            }
            if (item is LayoutGroup)
            {
                draggedItem = item as LayoutGroup;
                if (target is LayoutControlItem)
                {
                    targetItem = target as LayoutControlItem;
                    if (targetItem.Parent == draggedItem.Parent)
                    {
                        result = true;
                    }
                }
                if (target is LayoutGroup)
                {
                    targetItem = target as LayoutGroup;
                    if (targetItem.Parent == draggedItem.Parent)
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
        public override bool CanDrop(Point point, ILayoutElement element)
        {
            DockLayoutElementDragInfo dockLayoutElementDragInfo = new DockLayoutElementDragInfo(this.View, point, element);
            BaseLayoutItem            draggedItem = dockLayoutElementDragInfo.Item;
            BaseLayoutItem            target      = dockLayoutElementDragInfo.Target;

            if (!DragHelper.IsItemInGroup(draggedItem) && !DragHelper.IsTargetInGroup(target))
            {
                return(base.CanDrop(point, element));
            }
            bool result = DragHelper.AllowMoving(draggedItem, target);

            return(result);
        }
        public override bool CanDrop(Point point, ILayoutElement element)
        {
            DockLayoutElementDragInfo dockLayoutElementDragInfo = new DockLayoutElementDragInfo(base.View, point, element);
            var draggedItem = dockLayoutElementDragInfo.Item;
            var target      = dockLayoutElementDragInfo.Target;

            if ((dockLayoutElementDragInfo.DropTarget is HiddenItemElement || dockLayoutElementDragInfo.DropTarget is HiddenItemsListElement) && dockLayoutElementDragInfo.Item.AllowHide)
            {
                LayoutItemType itemType = dockLayoutElementDragInfo.Item.ItemType;
                return(LayoutItemsHelper.IsLayoutItem(dockLayoutElementDragInfo.Item) || itemType == LayoutItemType.Group);
            }
            if (!DragHelper.IsItemInGroup(draggedItem) && !DragHelper.IsTargetInGroup(target))
            {
                return(base.CanDrop(point, element));
            }
            return(DragHelper.AllowMoving(draggedItem, target));
        }