1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 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.Text;
|
---|
25 | using System.Windows.Forms;
|
---|
26 | using HeuristicLab.Core;
|
---|
27 | using HeuristicLab.Core.Views;
|
---|
28 | using HeuristicLab.Data;
|
---|
29 | using HeuristicLab.MainForm;
|
---|
30 | using HeuristicLab.MainForm.WindowsForms;
|
---|
31 |
|
---|
32 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
33 | [View("Problem Data View")]
|
---|
34 | [Content(typeof(DataAnalysisProblemData), true)]
|
---|
35 | public partial class ProblemDataView : ParameterizedNamedItemView {
|
---|
36 |
|
---|
37 | public new DataAnalysisProblemData Content {
|
---|
38 | get { return (DataAnalysisProblemData)base.Content; }
|
---|
39 | set { base.Content = value; }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public ProblemDataView() {
|
---|
43 | InitializeComponent();
|
---|
44 | }
|
---|
45 |
|
---|
46 | protected void FeatureCorrelationButton_Click(object sender, System.EventArgs e) {
|
---|
47 | ViewHost viewHost = new ViewHost();
|
---|
48 | viewHost.Content = (DataAnalysisProblemData)this.Content.Clone();
|
---|
49 | viewHost.ViewType = typeof(FeatureCorrelationView);
|
---|
50 | viewHost.Show();
|
---|
51 | }
|
---|
52 |
|
---|
53 | protected void parameterCollectionView_DragDrop(object sender, DragEventArgs e) {
|
---|
54 | if (e.Effect != DragDropEffects.None) {
|
---|
55 | var stringValueList = (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IFixedValueParameter).Value as ICheckedItemList<StringValue>;
|
---|
56 | SetInputVariables(stringValueList);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | private void SetInputVariables(ICheckedItemList<StringValue> stringValueList) {
|
---|
61 | var inputVariables = Content.InputVariables;
|
---|
62 | var stringValues = stringValueList.Select(x => x.Value);
|
---|
63 | var notContainedVariables = inputVariables.Where(x => !stringValues.Contains(x.Value));
|
---|
64 |
|
---|
65 | if (notContainedVariables.Count() != 0) {
|
---|
66 | StringBuilder strBuilder = new StringBuilder();
|
---|
67 | foreach (var variable in notContainedVariables) {
|
---|
68 | strBuilder.Append(variable.Value + ", ");
|
---|
69 | }
|
---|
70 | strBuilder.Remove(strBuilder.Length - 2, 2);
|
---|
71 | MessageBox.Show(String.Format("There was an error while changing the input variables. The following input " +
|
---|
72 | "variables have not been contained {0}", strBuilder.ToString()), "Error while changing the input variables",
|
---|
73 | MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
---|
74 | } else {
|
---|
75 | var checkedItems = stringValueList.CheckedItems.Select(x => x.Value.Value);
|
---|
76 | var setChecked = inputVariables.Where(x => checkedItems.Contains(x.Value));
|
---|
77 | foreach (var variable in inputVariables) {
|
---|
78 | if (setChecked.Contains(variable) && !inputVariables.ItemChecked(variable)) {
|
---|
79 | inputVariables.SetItemCheckedState(variable, true);
|
---|
80 | } else if (!setChecked.Contains(variable) && inputVariables.ItemChecked(variable)) {
|
---|
81 | inputVariables.SetItemCheckedState(variable, false);
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | protected void parameterCollectionView_DragEnterOver(object sender, DragEventArgs e) {
|
---|
88 | e.Effect = DragDropEffects.None;
|
---|
89 | if (ReadOnly)
|
---|
90 | return;
|
---|
91 | if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) == null)
|
---|
92 | return;
|
---|
93 |
|
---|
94 | var parameter = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IFixedValueParameter;
|
---|
95 | if (parameter == null)
|
---|
96 | return;
|
---|
97 |
|
---|
98 | var stringValueList = parameter.Value as ICheckedItemList<StringValue>;
|
---|
99 | if (stringValueList == null)
|
---|
100 | return;
|
---|
101 |
|
---|
102 | e.Effect = e.AllowedEffect;
|
---|
103 | }
|
---|
104 | }
|
---|
105 | }
|
---|