Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10785 for branches


Ignore:
Timestamp:
04/23/14 15:51:41 (10 years ago)
Author:
psteiner
Message:

filter or combination
filter control: checkedlistview

Location:
branches/DataPreprocessing
Files:
2 added
7 edited

Legend:

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

    r10769 r10785  
    220220      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
    221221        comparisonFilter.ConstraintColumn = i;
    222         bool[] filteredRows = Content.FilterLogic.Preview(filters);
     222        bool[] filteredRows = Content.FilterLogic.Preview(filters, true);
    223223        foundCells[i] = filteredRows.Select((value, index) => new { Index = index, Value = value })
    224224          .Where(pair => pair.Value)
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.Designer.cs

    r10713 r10785  
    3030    {
    3131      this.groupBoxFilter = new System.Windows.Forms.GroupBox();
     32      this.checkedFilterView = new HeuristicLab.DataPreprocessing.Views.CheckedFilterCollectionView();
    3233      this.groupBoxFilterInfo = new System.Windows.Forms.GroupBox();
    3334      this.lblPercentage = new System.Windows.Forms.Label();
     
    3839      this.lblTotal = new System.Windows.Forms.Label();
    3940      this.applyFilterButton = new System.Windows.Forms.Button();
     41      this.rBtnOr = new System.Windows.Forms.RadioButton();
     42      this.rBtnAnd = new System.Windows.Forms.RadioButton();
     43      this.btnReset = new System.Windows.Forms.Button();
     44      this.groupBoxFilter.SuspendLayout();
    4045      this.groupBoxFilterInfo.SuspendLayout();
    4146      this.SuspendLayout();
     
    4550      this.groupBoxFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    4651            | System.Windows.Forms.AnchorStyles.Right)));
     52      this.groupBoxFilter.Controls.Add(this.checkedFilterView);
    4753      this.groupBoxFilter.Location = new System.Drawing.Point(4, 4);
    4854      this.groupBoxFilter.Name = "groupBoxFilter";
     
    5258      this.groupBoxFilter.Text = "Filter";
    5359      //
     60      // checkedFilterView
     61      //
     62      this.checkedFilterView.Caption = "filterView";
     63      this.checkedFilterView.Content = null;
     64      this.checkedFilterView.Dock = System.Windows.Forms.DockStyle.Fill;
     65      this.checkedFilterView.Location = new System.Drawing.Point(3, 16);
     66      this.checkedFilterView.Name = "checkedFilterView";
     67      this.checkedFilterView.ReadOnly = false;
     68      this.checkedFilterView.ShowDetails = true;
     69      this.checkedFilterView.Size = new System.Drawing.Size(652, 308);
     70      this.checkedFilterView.TabIndex = 0;
     71      //
    5472      // groupBoxFilterInfo
    5573      //
    56       this.groupBoxFilterInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    57             | System.Windows.Forms.AnchorStyles.Left)
     74      this.groupBoxFilterInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    5875            | System.Windows.Forms.AnchorStyles.Right)));
    5976      this.groupBoxFilterInfo.Controls.Add(this.lblPercentage);
     
    139156      this.applyFilterButton.Click += new System.EventHandler(this.applyFilterButton_Click);
    140157      //
     158      // rBtnOr
     159      //
     160      this.rBtnOr.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     161      this.rBtnOr.AutoSize = true;
     162      this.rBtnOr.Enabled = false;
     163      this.rBtnOr.Location = new System.Drawing.Point(60, 480);
     164      this.rBtnOr.Name = "rBtnOr";
     165      this.rBtnOr.Size = new System.Drawing.Size(36, 17);
     166      this.rBtnOr.TabIndex = 3;
     167      this.rBtnOr.Text = "Or";
     168      this.rBtnOr.UseVisualStyleBackColor = true;
     169      //
     170      // rBtnAnd
     171      //
     172      this.rBtnAnd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     173      this.rBtnAnd.AutoSize = true;
     174      this.rBtnAnd.Checked = true;
     175      this.rBtnAnd.Enabled = false;
     176      this.rBtnAnd.Location = new System.Drawing.Point(10, 480);
     177      this.rBtnAnd.Name = "rBtnAnd";
     178      this.rBtnAnd.Size = new System.Drawing.Size(44, 17);
     179      this.rBtnAnd.TabIndex = 4;
     180      this.rBtnAnd.TabStop = true;
     181      this.rBtnAnd.Text = "And";
     182      this.rBtnAnd.UseVisualStyleBackColor = true;
     183      this.rBtnAnd.CheckedChanged += new System.EventHandler(this.rBtnAnd_CheckedChanged);
     184      //
     185      // btnReset
     186      //
     187      this.btnReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     188      this.btnReset.Enabled = false;
     189      this.btnReset.Location = new System.Drawing.Point(473, 473);
     190      this.btnReset.Name = "btnReset";
     191      this.btnReset.Size = new System.Drawing.Size(75, 23);
     192      this.btnReset.TabIndex = 5;
     193      this.btnReset.Text = "Reset";
     194      this.btnReset.UseVisualStyleBackColor = true;
     195      this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
     196      //
    141197      // FilterView
    142198      //
    143199      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    144200      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     201      this.Controls.Add(this.btnReset);
     202      this.Controls.Add(this.rBtnAnd);
     203      this.Controls.Add(this.rBtnOr);
    145204      this.Controls.Add(this.applyFilterButton);
    146205      this.Controls.Add(this.groupBoxFilterInfo);
     
    148207      this.Name = "FilterView";
    149208      this.Size = new System.Drawing.Size(670, 506);
     209      this.groupBoxFilter.ResumeLayout(false);
    150210      this.groupBoxFilterInfo.ResumeLayout(false);
    151211      this.groupBoxFilterInfo.PerformLayout();
    152212      this.ResumeLayout(false);
     213      this.PerformLayout();
    153214
    154215    }
     
    165226    private System.Windows.Forms.TextBox tbFiltered;
    166227    private System.Windows.Forms.Label lblFiltered;
     228    private System.Windows.Forms.RadioButton rBtnOr;
     229    private System.Windows.Forms.RadioButton rBtnAnd;
     230    private CheckedFilterCollectionView checkedFilterView;
     231    private System.Windows.Forms.Button btnReset;
    167232
    168233
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs

    r10713 r10785  
    1414  [Content(typeof(FilterContent), true)]
    1515  public partial class FilterView : ItemView {
    16     private CheckedItemCollectionView<IFilter> filterView;
     16    //private CheckedItemCollectionView<IFilter> filterView;
    1717
    1818    public FilterView() {
     
    2121      tbFiltered.Text = "0";
    2222      tbPercentage.Text = "0%";
    23       filterView = new CheckedItemCollectionView<IFilter>();
    24       filterView.Dock = DockStyle.Fill;
     23      checkedFilterView.Content = new CheckedItemCollection<IFilter>();
     24      //filterView = new CheckedItemCollectionView<IFilter>();
     25      //filterView = new CheckedFilterCollectionView();
     26      /*filterView.Dock = DockStyle.Fill;
    2527      filterView.Content = new CheckedItemCollection<IFilter>();
    26       filterView.Content.ItemsAdded += Content_ItemsAdded;
    27       filterView.Content.ItemsRemoved += Content_ItemsRemoved;
    28       filterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
    29       groupBoxFilter.Controls.Add(filterView);
     28       * */
     29      checkedFilterView.Content.ItemsAdded += Content_ItemsAdded;
     30      checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved;
     31      checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
     32      //groupBoxFilter.Controls.Add(filterView);*/
    3033    }
    3134
    3235    public new FilterContent Content {
    3336      get { return (FilterContent)base.Content; }
    34       set { base.Content = value; }
     37      set { base.Content = value; UpdateFilterInfo(); }
    3538    }
    3639
     
    3942      foreach (IFilter filter in e.Items)
    4043      {
    41  /*       if (filterView.Content.CheckedItems.Contains(filter) && (filter.ConstraintData == null || string.IsNullOrEmpty(((StringValue)filter.ConstraintData).Value)) )
    42         {
    43           filter.ConstraintData = new StringValue("0");
    44         }
    45   * */
    4644        filter.Active = !filter.Active;
    4745      }
     
    5250
    5351    private void UpdateFilterInfo() {
    54       List<IFilter> filters = filterView.ItemCollection.ToList<IFilter>();
     52      List<IFilter> filters = checkedFilterView.ItemCollection.ToList<IFilter>();
    5553
    5654      int activeFilters = filters.Count(c => c.Active);
    5755
    5856      applyFilterButton.Enabled = (activeFilters > 0);
     57      rBtnAnd.Enabled = (activeFilters > 0);
     58      rBtnOr.Enabled = (activeFilters > 0);
     59      btnReset.Enabled = (activeFilters > 0);
    5960
    60       bool[] result = Content.FilterLogic.Preview(filters);
     61      bool[] result = Content.FilterLogic.Preview(filters, rBtnAnd.Checked);
    6162     
    62       int filteredCnt = result.Count(c => !c);
     63      int filteredCnt = result.Count(c => c);
    6364 
    6465      tbFiltered.Text = filteredCnt.ToString();
     
    6970
    7071    private void applyFilterButton_Click(object sender, EventArgs e) {
    71       List<IFilter> filters = filterView.ItemCollection.ToList<IFilter>();
    72       Content.FilterLogic.Apply(filters);
     72      List<IFilter> filters = checkedFilterView.ItemCollection.ToList<IFilter>();
     73      Content.FilterLogic.Apply(filters, rBtnAnd.Checked);
    7374    }
    7475
     
    7879        filter.ConstrainedValue = Content.FilterLogic.PreprocessingData;
    7980        filter.Active = true;
    80         filterView.Content.SetItemCheckedState(filter, false);
     81        checkedFilterView.Content.SetItemCheckedState(filter, false);
    8182      }
    8283      UpdateFilterInfo();
     
    8788    }
    8889
     90    private void rBtnAnd_CheckedChanged(object sender, EventArgs e)
     91    {
     92      UpdateFilterInfo();
     93    }
     94
     95    private void btnReset_Click(object sender, EventArgs e)
     96    {
     97      Content.FilterLogic.Reset();
     98    }
     99
    89100  }
    90101}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj

    r10778 r10785  
    6464  </ItemGroup>
    6565  <ItemGroup>
     66    <Compile Include="CheckedFilterCollectionView.cs">
     67      <SubType>UserControl</SubType>
     68    </Compile>
     69    <Compile Include="CheckedFilterCollectionView.Designer.cs">
     70      <DependentUpon>CheckedFilterCollectionView.cs</DependentUpon>
     71    </Compile>
    6672    <Compile Include="CheckedTransformationCollectionView.cs">
    6773      <SubType>UserControl</SubType>
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/Filter/ComparisonFilter.cs

    r10716 r10785  
    128128                }
    129129
    130                 result[row] = base.Check(item);
     130                result[row] = !base.Check(item);
    131131            }
    132132
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs

    r10783 r10785  
    3535    }
    3636
    37     public bool[] Preview(IList<IFilter> filters)
     37    public bool[] Preview(IList<IFilter> filters, bool isAndCombination)
    3838    {
    3939       IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList<IFilter>();
     
    4444
    4545       bool[] result = Enumerable.Repeat<bool>(true, preprocessingData.Rows).ToArray();
     46         foreach (IFilter filter in activeFilters)
     47         {
     48           bool[] filterResult = filter.Check();
     49           for (int row = 0; row < result.Length; ++row)
     50           {
     51             result[row] = isAndCombination ?  result[row] && filterResult[row] : result[row] || filterResult[row];
     52           }
     53         }
    4654
    47        foreach (IFilter filter in activeFilters)
    48        {
    49             bool[] filterResult = filter.Check();
    50 
    51             for(int row = 0; row < result.Length; ++row) {
    52                 result[row] = result[row] && filterResult[row];
    53             }
    54         }
    5555
    5656        preprocessingData.SetFilter(result);
     
    5959    }
    6060
    61     public void Apply(IList<IFilter> filters)
     61    public void Apply(IList<IFilter> filters, bool isAndCombination)
    6262    {
    63         preprocessingData.SetFilter(Preview(filters));
     63        preprocessingData.SetFilter(Preview(filters, isAndCombination));
    6464        preprocessingData.PersistFilter();
    6565    }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IFilterLogic.cs

    r10638 r10785  
    2424namespace HeuristicLab.DataPreprocessing {
    2525  public interface IFilterLogic {
    26     bool[] Preview(IList<IFilter> filters);
    27     void Apply(IList<IFilter> filters);
     26    bool[] Preview(IList<IFilter> filters, bool isAndCombination);
     27    void Apply(IList<IFilter> filters, bool isAndCombination);
    2828    IPreprocessingData PreprocessingData{get;}
     29    void Reset();
    2930  }
    3031}
Note: See TracChangeset for help on using the changeset viewer.