Azmyth.Editor.Grid.GetCellX C# (CSharp) Méthode

GetCellX() private méthode

private GetCellX ( System p ) : int
p System
Résultat int
        private int GetCellX(System.Drawing.Point p)
        {
            int x = 0;

                m_mouseX = p.X;

                // We add a cell to the offset so that when the viewport and the grid are perfectly aligned the modulo
                // returns 0 instead of 16.  I substract this out from p.X to get the mouse position as it lies in the
                // entirely visible grid.
                m_mouseOffsetX = p.X - GetPartialCellSizeX();

                // Just doing a simple division works for m_mouseOffsetX > 0. But when a partially visible cell is selected
                // m_mouseOffsetX will be negative and -10 / 16 = 0, not -1.
                int cellX = (int)System.Math.Floor((((double)m_mouseOffsetX) / ((double)m_cellSize)));

                x = m_cellOffsetX - cellX;

                return x * -1;
        }