/// <summary><c>HexCoords</c> for the hex at the screen point, with the given AutoScroll position.</summary> /// <param name="this"></param> /// <param name="point">Screen point specifying hex to be identified.</param> /// <param name="autoScroll">AutoScrollPosition for game-display Panel.</param> static HexCoords GetHexCoordsInner(this IHexgrid @this, HexPoint point, HexSize autoScroll) { // Adjust for origin not as assumed by GetCoordinate(). var grid = new HexSize((int)(@this.GridSizeF().Width *2F / 3F), (int)@this.GridSizeF().Height); point -= autoScroll + grid - @this.Margin; return(HexCoords.NewCanonCoords(@this.GetCoordinate(@this.MatrixX(), point), @this.GetCoordinate(@this.MatrixY(), point))); }
/// <inheritdoc/> public virtual HexCoords GetHexCoords(HexPointF point, HexSizeF autoScroll) { // Adjust for origin not as assumed by GetCoordinate(). var grid = new HexSizeF(GridSizeF.Width * 2F / 3F, GridSizeF.Height); point -= autoScroll + grid - new HexSizeF(Margin.Width, Margin.Height); return(HexCoords.NewCanonCoords(GetCoordinate(_matrixX, point), GetCoordinate(_matrixY, point))); }
/// <inheritdoc/> public virtual HexCoords GetHexCoords(Point point, Size autoScroll) { if (Host == null) { return(HexCoords.EmptyCanon); } // Adjust for origin not as assumed by GetCoordinate(). var grid = new Size((int)(Host.GridSizeF.Width * 2F / 3F), (int)Host.GridSizeF.Height); var margin = new Size((int)(Host.MapMargin.Width * Host.MapScale), (int)(Host.MapMargin.Height * Host.MapScale)); point -= autoScroll + margin + grid; return(HexCoords.NewCanonCoords(GetCoordinate(matrixX, point), GetCoordinate(matrixY, point))); }