Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10637


Ignore:
Timestamp:
03/19/14 16:10:24 (10 years ago)
Author:
psteiner
Message:

implementation FilterView and ComparisonFilterView

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
Files:
1 added
5 edited

Legend:

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

    r10589 r10637  
    8484      this.cbAttr.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    8585            | System.Windows.Forms.AnchorStyles.Right)));
     86      this.cbAttr.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    8687      this.cbAttr.FormattingEnabled = true;
    8788      this.cbAttr.Location = new System.Drawing.Point(92, 12);
     
    8990      this.cbAttr.Size = new System.Drawing.Size(247, 21);
    9091      this.cbAttr.TabIndex = 3;
     92      this.cbAttr.SelectedIndexChanged += new System.EventHandler(this.cbAttr_SelectedIndexChanged);
    9193      //
    9294      // cbFilterOperation
     
    9496      this.cbFilterOperation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    9597            | System.Windows.Forms.AnchorStyles.Right)));
     98      this.cbFilterOperation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    9699      this.cbFilterOperation.FormattingEnabled = true;
    97100      this.cbFilterOperation.Location = new System.Drawing.Point(92, 39);
     
    99102      this.cbFilterOperation.Size = new System.Drawing.Size(247, 21);
    100103      this.cbFilterOperation.TabIndex = 4;
     104      this.cbFilterOperation.SelectedIndexChanged += new System.EventHandler(this.cbFilterOperation_SelectedIndexChanged);
    101105      //
    102106      // tbFilterData
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ComparisonFilterView.cs

    r10589 r10637  
    2020#endregion
    2121
     22using System.Linq;
    2223using HeuristicLab.Core.Views;
    2324using HeuristicLab.Core;
     
    2627using HeuristicLab.MainForm;
    2728using System.Collections;
     29using System;
    2830
    2931namespace HeuristicLab.DataPreprocessing.Views {
     
    4042    }
    4143
    42     //protected override void OnContentChanged() {
    43     //  base.OnContentChanged();
    44     //  cbAttr.Items.Clear();
    45     //  cbFilterOperation.Items.Clear();
    46     //  if (Content != null)
    47     //  {
    48     //    cbFilterOperation.Items.AddRange(Content.AllowedConstraintOperations.ToArray());
    49     //    if (Content.ConstraintOperation != null)
    50     //      cbFilterOperation.SelectedItem = Content.ConstraintOperation;
    51     //    else if (cbFilterOperation.Items.Count != 0)
    52     //      cbFilterOperation.SelectedIndex = 0;
    53     //    UpdateColumnComboBox();
    54     //    ReadOnly = Content.Active;
    55     //  }
    56     //}
    5744
     45    protected override void OnContentChanged()
     46    {
     47      base.OnContentChanged();
     48      cbAttr.Items.Clear(); //cmbConstraintColumn.Items.Clear();
     49      cbFilterOperation.Items.Clear(); //cmbConstraintOperation.Items.Clear();
     50      tbFilterData.Text = string.Empty;
     51      if (Content != null)
     52      {
     53        cbFilterOperation.Items.AddRange(Content.AllowedConstraintOperations.ToArray());
     54        if (Content.ConstraintOperation != null)
     55          cbFilterOperation.SelectedItem = Content.ConstraintOperation;
     56        else if (cbFilterOperation.Items.Count != 0)
     57          cbFilterOperation.SelectedIndex = 0;
     58        UpdateColumnComboBox();
     59        ReadOnly = Content.Active;
     60        if (Content.ConstraintData != null)
     61        {
     62          tbFilterData.Text = Content.ConstraintData.GetValue();
     63        }
     64      }
     65    }
    5866
     67    protected virtual void UpdateColumnComboBox()
     68    {
     69      this.cbAttr.Items.Clear();
     70      if (Content.ConstrainedValue != null)
     71      {
     72        this.cbAttr.Items.AddRange(Content.ConstrainedValue.VariableNames.ToArray<string>());
     73        //if (!string.IsNullOrEmpty(Content.ConstraintColumn))
     74        this.cbAttr.SelectedItem = Content.ConstraintColumn;
     75      }
     76    }
    5977
    60     //protected virtual void UpdateColumnComboBox()
    61     //{
    62     //  this.cbAttr.Items.Clear();
    63     //  if (Content.ConstrainedValue != null)
    64     //  {
    65     //    this.cbAttr.Items.AddRange(((IStringConvertibleMatrix)Content.ConstrainedValue).ColumnNames.ToArray());
    66     //    if (!string.IsNullOrEmpty(Content.ConstraintColumn))
    67     //      this.cbAttr.SelectedItem = Content.ConstraintColumn;
    68     //  }
    69     //}
     78    protected override void RegisterContentEvents()
     79    {
     80      base.RegisterContentEvents();
     81      this.Content.ActiveChanged += new EventHandler(Content_ActiveChanged);
     82      this.Content.ConstraintOperationChanged += new EventHandler(Content_ComparisonOperationChanged);
     83      this.Content.ConstraintColumnChanged += new EventHandler(Content_ConstraintColumnChanged);
     84      this.Content.ConstrainedValueChanged += new EventHandler(Content_ConstrainedValueChanged);
     85    }
     86
     87    protected override void DeregisterContentEvents()
     88    {
     89      base.DeregisterContentEvents();
     90      this.Content.ActiveChanged -= new EventHandler(Content_ActiveChanged);
     91      this.Content.ConstraintOperationChanged -= new EventHandler(Content_ComparisonOperationChanged);
     92      this.Content.ConstraintColumnChanged -= new EventHandler(Content_ConstraintColumnChanged);
     93      this.Content.ConstrainedValueChanged += new EventHandler(Content_ConstrainedValueChanged);
     94    }
     95
     96    protected virtual void Content_ConstrainedValueChanged(object sender, EventArgs e)
     97    {
     98      this.UpdateColumnComboBox();
     99    }
     100
     101    protected virtual void Content_ConstraintColumnChanged(object sender, EventArgs e)
     102    {
     103      if (Content.ConstrainedValue != null)
     104      {
     105          cbAttr.SelectedItem = Content.ConstraintColumn;
     106      }
     107    }
     108
     109    protected virtual void Content_ComparisonOperationChanged(object sender, EventArgs e)
     110    {
     111      if (Content.ConstraintOperation != (ConstraintOperation)this.cbFilterOperation.SelectedItem)
     112        this.cbFilterOperation.SelectedItem = Content.ConstraintOperation;
     113    }
     114
     115    protected override void SetEnabledStateOfControls()
     116    {
     117      base.SetEnabledStateOfControls();
     118      cbAttr.Enabled = !this.ReadOnly && Content != null;
     119      cbFilterOperation.Enabled = !this.ReadOnly && Content != null;
     120    }
     121
     122    private void cbAttr_SelectedIndexChanged(object sender, EventArgs e)
     123    {
     124      if (Content.ConstrainedValue != null)
     125      {
     126        Content.ConstraintColumn = Content.ConstrainedValue.GetColumnIndex(cbAttr.SelectedItem.ToString());
     127      }
     128    }
     129
     130    private void cbFilterOperation_SelectedIndexChanged(object sender, EventArgs e)
     131    {
     132      Content.ConstraintOperation = (ConstraintOperation)this.cbFilterOperation.SelectedItem;
     133    }
     134
     135    protected virtual void Content_ActiveChanged(object sender, EventArgs e)
     136    {
     137      this.ReadOnly = Content.Active;
     138    }
    70139
    71140  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.Designer.cs

    r10589 r10637  
    3131      this.groupBoxFilter = new System.Windows.Forms.GroupBox();
    3232      this.groupBoxFilterInfo = new System.Windows.Forms.GroupBox();
     33      this.lblPercentage = new System.Windows.Forms.Label();
     34      this.tbPercentage = new System.Windows.Forms.TextBox();
     35      this.tbFiltered = new System.Windows.Forms.TextBox();
     36      this.lblFiltered = new System.Windows.Forms.Label();
     37      this.tbTotal = new System.Windows.Forms.TextBox();
     38      this.lblTotal = new System.Windows.Forms.Label();
    3339      this.applyFilterButton = new System.Windows.Forms.Button();
     40      this.groupBoxFilterInfo.SuspendLayout();
    3441      this.SuspendLayout();
    3542      //
     
    5057            | System.Windows.Forms.AnchorStyles.Left)
    5158            | System.Windows.Forms.AnchorStyles.Right)));
     59      this.groupBoxFilterInfo.Controls.Add(this.lblPercentage);
     60      this.groupBoxFilterInfo.Controls.Add(this.tbPercentage);
     61      this.groupBoxFilterInfo.Controls.Add(this.tbFiltered);
     62      this.groupBoxFilterInfo.Controls.Add(this.lblFiltered);
     63      this.groupBoxFilterInfo.Controls.Add(this.tbTotal);
     64      this.groupBoxFilterInfo.Controls.Add(this.lblTotal);
    5265      this.groupBoxFilterInfo.Location = new System.Drawing.Point(4, 337);
    5366      this.groupBoxFilterInfo.Name = "groupBoxFilterInfo";
     
    5669      this.groupBoxFilterInfo.TabStop = false;
    5770      this.groupBoxFilterInfo.Text = "Filter Info";
     71      //
     72      // lblPercentage
     73      //
     74      this.lblPercentage.AutoSize = true;
     75      this.lblPercentage.Location = new System.Drawing.Point(15, 74);
     76      this.lblPercentage.Name = "lblPercentage";
     77      this.lblPercentage.Size = new System.Drawing.Size(65, 13);
     78      this.lblPercentage.TabIndex = 11;
     79      this.lblPercentage.Text = "Percentage:";
     80      //
     81      // tbPercentage
     82      //
     83      this.tbPercentage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     84            | System.Windows.Forms.AnchorStyles.Right)));
     85      this.tbPercentage.Enabled = false;
     86      this.tbPercentage.Location = new System.Drawing.Point(104, 71);
     87      this.tbPercentage.Name = "tbPercentage";
     88      this.tbPercentage.Size = new System.Drawing.Size(549, 20);
     89      this.tbPercentage.TabIndex = 10;
     90      //
     91      // tbFiltered
     92      //
     93      this.tbFiltered.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     94            | System.Windows.Forms.AnchorStyles.Right)));
     95      this.tbFiltered.Enabled = false;
     96      this.tbFiltered.Location = new System.Drawing.Point(104, 45);
     97      this.tbFiltered.Name = "tbFiltered";
     98      this.tbFiltered.Size = new System.Drawing.Size(549, 20);
     99      this.tbFiltered.TabIndex = 9;
     100      //
     101      // lblFiltered
     102      //
     103      this.lblFiltered.AutoSize = true;
     104      this.lblFiltered.Location = new System.Drawing.Point(15, 47);
     105      this.lblFiltered.Name = "lblFiltered";
     106      this.lblFiltered.Size = new System.Drawing.Size(41, 13);
     107      this.lblFiltered.TabIndex = 8;
     108      this.lblFiltered.Text = "Filtered";
     109      //
     110      // tbTotal
     111      //
     112      this.tbTotal.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     113            | System.Windows.Forms.AnchorStyles.Right)));
     114      this.tbTotal.Enabled = false;
     115      this.tbTotal.Location = new System.Drawing.Point(104, 19);
     116      this.tbTotal.Name = "tbTotal";
     117      this.tbTotal.Size = new System.Drawing.Size(549, 20);
     118      this.tbTotal.TabIndex = 7;
     119      //
     120      // lblTotal
     121      //
     122      this.lblTotal.AutoSize = true;
     123      this.lblTotal.Location = new System.Drawing.Point(15, 21);
     124      this.lblTotal.Name = "lblTotal";
     125      this.lblTotal.Size = new System.Drawing.Size(34, 13);
     126      this.lblTotal.TabIndex = 6;
     127      this.lblTotal.Text = "Total:";
    58128      //
    59129      // applyFilterButton
     
    77147      this.Name = "FilterView";
    78148      this.Size = new System.Drawing.Size(670, 506);
     149      this.groupBoxFilterInfo.ResumeLayout(false);
     150      this.groupBoxFilterInfo.PerformLayout();
    79151      this.ResumeLayout(false);
    80152
     
    86158    private System.Windows.Forms.GroupBox groupBoxFilterInfo;
    87159    private System.Windows.Forms.Button applyFilterButton;
     160    private System.Windows.Forms.TextBox tbTotal;
     161    private System.Windows.Forms.Label lblTotal;
     162    private System.Windows.Forms.Label lblPercentage;
     163    private System.Windows.Forms.TextBox tbPercentage;
     164    private System.Windows.Forms.TextBox tbFiltered;
     165    private System.Windows.Forms.Label lblFiltered;
    88166
    89167
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs

    r10589 r10637  
    2323    {
    2424      InitializeComponent();
     25      tbTotal.Text = "0";
     26      tbFiltered.Text = "0";
     27      tbPercentage.Text = "0%";
    2528      filterView = new CheckedItemCollectionView<IFilter>();
    2629      filterView.Dock = DockStyle.Fill;
     30      filterView.Content = new CheckedItemCollection<IFilter>();
     31      filterView.Content.ItemsAdded += Content_ItemsAdded;
     32      filterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
     33      //filterView.ReadOnly = false;
    2734      groupBoxFilter.Controls.Add(filterView);
    28       filterView.Content = new CheckedItemCollection<IFilter>();
    29       filterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
    3035    }
    3136
     
    3338    {
    3439      get { return (FilterContent)base.Content; }
    35       set { base.Content = value; }
     40      set { base.Content = value; tbTotal.Text = Content.FilterLogic.PreprocessingData.Rows.ToString(); }
    3641    }
    3742
    3843    private void Content_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e)
    3944    {
     45      //change active state of filters
     46      foreach (IFilter filter in e.Items)
     47      {
     48        filter.Active = !filter.Active;
     49      }
     50      List<IFilter> filters = filterView.ItemCollection.ToList<IFilter>();
     51      bool[] result = Content.FilterLogic.Preview(filters);
    4052      //todo: inform Logic for new filter
    4153    }
     
    4658    }
    4759
     60    //whenever a new filter is added the preprocessing data is set to the filter
     61    private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e)
     62    {
     63      foreach (IFilter filter in e.Items)
     64      {
     65        filter.ConstrainedValue = Content.FilterLogic.PreprocessingData;
     66      }
     67    }
     68
    4869  }
    4970}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj

    r10633 r10637  
    2222    <ErrorReport>prompt</ErrorReport>
    2323    <WarningLevel>4</WarningLevel>
     24    <UseVSHostingProcess>false</UseVSHostingProcess>
    2425  </PropertyGroup>
    2526  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     
    220221    </ProjectReference>
    221222  </ItemGroup>
     223  <ItemGroup>
     224    <EmbeddedResource Include="ComparisonFilterView.resx">
     225      <DependentUpon>ComparisonFilterView.cs</DependentUpon>
     226    </EmbeddedResource>
     227    <EmbeddedResource Include="DataPreprocessingView.resx">
     228      <DependentUpon>DataPreprocessingView.cs</DependentUpon>
     229    </EmbeddedResource>
     230    <EmbeddedResource Include="FilterView.resx">
     231      <DependentUpon>FilterView.cs</DependentUpon>
     232    </EmbeddedResource>
     233  </ItemGroup>
    222234  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    223235  <PropertyGroup>
Note: See TracChangeset for help on using the changeset viewer.