コード例 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "First turn is always" + (lastTurn.Equals(turns.O)? "'X'" : "'O'");
            System.Windows.Forms.ToolTip buttonAImovetip = new System.Windows.Forms.ToolTip();
            buttonAImovetip.SetToolTip(button2_AImove, "Make AI play first");
            int buttonBasePosH = this.ClientSize.Height / 2 - CustomButton.Height * 2;
            int buttonBasePosW = this.ClientSize.Width / 2 - CustomButton.Width * 2;

            for (int x = 0; x < GRIDSIZE; ++x)
            {
                for (int y = 0; y < GRIDSIZE; ++y)
                {
                    gridnum[x, y]    = 0;
                    gridButton[x, y] = new CustomButton()
                    {
                        Name     = String.Format("customButton{0}{1}", x, y),
                        TabIndex = 100 + GRIDSIZE * x + y,
                        Location = new Point(buttonBasePosW + CustomButton.Width * x,
                                             buttonBasePosH + CustomButton.Height * y)
                    };
                    gridButton[x, y].Click += new EventHandler(gridButton_Click);
                    Controls.Add(gridButton[x, y]);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: PalashBansal/tic-tac-toe
 private void Form1_Load(object sender, EventArgs e)
 {
     label1.Text = "First turn is always" + (lastTurn.Equals(turns.O) ? "'X'" : "'O'");
     System.Windows.Forms.ToolTip buttonAImovetip = new System.Windows.Forms.ToolTip();
     buttonAImovetip.SetToolTip(button2_AImove, "Make AI play first");
     makeButtonGrid();
     showGrid();
 }