Esempio n. 1
0
        private void CreateLabel()
        {
            revealLabel = new Label
            {
                Location = new Point(offsetX + x, offsetY + y),
                Width    = w,
                Height   = w,

                BorderStyle = BorderStyle.FixedSingle,

                TextAlign = ContentAlignment.MiddleCenter,
                Font      = new Font("Microsoft Sans Serif", w / 2),

                BackColor = Color.PaleTurquoise
            };

            void revealLabel_MouseClick(object sender, MouseEventArgs e)
            {
                if (parent.IsGameOver())
                {
                    return;
                }

                switch (e.Button)
                {
                case MouseButtons.Left:

                    parent.GetMainParent().StartTimer();

                    if (!revealed)
                    {
                        this.Reveal();
                    }

                    break;

                case MouseButtons.Right:

                    if (!revealed)
                    {
                        this.ToggleFlag();
                    }
                    break;
                }

                parent.CheckWinGame();
            }

            revealLabel.MouseClick += revealLabel_MouseClick;
        }