#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 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.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using HeuristicLab.Collections;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Optimization.Views {
///
/// The visual representation of a .
///
[View("Run View")]
[Content(typeof(IRun), true)]
public sealed partial class RunView : NamedItemView {
private readonly Dictionary parametersItemToListViewItem;
private readonly Dictionary resultsItemToListViewItem;
///
/// Gets or sets the variable to represent visually.
///
/// Uses property of base class .
/// No own data storage present.
public new IRun Content {
get { return (IRun)base.Content; }
set { base.Content = value; }
}
///
/// Initializes a new instance of with caption "Variable".
///
public RunView() {
InitializeComponent();
parametersItemToListViewItem = new Dictionary();
resultsItemToListViewItem = new Dictionary();
}
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.PropertyChanged += Content_PropertyChanged;
RegisterContentParametersEvents();
RegisterContentResultsEents();
}
private void RegisterContentParametersEvents() {
Content.Parameters.ItemsAdded += ParametersOnItemsChanged;
Content.Parameters.ItemsRemoved += ParametersOnItemsRemoved;
Content.Parameters.ItemsReplaced += ParametersOnItemsChanged;
Content.Parameters.CollectionReset += ParametersOnItemsChanged;
}
private void RegisterContentResultsEents() {
Content.Results.ItemsAdded += ResultsOnItemsChanged;
Content.Results.ItemsRemoved += ResultsOnItemsRemoved;
Content.Results.ItemsReplaced += ResultsOnItemsChanged;
Content.Results.CollectionReset += ResultsOnItemsChanged;
}
protected override void DeregisterContentEvents() {
base.DeregisterContentEvents();
Content.PropertyChanged -= Content_PropertyChanged;
DeregisterContentParametersEvents();
DeregisterContentResultsEvents();
}
private void DeregisterContentParametersEvents() {
Content.Parameters.ItemsAdded -= ParametersOnItemsChanged;
Content.Parameters.ItemsRemoved -= ParametersOnItemsRemoved;
Content.Parameters.ItemsReplaced -= ParametersOnItemsChanged;
Content.Parameters.CollectionReset -= ParametersOnItemsChanged;
}
private void DeregisterContentResultsEvents() {
Content.Results.ItemsAdded -= ResultsOnItemsChanged;
Content.Results.ItemsRemoved -= ResultsOnItemsRemoved;
Content.Results.ItemsReplaced -= ResultsOnItemsChanged;
Content.Results.CollectionReset -= ResultsOnItemsChanged;
}
private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
if (InvokeRequired) {
Invoke((Action