Ignore:
Timestamp:
05/14/14 13:37:28 (5 years ago)
Author:
aesterer
Message:

Added coloring feature for line chart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingDataTableView.cs

    r10804 r10847  
    6060      Content.Rows.ItemsReplaced -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
    6161      Content.Rows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
     62
     63      Content.SelectedRows.ItemsAdded -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded);
     64      Content.SelectedRows.ItemsRemoved -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved);
     65      Content.SelectedRows.ItemsReplaced -= new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
     66      Content.SelectedRows.CollectionReset -= new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
    6267      base.DeregisterContentEvents();
    6368    }
     
    6974      Content.Rows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced);
    7075      Content.Rows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(Rows_CollectionReset);
    71     }
     76
     77      Content.SelectedRows.ItemsAdded += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_ItemsAdded);
     78      Content.SelectedRows.ItemsRemoved += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_ItemsRemoved);
     79      Content.SelectedRows.ItemsReplaced += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_ItemsReplaced);
     80      Content.SelectedRows.CollectionReset += new CollectionItemsChangedEventHandler<DataRow>(SelectedRows_CollectionReset);
     81    }
     82
    7283
    7384    protected virtual void RegisterDataRowEvents(DataRow row) {
     
    141152      foreach (var row in rows) {
    142153        if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Line) {
    143           //RegisterDataRowEvents(row);
    144154          row.VisualProperties.IsVisibleInLegend = false;
    145           var series = new Series(row.Name);
     155
     156          //add selected to name in order to avoid naming conflict
     157          var series = new Series(row.Name+"(Selected)");
    146158          ConfigureSeries(series, row);
    147159          FillSeriesWithRowValues(series, row);
    148160          chart.Series.Add(series);
    149161        }
     162      }
     163    }
     164
     165    protected virtual void RemoveSelectedDataRows(IEnumerable<DataRow> rows) {
     166      foreach (var row in rows) {
     167        Series series = chart.Series[row.Name + "(Selected)"];
     168        chart.Series.Remove(series);
    150169      }
    151170    }
     
    307326    #endregion
    308327    #region Rows Event Handlers
     328
     329    private void SelectedRows_CollectionReset(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
     330      if (InvokeRequired)
     331        Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced), sender, e);
     332      else {
     333        RemoveSelectedDataRows(e.OldItems);
     334        AddSelectedDataRows(e.Items);
     335      }
     336    }
     337
     338    private void SelectedRows_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
     339      if (InvokeRequired)
     340        Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsReplaced), sender, e);
     341      else {
     342        RemoveSelectedDataRows(e.OldItems);
     343        AddSelectedDataRows(e.Items);
     344      }
     345    }
     346
     347    private void SelectedRows_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
     348      if (InvokeRequired)
     349        Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsRemoved), sender, e);
     350      else {
     351        RemoveSelectedDataRows(e.Items);
     352      }
     353    }
     354
     355    private void SelectedRows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
     356      if (InvokeRequired)
     357        Invoke(new CollectionItemsChangedEventHandler<DataRow>(Rows_ItemsAdded), sender, e);
     358      else {
     359        AddSelectedDataRows(e.Items);
     360      }
     361    }
     362
     363
    309364    private void Rows_ItemsAdded(object sender, CollectionItemsChangedEventArgs<DataRow> e) {
    310365      if (InvokeRequired)
     
    570625      }
    571626
     627
    572628      if (!row.VisualProperties.ExactBins) {
    573629        intervalWidth = HumanRoundRange(intervalWidth);
Note: See TracChangeset for help on using the changeset viewer.