#region License Information
/* HeuristicLab
* Copyright (C) 2002-2019 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.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using HeuristicLab.Collections;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.Data;
using HeuristicLab.MainForm;
using HeuristicLab.Optimization;
using HeuristicLab.PluginInfrastructure;
namespace HeuristicLab.Analysis.Statistics.Views {
[View("Chart Analysis", "HeuristicLab.Analysis.Statistics.Views.InfoResources.ChartAnalysisInfo.rtf")]
[Content(typeof(RunCollection), false)]
public sealed partial class ChartAnalysisView : ItemView {
public new RunCollection Content {
get { return (RunCollection)base.Content; }
set { base.Content = value; }
}
public override bool ReadOnly {
get { return true; }
set { /*not needed because results are always readonly */}
}
private List runs;
private IProgress progress;
private bool valuesAdded = false;
private bool suppressUpdates = false;
private SemaphoreSlim sem = new SemaphoreSlim(1, 1);
public ChartAnalysisView() {
InitializeComponent();
stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick += DataGridView_RowHeaderMouseDoubleClick;
var fittingAlgs = ApplicationManager.Manager.GetInstances();
foreach (var fit in fittingAlgs) {
fittingComboBox.Items.Add(fit);
}
fittingComboBox.SelectedIndex = 0;
}
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick -= DataGridView_RowHeaderMouseDoubleClick;
components.Dispose();
}
base.Dispose(disposing);
}
#region Content Events
protected override void OnContentChanged() {
base.OnContentChanged();
UpdateComboboxes();
UpdateCaption();
}
private void UpdateCaption() {
Caption = Content != null ? Content.OptimizerName + " Chart Analysis" : ViewAttribute.GetViewName(GetType());
}
private void UpdateComboboxes() {
if (Content != null) {
UpdateDataTableComboBox();
}
}
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.ColumnsChanged += Content_ColumnsChanged;
Content.RowsChanged += Content_RowsChanged;
Content.CollectionReset += Content_CollectionReset;
Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
}
protected override void DeregisterContentEvents() {
base.DeregisterContentEvents();
Content.ColumnsChanged -= Content_ColumnsChanged;
Content.RowsChanged -= Content_RowsChanged;
Content.CollectionReset -= Content_CollectionReset;
Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
}
void Content_RowsChanged(object sender, EventArgs e) {
if (suppressUpdates) return;
if (InvokeRequired) Invoke((Action