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; }
public void StartTimer() { if (!timer.Enabled && !g.IsGameOver()) { this.timer.Enabled = true; this.startTime = DateTime.Now; this.timer.Start(); } }