public BlockAttributes EffectiveAttribute() { if (elements.Count == 0) { return(BlockAttributes.Stack); } IInvokationBlockView first = (IInvokationBlockView)elements[0]; IInvokationBlockView last = (IInvokationBlockView)elements.Last(); bool connectAbove = first.Attribute != BlockAttributes.Hat; bool connectBelow = last.Attribute != BlockAttributes.Cap; if (connectAbove && connectBelow) { return(BlockAttributes.Stack); } else if (connectBelow) { return(BlockAttributes.Hat); } else if (connectAbove) { return(BlockAttributes.Cap); } else { throw new InvalidOperationException("What's a reporter block doing in a BlockStack?"); } }
void InvokationBlock_ArgChanged(object sender, int arg, IBlock _old, IBlock _new) { IBlockView v = ViewFromBlock(_new); IInvokationBlockView parent = (IInvokationBlockView)ViewFromBlock((IBlock)sender); parent.SetArgView(arg, v); modified(); }
public static IEnumerable <DropRegion> EdgeDropRegions( this IInvokationBlockView view, Point origin, Size size) { BlockAttributes Attribute = view.Attribute; int Width = size.Width; int Height = size.Height; if (Attribute == BlockAttributes.Stack) { yield return(new DropRegion(DropType.Above, new Rectangle(origin.Offseted(0, -2), new Size(Width, 5)), view)); yield return(new DropRegion(DropType.Below, new Rectangle(origin.Offseted(0, Height - 2), new Size(Width, 5)), view)); } else if (Attribute == BlockAttributes.Hat) { yield return(new DropRegion(DropType.Below, new Rectangle(origin.Offseted(0, Height - 2), new Size(Width, 5)), view)); } else if (Attribute == BlockAttributes.Cap) { yield return(new DropRegion(DropType.Above, new Rectangle(origin.Offseted(0, -2), new Size(Width, 5)), view)); } }