Changeset 10693


Ignore:
Timestamp:
04/02/14 11:22:11 (6 years ago)
Author:
psteiner
Message:

FilterInfo Update, View Changes on FilterView

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
Files:
3 edited

Legend:

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

    r10637 r10693  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.lblAttr = new System.Windows.Forms.Label();
    4849      this.lblFilterOperation = new System.Windows.Forms.Label();
     
    5152      this.cbFilterOperation = new System.Windows.Forms.ComboBox();
    5253      this.tbFilterData = new System.Windows.Forms.TextBox();
     54      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     55      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5356      this.SuspendLayout();
    5457      //
     
    112115      this.tbFilterData.Size = new System.Drawing.Size(247, 20);
    113116      this.tbFilterData.TabIndex = 5;
     117      this.tbFilterData.Validating += new System.ComponentModel.CancelEventHandler(this.tbFilterData_Validating);
     118      this.tbFilterData.Validated += new System.EventHandler(this.tbFilterData_Validated);
     119      //
     120      // errorProvider
     121      //
     122      this.errorProvider.ContainerControl = this;
    114123      //
    115124      // ComparisonFilterView
     
    125134      this.Name = "ComparisonFilterView";
    126135      this.Size = new System.Drawing.Size(348, 97);
     136      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    127137      this.ResumeLayout(false);
    128138      this.PerformLayout();
     
    138148    private System.Windows.Forms.ComboBox cbFilterOperation;
    139149    private System.Windows.Forms.TextBox tbFilterData;
     150    private System.Windows.Forms.ErrorProvider errorProvider;
    140151
    141152  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ComparisonFilterView.cs

    r10637 r10693  
    2828using System.Collections;
    2929using System;
     30using System.Collections.Generic;
    3031
    3132namespace HeuristicLab.DataPreprocessing.Views {
     
    6263          tbFilterData.Text = Content.ConstraintData.GetValue();
    6364        }
     65        else
     66        {
     67          this.Content_ConstraintColumnChanged(cbAttr, EventArgs.Empty); // TODO
     68        }
     69      }
     70      if (Content == null || Content.ConstraintData == null)
     71      {
     72        tbFilterData.Text = string.Empty;
     73      }
     74      else
     75      {
     76        tbFilterData.Text = Content.ConstraintData.GetValue();
    6477      }
    6578    }
     
    7285        this.cbAttr.Items.AddRange(Content.ConstrainedValue.VariableNames.ToArray<string>());
    7386        //if (!string.IsNullOrEmpty(Content.ConstraintColumn))
    74         this.cbAttr.SelectedItem = Content.ConstraintColumn;
     87        this.cbAttr.SelectedItem = this.cbAttr.Items[Content.ConstraintColumn];
     88
     89        if (Content.ConstraintColumn != null)
     90        {
     91          cbAttr.SelectedItem = Content.ConstraintColumn;
     92          if (Content.ConstraintData != null)
     93            tbFilterData.Text = Content.ConstraintData.GetValue();
     94          else
     95            this.Content_ConstraintColumnChanged(cbAttr, EventArgs.Empty);
     96        }
    7597      }
    7698    }
     
    83105      this.Content.ConstraintColumnChanged += new EventHandler(Content_ConstraintColumnChanged);
    84106      this.Content.ConstrainedValueChanged += new EventHandler(Content_ConstrainedValueChanged);
     107      this.Content.ConstraintDataChanged += new EventHandler(Content_ConstrainedDataChanged);
    85108    }
    86109
     
    91114      this.Content.ConstraintOperationChanged -= new EventHandler(Content_ComparisonOperationChanged);
    92115      this.Content.ConstraintColumnChanged -= new EventHandler(Content_ConstraintColumnChanged);
    93       this.Content.ConstrainedValueChanged += new EventHandler(Content_ConstrainedValueChanged);
     116      this.Content.ConstrainedValueChanged -= new EventHandler(Content_ConstrainedValueChanged);
     117      this.Content.ConstraintDataChanged -= new EventHandler(Content_ConstrainedDataChanged);
    94118    }
    95119
     
    99123    }
    100124
     125    private void Content_ConstrainedDataChanged(object sender, EventArgs e)
     126    {
     127      if (Content.ConstraintData != null)
     128        tbFilterData.Text = Content.ConstraintData.GetValue();
     129      else
     130        tbFilterData.Text = string.Empty;
     131    }
     132
    101133    protected virtual void Content_ConstraintColumnChanged(object sender, EventArgs e)
    102134    {
    103135      if (Content.ConstrainedValue != null)
    104136      {
    105           cbAttr.SelectedItem = Content.ConstraintColumn;
    106       }
    107     }
     137        if (cbAttr.Items.IndexOf(cbAttr.SelectedItem) != Content.ConstraintColumn)
     138        {
     139          cbAttr.SelectedItem = this.cbAttr.Items[Content.ConstraintColumn];
     140        }
     141      }
     142      this.Content.ConstraintData = new StringValue();
     143    }
     144
    108145
    109146    protected virtual void Content_ComparisonOperationChanged(object sender, EventArgs e)
     
    116153    {
    117154      base.SetEnabledStateOfControls();
     155      /*
    118156      cbAttr.Enabled = !this.ReadOnly && Content != null;
    119157      cbFilterOperation.Enabled = !this.ReadOnly && Content != null;
     158      tbFilterData.Enabled = Content != null;
     159      tbFilterData.ReadOnly = ReadOnly;
     160       * */
     161      cbAttr.Enabled = Content != null && !Content.Active;
     162      cbFilterOperation.Enabled = Content != null && !Content.Active;
     163      tbFilterData.Enabled = Content != null && !Content.Active;
    120164    }
    121165
     
    135179    protected virtual void Content_ActiveChanged(object sender, EventArgs e)
    136180    {
    137       this.ReadOnly = Content.Active;
     181      this.ReadOnly = !Content.Active;
     182      SetEnabledStateOfControls();
     183      Refresh(); ResumeRepaint(true);
     184    }
     185
     186    private void tbFilterData_Validated(object sender, EventArgs e)
     187    {
     188      IStringConvertibleValue value = new StringValue();
     189        value.SetValue(tbFilterData.Text);
     190        Content.ConstraintData = value;
     191    }
     192
     193    private void tbFilterData_Validating(object sender, System.ComponentModel.CancelEventArgs e)
     194    {
     195        string errorMessage = string.Empty;
     196        if (!Content.ConstraintData.Validate(tbFilterData.Text, out errorMessage))
     197        {
     198          errorProvider.SetError(tbFilterData, errorMessage);
     199          e.Cancel = true;
     200        }
     201        else
     202          errorProvider.Clear();
    138203    }
    139204
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs

    r10637 r10693  
    1111using HeuristicLab.Core;
    1212using HeuristicLab.DataPreprocessing.Filter;
     13using HeuristicLab.Collections;
    1314
    1415namespace HeuristicLab.DataPreprocessing.Views
     
    3031      filterView.Content = new CheckedItemCollection<IFilter>();
    3132      filterView.Content.ItemsAdded += Content_ItemsAdded;
     33      filterView.Content.ItemsRemoved += Content_ItemsRemoved;
    3234      filterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
    33       //filterView.ReadOnly = false;
    3435      groupBoxFilter.Controls.Add(filterView);
    3536    }
     
    4849        filter.Active = !filter.Active;
    4950      }
     51      UpdateFilterInfo();
     52      Refresh();
     53      ResumeRepaint(true);
     54    }
     55
     56    private void UpdateFilterInfo()
     57    {
    5058      List<IFilter> filters = filterView.ItemCollection.ToList<IFilter>();
    5159      bool[] result = Content.FilterLogic.Preview(filters);
    52       //todo: inform Logic for new filter
     60      int filteredCnt = 0;
     61      for (int i = 0; i < result.Length; i++)
     62      {
     63        if (result[i] == true)
     64          filteredCnt++;
     65      }
     66      tbFiltered.Text = filteredCnt.ToString();
     67      double percentage = filteredCnt * 100 / result.Length;
     68      tbPercentage.Text = percentage.ToString() + "%";
     69      tbTotal.Text = result.Length.ToString();
    5370    }
    5471
     
    6481      {
    6582        filter.ConstrainedValue = Content.FilterLogic.PreprocessingData;
     83        filter.Active = true;
     84        filterView.Content.SetItemCheckedState(filter, false);
    6685      }
     86      UpdateFilterInfo();
     87    }
     88
     89    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IFilter> e)
     90    {
     91      UpdateFilterInfo();
    6792    }
    6893
Note: See TracChangeset for help on using the changeset viewer.