Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/14 16:08:49 (11 years ago)
Author:
sbreuer
Message:
  • context menu for replacing values by average, median, ...
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10377 r10380  
    7878  <ItemGroup>
    7979    <Compile Include="Implementations\DataGridLogic.cs" />
     80    <Compile Include="Implementations\ManipulationLogic.cs" />
    8081    <Compile Include="Interfaces\IDataGridLogic.cs" />
    81     <Compile Include="Interfaces\IManipulationLogic.cs" />
    8282    <Compile Include="Implementations\FilterContent.cs" />
    8383    <Compile Include="Implementations\DataPreprocessorStarter.cs" />
     
    9393    <Compile Include="Interfaces\IHistogramLogic.cs" />
    9494    <Compile Include="Interfaces\ILineChartLogic.cs" />
     95    <Compile Include="Interfaces\IManipulationLogic.cs" />
    9596    <Compile Include="Interfaces\ITransformationLogic.cs" />
    9697    <Compile Include="PreprocessingCloner.cs" />
     
    135136    <Compile Include="Implementations\PreprocessingContext.cs" />
    136137    <Compile Include="Implementations\PreprocessingData.cs" />
    137     <Compile Include="Implementations\ManipulationLogic.cs" />
    138138    <Compile Include="Implementations\SearchLogic.cs" />
    139139    <Compile Include="Implementations\StatisticsLogic.cs" />
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/DataGridContentView.Designer.cs

    r10317 r10380  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      this.components = new System.ComponentModel.Container();
    2627      this.btnApplySort = new System.Windows.Forms.Button();
     28      this.contextMenuCell = new System.Windows.Forms.ContextMenuStrip(this.components);
     29      this.replaceValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     30      this.averageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     31      this.medianToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     32      this.randomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     33      this.mostCommonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     34      this.interpolationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    2735      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     36      this.contextMenuCell.SuspendLayout();
    2837      this.SuspendLayout();
    2938      //
     
    5867      this.btnApplySort.Click += new System.EventHandler(this.btnApplySort_Click);
    5968      //
     69      // contextMenuCell
     70      //
     71      this.contextMenuCell.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     72            this.replaceValueToolStripMenuItem});
     73      this.contextMenuCell.Name = "contextMenuCell";
     74      this.contextMenuCell.Size = new System.Drawing.Size(153, 48);
     75      //
     76      // replaceValueToolStripMenuItem
     77      //
     78      this.replaceValueToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
     79            this.averageToolStripMenuItem,
     80            this.medianToolStripMenuItem,
     81            this.randomToolStripMenuItem,
     82            this.mostCommonToolStripMenuItem,
     83            this.interpolationToolStripMenuItem});
     84      this.replaceValueToolStripMenuItem.Name = "replaceValueToolStripMenuItem";
     85      this.replaceValueToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     86      this.replaceValueToolStripMenuItem.Text = "Replace Value";
     87      //
     88      // averageToolStripMenuItem
     89      //
     90      this.averageToolStripMenuItem.Name = "averageToolStripMenuItem";
     91      this.averageToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
     92      this.averageToolStripMenuItem.Text = "Average";
     93      this.averageToolStripMenuItem.Click += new System.EventHandler(this.ReplaceWithAverage_Click);
     94      //
     95      // medianToolStripMenuItem
     96      //
     97      this.medianToolStripMenuItem.Name = "medianToolStripMenuItem";
     98      this.medianToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
     99      this.medianToolStripMenuItem.Text = "Median";
     100      this.medianToolStripMenuItem.Click += new System.EventHandler(this.ReplaceWithMedian_Click);
     101      //
     102      // randomToolStripMenuItem
     103      //
     104      this.randomToolStripMenuItem.Name = "randomToolStripMenuItem";
     105      this.randomToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
     106      this.randomToolStripMenuItem.Text = "Random";
     107      this.randomToolStripMenuItem.Click += new System.EventHandler(this.ReplaceWithRandom_Click);
     108      //
     109      // mostCommonToolStripMenuItem
     110      //
     111      this.mostCommonToolStripMenuItem.Name = "mostCommonToolStripMenuItem";
     112      this.mostCommonToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
     113      this.mostCommonToolStripMenuItem.Text = "Most Common";
     114      this.mostCommonToolStripMenuItem.Click += new System.EventHandler(this.ReplaceWithMostCommon_Click);
     115      //
     116      // interpolationToolStripMenuItem
     117      //
     118      this.interpolationToolStripMenuItem.Name = "interpolationToolStripMenuItem";
     119      this.interpolationToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
     120      this.interpolationToolStripMenuItem.Text = "Interpolation";
     121      this.interpolationToolStripMenuItem.Click += new System.EventHandler(this.ReplaceWithInterpolation_Click);
     122      //
    60123      // DataGridContentView
    61124      //
     
    72135      this.Controls.SetChildIndex(this.btnApplySort, 0);
    73136      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     137      this.contextMenuCell.ResumeLayout(false);
    74138      this.ResumeLayout(false);
    75139      this.PerformLayout();
     
    80144
    81145    private System.Windows.Forms.Button btnApplySort;
     146    private System.Windows.Forms.ContextMenuStrip contextMenuCell;
     147    private System.Windows.Forms.ToolStripMenuItem replaceValueToolStripMenuItem;
     148    private System.Windows.Forms.ToolStripMenuItem averageToolStripMenuItem;
     149    private System.Windows.Forms.ToolStripMenuItem medianToolStripMenuItem;
     150    private System.Windows.Forms.ToolStripMenuItem randomToolStripMenuItem;
     151    private System.Windows.Forms.ToolStripMenuItem mostCommonToolStripMenuItem;
     152    private System.Windows.Forms.ToolStripMenuItem interpolationToolStripMenuItem;
    82153  }
    83154}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/DataGridContentView.cs

    r10345 r10380  
    88using System.Collections.Generic;
    99using System.Linq;
     10using System;
    1011
    1112namespace HeuristicLab.DataPreprocessing {
     
    1314  [Content(typeof(IDataGridContent), true)]
    1415  public partial class DataGridContentView : StringConvertibleMatrixView {
     16
     17    private int lastClickedRow;
     18    private int lastClickedColumn;
    1519
    1620    public new IDataGridContent Content {
     
    2125    public DataGridContentView() {
    2226      InitializeComponent();
     27      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
     28      contextMenuCell.Items.Add(ShowHideColumns);
    2329    }
    2430
     
    4955    }
    5056
     57    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
     58      if (Content == null) return;
     59      if (e.Button == System.Windows.Forms.MouseButtons.Right) {
     60        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
     61          contextMenu.Show(MousePosition);
     62        } else {
     63          interpolationToolStripMenuItem.Enabled = !(e.RowIndex == 0 || e.RowIndex == Content.Rows);
     64          contextMenuCell.Show(MousePosition);
     65          lastClickedColumn = e.ColumnIndex;
     66          lastClickedRow = e.RowIndex;
     67        }
     68      }
     69    }
     70
    5171    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
    5272      btnApplySort.Enabled = sortedColumns.Any();
     
    5878      base.ClearSorting();
    5979    }
     80
     81    private void ReplaceWithAverage_Click(object sender, EventArgs e) {
     82      var asdf = new List<int>() { lastClickedRow };
     83      Content.PreprocessingDataManipulation.ReplaceIndicesByAverageValue(lastClickedColumn, new List<int>() { lastClickedRow });
     84    }
     85
     86    private void ReplaceWithMedian_Click(object sender, EventArgs e) {
     87      Content.PreprocessingDataManipulation.ReplaceIndicesByMedianValue(lastClickedColumn, new List<int>() { lastClickedRow });
     88    }
     89
     90    private void ReplaceWithRandom_Click(object sender, EventArgs e) {
     91      Content.PreprocessingDataManipulation.ReplaceIndicesByRandomValue(lastClickedColumn, new List<int>() { lastClickedRow });
     92    }
     93
     94    private void ReplaceWithMostCommon_Click(object sender, EventArgs e) {
     95      Content.PreprocessingDataManipulation.ReplaceIndicesByMostCommonValue(lastClickedColumn, new List<int>() { lastClickedRow });
     96    }
     97
     98    private void ReplaceWithInterpolation_Click(object sender, EventArgs e) {
     99      Content.PreprocessingDataManipulation.ReplaceIndicesByLinearInterpolationOfNeighbours(lastClickedColumn, new List<int>() { lastClickedRow });
     100    }
    60101  }
    61102}
Note: See TracChangeset for help on using the changeset viewer.