void OpenBlock(int rowNo, int colNo, int mineNos) { NumberedLabel cuLbl = new NumberedLabel(); if (mineNos > 0) { cuLbl.Text = mineNos.ToString(); } cuLbl.Location = currentButtons[rowNo, colNo].Location; cuLbl.Name = "Lbl" + rowNo.ToString() + colNo.ToString(); cuLbl.Size = new System.Drawing.Size(20, 20); cuLbl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; cuLbl.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); cuLbl.RowNumber = rowNo; cuLbl.ColumnNumber = colNo; cuLbl.Number = mineNos; cuLbl.MouseDown += new MouseEventHandler(this.lbl_Click); switch (mineNos) { case 1: cuLbl.ForeColor = System.Drawing.Color.Navy; break; case 2: cuLbl.ForeColor = System.Drawing.Color.DarkGreen; break; case 3: cuLbl.ForeColor = System.Drawing.Color.DarkRed; break; case 4: cuLbl.ForeColor = System.Drawing.Color.Lime; break; case 5: cuLbl.ForeColor = System.Drawing.Color.CornflowerBlue; break; case 6: cuLbl.ForeColor = System.Drawing.Color.DeepPink; break; case 7: cuLbl.ForeColor = System.Drawing.Color.SlateBlue; break; case 8: cuLbl.ForeColor = System.Drawing.Color.Violet; break; } this.Controls.Add(cuLbl); cuLbl.Show(); currentButtons[rowNo, colNo].Hide(); }
private void lbl_Click(object sender, MouseEventArgs e) { if (!gameOver) { ClickResult aResult = ClickResult.DoNothing; NumberedLabel aLabel = (NumberedLabel)sender; currentMine = currentButtons[aLabel.RowNumber, aLabel.ColumnNumber]; if (e.Button == MouseButtons.Left) { if (lblTimer.Enabled && leftRightClick == 2) { leftRightClick = 0; pairs.Clear(); aResult = mineSweeper.DoubleClickEvent(currentMine.RowNumber, currentMine.ColumnNumber, pairs); lblTimer.Enabled = false; HandleButtonClicked(aResult, -1); return; } leftRightClick = 1; lblTimer.Enabled = true; } else if (e.Button == MouseButtons.Right) { if (lblTimer.Enabled && leftRightClick == 1) { leftRightClick = 0; pairs.Clear(); aResult = mineSweeper.DoubleClickEvent(currentMine.RowNumber, currentMine.ColumnNumber, pairs); lblTimer.Enabled = false; HandleButtonClicked(aResult, -1); return; } leftRightClick = 2; lblTimer.Enabled = true; } } }