public IEnumerable <DropRegion> DropRegions(Point origin) { if (elements.Count == 0) { yield break; } else { bool connectAbove = false, connectBelow = false; IStackableBlockView first = (IStackableBlockView)elements[0]; IStackableBlockView last = (IStackableBlockView)elements.Last(); connectAbove = first.EffectiveAttribute() != BlockAttributes.Hat; connectBelow = last.EffectiveAttribute() != BlockAttributes.Cap; if (connectAbove) { yield return(new DropRegion(DropType.Above, new Rectangle(origin.Offseted(0, -2), new Size(_cached.Width, 5)), this)); } int y = origin.Y + elementBitmaps[0].Height - BlockStackView.NotchHeight; for (int i = 1; i < elements.Count; ++i) { yield return(new DropRegion(DropType.Between, new Rectangle(origin.X, y - 2, elementBitmaps[i].Width, 5), this, i)); y += elementBitmaps[i].Height - BlockStackView.NotchHeight; } if (connectBelow) { yield return(new DropRegion(DropType.Below, new Rectangle(origin.Offseted(0, _cached.Height - 2), new Size(_cached.Width, 5)), this)); } foreach (DropRegion r in ChildDropRegions(origin)) { yield return(r); } } }
public static bool HasBottomNotch(this IStackableBlockView v) { return(v.EffectiveAttribute() == BlockAttributes.Hat || v.EffectiveAttribute() == BlockAttributes.Stack); }