public bool TryNavigateEnter(NavigationDirection StartingSide, Rectangle?ClosestTo) { IsGamepadFocused = true; IsNavigatingWithGamepad = true; if (ClosestTo.HasValue) { List <Rectangle> AllSlots = TaskHeaderPositions.Select(x => x.Value).Union(ItemSlotPositions.Select(x => x.Value)).ToList(); Rectangle ToSelect = AllSlots.OrderBy(x => x.GetOffseted(TopLeftScreenPosition).SquaredDistanceBetweenCenters(ClosestTo.Value)).First(); foreach (KeyValuePair <BundleItem, Rectangle> KVP in ItemSlotPositions) { if (KVP.Value == ToSelect) { HoveredBundleItem = KVP.Key; HoveredBundleTask = null; return(true); } } foreach (KeyValuePair <BundleTask, Rectangle> KVP in TaskHeaderPositions) { if (KVP.Value == ToSelect) { HoveredBundleTask = KVP.Key; HoveredBundleItem = null; return(true); } } } 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 = TaskHeaderPositions.Select(x => x.Value).Union(ItemSlotPositions.Select(x => x.Value)).Union(LockedSlotPositions) .OrderBy(x => x.Top).ThenBy(x => x.Left).ToList(); return(GamepadControls.TryGetSlotNeighbor(AllSlots, ItemSlot, ColumnCount, Direction, HorizontalWrapping, VerticalWrapping, out Neighbor)); }