1 |
|
---|
2 | using System.Windows.Forms;
|
---|
3 | using HeuristicLab.Core.Views;
|
---|
4 | using HeuristicLab.MainForm;
|
---|
5 | using HeuristicLab.MainForm.WindowsForms;
|
---|
6 | using HeuristicLab.Problems.DataAnalysis;
|
---|
7 | using HeuristicLab.Data.Views;
|
---|
8 | using System.Collections.Generic;
|
---|
9 | using System.Linq;
|
---|
10 |
|
---|
11 | namespace 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 | }
|
---|