Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/13 16:24:16 (11 years ago)
Author:
pfleck
Message:

Reintegrated cloning into tryout-Button.

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
2 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/DataPreprocessingView.cs

    r10247 r10254  
    11using System;
    22using System.Collections.Generic;
    3 using System.ComponentModel;
    4 using System.Drawing;
    5 using System.Data;
    63using System.Linq;
    7 using System.Text;
    84using System.Windows.Forms;
    9 using HeuristicLab.Core.Views;
    10 using HeuristicLab.DataPreprocessing.Implementations;
    11 using HeuristicLab.MainForm;
    125using HeuristicLab.Common;
    136using HeuristicLab.Core;
     7using HeuristicLab.Core.Views;
    148using HeuristicLab.Data;
     9using HeuristicLab.MainForm;
     10using HeuristicLab.Optimization;
    1511using HeuristicLab.Problems.DataAnalysis;
    1612
    17 namespace HeuristicLab.DataPreprocessing
    18 {
     13namespace HeuristicLab.DataPreprocessing {
    1914  [View("DataPreprocessing View")]
    2015  [Content(typeof(PreprocessingContext), true)]
     
    2924
    3025      InitializeContents();
    31      
     26
    3227    }
    3328
     
    3631      ListViewItem listViewItem = new ListViewItem();
    3732
    38         listViewItem.Text = item.ToString();
    39         //listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
    40         //itemsListView.SmallImageList.Images.Add(content.);
    41         //listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
    42         //listViewItem.Tag = item;
     33      listViewItem.Text = item.ToString();
     34      //listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
     35      //itemsListView.SmallImageList.Images.Add(content.);
     36      //listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
     37      //listViewItem.Tag = item;
    4338      return listViewItem;
    4439    }
    4540
    4641    private void InitializeContents() {
    47       dataGridContent = new DataGridContent(new DataGridLogic(this.Content));
     42      dataGridContent = new DataGridContent(new DataGridLogic(Content != null ? this.Content.Data : null));
    4843
    49       listViewItemItemMapping = new Dictionary<ListViewItem,IItem>();
     44      listViewItemItemMapping = new Dictionary<ListViewItem, IItem>();
    5045      ListViewItem contentListViewItem = CreateListViewItem(dataGridContent);
    5146      listViewItemItemMapping[contentListViewItem] = dataGridContent;
     
    5449    }
    5550
    56     public new PreprocessingData Content {
    57       get { return (PreprocessingData)base.Content; }
     51    public new PreprocessingContext Content {
     52      get { return (PreprocessingContext)base.Content; }
    5853      set { base.Content = value; }
    5954    }
     
    6156    private void listView1_SelectedIndexChanged(object sender, EventArgs e) {
    6257
    63         if (contentListView.SelectedItems.Count > 0)
    64         {
    65             ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
    66             this.viewHost.Content = listViewItemItemMapping[listViewItem];
    67         }
     58      if (contentListView.SelectedItems.Count > 0) {
     59        ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0];
     60        this.viewHost.Content = listViewItemItemMapping[listViewItem];
     61      }
    6862    }
    6963
     
    7367    }
    7468
    75     private void tryOutAlgorithmButton_Click(object sender, EventArgs e)
    76     {
     69    private void tryOutAlgorithmButton_Click(object sender, EventArgs e) {
     70      IPreprocessingData Data = Content.Data;
    7771
     72      foreach (string variable in Data.VariableNames) {
     73        for (int j = 0; j < Data.Rows; j++) {
     74          // assume: all double
     75          Data.SetCell(variable, j, 1.0);
     76        }
     77      }
     78
     79      MessageBox.Show("Success, now cloning... ");
     80
     81      Dataset dataset = Data.ExportToDataset();
     82      var variables = new CheckedItemList<StringValue>(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly();
     83
     84      var cloner = new Cloner();
     85
     86      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.Dataset, dataset);
     87      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TrainingPartition, Data.TrainingPartition);
     88      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TestPartition, Data.TestPartition);
     89      cloner.RegisterClonedObject(Content.DataAnalysisProblemData.InputVariables, variables);
     90      if (Content.Algorithm != null) {
     91        cloner.RegisterClonedObject(Content.Algorithm.Runs, new RunCollection { OptimizerName = Content.Algorithm.Name });
     92      }
     93
     94      var item = cloner.Clone(Content.ParentItem);
     95
     96      MainFormManager.MainForm.ShowContent(item);
    7897    }
    79 
    80     //private void button1_Click(object sender, System.EventArgs e)
    81     //{
    82 
    83     //    IPreprocessingData Data = Content.Data;
    84 
    85     //    foreach (string variable in Data.VariableNames)
    86     //    {
    87     //        for (int j = 0; j < Data.Rows; j++)
    88     //        {
    89     //            // assume: all double
    90     //            Data.SetCell(variable, j, 1.0);
    91     //        }
    92     //    }
    93 
    94     //    MessageBox.Show("Success, now cloning... ");
    95 
    96     //    Dataset dataset = Data.ExportToDataset();
    97     //    var variables = new CheckedItemList<StringValue>(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly();
    98 
    99     //    var cloner = new Cloner();
    100 
    101     //    cloner.RegisterClonedObject(Content.DataAnalysisProblemData.Dataset, dataset);
    102     //    cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TrainingPartition, Data.TrainingPartition);
    103     //    cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TestPartition, Data.TestPartition);
    104     //    cloner.RegisterClonedObject(Content.DataAnalysisProblemData.InputVariables, variables);
    105 
    106     //    var item = cloner.Clone(Content.ParentItem);
    107 
    108     //    MainFormManager.MainForm.ShowContent(item);
    109 
    110     //    //var clone = null;
    111 
    112     //}
    113 
    114 
    11598  }
    11699}
    117100
    118    
Note: See TracChangeset for help on using the changeset viewer.