Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10551


Ignore:
Timestamp:
03/05/14 17:27:15 (11 years ago)
Author:
rstoll
Message:

Event registration implemented for statistics view

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataPreprocessingChangedEvent.cs

    r10544 r10551  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    523
    624namespace HeuristicLab.DataPreprocessing {
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsContent.cs

    r10539 r10551  
    4848      return new StatisticsContent(this, cloner);
    4949    }
     50
     51    public event DataPreprocessingChangedEventHandler Changed {
     52      add { statisticsLogic.Changed += value; }
     53      remove { statisticsLogic.Changed -= value; }
     54    }
     55
    5056  }
    5157}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/StatisticsLogic.cs

    r10539 r10551  
    185185      return dateTime.Add(new TimeSpan(0, 0, (int)seconds));
    186186    }
     187
     188    public event DataPreprocessingChangedEventHandler Changed {
     189      add { preprocessingData.Changed += value; }
     190      remove { preprocessingData.Changed -= value; }
     191    }
    187192  }
    188193}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IStatisticsLogic.cs

    r10539 r10551  
    4949    string GetColumnTypeAsString(int columnIndex);
    5050    string GetVariableName(int columnIndex);
     51
     52    event DataPreprocessingChangedEventHandler Changed;
    5153  }
    5254}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/StatisticsView.cs

    r10539 r10551  
    5858      }
    5959    }
     60
     61    /// <summary>
     62    /// Adds eventhandlers to the current instance.
     63    /// </summary>
     64    protected override void RegisterContentEvents() {
     65      Content.Changed += Content_Changed;
     66    }
     67
     68
     69    /// <summary>
     70    /// Removes the eventhandlers from the current instance.
     71    /// </summary>
     72    protected override void DeregisterContentEvents() {
     73      Content.Changed -= Content_Changed;
     74    }
     75
    6076    private void UpdateData() {
    6177      var logic = Content.StatisticsLogic;
     
    86102
    87103      for (int i = 0; i < logic.GetColumnCount(); ++i) {
    88         List<string> list;
    89         if (logic.IsType<double>(i)) {
    90           list = GetDoubleColumns(i);
    91         } else if (logic.IsType<string>(i)) {
    92           list = GetStringColumns(i);
    93         } else if (logic.IsType<DateTime>(i)) {
    94           list = GetDateTimeColumns(i);
    95         } else {
    96           list = new List<string>();
    97           for (int j = 0; j < COLUMNS; ++j) {
    98             list.Add("unknown column type");
    99           }
    100         }
    101         columnsRowsMatrix.Add(list);
     104        columnsRowsMatrix.Add(GetList(i));
    102105      }
    103106
     
    110113      }
    111114      dataGridView.AllowUserToResizeColumns = true;
     115    }
     116
     117    private List<string> GetList(int i) {
     118      List<string> list;
     119      var logic = Content.StatisticsLogic;
     120      if (logic.IsType<double>(i)) {
     121        list = GetDoubleColumns(i);
     122      } else if (logic.IsType<string>(i)) {
     123        list = GetStringColumns(i);
     124      } else if (logic.IsType<DateTime>(i)) {
     125        list = GetDateTimeColumns(i);
     126      } else {
     127        list = new List<string>();
     128        for (int j = 0; j < COLUMNS; ++j) {
     129          list.Add("unknown column type");
     130        }
     131      }
     132      return list;
    112133    }
    113134
     
    169190      }
    170191    }
     192
     193    private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
     194      switch (e.Type) {
     195        case DataPreprocessingChangedEventType.DeleteColumn:
     196          columnsRowsMatrix.RemoveAt(e.Column);
     197          break;
     198        case DataPreprocessingChangedEventType.AddColumn:
     199          columnsRowsMatrix.Insert(e.Row, GetList(e.Column));
     200          dataGridView.RowCount++;
     201          break;
     202        case DataPreprocessingChangedEventType.ChangeItem:
     203          columnsRowsMatrix[e.Column] = GetList(e.Column);
     204          break;
     205        case DataPreprocessingChangedEventType.DeleteRow:
     206        case DataPreprocessingChangedEventType.AddRow:
     207          for (int i = 0; i < columnsRowsMatrix.Count; ++i) {
     208            columnsRowsMatrix[i] = GetList(e.Column);
     209          }
     210          break;
     211      }
     212      dataGridView.Refresh();
     213    }
    171214  }
    172215}
Note: See TracChangeset for help on using the changeset viewer.