예제 #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////
        // CHESSBOARD METHODS
        //////////////////////////////////////////////////////////////////////////////////////////////////
        // update our status bar
        private void Chessboard_MouseMove(object sender, MouseEventArgs e)
        {
            int curCol = Etc.Clamp(this.Chessboard.GetMouseColPosition(), 0, 7) /*+ 1*/;
            int curRow = Etc.Clamp(this.Chessboard.GetMouseRowPosition(), 0, 7) /*+ 1*/;
            int curSqu = Etc.Clamp(this.Chessboard.GetMouseSquarePosition(), 0, 63) /*+ 1*/;

            this.toolStripStatusLabel1.Text = "Column: " + curCol.ToString() + " row: " + curRow.ToString() + " square: " + curSqu.ToString();
        }
예제 #2
0
        // handles mouse mouse event
        private void Chessboard_MouseMove(object sender, MouseEventArgs e)
        {
            // get local mouse location
            m_LocalMousePosition = PointToClient(MousePosition);

            // clamp location
            m_LocalMousePosition.X = Etc.Clamp(m_LocalMousePosition.X, 1, this.Width);
            m_LocalMousePosition.Y = Etc.Clamp(m_LocalMousePosition.Y, 1, this.Height);

            // invert Y coordinate
            m_LocalMousePosition.Y = this.Height - m_LocalMousePosition.Y;

            // update mouse down offset
            if (m_bMouseDown)
            {
                m_PieceOffsetX = m_LocalMousePosition.X - m_MouseDownPosX;
                m_PieceOffsetY = this.Height - m_LocalMousePosition.Y - m_MouseDownPosY;
            }

            // make board repaint when the mouse moves
            this.Invalidate(new Rectangle(0, 0, this.Width, this.Height));
        }