public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo) { IsGamepadFocused = true; IsNavigatingWithGamepad = true; if (ClosestTo.HasValue) { List <Rectangle> AllSlots = SlotBounds.Union(LockedSlotBounds).OrderBy(x => x.Top).ThenBy(x => x.Left).ToList(); HoveredSlot = AllSlots.OrderBy(x => x.SquaredDistanceBetweenCenters(ClosestTo.Value)).First(); } else { if (StartingSide == NavigationDirection.Right) { while (TryNavigate(NavigationDirection.Right, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap)) { } } if (StartingSide == NavigationDirection.Down) { while (TryNavigate(NavigationDirection.Down, NavigationWrappingMode.NoWrap, NavigationWrappingMode.NoWrap)) { } } } return(true); }
public bool TryGetSlotNeighbor(Rectangle?ItemSlot, NavigationDirection Direction, NavigationWrappingMode HorizontalWrapping, NavigationWrappingMode VerticalWrapping, out Rectangle?Neighbor) { List <Rectangle> AllSlots = SlotBounds.Union(LockedSlotBounds).OrderBy(x => x.Top).ThenBy(x => x.Left).ToList(); return(GamepadControls.TryGetSlotNeighbor(AllSlots, ItemSlot, ColumnCount, Direction, HorizontalWrapping, VerticalWrapping, out Neighbor)); }