Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/15 12:02:40 (8 years ago)
Author:
mkommend
Message:

#2486: Merged r12983, r12986, r13252 and r13271 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing.Views

  • stable/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r12718 r13289  
    5959      InitializeComponent();
    6060      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
     61      dataGridView.RowHeaderMouseClick += dataGridView_RowHeaderMouseClick;
    6162      dataGridView.KeyDown += dataGridView_KeyDown;
    6263      dataGridView.MouseUp += dataGridView_MouseUp;
     
    142143
    143144
    144     //protected override void PasteValuesToDataGridView() {
    145     //  base.PasteValuesToDataGridView();
    146     //  dataGridView.Refresh();
    147     //}
     145    protected override void PasteValuesToDataGridView() {
     146      string[,] values = SplitClipboardString(Clipboard.GetText());
     147      int rowIndex = 0;
     148      int columnIndex = 0;
     149      if (dataGridView.CurrentCell != null) {
     150        rowIndex = dataGridView.CurrentCell.RowIndex;
     151        columnIndex = dataGridView.CurrentCell.ColumnIndex;
     152      }
     153      if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex;
     154      if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex;
     155
     156      ReplaceTransaction(() => {
     157        Content.PreProcessingData.InTransaction(() => {
     158          for (int row = 0; row < values.GetLength(1); row++) {
     159            for (int col = 0; col < values.GetLength(0); col++) {
     160              Content.SetValue(values[col, row], row + rowIndex, col + columnIndex);
     161            }
     162          }
     163        });
     164      });
     165
     166      ClearSorting();
     167    }
    148168
    149169    protected override void SetEnabledStateOfControls() {
     
    165185    protected override void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
    166186      if (Content != null) {
    167         if (e.Button == System.Windows.Forms.MouseButtons.Left) {
     187        if (e.Button == MouseButtons.Left) {
    168188          dataGridView.Focus();
    169189          dataGridView.ClearSelection();
     
    174194            dataGridView[e.ColumnIndex, i].Selected = true;
    175195          }
    176         } else if (Content.SortableView) {
     196        } else if (e.Button == MouseButtons.Middle) {
     197          int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0;
     198          Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex);
     199        } else if (e.Button == MouseButtons.Right && Content.SortableView) {
    177200          SortColumn(e.ColumnIndex);
    178201        }
    179202      }
    180203      searchIterator = null;
     204    }
     205    private void dataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
     206      if (Content != null) {
     207        if (e.Button == MouseButtons.Middle) {
     208          int newIndex = e.RowIndex >= 0 ? e.RowIndex : 0;
     209          Content.PreProcessingData.InsertRow(newIndex);
     210        }
     211      }
    181212    }
    182213
     
    450481    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
    451482      if (Content == null) return;
    452       if (e.Button == System.Windows.Forms.MouseButtons.Right && !(e.ColumnIndex != -1 && e.RowIndex == -1)) {
     483      if (e.Button == MouseButtons.Right && !(e.ColumnIndex != -1 && e.RowIndex == -1)) {
    453484        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
    454485          replaceValueOverColumnToolStripMenuItem.Visible = false;
     
    612643    #endregion
    613644
     645    private void addRowButton_Click(object sender, EventArgs e) {
     646      Content.PreProcessingData.InsertRow(Content.Rows);
     647    }
     648
     649    private void addColumnButton_Click(object sender, EventArgs e) {
     650      Content.PreProcessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);
     651    }
     652
     653    private void renameColumnsButton_Click(object sender, EventArgs e) {
     654      var renameDialog = new RenameColumnsDialog(Content.ColumnNames);
     655
     656      if (renameDialog.ShowDialog(this) == DialogResult.OK) {
     657        Content.PreProcessingData.RenameColumns(renameDialog.ColumnNames);
     658      }
     659    }
    614660  }
    615661}
Note: See TracChangeset for help on using the changeset viewer.