Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs @ 14145

Last change on this file since 14145 was 14095, checked in by mkommend, 8 years ago

#2597: Merged all changesets from HeuristiLab.RegressionSolutionGradientView into the trunk.

File size: 3.2 KB
RevLine 
[5829]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5829]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
[13766]22using System;
23using System.Linq;
24using System.Threading.Tasks;
[5829]25using System.Windows.Forms;
[6666]26using HeuristicLab.Core;
[13766]27using HeuristicLab.Data;
28using HeuristicLab.Data.Views;
[5829]29using HeuristicLab.MainForm;
[13766]30using HeuristicLab.MainForm.WindowsForms;
[5829]31
32namespace HeuristicLab.Problems.DataAnalysis.Views {
[14095]33  [View("Solution View")]
[6652]34  [Content(typeof(RegressionSolutionBase), false)]
[5829]35  public partial class RegressionSolutionView : DataAnalysisSolutionView {
36    public RegressionSolutionView() {
37      InitializeComponent();
38    }
39
[6597]40    public new RegressionSolutionBase Content {
41      get { return (RegressionSolutionBase)base.Content; }
[5829]42      set { base.Content = value; }
43    }
[6653]44
[13942]45    protected override void SetEnabledStateOfControls() {
46      base.SetEnabledStateOfControls();
47      btnImpactCalculation.Enabled = Content != null && !Locked;
48    }
49
[13766]50    protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
51      var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
52      var view = new StringConvertibleArrayView();
53      view.Caption = Content.Name + " Variable Impacts";
54      view.Show();
55
56      Task.Factory.StartNew(() => {
57        try {
58          mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
59
60          var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
61          var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
62          impactArray.ElementNames = impacts.Select(i => i.Item1);
63          view.Content = (DoubleArray)impactArray.AsReadOnly();
64        }
65        finally {
66          mainForm.RemoveOperationProgressFromView(view);
67        }
68      });
69    }
70
[6653]71    #region drag and drop
72    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
73      validDragOperation = false;
[6666]74      if (ReadOnly) return;
75
76      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
[10173]77      if (dropData is IRegressionProblemData) validDragOperation = true;
78      else if (dropData is IRegressionProblem) validDragOperation = true;
[6666]79      else if (dropData is IValueParameter) {
80        var param = (IValueParameter)dropData;
81        if (param.Value is RegressionProblemData) validDragOperation = true;
[6653]82      }
83    }
84    #endregion
[5829]85  }
86}
Note: See TracBrowser for help on using the repository browser.