- Timestamp:
- 07/14/16 22:38:23 (8 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13502,13504,13507-13508,13512,13514,13517
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.DataPreprocessing.Views merged: 13502,13504,13507-13508,13512,13514,13517
- Property svn:mergeinfo changed
-
stable/HeuristicLab.DataPreprocessing.Views/3.4/FilterView.cs
r11044 r14075 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; 4 using System.Windows.Forms;5 25 using HeuristicLab.Collections; 6 using HeuristicLab.Core;7 26 using HeuristicLab.Core.Views; 8 using HeuristicLab.Data;9 27 using HeuristicLab.DataPreprocessing.Filter; 10 28 using HeuristicLab.MainForm; … … 22 40 } 23 41 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; 42 private void InitData() { 43 checkedFilterView.Content = Content.Filters; 44 checkedFilterView.Content.ItemsAdded += Content_ItemsAdded; 45 checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved; 46 checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged; 30 47 } 31 48 … … 35 52 } 36 53 37 protected override void OnContentChanged() 38 { 54 protected override void OnContentChanged() { 39 55 base.OnContentChanged(); 40 if (Content != null) 41 { 56 if (Content != null) { 42 57 InitData(); 43 58 UpdateFilterInfo(); … … 46 61 47 62 private void Content_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e) { 48 if (Content != null) 49 { 50 foreach (IFilter filter in e.Items) 51 { 63 if (Content != null) { 64 foreach (IFilter filter in e.Items) { 52 65 filter.Active = checkedFilterView.Content.ItemChecked(filter); 53 66 } … … 57 70 58 71 private void UpdateFilterInfo() { 59 60 61 62 63 64 65 72 List<IFilter> filters = Content.Filters.ToList(); 73 int activeFilters = filters.Count(c => c.Active); 74 applyFilterButton.Enabled = (activeFilters > 0); 75 rBtnAnd.Enabled = (activeFilters > 0); 76 rBtnOr.Enabled = (activeFilters > 0); 77 Content.FilterLogic.Reset(); 78 bool[] result = Content.FilterLogic.Preview(filters, rBtnAnd.Checked); 66 79 67 80 int filteredCnt = result.Count(c => !c); 68 81 69 70 71 72 82 tbRemaining.Text = filteredCnt.ToString(); 83 double percentage = result.Length == 0 ? 0.0 : filteredCnt * 100 / (double)result.Length; 84 tbPercentage.Text = String.Format("{0:0.0000}%", percentage); 85 tbTotal.Text = result.Length.ToString(); 73 86 } 74 87 75 88 private void applyFilterButton_Click(object sender, EventArgs e) { 76 if (Content != null) 77 { 89 if (Content != null) { 78 90 List<IFilter> filters = Content.Filters.ToList(); 79 91 //apply filters … … 81 93 //deactivate checked filters 82 94 filters = checkedFilterView.Content.CheckedItems.ToList(); 83 foreach (IFilter filter in filters) 84 { 95 foreach (IFilter filter in filters) { 85 96 checkedFilterView.Content.SetItemCheckedState(filter, false); 86 97 filter.Active = false; … … 92 103 //whenever a new filter is added the preprocessing data is set to the filter 93 104 private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e) { 94 if (Content != null) 95 { 96 foreach (IFilter filter in e.Items) 97 { 105 if (Content != null) { 106 foreach (IFilter filter in e.Items) { 98 107 filter.ConstrainedValue = Content.FilterLogic.PreprocessingData; 99 108 } … … 102 111 103 112 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IFilter> e) { 104 if (Content != null) 105 { 113 if (Content != null) { 106 114 UpdateFilterInfo(); 107 115 } 108 116 } 109 117 110 private void rBtnAnd_CheckedChanged(object sender, EventArgs e) 111 { 112 if (Content != null) 113 { 118 private void rBtnAnd_CheckedChanged(object sender, EventArgs e) { 119 if (Content != null) { 114 120 UpdateFilterInfo(); 115 121 Content.IsAndCombination = rBtnAnd.Checked;
Note: See TracChangeset
for help on using the changeset viewer.