1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
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 |
|
---|
22 | using System;
|
---|
23 | using System.Linq;
|
---|
24 | using System.Threading.Tasks;
|
---|
25 | using System.Windows.Forms;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Data;
|
---|
28 | using HeuristicLab.Data.Views;
|
---|
29 | using HeuristicLab.MainForm;
|
---|
30 | using HeuristicLab.MainForm.WindowsForms;
|
---|
31 |
|
---|
32 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
33 | [View("RegressionSolution View")]
|
---|
34 | [Content(typeof(RegressionSolutionBase), false)]
|
---|
35 | public partial class RegressionSolutionView : DataAnalysisSolutionView {
|
---|
36 | public RegressionSolutionView() {
|
---|
37 | InitializeComponent();
|
---|
38 | }
|
---|
39 |
|
---|
40 | public new RegressionSolutionBase Content {
|
---|
41 | get { return (RegressionSolutionBase)base.Content; }
|
---|
42 | set { base.Content = value; }
|
---|
43 | }
|
---|
44 |
|
---|
45 | protected override void SetEnabledStateOfControls() {
|
---|
46 | base.SetEnabledStateOfControls();
|
---|
47 | btnImpactCalculation.Enabled = Content != null && !Locked;
|
---|
48 | }
|
---|
49 |
|
---|
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 |
|
---|
71 | #region drag and drop
|
---|
72 | protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
|
---|
73 | validDragOperation = false;
|
---|
74 | if (ReadOnly) return;
|
---|
75 |
|
---|
76 | var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
77 | if (dropData is IRegressionProblemData) validDragOperation = true;
|
---|
78 | else if (dropData is IRegressionProblem) validDragOperation = true;
|
---|
79 | else if (dropData is IValueParameter) {
|
---|
80 | var param = (IValueParameter)dropData;
|
---|
81 | if (param.Value is RegressionProblemData) validDragOperation = true;
|
---|
82 | }
|
---|
83 | }
|
---|
84 | #endregion
|
---|
85 | }
|
---|
86 | }
|
---|