Changeset 10877 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs
- Timestamp:
- 05/21/14 13:42:43 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs
r10849 r10877 20 20 tbFiltered.Text = "0"; 21 21 tbPercentage.Text = "0%"; 22 checkedFilterView.Content = new CheckedItemCollection<IFilter>(); 23 checkedFilterView.Content.ItemsAdded += Content_ItemsAdded; 24 checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved; 25 checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged; 22 } 23 24 private void InitData() 25 { 26 checkedFilterView.Content = Content.Filters; 27 checkedFilterView.Content.ItemsAdded += Content_ItemsAdded; 28 checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved; 29 checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged; 26 30 } 27 31 … … 36 40 if (Content != null) 37 41 { 38 I mportFiltersFromContent();42 InitData(); 39 43 UpdateFilterInfo(); 40 44 } … … 42 46 43 47 private void Content_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e) { 44 45 foreach (IFilter filter in e.Items) 48 if (Content != null) 46 49 { 47 filter.Active = checkedFilterView.Content.ItemChecked(filter); 50 foreach (IFilter filter in e.Items) 51 { 52 filter.Active = checkedFilterView.Content.ItemChecked(filter); 53 } 54 UpdateFilterInfo(); 48 55 } 49 UpdateFilterInfo();50 ExportFiltersToContent();51 Refresh();52 ResumeRepaint(true);53 56 } 54 57 55 58 private void UpdateFilterInfo() { 56 List<IFilter> filters = checkedFilterView.ItemCollection.ToList<IFilter>(); 59 //List<IFilter> filters = checkedFilterView.ItemCollection.ToList<IFilter>(); 60 List<IFilter> filters = Content.Filters.ToList(); 57 61 58 int activeFilters = filters.Count(c => c.Active);62 int activeFilters = filters.Count(c => c.Active); 59 63 60 applyFilterButton.Enabled = (activeFilters > 0);61 rBtnAnd.Enabled = (activeFilters > 0);62 rBtnOr.Enabled = (activeFilters > 0);63 btnReset.Enabled = (activeFilters > 0);64 Content.FilterLogic.Reset();65 bool[] result = Content.FilterLogic.Preview(filters, rBtnAnd.Checked);66 67 int filteredCnt = result.Count(c => c);68 69 tbFiltered.Text = filteredCnt.ToString();70 double percentage = result.Length == 0 ? 0.0 : filteredCnt * 100 / result.Length;71 tbPercentage.Text = percentage.ToString() + "%";72 tbTotal.Text = result.Length.ToString();64 applyFilterButton.Enabled = (activeFilters > 0); 65 rBtnAnd.Enabled = (activeFilters > 0); 66 rBtnOr.Enabled = (activeFilters > 0); 67 btnReset.Enabled = (activeFilters > 0); 68 Content.FilterLogic.Reset(); 69 bool[] result = Content.FilterLogic.Preview(filters, rBtnAnd.Checked); 70 71 int filteredCnt = result.Count(c => c); 72 73 tbFiltered.Text = filteredCnt.ToString(); 74 double percentage = result.Length == 0 ? 0.0 : filteredCnt * 100 / result.Length; 75 tbPercentage.Text = percentage.ToString() + "%"; 76 tbTotal.Text = result.Length.ToString(); 73 77 } 74 78 75 79 private void applyFilterButton_Click(object sender, EventArgs e) { 76 List<IFilter> filters = checkedFilterView.ItemCollection.ToList<IFilter>(); 77 Content.FilterLogic.Apply(filters, rBtnAnd.Checked); 80 if (Content != null) 81 { 82 List<IFilter> filters = Content.Filters.ToList(); 83 Content.FilterLogic.Apply(filters, rBtnAnd.Checked); 84 } 78 85 } 79 86 80 87 //whenever a new filter is added the preprocessing data is set to the filter 81 88 private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e) { 82 foreach (IFilter filter in e.Items) { 83 filter.ConstrainedValue = Content.FilterLogic.PreprocessingData; 89 if (Content != null) 90 { 91 foreach (IFilter filter in e.Items) 92 { 93 filter.ConstrainedValue = Content.FilterLogic.PreprocessingData; 94 } 95 UpdateFilterInfo(); 84 96 } 85 UpdateFilterInfo();86 ExportFiltersToContent();87 97 } 88 98 89 99 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IFilter> e) { 90 UpdateFilterInfo(); 91 ExportFiltersToContent(); 100 if (Content != null) 101 { 102 UpdateFilterInfo(); 103 } 92 104 } 93 105 94 106 private void rBtnAnd_CheckedChanged(object sender, EventArgs e) 95 107 { 96 UpdateFilterInfo(); 97 ExportFiltersToContent(); 98 Content.isAndCombination = rBtnAnd.Checked; 108 if (Content != null) 109 { 110 UpdateFilterInfo(); 111 Content.isAndCombination = rBtnAnd.Checked; 112 } 99 113 } 100 114 101 115 private void btnReset_Click(object sender, EventArgs e) 102 116 { 103 Content.FilterLogic.Reset(); 104 } 105 106 private void ImportFiltersFromContent() 107 { 108 checkedFilterView.ItemCollection.AddRange(Content.Filters); 109 110 foreach (IFilter filter in checkedFilterView.ItemCollection) { 111 if (filter.Active) 112 { 113 checkedFilterView.Content.SetItemCheckedState(filter, true); 114 } 115 else 116 { 117 checkedFilterView.Content.SetItemCheckedState(filter, false); 118 } 119 rBtnAnd.Checked = Content.isAndCombination; 120 rBtnOr.Checked = !Content.isAndCombination; 117 if (Content != null) 118 { 119 Content.FilterLogic.Reset(); 121 120 } 122 121 } 123 122 124 private void ExportFiltersToContent()125 {126 Content.Filters = checkedFilterView.ItemCollection.ToList<IFilter>();127 }128 123 } 129 124 }
Note: See TracChangeset
for help on using the changeset viewer.