Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/09/15 13:07:30 (9 years ago)
Author:
abeham
Message:

#2208: merged trunk changes

Location:
branches/HeuristicLab.Problems.Orienteering
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.Orienteering

  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views

    • Property svn:mergeinfo set to (toggle deleted branches)
      /branches/HLScript/HeuristicLab.Optimization.Viewsmergedeligible
      /stable/HeuristicLab.Optimization.Viewsmergedeligible
      /trunk/sources/HeuristicLab.Optimization.Viewsmergedeligible
      /branches/1721-RandomForestPersistence/HeuristicLab.Optimization.Views10321-10322
      /branches/Algorithms.GradientDescent/HeuristicLab.Optimization.Views5516-5520
      /branches/Benchmarking/sources/HeuristicLab.Optimization.Views6917-7005
      /branches/CloningRefactoring/HeuristicLab.Optimization.Views4656-4721
      /branches/CodeEditor/HeuristicLab.Optimization.Views11700-11806
      /branches/DataAnalysis Refactoring/HeuristicLab.Optimization.Views5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Optimization.Views5815-6180
      /branches/DataAnalysis/HeuristicLab.Optimization.Views4458-4459,​4462,​4464
      /branches/DataPreprocessing/HeuristicLab.Optimization.Views10085-11101
      /branches/GP.Grammar.Editor/HeuristicLab.Optimization.Views6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Optimization.Views5060
      /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Optimization.Views11570-12508
      /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Optimization.Views6123-9799
      /branches/LogResidualEvaluator/HeuristicLab.Optimization.Views10202-10483
      /branches/NET40/sources/HeuristicLab.Optimization.Views5138-5162
      /branches/NSGA-II Changes/HeuristicLab.Optimization.Views12033-12122
      /branches/ParallelEngine/HeuristicLab.Optimization.Views5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Optimization.Views7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Optimization.Views6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Optimization.Views6828
      /branches/RuntimeOptimizer/HeuristicLab.Optimization.Views8943-9078
      /branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization.Views7787-8333
      /branches/SlaveShutdown/HeuristicLab.Optimization.Views8944-8956
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Optimization.Views10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Optimization.Views5370-5682
      /branches/TimeLimitRunOptimizer/HeuristicLab.Optimization.Views9438-12626
      /branches/Trunk/HeuristicLab.Optimization.Views6829-6865
      /branches/UnloadJobs/HeuristicLab.Optimization.Views9168-9215
      /branches/VNS/HeuristicLab.Optimization.Views5594-5752
      /branches/histogram/HeuristicLab.Optimization.Views5959-6341
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.Designer.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBoxPlotView.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Linq;
    2526using System.Windows.Forms;
     
    9293    protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) {
    9394      foreach (IRun run in runs)
    94         run.Changed += new EventHandler(run_Changed);
     95        run.PropertyChanged += run_PropertyChanged;
    9596    }
    9697    protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) {
    9798      foreach (IRun run in runs)
    98         run.Changed -= new EventHandler(run_Changed);
     99        run.PropertyChanged -= run_PropertyChanged;
    99100    }
    100101
     
    121122      if (InvokeRequired)
    122123        Invoke(new EventHandler(Content_Reset), sender, e);
    123       else {
     124      else if (!suppressUpdates) {
    124125        UpdateDataPoints();
    125126        UpdateAxisLabels();
     
    133134      }
    134135    }
    135     private void run_Changed(object sender, EventArgs e) {
     136    private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    136137      if (InvokeRequired)
    137         this.Invoke(new EventHandler(run_Changed), sender, e);
     138        this.Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e);
    138139      else if (!suppressUpdates) {
    139         UpdateDataPoints();
     140        if (e.PropertyName == "Visible")
     141          UpdateDataPoints();
    140142      }
    141143    }
     
    374376      Axis yAxis = this.chart.ChartAreas[BoxPlotChartAreaName].AxisY;
    375377      int axisDimensionCount = Enum.GetNames(typeof(AxisDimension)).Count();
    376       //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
    377379      var xSAxisSelectedIndex = xAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(xAxisValue);
    378380      var ySAxisSelectedIndex = yAxisValue == null ? 0 : xAxisComboBox.Items.IndexOf(yAxisValue);
     
    451453    }
    452454
     455    public void SetXAxis(string axisName) {
     456      xAxisComboBox.SelectedItem = axisName;
     457    }
     458
     459    public void SetYAxis(string axisName) {
     460      yAxisComboBox.SelectedItem = axisName;
     461    }
    453462  }
    454463}
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.Designer.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Drawing;
    2526using System.Linq;
     
    116117    protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) {
    117118      foreach (IRun run in runs)
    118         run.Changed += new EventHandler(run_Changed);
     119        run.PropertyChanged += run_PropertyChanged;
    119120    }
    120121    protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) {
    121122      foreach (IRun run in runs)
    122         run.Changed -= new EventHandler(run_Changed);
     123        run.PropertyChanged -= run_PropertyChanged;
    123124    }
    124125
     
    133134      RegisterRunEvents(e.Items);
    134135    }
    135     private void run_Changed(object sender, EventArgs e) {
     136    private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    136137      if (suppressUpdates) return;
    137138      if (InvokeRequired)
    138         this.Invoke(new EventHandler(run_Changed), sender, e);
     139        this.Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e);
    139140      else {
    140         IRun run = (IRun)sender;
    141         UpdateRun(run);
    142         UpdateCursorInterval();
    143         chart.ChartAreas[0].RecalculateAxesScale();
    144         UpdateAxisLabels();
     141        if (e.PropertyName == "Color" || e.PropertyName == "Visible") {
     142          IRun run = (IRun)sender;
     143          UpdateRun(run);
     144          UpdateCursorInterval();
     145          chart.ChartAreas[0].RecalculateAxesScale();
     146          UpdateAxisLabels();
     147        }
    145148      }
    146149    }
     
    259262
    260263    private void Content_Reset(object sender, EventArgs e) {
     264      if (suppressUpdates) return;
    261265      if (InvokeRequired)
    262266        Invoke(new EventHandler(Content_Reset), sender, e);
     
    670674      if (xAxisValue != null)
    671675        xAxis.Title = xAxisValue;
    672       if(yAxisValue != null)
    673       yAxis.Title = yAxisValue;
     676      if (yAxisValue != null)
     677        yAxis.Title = yAxisValue;
    674678    }
    675679
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.Designer.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionChartAggregationView.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Linq;
    25 using System.Windows.Forms;
    2626using HeuristicLab.Analysis;
    2727using HeuristicLab.Collections;
     
    4040    }
    4141
    42     private int rowNumber = 0;
     42    private int rowNumber;
    4343    private bool suppressUpdates;
    4444    private readonly Dictionary<IRun, IEnumerable<DataRow>> runMapping;
     
    5959    protected override void RegisterContentEvents() {
    6060      base.RegisterContentEvents();
    61       Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    62       Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    63       Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    64       Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
    65       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;
    6666    }
    6767    protected override void DeregisterContentEvents() {
    68       Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    69       Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    70       Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    71       Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
    72       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;
    7373      base.DeregisterContentEvents();
    7474    }
    7575
    7676    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     77      if (suppressUpdates) return;
    7778      if (InvokeRequired) {
    7879        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
    7980        return;
    8081      }
     82      UpdateDataTableComboBox();
     83      UpdateDataRowComboBox();
    8184      AddRuns(e.Items);
    8285    }
    8386    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     87      if (suppressUpdates) return;
    8488      if (InvokeRequired) {
    8589        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
    8690        return;
    8791      }
     92      UpdateDataTableComboBox();
     93      UpdateDataRowComboBox();
    8894      RemoveRuns(e.Items);
    8995    }
    9096    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     97      if (suppressUpdates) return;
    9198      if (InvokeRequired) {
    9299        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
    93100        return;
    94101      }
     102      UpdateDataTableComboBox();
     103      UpdateDataRowComboBox();
    95104      RemoveRuns(e.OldItems);
    96105      AddRuns(e.Items);
     
    107116      }
    108117      suppressUpdates = Content.UpdateOfRunsInProgress;
    109       if (!suppressUpdates) UpdateRuns(Content);
     118      if (!suppressUpdates) {
     119        UpdateDataTableComboBox();
     120        UpdateDataRowComboBox();
     121        UpdateRuns(Content);
     122      }
    110123    }
    111124
    112125    private void RegisterRunEvents(IRun run) {
    113       run.Changed += new System.EventHandler(run_Changed);
     126      run.PropertyChanged += run_PropertyChanged;
    114127    }
    115128    private void DeregisterRunEvents(IRun run) {
    116       run.Changed -= new System.EventHandler(run_Changed);
    117     }
    118     private void run_Changed(object sender, EventArgs e) {
    119       if (suppressUpdates) return;
    120       var run = (IRun)sender;
    121       UpdateRuns(new IRun[] { run });
     129      run.PropertyChanged -= run_PropertyChanged;
     130    }
     131    private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     132      if (suppressUpdates) return;
     133      if (InvokeRequired) {
     134        Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e);
     135      } else {
     136        var run = (IRun)sender;
     137        if (e.PropertyName == "Color" || e.PropertyName == "Visible")
     138          UpdateRuns(new[] { run });
     139      }
    122140    }
    123141    #endregion
     
    162180
    163181    private void UpdateRuns(IEnumerable<IRun> runs) {
    164       if (suppressUpdates) return;
    165182      foreach (var run in runs) {
    166183        //update color
    167         foreach (var dataRow in runMapping[run]) {
    168           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          }
    169191        }
    170         //update visibility - remove and add all rows to keep the same order as before
    171         combinedDataTable.Rows.Clear();
    172         combinedDataTable.Rows.AddRange(runMapping.Where(mapping => mapping.Key.Visible).SelectMany(mapping => mapping.Value));
    173       }
     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));
    174196    }
    175197
    176198    private IEnumerable<DataRow> ExtractDataRowsFromRun(IRun run) {
    177199      var resultName = (string)dataTableComboBox.SelectedItem;
     200      if (string.IsNullOrEmpty(resultName)) yield break;
     201
    178202      var rowName = (string)dataRowComboBox.SelectedItem;
    179203      if (!run.Results.ContainsKey(resultName)) yield break;
     
    193217
    194218    private void UpdateDataTableComboBox() {
     219      string selectedItem = (string)dataTableComboBox.SelectedItem;
     220
    195221      dataTableComboBox.Items.Clear();
    196222      var dataTables = (from run in Content
     
    200226
    201227      dataTableComboBox.Items.AddRange(dataTables);
    202       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      }
    203233    }
    204234
     
    208238
    209239    private void UpdateDataRowComboBox() {
     240      string selectedItem = (string)dataRowComboBox.SelectedItem;
     241
    210242      dataRowComboBox.Items.Clear();
    211243      var resultName = (string)dataTableComboBox.SelectedItem;
     244      if (resultName == null) return;
     245
    212246      var dataTables = from run in Content
    213247                       where run.Results.ContainsKey(resultName)
     
    219253      dataRowComboBox.Items.AddRange(rowNames);
    220254      dataRowComboBox.Items.Add(AllDataRows);
    221       if (dataRowComboBox.Items.Count > 0) dataRowComboBox.SelectedItem = dataRowComboBox.Items[0];
    222     }
    223 
    224     private void dataTableComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
    225       UpdateDataRowComboBox();
    226     }
    227     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;
    228267      RebuildCombinedDataTable();
    229268    }
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.Designer.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionTableView.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Collections.Generic;
     24using System.ComponentModel;
    2425using System.Linq;
    2526using System.Windows.Forms;
     
    5253      base.OnContentChanged();
    5354      if (Content != null) {
    54         runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    5555        UpdateRowAttributes();
    5656      }
     
    7070    private void RegisterRunEvents(IEnumerable<IRun> runs) {
    7171      foreach (IRun run in runs)
    72         run.Changed += new EventHandler(run_Changed);
     72        run.PropertyChanged += run_PropertyChanged;
    7373    }
    7474    protected override void DeregisterContentEvents() {
     
    8383    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
    8484      foreach (IRun run in runs)
    85         run.Changed -= new EventHandler(run_Changed);
     85        run.PropertyChanged -= run_PropertyChanged;
    8686    }
    8787    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     
    100100      else UpdateCaption();
    101101    }
    102     private void run_Changed(object sender, EventArgs e) {
     102    private void run_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    103103      if (suppressUpdates) return;
    104104      if (InvokeRequired)
    105         this.Invoke(new EventHandler(run_Changed), sender, e);
     105        this.Invoke((Action<object, PropertyChangedEventArgs>)run_PropertyChanged, sender, e);
    106106      else {
    107107        IRun run = (IRun)sender;
    108         UpdateRun(run);
     108        if (e.PropertyName == "Color" || e.PropertyName == "Visible")
     109          UpdateRun(run);
    109110      }
    110111    }
     
    113114    private void UpdateCaption() {
    114115      Caption = Content != null ? Content.OptimizerName + " Table" : ViewAttribute.GetViewName(GetType());
     116    }
     117
     118    protected override void UpdateData() {
     119      if (suppressUpdates) return;
     120      base.UpdateData();
    115121    }
    116122
     
    143149      else {
    144150        suppressUpdates = Content.UpdateOfRunsInProgress;
    145         if (!suppressUpdates) UpdateRowAttributes();
     151        if (!suppressUpdates) {
     152          UpdateData();
     153          UpdateRowAttributes();
     154        }
    146155      }
    147156    }
     
    169178    protected override void ClearSorting() {
    170179      base.ClearSorting();
    171       runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    172180      UpdateRowAttributes();
    173181    }
     
    188196        i++;
    189197      }
    190       UpdateRowAttributes();
     198      UpdateRowAttributes(rebuild: false);
    191199      return newSortedIndex;
    192200    }
    193201
    194     private void UpdateRowAttributes() {
     202    private void UpdateRowAttributes(bool rebuild = true) {
     203      if (rebuild) runToRowMapping = Enumerable.Range(0, Content.Count).ToArray();
    195204      int runIndex = 0;
    196205      foreach (IRun run in Content) {
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.Designer.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
  • branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r11185 r12694  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2323using System.Collections;
    2424using System.Collections.Generic;
     25using System.ComponentModel;
    2526using System.Drawing;
    2627using System.Linq;
     
    4041    private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping;
    4142    private bool validDragOperation;
     43    private bool suppressUpdates;
    4244
    4345    public new IItemCollection<IRun> Content {
     
    6567      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    6668      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     69      if (RunCollection != null)
     70        RunCollection.UpdateOfRunsInProgressChanged -= new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    6771      foreach (IRun run in itemListViewItemMapping.Keys) {
    6872        DeregisterItemEvents(run);
     
    7579      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    7680      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     81      if (RunCollection != null)
     82        RunCollection.UpdateOfRunsInProgressChanged += new EventHandler(RunCollection_UpdateOfRunsInProgressChanged);
    7783    }
    7884    private void DeregisterItemEvents(IRun item) {
    7985      item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
    8086      item.ToStringChanged -= new EventHandler(Item_ToStringChanged);
    81       item.Changed -= new EventHandler(Item_Changed);
     87      item.PropertyChanged -= Item_PropertyChanged;
    8288    }
    8389    private void RegisterItemEvents(IRun item) {
    8490      item.ItemImageChanged += new EventHandler(Item_ItemImageChanged);
    8591      item.ToStringChanged += new EventHandler(Item_ToStringChanged);
    86       item.Changed += new EventHandler(Item_Changed);
     92      item.PropertyChanged += Item_PropertyChanged;
    8793    }
    8894
     
    385391      try {
    386392        RunCollection.Modify();
    387       }
    388       finally {
     393      } finally {
    389394        ReadOnly = false;
    390395      }
     
    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);
     
    462493      }
    463494    }
    464     private void Item_Changed(object sender, EventArgs e) {
     495    private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     496      if (suppressUpdates) return;
    465497      if (InvokeRequired)
    466         this.Invoke(new EventHandler(Item_Changed), sender, e);
     498        Invoke((Action<object, PropertyChangedEventArgs>)Item_PropertyChanged, sender, e);
    467499      else {
    468500        IRun run = (IRun)sender;
    469         UpdateRun(run);
     501        if (e.PropertyName == "Color" || e.PropertyName == "Visible")
     502          UpdateRun(run);
    470503      }
    471504    }
Note: See TracChangeset for help on using the changeset viewer.