Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/11/15 13:37:32 (9 years ago)
Author:
ascheibe
Message:

#2270 and #2354: merged r12173, r12458, r12077, r12599, r12613, r12112, r12116, r12117, r12131, r12631, r12672, r12684, r12690, r12692 into stable

Location:
stable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs

    r12009 r12725  
    122122      if (InvokeRequired)
    123123        Invoke(new EventHandler(Content_Reset), sender, e);
    124       else {
     124      else if (!suppressUpdates) {
    125125        UpdateDataPoints();
    126126        UpdateAxisLabels();
     
    376376      Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY;
    377377      int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
    378       //mkommend: combobox.SelectedIndex could not be used as this changes during hoovering over possible values
     378      //mkommend: combobox.SelectedIndex could not be used as this changes during hovering over possible values
    379379      var xSAxisSelectedIndex = xAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(xAxisValue);
    380380      var ySAxisSelectedIndex = yAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(yAxisValue);
  • stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r12009 r12725  
    262262
    263263    private void Content_Reset(object sender, EventArgs e) {
     264      if (suppressUpdates) return;
    264265      if (InvokeRequired)
    265266        Invoke(new EventHandler(Content_Reset), sender, e);
  • stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs

    r12009 r12725  
    2424using System.ComponentModel;
    2525using System.Linq;
    26 using System.Windows.Forms;
    2726using HeuristicLab.Analysis;
    2827using HeuristicLab.Collections;
     
    4140    }
    4241
    43     private int rowNumber = 0;
     42    private int rowNumber;
    4443    private bool suppressUpdates;
    4544    private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping;
     
    6059    protected override void RegisterContentEvents() {
    6160      base.RegisterContentEvents();
    62       Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    63       Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    64       Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    65       Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
    66       Content.OptimizerNameChanged += new EventHandler(Content_AlgorithmNameChanged);
     61      Content.ItemsAdded += Content_ItemsAdded;
     62      Content.ItemsRemoved += Content_ItemsRemoved;
     63      Content.CollectionReset += Content_CollectionReset;
     64      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
     65      Content.OptimizerNameChanged += Content_AlgorithmNameChanged;
    6766    }
    6867    protected override void DeregisterContentEvents() {
    69       Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    70       Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    71       Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    72       Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
    73       Content.OptimizerNameChanged -= new EventHandler(Content_AlgorithmNameChanged);
     68      Content.ItemsAdded -= Content_ItemsAdded;
     69      Content.ItemsRemoved -= Content_ItemsRemoved;
     70      Content.CollectionReset -= Content_CollectionReset;
     71      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
     72      Content.OptimizerNameChanged -= Content_AlgorithmNameChanged;
    7473      base.DeregisterContentEvents();
    7574    }
    7675
    7776    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     77      if (suppressUpdates) return;
    7878      if (InvokeRequired) {
    7979        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
    8080        return;
    8181      }
     82      UpdateDataTableComboBox();
     83      UpdateDataRowComboBox();
    8284      AddRuns(e.Items);
    8385    }
    8486    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     87      if (suppressUpdates) return;
    8588      if (InvokeRequired) {
    8689        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
    8790        return;
    8891      }
     92      UpdateDataTableComboBox();
     93      UpdateDataRowComboBox();
    8994      RemoveRuns(e.Items);
    9095    }
    9196    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     97      if (suppressUpdates) return;
    9298      if (InvokeRequired) {
    9399        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
    94100        return;
    95101      }
     102      UpdateDataTableComboBox();
     103      UpdateDataRowComboBox();
    96104      RemoveRuns(e.OldItems);
    97105      AddRuns(e.Items);
     
    108116      }
    109117      suppressUpdates = Content.UpdateOfRunsInProgress;
    110       if (!suppressUpdates) UpdateRuns(Content);
     118      if (!suppressUpdates) {
     119        UpdateDataTableComboBox();
     120        UpdateDataRowComboBox();
     121        UpdateRuns(Content);
     122      }
    111123    }
    112124
     
    124136        var run = (IRun)sender;
    125137        if (e.PropertyName == "Color" || e.PropertyName == "Visible")
    126           UpdateRuns(new IRun[] { run });
     138          UpdateRuns(new[] { run });
    127139      }
    128140    }
     
    168180
    169181    private void UpdateRuns(IEnumerable<IRun> runs) {
    170       if (suppressUpdates) return;
    171182      foreach (var run in runs) {
    172183        //update color
    173         foreach (var dataRow in runMapping[run]) {
    174           dataRow.VisualProperties.Color = run.Color;
     184        if (!runMapping.ContainsKey(run)) {
     185          runMapping[run] = ExtractDataRowsFromRun(run).ToList();
     186          RegisterRunEvents(run);
     187        } else {
     188          foreach (var dataRow in runMapping[run]) {
     189            dataRow.VisualProperties.Color = run.Color;
     190          }
    175191        }
    176         //update visibility - remove and add all rows to keep the same order as before
    177         combinedDataTable.Rows.Clear();
    178         combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    179       }
     192      }
     193      //update visibility - remove and add all rows to keep the same order as before
     194      combinedDataTable.Rows.Clear();
     195      combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    180196    }
    181197
    182198    private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) {
    183199      var resultName = (string)dataTableComboBox.SelectedItem;
     200      if (string.IsNullOrEmpty(resultName)) yield break;
     201
    184202      var rowName = (string)dataRowComboBox.SelectedItem;
    185203      if (!run.Results.ContainsKey(resultName)) yield break;
     
    199217
    200218    private void UpdateDataTableComboBox() {
     219      string selectedItem = (string)dataTableComboBox.SelectedItem;
     220
    201221      dataTableComboBox.Items.Clear();
    202222      var dataTables = (from run in Content
     
    206226
    207227      dataTableComboBox.Items.AddRange(dataTables);
    208       if (dataTableComboBox.Items.Count > 0) dataTableComboBox.SelectedItem = dataTableComboBox.Items[0];
     228      if (selectedItem != null && dataTableComboBox.Items.Contains(selectedItem)) {
     229        dataTableComboBox.SelectedItem = selectedItem;
     230      } else if (dataTableComboBox.Items.Count > 0) {
     231        dataTableComboBox.SelectedItem = dataTableComboBox.Items[0];
     232      }
    209233    }
    210234
     
    214238
    215239    private void UpdateDataRowComboBox() {
     240      string selectedItem = (string)dataRowComboBox.SelectedItem;
     241
    216242      dataRowComboBox.Items.Clear();
    217243      var resultName = (string)dataTableComboBox.SelectedItem;
     244      if (resultName == null) return;
     245
    218246      var dataTables = from run in Content
    219247                       where run.Results.ContainsKey(resultName)
     
    225253      dataRowComboBox.Items.AddRange(rowNames);
    226254      dataRowComboBox.Items.Add(AllDataRows);
    227       if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0];
    228     }
    229 
    230     private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
    231       UpdateDataRowComboBox();
    232     }
    233     private void dataRowComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     255      if (selectedItem != null && dataRowComboBox.Items.Contains(selectedItem)) {
     256        dataRowComboBox.SelectedItem = selectedItem;
     257      } else if (dataRowComboBox.Items.Count > 0) {
     258        dataRowComboBox.SelectedItem = dataRowComboBox.Items[0];
     259      }
     260    }
     261
     262    private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     263      UpdateDataRowComboBox();
     264    }
     265    private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     266      if (suppressUpdates) return;
    234267      RebuildCombinedDataTable();
    235268    }
  • stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs

    r12009 r12725  
    5353      base.OnContentChanged();
    5454      if (Content != null) {
    55         runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    5655        UpdateRowAttributes();
    5756      }
     
    117116    }
    118117
     118    protected override void UpdateData() {
     119      if (suppressUpdates) return;
     120      base.UpdateData();
     121    }
     122
    119123    protected override void UpdateColumnHeaders() {
    120124      HashSet<string> visibleColumnNames = new HashSet<string>(dataGridView.Columns.OfType<DataGridViewColumn>()
     
    145149      else {
    146150        suppressUpdates = Content.UpdateOfRunsInProgress;
    147         if (!suppressUpdates) UpdateRowAttributes();
     151        if (!suppressUpdates) {
     152          UpdateData();
     153          UpdateRowAttributes();
     154        }
    148155      }
    149156    }
     
    171178    protected override void ClearSorting() {
    172179      base.ClearSorting();
    173       runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    174180      UpdateRowAttributes();
    175181    }
     
    190196        i++;
    191197      }
    192       UpdateRowAttributes();
     198      UpdateRowAttributes(rebuild: false);
    193199      return newSortedIndex;
    194200    }
    195201
    196     private void UpdateRowAttributes() {
     202    private void UpdateRowAttributes(bool rebuild = true) {
     203      if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    197204      int runIndex = 0;
    198205      foreach (IRun run in Content) {
  • stable/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r12009 r12725  
    4141    private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping;
    4242    private bool validDragOperation;
     43    private bool suppressUpdates;
    4344
    4445    public new IItemCollection<IRun> Content {
     
    6667      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    6768      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     69      if (RunCollection != null)
     70        RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    6871      foreach (IRun run in itemListViewItemMapping.Keys) {
    6972        DeregisterItemEvents(run);
     
    7679      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    7780      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     81      if (RunCollection != null)
     82        RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    7883    }
    7984    private void DeregisterItemEvents(IRun item) {
     
    394399    #region Content Events
    395400    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     401      if (suppressUpdates) return;
    396402      if (InvokeRequired)
    397403        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
     
    407413    }
    408414    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     415      if (suppressUpdates) return;
    409416      if (InvokeRequired)
    410417        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
     
    422429    }
    423430    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     431      if (suppressUpdates) return;
    424432      if (InvokeRequired)
    425433        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
     
    440448      }
    441449    }
     450    private void RunCollection_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     451      if (InvokeRequired) Invoke((Action<object, EventArgs>)RunCollection_UpdateOfRunsInProgressChanged, sender, e);
     452      else {
     453        suppressUpdates = RunCollection.UpdateOfRunsInProgress;
     454        if (!suppressUpdates) {
     455          foreach (IRun item in Content) {
     456            //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection
     457            ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault();
     458            if (listViewItem != null) RemoveListViewItem(listViewItem);
     459          }
     460          RebuildImageList();
     461          foreach (IRun item in Content)
     462            AddListViewItem(CreateListViewItem(item));
     463
     464          AdjustListViewColumnSizes();
     465          analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
     466          clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
     467          runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
     468        }
     469      }
     470    }
    442471    #endregion
    443472
    444473    #region Item Events
    445474    private void Item_ItemImageChanged(object sender, EventArgs e) {
     475      if (suppressUpdates) return;
    446476      if (InvokeRequired)
    447477        Invoke(new EventHandler(Item_ItemImageChanged), sender, e);
     
    453483    }
    454484    private void Item_ToStringChanged(object sender, EventArgs e) {
     485      if (suppressUpdates) return;
    455486      if (InvokeRequired)
    456487        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
     
    463494    }
    464495    private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     496      if (suppressUpdates) return;
    465497      if (InvokeRequired)
    466         this.Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
     498        Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
    467499      else {
    468500        IRun run = (IRun)sender;
Note: See TracChangeset for help on using the changeset viewer.