public UIDragHandler(UIElement mouseTarget, UIElement dragControl) { UpdateHook = new UpdateHookDelegate(Update); MouseTarget = mouseTarget; DragControl = dragControl; MouseEvent = mouseTarget.ListenForMouse(mouseTarget.GetBounds(), new UIMouseEvent(DragMouseEvents)); }
public void CenterAround(UIElement element, int offsetX, int offsetY) { var bounds = element.GetBounds(); if (bounds == null) { return; } var topLeft = element.LocalPoint(new Microsoft.Xna.Framework.Vector2(bounds.X, bounds.Y)); this.X = offsetX + topLeft.X + ((bounds.Width - this.Width) / 2); this.Y = offsetY + topLeft.Y + ((bounds.Height - this.Height) / 2); }