Changeset 8872


Ignore:
Timestamp:
11/06/12 17:40:06 (10 years ago)
Author:
abeham
Message:

#1043: Added repetitions counting to optimizer/experiment list view as well

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/OptimizerListView.cs

    r7259 r8872  
    5151        try {
    5252          return (IOptimizer)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    53         }
    54         catch (Exception ex) {
     53        } catch (Exception ex) {
    5554          ErrorHandling.ShowErrorDialog(this, ex);
    5655        }
     
    5857      return null;
    5958    }
     59
     60    protected override void DeregisterItemEvents(IOptimizer item) {
     61      var batchRun = item as BatchRun;
     62      if (batchRun != null) {
     63        batchRun.RepetitionsChanged -= BatchRun_UpdateText;
     64        batchRun.RepetetionsCounterChanged -= BatchRun_UpdateText;
     65      }
     66      base.DeregisterItemEvents(item);
     67    }
     68
     69    protected override void RegisterItemEvents(IOptimizer item) {
     70      base.RegisterItemEvents(item);
     71      var batchRun = item as BatchRun;
     72      if (batchRun != null) {
     73        batchRun.RepetitionsChanged += BatchRun_UpdateText;
     74        batchRun.RepetetionsCounterChanged += BatchRun_UpdateText;
     75      }
     76    }
     77
     78    protected override ListViewItem CreateListViewItem(IOptimizer item) {
     79      var listViewItem = base.CreateListViewItem(item);
     80      var batchRun = item as BatchRun;
     81      if (batchRun != null) {
     82        listViewItem.Text += string.Format(" {0}/{1}", batchRun.RepetitionsCounter, batchRun.Repetitions);
     83      }
     84      return listViewItem;
     85    }
     86
     87    protected override void UpdateListViewItemText(ListViewItem listViewItem) {
     88      base.UpdateListViewItemText(listViewItem);
     89      var batchRun = listViewItem.Tag as BatchRun;
     90      if (batchRun != null) {
     91        listViewItem.Text = batchRun.ToString() + string.Format(" {0}/{1}", batchRun.RepetitionsCounter, batchRun.Repetitions);
     92      }
     93    }
     94
     95    protected virtual void BatchRun_UpdateText(object sender, EventArgs eventArgs) {
     96      if (sender is BatchRun) {
     97        foreach (var item in GetListViewItemsForItem(sender as BatchRun))
     98          UpdateListViewItemText(item);
     99      }
     100    }
    60101  }
    61102}
Note: See TracChangeset for help on using the changeset viewer.