Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/19/11 11:25:46 (13 years ago)
Author:
mkommend
Message:

#1624: Implemented RunCollectionContentConstraint to hide specific runs.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionContentConstraintView.cs

    r6661 r6673  
    2222using System;
    2323using System.Linq;
    24 using HeuristicLab.Core;
     24using System.Windows.Forms;
     25using HeuristicLab.Common;
    2526using HeuristicLab.Core.Views;
    26 using HeuristicLab.Data;
    2727using HeuristicLab.MainForm;
    2828
    2929namespace HeuristicLab.Optimization.Views {
    30   [Content(typeof(IRunCollectionConstraint))]
    31   public partial class RunCollectionConstraintView : ItemView {
    32     public RunCollectionConstraintView() {
     30  [Content(typeof(RunCollectionContentConstraint), true)]
     31  public partial class RunCollectionContentConstraintView : ItemView {
     32    public RunCollectionContentConstraintView() {
    3333      InitializeComponent();
     34      runsView.ShowDetails = false;
    3435    }
    3536
    36     public new IRunCollectionConstraint Content {
    37       get { return (IRunCollectionConstraint)base.Content; }
     37    public new RunCollectionContentConstraint Content {
     38      get { return (RunCollectionContentConstraint)base.Content; }
    3839      set { base.Content = value; }
    3940    }
     
    4142    protected override void OnContentChanged() {
    4243      base.OnContentChanged();
    43       cmbConstraintColumn.Items.Clear();
    44       cmbConstraintOperation.Items.Clear();
    45 
    4644      if (Content != null) {
    47         cmbConstraintOperation.Items.AddRange(Content.AllowedConstraintOperations.ToArray());
    48         if (Content.ConstraintOperation != null)
    49           cmbConstraintOperation.SelectedItem = Content.ConstraintOperation;
    50         else if (cmbConstraintOperation.Items.Count != 0)
    51           cmbConstraintOperation.SelectedIndex = 0;
    52         UpdateColumnComboBox();
    5345        chbActive.Checked = Content.Active;
    5446        ReadOnly = Content.Active;
    55       } else
     47        runsView.RunCollection = Content.ConstrainedValue;
     48        runsView.Content = Content.ConstraintData;
     49      } else {
    5650        chbActive.Checked = false;
    57     }
    58 
    59     protected virtual void UpdateColumnComboBox() {
    60       this.cmbConstraintColumn.Items.Clear();
    61       if (Content.ConstrainedValue != null) {
    62         this.cmbConstraintColumn.Items.AddRange(((IStringConvertibleMatrix)Content.ConstrainedValue).ColumnNames.ToArray());
    63         if (!string.IsNullOrEmpty(Content.ConstraintColumn))
    64           this.cmbConstraintColumn.SelectedItem = Content.ConstraintColumn;
     51        runsView.RunCollection = null;
     52        runsView.Content = null;
    6553      }
    6654    }
     
    6856    protected override void RegisterContentEvents() {
    6957      base.RegisterContentEvents();
    70       this.Content.ActiveChanged += new EventHandler(Content_ActiveChanged);
    71       this.Content.ConstraintOperationChanged += new EventHandler(Content_ComparisonOperationChanged);
    72       this.Content.ConstraintColumnChanged += new EventHandler(Content_ConstraintColumnChanged);
    73       this.Content.ConstrainedValueChanged += new EventHandler(Content_ConstrainedValueChanged);
     58      Content.ActiveChanged += new EventHandler(Content_ActiveChanged);
    7459    }
    7560
    7661    protected override void DeregisterContentEvents() {
    7762      base.DeregisterContentEvents();
    78       this.Content.ActiveChanged -= new EventHandler(Content_ActiveChanged);
    79       this.Content.ConstraintOperationChanged -= new EventHandler(Content_ComparisonOperationChanged);
    80       this.Content.ConstraintColumnChanged -= new EventHandler(Content_ConstraintColumnChanged);
    81       this.Content.ConstrainedValueChanged += new EventHandler(Content_ConstrainedValueChanged);
     63      Content.ActiveChanged -= new EventHandler(Content_ActiveChanged);
    8264    }
    8365
    8466    protected override void SetEnabledStateOfControls() {
    8567      base.SetEnabledStateOfControls();
    86       cmbConstraintColumn.Enabled = !this.ReadOnly && Content != null;
    87       cmbConstraintOperation.Enabled = !this.ReadOnly && Content != null;
    88       chbActive.Enabled = !this.Locked && Content != null;
    89     }
    90 
    91     protected virtual void Content_ConstrainedValueChanged(object sender, EventArgs e) {
    92       this.UpdateColumnComboBox();
    93     }
    94 
    95     protected virtual void Content_ConstraintColumnChanged(object sender, EventArgs e) {
    96       if (Content.ConstrainedValue != null) {
    97         if (cmbConstraintColumn.SelectedItem.ToString() != Content.ConstraintColumn)
    98           cmbConstraintColumn.SelectedItem = Content.ConstraintColumn;
    99       }
    100     }
    101     private void cmbConstraintColumn_SelectedIndexChanged(object sender, EventArgs e) {
    102       if (Content.ConstrainedValue != null) {
    103         Content.ConstraintColumn = (string)cmbConstraintColumn.SelectedItem;
    104       }
    105     }
    106 
    107     protected virtual void Content_ComparisonOperationChanged(object sender, EventArgs e) {
    108       if (Content.ConstraintOperation != (ConstraintOperation)this.cmbConstraintOperation.SelectedItem)
    109         this.cmbConstraintOperation.SelectedItem = Content.ConstraintOperation;
    110     }
    111     protected virtual void cmbComparisonOperation_SelectedIndexChanged(object sender, EventArgs e) {
    112       Content.ConstraintOperation = (ConstraintOperation)this.cmbConstraintOperation.SelectedItem;
     68      chbActive.Enabled = !Locked && Content != null;
     69      runsView.Enabled = !Locked && Content != null;
    11370    }
    11471
    11572    protected virtual void Content_ActiveChanged(object sender, EventArgs e) {
    116       if (this.chbActive.Checked != Content.Active)
    117         this.chbActive.Checked = Content.Active;
    118       this.ReadOnly = Content.Active;
     73      chbActive.Checked = Content.Active;
     74      ReadOnly = Content.Active;
    11975    }
    12076    protected virtual void chbActive_CheckedChanged(object sender, EventArgs e) {
     
    12278        Content.Active = chbActive.Checked;
    12379    }
     80
     81    private class RunSetView : ItemSetView<IRun> {
     82      public RunCollection RunCollection { get; set; }
     83
     84      protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
     85        base.itemsListView_DragEnter(sender, e);
     86        if (RunCollection != null) {
     87          var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     88          foreach (var run in dropData.GetObjectGraphObjects().OfType<IRun>())
     89            validDragOperation = validDragOperation && RunCollection.Contains(run);
     90        }
     91      }
     92
     93      protected override void itemsListView_DragOver(object sender, DragEventArgs e) {
     94        e.Effect = DragDropEffects.None;
     95        if (validDragOperation) {
     96          e.Effect = DragDropEffects.Link;
     97        }
     98      }
     99    }
    124100  }
    125101}
Note: See TracChangeset for help on using the changeset viewer.