using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Core.Views; using HeuristicLab.Data; using HeuristicLab.MainForm; using HeuristicLab.Optimization; using HeuristicLab.Problems.DataAnalysis; namespace HeuristicLab.DataPreprocessing { [View("DataPreprocessing View")] [Content(typeof(PreprocessingContext), true)] public partial class DataPreprocessingView : ItemView { private DataGridContent dataGridContent; private Dictionary listViewItemItemMapping; public DataPreprocessingView() { InitializeComponent(); b } protected override void OnContentChanged() { base.OnContentChanged(); InitializeContents(); } private ListViewItem CreateListViewItem(IItem item) { ListViewItem listViewItem = new ListViewItem(); listViewItem.Text = item.ToString(); //listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; //itemsListView.SmallImageList.Images.Add(content.); //listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; //listViewItem.Tag = item; return listViewItem; } private void InitializeContents() { IPreprocessingData data = Content.Data; ISearchLogic searchLogic = new SearchLogic(data); dataGridContent = new DataGridContent(new DataGridLogic(data), new PreprocessingDataManipulation(data, searchLogic, new StatisticsLogic(data, searchLogic))); listViewItemItemMapping = new Dictionary(); ListViewItem contentListViewItem = CreateListViewItem(dataGridContent); listViewItemItemMapping[contentListViewItem] = dataGridContent; contentListView.Items.Add(contentListViewItem); } public new PreprocessingContext Content { get { return (PreprocessingContext)base.Content; } set { base.Content = value; } } private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (contentListView.SelectedItems.Count > 0) { ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0]; this.viewHost.Content = listViewItemItemMapping[listViewItem]; } } private void listView1_DoubleClick(object sender, EventArgs e) { ListViewItem listViewItem = (ListViewItem)contentListView.SelectedItems[0]; MainFormManager.MainForm.ShowContent(listViewItemItemMapping[listViewItem]); } private void tryOutAlgorithmButton_Click(object sender, EventArgs e) { IPreprocessingData Data = Content.Data; foreach (string variable in Data.VariableNames) { for (int j = 0; j < Data.Rows; j++) { // assume: all double Data.SetCell(variable, j, 1.0); } } MessageBox.Show("Success, now cloning... "); Dataset dataset = Data.ExportToDataset(); var variables = new CheckedItemList(Data.VariableNames.Select(s => new StringValue(s))).AsReadOnly(); var cloner = new Cloner(); cloner.RegisterClonedObject(Content.DataAnalysisProblemData.Dataset, dataset); cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TrainingPartition, Data.TrainingPartition); cloner.RegisterClonedObject(Content.DataAnalysisProblemData.TestPartition, Data.TestPartition); cloner.RegisterClonedObject(Content.DataAnalysisProblemData.InputVariables, variables); if (Content.Algorithm != null) { cloner.RegisterClonedObject(Content.Algorithm.Runs, new RunCollection { OptimizerName = Content.Algorithm.Name }); } var item = cloner.Clone(Content.ParentItem); MainFormManager.MainForm.ShowContent(item); } } }