Beispiel #1
0
 private bool FindActiveDropRegion(Rectangle rect, out DropRegion ret)
 {
     foreach (DropRegion dr in DropRegions)
     {
         if (EffectiveDropRegion(rect, dr))
         {
             canvasView.SetDropRegion(dr);
             ret = dr;
             return(true);
         }
     }
     canvasView.ResetDropRegion();
     ret = new DropRegion();
     return(false);
 }
Beispiel #2
0
        private void ConnectBlocks(DropRegion dr, TopLevelScript block)
        {
            Point destinationLoc = new Point();

            if (allViews.ContainsKey(dr.Destination))
            {
                destinationLoc = allViews[dr.Destination];
            }
            int sourceHeight = blockViews[block.Block].Assemble().Height;

            switch (dr.DropType)
            {
            case DropType.Above:

                IBlock finalStack = blockSpace.StackAbove(block, dr.Destination.Model);
                if (finalStack.ParentRelationship.Type == ParentRelationshipType.None)
                {
                    // We've stacked A above B, we need to reposition the result so that
                    // B's old location stays the same
                    TopLevelScript ts = blockSpace.FindScript(finalStack);
                    ts.Location = new Point(destinationLoc.X, destinationLoc.Y - sourceHeight + BlockStackView.NotchHeight);
                }
                break;

            case DropType.Below:
                blockSpace.StackBelow(block, dr.Destination.Model);
                break;

            case DropType.Between:
                blockSpace.RemoveScript(draggedModel);
                (dr.Destination.Model as BlockStack).Insert((int)dr.ExtraInfo, block.Block);
                break;

            case DropType.AsArgument:
                blockSpace.RemoveScript(draggedModel);
                (dr.Destination.Model as InvokationBlock).SetArg((int)dr.ExtraInfo, block.Block);
                break;
            }
        }
Beispiel #3
0
 public void SetDropRegion(DropRegion dr)
 {
     CurrentDropRegion = dr;
     activeDropRegion  = true;
 }
Beispiel #4
0
        private bool FindActiveDropRegion(Rectangle rect, out DropRegion  ret)
        {
            foreach (DropRegion dr in DropRegions)
            {
                if (EffectiveDropRegion(rect, dr))
                {
                    canvasView.SetDropRegion(dr);
                    ret = dr;
                    return true;
                }

            }
            canvasView.ResetDropRegion();
            ret = new DropRegion();
            return false;
        }
Beispiel #5
0
        private void ConnectBlocks(DropRegion dr, TopLevelScript block)
        {
            Point destinationLoc = new Point();
            if(allViews.ContainsKey(dr.Destination))
                destinationLoc = allViews[dr.Destination];
            int sourceHeight = blockViews[block.Block].Assemble().Height;
            switch (dr.DropType)
            {
                case DropType.Above:

                    IBlock finalStack = blockSpace.StackAbove(block, dr.Destination.Model);
                    if (finalStack.ParentRelationship.Type == ParentRelationshipType.None)
                    {
                        // We've stacked A above B, we need to reposition the result so that
                        // B's old location stays the same
                        TopLevelScript ts = blockSpace.FindScript(finalStack);
                        ts.Location = new Point(destinationLoc.X, destinationLoc.Y - sourceHeight + BlockStackView.NotchHeight);
                    }
                    break;
                case DropType.Below:
                    blockSpace.StackBelow(block, dr.Destination.Model);
                    break;
                case DropType.Between:
                    blockSpace.RemoveScript(draggedModel);
                    (dr.Destination.Model as BlockStack).Insert((int)dr.ExtraInfo, block.Block);
                    break;
                case DropType.AsArgument:
                    blockSpace.RemoveScript(draggedModel);
                    (dr.Destination.Model as InvokationBlock).SetArg((int)dr.ExtraInfo, block.Block);
                    break;
            }
        }
Beispiel #6
0
 private static bool EffectiveDropRegion(Rectangle rect, DropRegion dr)
 {
     switch (dr.DropType)
     {
         case DropType.Above:
             if (rect.BottomSlice(5).IntersectsWith(dr.Rectangle))
             {
                 return true;
             }
             break;
         case DropType.Below:
         case DropType.Between:
             if (rect.TopSlice(5).IntersectsWith(dr.Rectangle))
             {
                 return true; ;
             }
             break;
         case DropType.AsArgument:
             if (rect.IntersectsWith(dr.Rectangle))
             {
                 return true; ;
             }
             break;
     }
     return false;
 }
Beispiel #7
0
 public void SetDropRegion(DropRegion dr)
 {
     CurrentDropRegion = dr;
     activeDropRegion = true;
 }