Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/DataGridContentView.cs @ 10345

Last change on this file since 10345 was 10345, checked in by sbreuer, 10 years ago
  • disable apply sort button if nothing to do
File size: 1.9 KB
Line 
1
2using System.Windows.Forms;
3using HeuristicLab.Core.Views;
4using HeuristicLab.MainForm;
5using HeuristicLab.MainForm.WindowsForms;
6using HeuristicLab.Problems.DataAnalysis;
7using HeuristicLab.Data.Views;
8using System.Collections.Generic;
9using System.Linq;
10
11namespace HeuristicLab.DataPreprocessing {
12  [View("Data Grid Content View")]
13  [Content(typeof(IDataGridContent), true)]
14  public partial class DataGridContentView : StringConvertibleMatrixView {
15
16    public new IDataGridContent Content {
17      get { return (IDataGridContent)base.Content; }
18      set { base.Content = value; }
19    }
20
21    public DataGridContentView() {
22      InitializeComponent();
23    }
24
25    protected override void OnContentChanged() {
26      base.OnContentChanged();
27    }
28
29
30    private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {
31      if (!dataGridView.ReadOnly) {
32        string errorMessage;
33        if (Content != null && !Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex)) {
34          e.Cancel = true;
35          dataGridView.Rows[e.RowIndex].ErrorText = errorMessage;
36        }
37      }
38    }
39
40    protected override void SetEnabledStateOfControls() {
41      base.SetEnabledStateOfControls();
42      rowsTextBox.ReadOnly = true;
43      columnsTextBox.ReadOnly = true;
44    }
45
46    private void btnApplySort_Click(object sender, System.EventArgs e) {
47      Content.PreprocessingDataManipulation.reOrderToIndices(virtualRowIndices);
48      OnContentChanged();
49    }
50
51    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
52      btnApplySort.Enabled = sortedColumns.Any();
53      return base.Sort(sortedColumns);
54    }
55
56    protected override void ClearSorting() {
57      btnApplySort.Enabled = false;
58      base.ClearSorting();
59    }
60  }
61}
Note: See TracBrowser for help on using the repository browser.