Beispiel #1
0
        private void MagnetBot(object source, BaseShape other)
        {
            if (other == null)
            {
                return;
            }


            //determine relationship for pivot and its new head.
            if (other.IsTail())
            {
                //other is a single
                //calculate the position of pivot.
                _pivot.X = other.X;
                var delta = Math.Abs(other.InnerLowerY + 8.8 - _pivot.Y);
                _pivot.Y = other.InnerLowerY + 8.8;
                //calculate the next shape head by pivot.
                _pivot.DoAllWithoutHead(i =>
                {
                    i.X  = other.X;
                    i.Y -= delta;
                });
            }
            else
            {
                // when drag pivot in middle of two shape

                //calculate the position of pivot.
                _pivot.X = other.X;
                var delta = Math.Abs(other.InnerLowerY + 8.8 - _pivot.Y);
                _pivot.Y = other.InnerLowerY + 8.8;

                double totalHeight = 0;
                _pivot.DoAllWithoutHead(i =>
                {
                    i.X          = other.X;
                    i.Y         -= delta;
                    totalHeight += i.Height + 8.8;
                });
                other.Next.Y += totalHeight;

                //calculate the next shape head by pivot.
                var next = other.Next;
                next.Prev = _pivot.GetTail();
                _pivot.GetTail().Next = next;
            }
            other.Next         = _pivot;
            _pivot.Prev        = other;
            _pivot.StrokeColor = Transparent;
            other.StrokeColor  = Transparent;
            _previousState.Clear();
        }
Beispiel #2
0
        private void LightBorderAndPush(bool needPushAll, BaseShape other)
        {
            if (needPushAll)
            {
                other.Y += _pivot.Height + 8.8;
            }

            other.DoAllWithoutHead(i => i.Y += _pivot.Height + 8.8);
        }