1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System.IO;
|
---|
23 | using System.Windows.Forms;
|
---|
24 | using HeuristicLab.Common;
|
---|
25 |
|
---|
26 | namespace HeuristicLab.Problems.Robocode.Views {
|
---|
27 | public partial class BattleRunnerDialog : Form {
|
---|
28 | public int NrOfRounds {
|
---|
29 | get { return (int)nrOfRoundsNumericUpDown.Value; }
|
---|
30 | set { nrOfRoundsNumericUpDown.Value = value; }
|
---|
31 | }
|
---|
32 |
|
---|
33 | public EnemyCollection Enemies {
|
---|
34 | get { return enemyCollectionView.Content; }
|
---|
35 | set { enemyCollectionView.Content = value; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | public BattleRunnerDialog(Solution solution) {
|
---|
39 | InitializeComponent();
|
---|
40 | errorProvider.SetIconAlignment(robocodePathTextBox, ErrorIconAlignment.MiddleLeft);
|
---|
41 | errorProvider.SetIconPadding(robocodePathTextBox, 2);
|
---|
42 | nrOfRoundsNumericUpDown.Maximum = int.MaxValue;
|
---|
43 | NrOfRounds = solution.NrOfRounds;
|
---|
44 | Enemies = (EnemyCollection)solution.Enemies.Clone(new Cloner());
|
---|
45 | robocodePathTextBox.Text = Enemies.RobocodePath;
|
---|
46 | }
|
---|
47 |
|
---|
48 | private void searchButton_Click(object sender, System.EventArgs e) {
|
---|
49 | var result = folderBrowserDialog.ShowDialog(this);
|
---|
50 | if (result == DialogResult.OK)
|
---|
51 | Enemies.RobocodePath = robocodePathTextBox.Text = folderBrowserDialog.SelectedPath;
|
---|
52 | }
|
---|
53 |
|
---|
54 | private void runInRobocodeButton_Click(object sender, System.EventArgs e) {
|
---|
55 | DialogResult = DialogResult.OK;
|
---|
56 | Close();
|
---|
57 | }
|
---|
58 |
|
---|
59 | private void robocodePathTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
|
---|
60 | string robocodePath = robocodePathTextBox.Text;
|
---|
61 | if (string.IsNullOrEmpty(robocodePath)) {
|
---|
62 | e.Cancel = true;
|
---|
63 | errorProvider.SetError(robocodePathTextBox, "Robocode directory has to be set");
|
---|
64 | robocodePathTextBox.SelectAll();
|
---|
65 | return;
|
---|
66 | }
|
---|
67 | var info = new DirectoryInfo(robocodePath);
|
---|
68 | if (!info.Exists) {
|
---|
69 | e.Cancel = true;
|
---|
70 | errorProvider.SetError(robocodePathTextBox, "This directory does not exist");
|
---|
71 | robocodePathTextBox.SelectAll();
|
---|
72 | return;
|
---|
73 | }
|
---|
74 | Enemies.RobocodePath = robocodePathTextBox.Text;
|
---|
75 | }
|
---|
76 |
|
---|
77 | private void robocodePathTextBox_Validated(object sender, System.EventArgs e) {
|
---|
78 | errorProvider.SetError(robocodePathTextBox, string.Empty);
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|