private void OnClickPlate(object sender, PlateEventArgs e) { // Opens requested plate through simulating Button Click string btnName = "Button"; if (e.PlateRow < 10) { btnName += String.Format("0{0}", e.PlateRow); } else { btnName += String.Format("{0:D2}", e.PlateRow); } if (e.PlateColumn < 10) { btnName += String.Format("0{0}", e.PlateColumn); } else { btnName += String.Format("{0:D2}", e.PlateColumn); } Button senderButton = (ButtonsGrid.FindName(btnName) as Button); if (senderButton == null) { throw new MinesweeperException("Invalid Button to MinesGrid reference on multiple reveal"); // the plate refers to an invalid button } // calls respecive "Button Click" event handler this.Button_Click(senderButton, new RoutedEventArgs()); }
private void OnClickPlate(object sender, PlateEventArgs e) { string btnName = "Button"; if (Mines.Width <= 10 && Mines.Height <= 10) { btnName += String.Format("{0:D1}{1:D1}", e.PlateRow, e.PlateColumn); } else { btnName += String.Format("{0:D2}{1:D2}", e.PlateRow, e.PlateColumn); } Button senderButton = (ButtonsGrid.FindName(btnName) as Button); if (senderButton == null) { throw new MinesweeperException("Invalid Button to MinesGrid reference on multiple reveal"); } this.Button_Click(senderButton, new RoutedEventArgs()); }