Azmyth.Editor.Grid.Grid_MouseUp C# (CSharp) Method

Grid_MouseUp() private method

private Grid_MouseUp ( object sender, MouseEventArgs e ) : void
sender object
e MouseEventArgs
return void
        private void Grid_MouseUp(object sender, MouseEventArgs e)
        {
            if (m_dragging)
                {
                    m_dragging = false;
                    Invalidate();
                }
                if (m_selecting)
                {
                    m_selecting = false;

                    if (selection.X == m_selectionStartX && selection.Width % m_cellSize != 0)
                    {
                        var nextWholeCellSnapX = m_cellSize - (selection.Width % m_cellSize);
                        selection.Width += nextWholeCellSnapX;
                    }
                    else if (e.Location.X < m_selectionStartX)
                    {
                        var nextWholeCellSnapX = selection.X % m_cellSize;
                        nextWholeCellSnapX += (m_cellSize - GetPartialCellSizeX());
                        nextWholeCellSnapX %= m_cellSize;
                        selection.X -= nextWholeCellSnapX;
                        selection.Width += nextWholeCellSnapX;
                    }

                    if (selection.Y == m_selectionStartY && selection.Height % m_cellSize != 0)
                    {
                        var nextWholeCellSnapY = m_cellSize - (selection.Height % m_cellSize);
                        selection.Height += nextWholeCellSnapY;
                    }
                    else if (e.Location.Y < m_selectionStartY)
                    {
                        var nextWholeCellSnapY = selection.Y % m_cellSize;
                        nextWholeCellSnapY += (m_cellSize - GetPartialCellSizeY());
                        nextWholeCellSnapY %= m_cellSize;
                        selection.Y -= nextWholeCellSnapY;
                        selection.Height += nextWholeCellSnapY;
                    }

                    Invalidate();
                }
        }