Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10813


Ignore:
Timestamp:
05/07/14 13:24:56 (11 years ago)
Author:
psteiner
Message:

BugFix within the logical conjunction of filters
persistence of filters in content

Location:
branches/DataPreprocessing
Files:
3 edited

Legend:

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

    r10785 r10813  
    2727    protected override void addButton_Click(object sender, EventArgs e)
    2828    {
    29       Content.Add(new ComparisonFilter());
     29      IFilter filter = new ComparisonFilter();
     30      Content.Add(filter);
     31      Content.SetItemCheckedState(filter, false);
    3032    }
     33
    3134  }
    3235}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs

    r10785 r10813  
    1414  [Content(typeof(FilterContent), true)]
    1515  public partial class FilterView : ItemView {
    16     //private CheckedItemCollectionView<IFilter> filterView;
    1716
    1817    public FilterView() {
     
    2221      tbPercentage.Text = "0%";
    2322      checkedFilterView.Content = new CheckedItemCollection<IFilter>();
    24       //filterView = new CheckedItemCollectionView<IFilter>();
    25       //filterView = new CheckedFilterCollectionView();
    26       /*filterView.Dock = DockStyle.Fill;
    27       filterView.Content = new CheckedItemCollection<IFilter>();
    28        * */
    2923      checkedFilterView.Content.ItemsAdded += Content_ItemsAdded;
    3024      checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved;
    3125      checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
    32       //groupBoxFilter.Controls.Add(filterView);*/
    3326    }
    3427
    3528    public new FilterContent Content {
    3629      get { return (FilterContent)base.Content; }
    37       set { base.Content = value; UpdateFilterInfo(); }
     30      set { base.Content = value; }
     31    }
     32
     33    protected override void OnContentChanged()
     34    {
     35      base.OnContentChanged();
     36      if (Content != null)
     37      {
     38        ImportFiltersFromContent();
     39        UpdateFilterInfo();
     40      }
    3841    }
    3942
     
    4245      foreach (IFilter filter in e.Items)
    4346      {
    44         filter.Active = !filter.Active;
     47        filter.Active = checkedFilterView.Content.ItemChecked(filter);
    4548      }
    4649      UpdateFilterInfo();
     50      ExportFiltersToContent();
    4751      Refresh();
    4852      ResumeRepaint(true);
     
    6468 
    6569      tbFiltered.Text = filteredCnt.ToString();
    66       double percentage = filteredCnt * 100 / result.Length;
     70      double percentage = result.Length == 0 ? 0.0 : filteredCnt * 100 / result.Length;
    6771      tbPercentage.Text = percentage.ToString() + "%";
    6872      tbTotal.Text = result.Length.ToString();
     
    7882      foreach (IFilter filter in e.Items) {
    7983        filter.ConstrainedValue = Content.FilterLogic.PreprocessingData;
    80         filter.Active = true;
    81         checkedFilterView.Content.SetItemCheckedState(filter, false);
    8284      }
    8385      UpdateFilterInfo();
     86      ExportFiltersToContent();
    8487    }
    8588
    8689    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IFilter> e) {
    8790      UpdateFilterInfo();
     91      ExportFiltersToContent();
    8892    }
    8993
     
    9195    {
    9296      UpdateFilterInfo();
     97      ExportFiltersToContent();
    9398    }
    9499
     
    98103    }
    99104
     105    private void ImportFiltersFromContent()
     106    {
     107      checkedFilterView.ItemCollection.AddRange(Content.Filters);
     108
     109      foreach (IFilter filter in checkedFilterView.ItemCollection) {
     110        if (filter.Active)
     111        {
     112          checkedFilterView.Content.SetItemCheckedState(filter, true);
     113        }
     114        else
     115        {
     116          checkedFilterView.Content.SetItemCheckedState(filter, false);
     117        }
     118
     119      }
     120    }
     121
     122    private void ExportFiltersToContent()
     123    {
     124      Content.Filters = checkedFilterView.ItemCollection.ToList<IFilter>();
     125    }
    100126  }
    101127}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterContent.cs

    r10614 r10813  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using System.Collections.Generic;
     26using HeuristicLab.DataPreprocessing.Filter;
    2527
    2628namespace HeuristicLab.DataPreprocessing {
    2729  [Item("Filter", "Represents the filter grid.")]
    2830  public class FilterContent : Item, IViewShortcut {
     31
     32    private IList<IFilter> filters = new List<IFilter>();
    2933
    3034    public static new Image StaticItemImage {
     
    4347    }
    4448
     49    public IList<IFilter> Filters
     50    {
     51      get
     52      {
     53        return this.filters;
     54      }
     55      set
     56      {
     57        this.filters = value;
     58      }
     59    }
     60
    4561    public FilterContent(FilterContent content, Cloner cloner)
    4662      : base(content, cloner) {
     
    5268    }
    5369
     70
     71
    5472  }
    5573}
Note: See TracChangeset for help on using the changeset viewer.