#region License Information
/* HeuristicLab
* Copyright (C) 2002-2015 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 HeuristicLab.Common.Resources;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.Data;
using HeuristicLab.MainForm;
using HeuristicLab.Optimization;
using HeuristicLab.PluginInfrastructure;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace HeuristicLab.Clients.OKB.RunCreation {
[View("OKBProblem View")]
[Content(typeof(SingleObjectiveOKBProblem), true)]
[Content(typeof(MultiObjectiveOKBProblem), true)]
public sealed partial class OKBProblemView : NamedItemView {
private readonly CheckedItemList calculatorList;
public new OKBProblem Content {
get { return (OKBProblem)base.Content; }
set { base.Content = value; }
}
public OKBProblemView() {
InitializeComponent();
var calculatorListView = new CheckedItemListView() {
Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top,
Location = new Point(flaSplitContainer.Padding.Left, calculateButton.Location.Y + calculateButton.Height + calculateButton.Padding.Bottom + 3),
};
calculatorListView.Size = new Size(flaSplitContainer.Panel1.Size.Width - flaSplitContainer.Panel1.Padding.Horizontal,
flaSplitContainer.Panel1.Height - calculatorListView.Location.Y - flaSplitContainer.Panel1.Padding.Bottom);
calculatorList = new CheckedItemList();
calculatorList.ItemsAdded += CalculatorListOnChanged;
calculatorList.ItemsRemoved += CalculatorListOnChanged;
calculatorList.ItemsReplaced += CalculatorListOnChanged;
calculatorList.CollectionReset += CalculatorListOnChanged;
calculatorList.CheckedItemsChanged += CalculatorListOnChanged;
calculatorListView.Content = calculatorList.AsReadOnly();
flaSplitContainer.Panel1.Controls.Add(calculatorListView);
calculateButton.Text = string.Empty;
calculateButton.Image = VSImageLibrary.Play;
refreshButton.Text = string.Empty;
refreshButton.Image = VSImageLibrary.Refresh;
cloneProblemButton.Text = string.Empty;
cloneProblemButton.Image = VSImageLibrary.Clone;
downloadCharacteristicsButton.Text = string.Empty;
downloadCharacteristicsButton.Image = VSImageLibrary.Refresh;
uploadCharacteristicsButton.Text = string.Empty;
uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb;
refreshSolutionsButton.Text = string.Empty;
refreshSolutionsButton.Image = VSImageLibrary.Refresh;
uploadSolutionsButton.Text = string.Empty;
uploadSolutionsButton.Image = VSImageLibrary.PublishToWeb;
}
private void CalculatorListOnChanged(object sender, EventArgs e) {
SetEnabledStateOfControls();
}
protected override void OnInitialized(System.EventArgs e) {
base.OnInitialized(e);
RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing);
RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed);
PopulateComboBox();
}
protected override void DeregisterContentEvents() {
Content.ProblemChanged -= new EventHandler(Content_ProblemChanged);
base.DeregisterContentEvents();
}
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.ProblemChanged += new EventHandler(Content_ProblemChanged);
Content.Solutions.ItemsAdded += SolutionsOnChanged;
Content.Solutions.ItemsReplaced += SolutionsOnChanged;
Content.Solutions.ItemsRemoved += SolutionsOnChanged;
Content.Solutions.CollectionReset += SolutionsOnChanged;
}
private void SolutionsOnChanged(object sender, EventArgs e) {
if (InvokeRequired) { Invoke((Action