Exemple #1
0
            /// <summary>
            /// Set the new position in the placement
            /// </summary>
            public void Commit(MoveMouseHandler handler)
            {
                var location = lastCommitLocation;
                var rect     = GetNewBounds(handler);
                var dx       = rect.X - location.X;
                var dy       = rect.Y - location.Y;

                handler.Move(placement, dx, dy);
                lastCommitLocation = newLocation;
            }
Exemple #2
0
            /// <summary>
            /// Gets the new bounds of the placement.
            /// </summary>
            public Rectangle GetNewBounds(MoveMouseHandler handler)
            {
                var newBounds = new Rectangle(newLocation, placement.Item.Size);

                // Snap to other items

                // First try top-left
                var pt       = new Point(newBounds.Left, newBounds.Top);
                var sPt      = handler.SnapPoint(pt);
                var snappedX = false;
                var snappedY = false;

                if (pt.X != sPt.X)
                {
                    // Snap to left
                    newBounds.X = sPt.X;
                    snappedX    = true;
                }
                if (pt.Y != sPt.Y)
                {
                    // Snap to top
                    newBounds.Y = sPt.Y;
                    snappedY    = true;
                }

                // Now try bottom-right
                if (!(snappedX && snappedY))
                {
                    pt  = new Point(newBounds.Right, newBounds.Bottom);
                    sPt = handler.SnapPoint(pt);
                    if ((!snappedX) && (pt.X != sPt.X))
                    {
                        // Snap to right
                        newBounds.X = sPt.X - newBounds.Width;
                    }
                    if ((!snappedY) && (pt.Y != sPt.Y))
                    {
                        // Snap to bottom
                        newBounds.Y = sPt.Y - newBounds.Height;
                    }
                }
                return(newBounds);
            }
Exemple #3
0
            /// <summary>
            /// Move the placement
            /// </summary>
            public void Move(float dx, float dy, MoveMouseHandler handler)
            {
                var pt = handler.LimitMoveToPosition(new Point((int)(startLocation.X + dx), (int)(startLocation.Y + dy)));

                newLocation = pt;
            }