Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8593 for trunk


Ignore:
Timestamp:
09/07/12 11:01:10 (12 years ago)
Author:
sforsten
Message:

#1681: Input variables can now be drag & dropped between ProblemData. The input variables don't have to be in the exact same order.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.Designer.cs

    r8578 r8593  
    2727      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    2828      this.SuspendLayout();
     29      //
     30      // parameterCollectionView
     31      //
     32      this.parameterCollectionView.AllowDrop = true;
     33      this.parameterCollectionView.DragDrop += new System.Windows.Forms.DragEventHandler(this.parameterCollectionView_DragDrop);
     34      this.parameterCollectionView.DragEnter += new System.Windows.Forms.DragEventHandler(this.parameterCollectionView_DragEnterOver);
     35      this.parameterCollectionView.DragOver += new System.Windows.Forms.DragEventHandler(this.parameterCollectionView_DragEnterOver);
    2936      //
    3037      // nameTextBox
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataView.cs

    r8578 r8593  
    2020#endregion
    2121
     22using System;
     23using System.Linq;
     24using System.Text;
    2225using System.Windows.Forms;
     26using HeuristicLab.Core;
    2327using HeuristicLab.Core.Views;
     28using HeuristicLab.Data;
    2429using HeuristicLab.MainForm;
    2530using HeuristicLab.MainForm.WindowsForms;
     
    3944    }
    4045
    41     private void FeatureCorrelationButton_Click(object sender, System.EventArgs e) {
     46    protected void FeatureCorrelationButton_Click(object sender, System.EventArgs e) {
    4247      ViewHost viewHost = new ViewHost();
    4348      viewHost.Content = (DataAnalysisProblemData)this.Content.Clone();
     
    4550      viewHost.Show();
    4651    }
     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    }
    47104  }
    48105}
Note: See TracChangeset for help on using the changeset viewer.