Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/02/12 13:46:27 (12 years ago)
Author:
sforsten
Message:

#1963: if possible all solutions are added/removed at once, otherwise one solution is added/removed at a time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.cs

    r7259 r8719  
    2020#endregion
    2121
     22using System;
    2223using System.Linq;
    2324using System.Windows.Forms;
    2425using HeuristicLab.Common;
     26using HeuristicLab.Core;
    2527using HeuristicLab.Core.Views;
    2628using HeuristicLab.MainForm;
     
    8385            solutions = solutions.Select(s => cloner.Clone(s));
    8486          }
    85           foreach (var solution in solutions)
    86             Content.Add(solution);
     87          var solutionCollection = Content as ItemCollection<IRegressionSolution>;
     88          if (solutionCollection != null) {
     89            solutionCollection.AddRange(solutions);
     90          } else {
     91            foreach (var solution in solutions)
     92              Content.Add(solution);
     93          }
     94        }
     95      }
     96      protected override void itemsListView_KeyDown(object sender, KeyEventArgs e) {
     97        var solutionCollection = Content as ItemCollection<IRegressionSolution>;
     98        if (e.KeyCode == Keys.Delete && solutionCollection != null) {
     99          if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) {
     100            solutionCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(x => (IRegressionSolution)x.Tag));
     101          }
     102        } else {
     103          base.itemsListView_KeyDown(sender, e);
     104        }
     105      }
     106      protected override void removeButton_Click(object sender, EventArgs e) {
     107        var solutionCollection = Content as ItemCollection<IRegressionSolution>;
     108        if (itemsListView.SelectedItems.Count > 0 && solutionCollection != null) {
     109          solutionCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(x => (IRegressionSolution)x.Tag));
     110          itemsListView.SelectedItems.Clear();
     111        } else {
     112          base.removeButton_Click(sender, e);
    87113        }
    88114      }
Note: See TracChangeset for help on using the changeset viewer.