Beispiel #1
0
        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);
                }
            }
        }
Beispiel #2
0
        private void SetScriptView(int i, IStackableBlockView v)
        {
            IBlockView oldView = Scripts[i];

            if (!(oldView.Parent == this))
            {
                throw new InvalidOperationException("How did the parent of my arg not be me??");
            }
            oldView.Parent   = null;
            oldView.Changed -= subView_Changed;

            if (v.Parent != null)
            {
                v.Changed -= ((CBlockView)v.Parent).subView_Changed;
            }
            v.Changed += new ViewChangedEvent(subView_Changed);
            v.Parent   = this;
            Scripts[i] = v;

            Reassemble();
            Changed(this);
        }
Beispiel #3
0
        private void SetScriptView(int i, IStackableBlockView v)
        {
            IBlockView oldView = Scripts[i];
            if (!(oldView.Parent == this))
            {
                throw new InvalidOperationException("How did the parent of my arg not be me??");
            }
            oldView.Parent = null;
            oldView.Changed -= subView_Changed;

            if (v.Parent != null)
            {
                v.Changed -= ((CBlockView)v.Parent).subView_Changed;
            }
            v.Changed += new ViewChangedEvent(subView_Changed);
            v.Parent = this;
            Scripts[i] = v;

            Reassemble();
            Changed(this);
        }
Beispiel #4
0
 public static bool HasBottomNotch(this IStackableBlockView v)
 {
     return(v.EffectiveAttribute() == BlockAttributes.Hat ||
            v.EffectiveAttribute() == BlockAttributes.Stack);
 }