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