private void MenuItemMapEditor_Click(object sender, RoutedEventArgs e) { WindowEditor editor = new WindowEditor(); editor.ShowDialog(); }
private void buttonStart_Click(object sender, RoutedEventArgs e) { if (treeView2.Items.Count == 0) { MessageBox.Show("No robot was added. A tournament without robots would be very boring so please select at least two", "Not enough Robots", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (treeView2.Items.Count == 1) { MessageBox.Show("Only one robot was added. A tournament with just one robot would be very boring so please select at least a second", "Not enough Robots", MessageBoxButton.OK, MessageBoxImage.Information); return; } foreach (TreeViewItem item in treeView2.Items) { tournament.RobotManager.AddRobot(((TreeViewRobotInfo)item.Tag).FileName, tournament.Rules.Teamsize, tournament.Map.Map); } if (tournament.Rules.Mode == TournamentMode.LastManStanding || tournament.Rules.Mode == TournamentMode.TeamLastTeamStanding) { tournament.Bracket = new TournamentBracket(tournament.RobotManager.TeamCount, true); } else { tournament.Bracket = new TournamentBracket(tournament.RobotManager.TeamCount); } // --- Map --- byte[][] newMap; if (radioButtonMapFile.IsChecked == true) { try { WindowEditor.ReadMapFile(textBlockMapFile.Text, out newMap); } catch (Exception exception) { MessageBox.Show("Error opening file.\n" + exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } else { int mapSize = (int)numericMapSize.Value; newMap = new byte[mapSize][]; for (int i = 0; i < mapSize; i++) { newMap[i] = new byte[mapSize]; for (int j = 0; j < mapSize; j++) { newMap[i][j] = 0; } } } tournament.Map = new TournamentMap(newMap); int maxRobots = tournament.RobotManager.TeamCount * tournament.Rules.Teamsize; if (tournament.Map.FreeFields < maxRobots) { MessageBox.Show("The map contains " + tournament.Map.FreeFields + " free fields but there will be " + maxRobots + " robots.\n" + "Please select a different map or reduce the number of robots.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } DialogResult = true; Close(); }