Esempio n. 1
0
        private void DeckPictureBoxMouseMove(object sender, MouseEventArgs e)
        {
            // Existe algum comboio selecionado?
            if (CombSelec != -1)
            {
                // O Jogador está a selecionar alguma célula do tabuleiro?
                if (GraphicContext.GetCoorX(this, DeckPictureBox) != -1 && GraphicContext.GetCoorY(this, DeckPictureBox) != -1)
                {
                    // O rato mexeu-se?
                    if (GraphicContext.GetCell(GraphicContext.GetCoorX(this, DeckPictureBox)) != mouseCellX || GraphicContext.GetCell(GraphicContext.GetCoorY(this, DeckPictureBox)) != mouseCellY)
                    {
                        // Reescreva as informações da célula do mouse.
                        mouseCellX = GraphicContext.GetCell(GraphicContext.GetCoorX(this, DeckPictureBox));
                        mouseCellY = GraphicContext.GetCell(GraphicContext.GetCoorY(this, DeckPictureBox));

                        // Redesenha o Tabuleiro
                        DeckPictureBox.Refresh();

                        // Mostra a cor do comboio selecionado no Tabuleiro
                        for (int i = 0; i < ComboioTabuleiro.CombTamanho[CombSelec]; i++)
                        {
                            //O comboio desenhado não atravessa os limites do tabuleiro
                            if (mouseCellX + i <= 9)
                            {
                                GraphicContext.DrawInnerFrameCell(mouseCellX + i, mouseCellY, CombSelec, this, DeckPictureBox);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    // Fora dos limites do tabuleiro
                    if (mouseCellX != -1 || mouseCellY != -1)
                    {
                        mouseCellX = -1;
                        mouseCellY = -1;

                        // Redesenha o Tabuleiro
                        DeckPictureBox.Refresh();
                    }
                }
            }
        }
Esempio n. 2
0
        private void DeckPictureBoxMouseMove(object sender, MouseEventArgs e)
        {
            // Are we on the grid of the first deck?
            if (GraphicContext.GetCoorX(this, DeckPictureBox) != -1 && GraphicContext.GetCoorY(this, DeckPictureBox) != -1)
            {
                // Have the cell selected by mouse changed?
                if (GraphicContext.GetCell(GraphicContext.GetCoorX(this, DeckPictureBox)) != mouseCellX || GraphicContext.GetCell(GraphicContext.GetCoorY(this, DeckPictureBox)) != mouseCellY)
                {
                    // Update the cell selected by mouse.
                    mouseCellX = GraphicContext.GetCell(GraphicContext.GetCoorX(this, DeckPictureBox));
                    mouseCellY = GraphicContext.GetCell(GraphicContext.GetCoorY(this, DeckPictureBox));

                    // Repaint the first deck.
                    DeckPictureBox.Refresh();
                    // Draw the outer frame of the selected cell.

                    if (Game.SwitchJogador)
                    {
                        GraphicContext.DrawOuterFrameCell(mouseCellX, mouseCellY, Game.Jogador1.CorEsc, this, DeckPictureBox);
                    }
                    else
                    {
                        GraphicContext.DrawOuterFrameCell(mouseCellX, mouseCellY, Game.Jogador2.CorEsc, this, DeckPictureBox);
                    }
                }
            }
            else
            {
                // Unselect the cell in the first deck.
                mouseCellX = -1;
                mouseCellY = -1;

                // Repaint the first deck.
                DeckPictureBox.Refresh();
            }
        }