#region License Information
/* HeuristicLab
* Copyright (C) 2002-2010 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;
using System.Windows.Forms;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Hive.ExperimentManager.Views {
[View("HiveExperimentList View")]
[Content(typeof(HiveExperimentList), true)]
[Content(typeof(IItemList), false)]
public partial class HiveExperimentListView : ItemListView {
public HiveExperimentListView() {
InitializeComponent();
itemsGroupBox.Text = "Hive Experiments";
}
protected override HiveExperiment CreateItem() {
return new HiveExperiment();
}
protected override void SetEnabledStateOfControls() {
if (InvokeRequired) {
this.InvokeIfRequired(c => { SetEnabledStateOfControls(); });
} else {
base.SetEnabledStateOfControls();
if (Content != null) {
if (itemsListView.SelectedItems.Count > 0) {
// only allow delete-operation if all selected items are stored in hive (they have HiveExperimentId)
bool canRemove = true;
foreach (ListViewItem item in itemsListView.SelectedItems) {
canRemove = canRemove && Content[item.Index].HiveExperimentId != Guid.Empty;
}
this.removeButton.Enabled = canRemove;
}
}
}
}
protected override void removeButton_Click(object sender, EventArgs e) {
DialogResult result = MessageBox.Show("This action will permanently delete this experiment (also on the hive server). Continue?", "Delete Experiment", MessageBoxButtons.OKCancel);
if (result == DialogResult.OK) {
base.removeButton_Click(sender, e);
}
}
}
}