コード例 #1
0
ファイル: MoveLogic.cs プロジェクト: windcatcher/SharpDevelop
        bool ChangeContainerIfPossible(Point p)
        {
            DesignPanelHitTestResult result = HitTestUnselectedModel(p);

            if (result.ModelHit == null)
            {
                return(false);
            }
            if (result.ModelHit == operation.CurrentContainer)
            {
                return(false);
            }

            // check that we don't move an item into itself:
            DesignItem tmp = result.ModelHit;

            while (tmp != null)
            {
                if (tmp == clickedOn)
                {
                    return(false);
                }
                tmp = tmp.Parent;
            }

            IPlacementBehavior b = result.ModelHit.GetBehavior <IPlacementBehavior>();

            if (b != null && b.CanEnterContainer(operation, false))
            {
                operation.ChangeContainer(result.ModelHit);
                return(true);
            }
            return(false);
        }