Changeset 3632


Ignore:
Timestamp:
05/05/10 14:04:53 (12 years ago)
Author:
mkommend
Message:

corrected RunCollectionConstraints and the according views (ticket#970)

Location:
trunk/sources
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.Designer.cs

    r3346 r3632  
    165165    #endregion
    166166
    167     private System.Windows.Forms.Label rowsLabel;
    168     private System.Windows.Forms.TextBox rowsTextBox;
    169     private System.Windows.Forms.ErrorProvider errorProvider;
    170     private System.Windows.Forms.TextBox columnsTextBox;
    171     private System.Windows.Forms.Label columnsLabel;
    172     private System.Windows.Forms.ContextMenuStrip contextMenu;
    173     private System.Windows.Forms.ToolStripMenuItem ShowHideColumns;
     167    protected System.Windows.Forms.Label rowsLabel;
     168    protected System.Windows.Forms.TextBox rowsTextBox;
     169    protected System.Windows.Forms.ErrorProvider errorProvider;
     170    protected System.Windows.Forms.TextBox columnsTextBox;
     171    protected System.Windows.Forms.Label columnsLabel;
     172    protected System.Windows.Forms.ContextMenuStrip contextMenu;
     173    protected System.Windows.Forms.ToolStripMenuItem ShowHideColumns;
    174174    protected System.Windows.Forms.DataGridView dataGridView;
    175175
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectioComparisonConstraintView.Designer.cs

    r3614 r3632  
    3434      this.txtConstraintData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    3535                  | System.Windows.Forms.AnchorStyles.Right)));
     36      this.errorProvider.SetIconAlignment(this.txtConstraintData, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     37      this.errorProvider.SetIconPadding(this.txtConstraintData, 2);
    3638      this.txtConstraintData.Location = new System.Drawing.Point(127, 56);
    3739      this.txtConstraintData.Name = "txtConstraintData";
    3840      this.txtConstraintData.Size = new System.Drawing.Size(246, 20);
    3941      this.txtConstraintData.TabIndex = 9;
    40       this.txtConstraintData.TextChanged += new System.EventHandler(this.txtConstraintData_TextChanged);
     42      this.txtConstraintData.Validated += new System.EventHandler(this.txtConstraintData_Validated);
    4143      this.txtConstraintData.Validating += new System.ComponentModel.CancelEventHandler(this.txtConstraintData_Validating);
    4244      //
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectioComparisonConstraintView.cs

    r3614 r3632  
    3636
    3737    protected override void DeregisterContentEvents() {
    38       base.RegisterContentEvents();
     38      base.DeregisterContentEvents();
    3939      Content.ConstraintDataChanged -= new EventHandler(Content_ConstraintDataChanged);
    4040    }
     
    5252          }
    5353        }
    54         if (Content.ConstraintColumn >= 0)
     54        if (Content.ConstraintColumn >= 0) {
    5555          this.cmbConstraintColumn.SelectedItem = (matrix.ColumnNames.ElementAt(Content.ConstraintColumn));
     56          if (Content.ConstraintData != null)
     57            txtConstraintData.Text = Content.ConstraintData.GetValue();
     58          else
     59            this.Content_ConstraintColumnChanged(cmbConstraintColumn, EventArgs.Empty);
     60        }
    5661      }
    5762    }
     
    7479    }
    7580
    76     private void txtConstraintData_TextChanged(object sender, EventArgs e) {
    77       Content.ConstraintData.SetValue(txtConstraintData.Text);
     81    private void txtConstraintData_Validated(object sender, EventArgs e) {
     82      IStringConvertibleValue value = (IStringConvertibleValue)Activator.CreateInstance(Content.ConstrainedValue.GetDataType(cmbConstraintColumn.SelectedItem.ToString()).First());
     83      value.SetValue(txtConstraintData.Text);
     84      Content.ConstraintData = value;
    7885    }
    7986
    8087    private void txtConstraintData_Validating(object sender, CancelEventArgs e) {
    81       string errorMessage;
     88      string errorMessage = string.Empty;
    8289      if (!Content.ConstraintData.Validate(txtConstraintData.Text, out errorMessage)) {
    8390        errorProvider.SetError(txtConstraintData, errorMessage);
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs

    r3614 r3632  
    120120    }
    121121    private void run_Changed(object sender, EventArgs e) {
    122       IRun run = (IRun)sender;
    123       UpdateRun(run);
     122      if (InvokeRequired)
     123        this.Invoke(new EventHandler(run_Changed), sender, e);
     124      else {
     125        IRun run = (IRun)sender;
     126        UpdateRun(run);
     127      }
    124128    }
    125129
     
    144148      UpdateComboBoxes();
    145149      UpdateDataPoints();
    146       foreach(IRun run in Content)
     150      foreach (IRun run in Content)
    147151        UpdateRun(run);
    148152    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.Designer.cs

    r3614 r3632  
    1212    protected override void Dispose(bool disposing) {
    1313      if (disposing) {
    14         if (createParameterDialog != null) createParameterDialog.Dispose();
    1514        if (components != null) components.Dispose();
    1615      }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs

    r3614 r3632  
    3232  [Content(typeof(IItemCollection<IRunCollectionConstraint>), false)]
    3333  public partial class RunCollectionConstraintCollectionView : ItemCollectionView<IRunCollectionConstraint> {
    34     protected CreateParameterDialog createParameterDialog;
    3534    /// <summary>
    3635    /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".
     
    6463      base.RegisterContentEvents();
    6564      foreach (IRunCollectionConstraint constraint in Content)
    66         constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     65        RegisterConstraintEvents(constraint);
    6766    }
    6867    protected override void DeregisterContentEvents() {
    6968      base.DeregisterContentEvents();
    7069      foreach (IRunCollectionConstraint constraint in Content)
    71         constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
     70        DeregisterConstraintEvents(constraint);
    7271    }
    7372    protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    7473      base.Content_ItemsAdded(sender, e);
    7574      foreach (IRunCollectionConstraint constraint in e.Items)
    76         constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     75        RegisterConstraintEvents(constraint);
    7776    }
    7877    protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    7978      base.Content_ItemsRemoved(sender, e);
    8079      foreach (IRunCollectionConstraint constraint in e.Items)
    81         constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
     80        DeregisterConstraintEvents(constraint);
    8281    }
    8382    protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    8483      base.Content_CollectionReset(sender, e);
    8584      foreach (IRunCollectionConstraint constraint in e.OldItems)
    86         constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
     85        RegisterConstraintEvents(constraint);
    8786      foreach (IRunCollectionConstraint constraint in e.Items)
    88         constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     87        DeregisterConstraintEvents(constraint);
     88    }
     89
     90    protected virtual void RegisterConstraintEvents(IRunCollectionConstraint constraint) {
     91      constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
     92    }
     93
     94    protected virtual void DeregisterConstraintEvents(IRunCollectionConstraint constraint) {
     95      constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
    8996    }
    9097
     
    99106        }
    100107      }
     108      this.AdjustListViewColumnSizes();
    101109    }
    102 
    103 
    104110  }
    105111}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs

    r3614 r3632  
    9595    }
    9696    private void run_Changed(object sender, EventArgs e) {
    97       IRun run = (IRun)sender;
    98       UpdateRun(run);
     97      if (InvokeRequired)
     98        this.Invoke(new EventHandler(run_Changed), sender, e);
     99      else {
     100        IRun run = (IRun)sender;
     101        UpdateRun(run);
     102      }
    99103    }
    100104
     
    104108      this.dataGridView.Rows[rowIndex].Visible = run.Visible;
    105109      this.dataGridView.Rows[rowIndex].DefaultCellStyle.ForeColor = run.Color;
     110      this.rowsTextBox.Text = this.Content.Count(r => r.Visible).ToString();
    106111    }
    107112
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs

    r3614 r3632  
    335335    }
    336336    protected virtual void Run_Changed(object sender, EventArgs e) {
    337       IRun run = (IRun)sender;
    338       UpdateRun(run);
     337      if (InvokeRequired)
     338        this.Invoke(new EventHandler(Run_Changed), sender, e);
     339      else {
     340        IRun run = (IRun)sender;
     341        UpdateRun(run);
     342      }
    339343    }
    340344
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r3625 r3632  
    8484        OnColumnNamesChanged();
    8585      OnRowNamesChanged();
     86      this.UpdateFiltering(false);
    8687    }
    8788    protected override void OnItemsRemoved(IEnumerable<IRun> items) {
     
    160161    public override IDeepCloneable Clone(Cloner cloner) {
    161162      RunCollection clone = (RunCollection)base.Clone(cloner);
    162       clone.resultNames = this.resultNames;
    163       clone.parameterNames = this.parameterNames;
     163      clone.resultNames = new List<string>(this.resultNames);
     164      clone.parameterNames = new List<string>(this.parameterNames);
    164165      clone.dataTypes = new Dictionary<string, HashSet<Type>>();
    165166      foreach (string s in this.dataTypes.Keys)
    166167        clone.dataTypes[s] = new HashSet<Type>(this.dataTypes[s]);
    167 
    168168      return clone;
    169169    }
     
    252252
    253253    #region filtering
    254     private void UpdateFiltering() {
    255       list.ForEach(r => r.Visible = true);
     254    private void UpdateFiltering(bool reset) {
     255      if (reset)
     256        list.ForEach(r => r.Visible = true);
    256257      foreach (IRunCollectionConstraint constraint in this.constraints)
    257258        constraint.Check();
     
    278279      DeregisterConstraintEvents(e.OldItems);
    279280      RegisterConstraintEvents(e.Items);
    280       this.UpdateFiltering();
     281      this.UpdateFiltering(true);
    281282    }
    282283    protected virtual void Constraints_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
     
    284285      foreach (IRunCollectionConstraint constraint in e.Items)
    285286        constraint.ConstrainedValue = this;
    286       this.UpdateFiltering();
     287      this.UpdateFiltering(false);
    287288    }
    288289    protected virtual void Constraints_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    289290      DeregisterConstraintEvents(e.Items);
    290       this.UpdateFiltering();
     291      this.UpdateFiltering(true);
    291292    }
    292293    protected virtual void Constraint_ActiveChanged(object sender, EventArgs e) {
    293       this.UpdateFiltering();
     294      IRunCollectionConstraint constraint = (IRunCollectionConstraint)sender;
     295      this.UpdateFiltering(!constraint.Active);
    294296    }
    295297    protected virtual void Constraint_ConstrainedValueChanged(object sender, EventArgs e) {
     
    297299    }
    298300    protected virtual void Constraint_ConstraintOperationChanged(object sender, EventArgs e) {
    299       this.UpdateFiltering();
     301      IRunCollectionConstraint constraint = (IRunCollectionConstraint)sender;
     302      if (constraint.Active)
     303        this.UpdateFiltering(true);
    300304    }
    301305    protected virtual void Constraint_ConstraintDataChanged(object sender, EventArgs e) {
    302       this.UpdateFiltering();
     306      IRunCollectionConstraint constraint = (IRunCollectionConstraint)sender;
     307      if (constraint.Active)
     308        this.UpdateFiltering(true);
    303309    }
    304310    #endregion
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionComparisonConstraint.cs

    r3617 r3632  
    7070          constraintColumn = value;
    7171          this.OnConstraintColumnChanged();
     72          this.OnToStringChanged();
    7273        }
    7374      }
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionTypeCompatiblityConstraint.cs

    r3617 r3632  
    6060          constraintColumn = value;
    6161          this.OnConstraintColumnChanged();
     62          this.OnToStringChanged();
    6263        }
    6364      }
Note: See TracChangeset for help on using the changeset viewer.