コード例 #1
0
ファイル: Reversi.cs プロジェクト: Joseph24/AI
        public ReversiForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            // Create the game board.
            this.board = new Board();

            // Create the controls for each square, add them to the squares
            // panel and set up event handling.
            this.squareControls = new SquareControl[8, 8];
            int i, j;
            for (i = 0; i < 8; i++)
                for (j = 0; j < 8; j++)
                {
                    // Create it.
                    this.squareControls[i, j] = new SquareControl(i, j);
                    // Position it.
                    this.squareControls[i, j].Left = j * this.squareControls[i, j].Width;
                    this.squareControls[i, j].Top  = i * this.squareControls[i, j].Height;
                    // Add it.
                    this.squaresPanel.Controls.Add(this.squareControls[i, j]);
                    // Set up event handling for it.
                    this.squareControls[i, j].MouseMove  += new MouseEventHandler(this.SquareControl_MouseMove);
                    this.squareControls[i, j].MouseLeave += new EventHandler(this.SquareControl_MouseLeave);
                    this.squareControls[i, j].Click      += new EventHandler(this.SquareControl_Click);
                }

            // Create the column and row labels.
            this.colLabels = new Label[8];
            for (i = 0; i < 8; i++)
            {
                // Create a column label.
                this.colLabels[i] = new Label();

                // Set its display properties.
                this.colLabels[i].Text = ReversiForm.alpha.Substring(i, 1);
                this.colLabels[i].BackColor = this.cornerLabel.BackColor;
                this.colLabels[i].ForeColor = this.cornerLabel.ForeColor;
                this.colLabels[i].TextAlign = ContentAlignment.MiddleCenter;

                // Set its size and position.
                this.colLabels[i].Width = this.squareControls[0, 0].Width;
                this.colLabels[i].Height = this.cornerLabel.Height;
                this.colLabels[i].Left = this.cornerLabel.Width + i * this.colLabels[0].Width;
                this.colLabels[i].Top = 0;

                // Add it.
                this.boardPanel.Controls.Add(this.colLabels[i]);
            }
            this.rowLabels = new Label[8];
            for (i = 0; i < 8; i++)
            {
                // Create a row label.
                this.rowLabels[i] = new Label();

                // Set its display properties.
                this.rowLabels[i].Text      = (i + 1).ToString();
                this.rowLabels[i].BackColor = this.cornerLabel.BackColor;
                this.rowLabels[i].ForeColor = this.cornerLabel.ForeColor;
                this.rowLabels[i].TextAlign = ContentAlignment.MiddleCenter;

                // Set its size and position.
                this.rowLabels[i].Width  = this.cornerLabel.Height;
                this.rowLabels[i].Height = this.squareControls[0, 0].Height;
                this.rowLabels[i].Left   = 0;
                this.rowLabels[i].Top    = this.cornerLabel.Height + i * this.rowLabels[0].Width;

                // Add it.
                this.boardPanel.Controls.Add(this.rowLabels[i]);
            }

            // Initialize the game state.
            this.gameState = ReversiForm.GameState.GameOver;

            // Initialize the animation timer.
            this.animationTimer.Interval = ReversiForm.animationTimerInterval;
            this.animationTimer.Tick += new EventHandler(this.AnimateMove);

            // Initialize the window settings.
            this.windowSettings = new Rectangle(
                this.DesktopLocation.X,
                this.DesktopLocation.Y,
                this.ClientSize.Width,
                this.ClientSize.Height);

            // Load any saved program settings.
            this.settings = new ProgramSettings(ReversiForm.programSettingsFileName);
            this.LoadProgramSettings();
        }
コード例 #2
0
ファイル: Reversi.cs プロジェクト: ogeraisi/THE-HORROR
        public ReversiForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Initialize Board and labels
            this.InitializeBoard();
            this.InitializeColumnLabels();
            this.InitializeRowLabels();

            // Initialize the game state.
            this.gameState = ReversiForm.GameState.GameOver;

            // Initialize the animation timer.
            this.animationTimer.Interval = ReversiForm.animationTimerInterval;
            this.animationTimer.Tick += new EventHandler(this.AnimateMove);

            // Initialize the window settings.
            this.windowSettings = new Rectangle(
                this.DesktopLocation.X,
                this.DesktopLocation.Y,
                this.ClientSize.Width,
                this.ClientSize.Height);

            // Load any saved program settings.
            this.settings = new ProgramSettings(ReversiForm.programSettingsFileName);
            this.LoadProgramSettings();
        }