#region License Information /* HeuristicLab * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using HeuristicLab.Core; namespace HeuristicLab.Clients.OKB.RunCreation { public partial class OKBRunConfigSelectionView : UserControl { private const string algorithmTypeParameterName = "Algorithm Type"; private const string problemTypeParameterName = "Problem Type"; private List algorithms; public List Algorithms { get { return algorithms; } set { algorithms = value; foreach (Algorithm a in Algorithms) { cmbAlgorithm.Items.Add(a); } } } private List problems; public List Problems { get { return problems; } set { problems = value; foreach (Problem p in Problems) { cmbProblem.Items.Add(p); } } } private HeuristicLab.Optimization.IRun experimentRun; public HeuristicLab.Optimization.IRun ExperimentRun { get { return experimentRun; } set { experimentRun = value; txtRunName.Text = ExperimentRun.Name; } } public OKBRunConfigSelectionView() { InitializeComponent(); } public OKBRunConfigSelectionView(HeuristicLab.Optimization.IRun run, List algorithms, List problems) { InitializeComponent(); ExperimentRun = run; Algorithms = algorithms; Problems = problems; PopulateComboboxes(); } private void PopulateComboboxes() { IItem algorithmType; IItem problemType; if (cmbAlgorithm.Items.Count > 0) { cmbAlgorithm.SelectedIndex = 0; } if (cmbProblem.Items.Count > 0) { cmbProblem.SelectedIndex = 0; } if (ExperimentRun.Parameters.TryGetValue(algorithmTypeParameterName, out algorithmType)) { HeuristicLab.Data.StringValue algStr = algorithmType as HeuristicLab.Data.StringValue; if (algStr != null) { var result = Algorithms.FindAll(x => x.Name == algStr.Value); if (result.Count > 0) { cmbAlgorithm.SelectedItem = result.First(); } } } if (ExperimentRun.Parameters.TryGetValue(problemTypeParameterName, out problemType)) { HeuristicLab.Data.StringValue prbStr = problemType as HeuristicLab.Data.StringValue; if (prbStr != null) { var result = Problems.FindAll(x => x.Name == prbStr.Value); if (result.Count > 0) { cmbProblem.SelectedItem = result.First(); } } } } public Algorithm GetSelectedAlgorithm() { return cmbAlgorithm.SelectedItem as Algorithm; } public Problem GetSelectedProblem() { return cmbProblem.SelectedItem as Problem; } public bool UploadToOKB() { return chkUpload.Checked; } } }