Changeset 6673 for trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionContentConstraintView.cs
- Timestamp:
- 08/19/11 11:25:46 (13 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionContentConstraintView.cs
r6661 r6673 22 22 using System; 23 23 using System.Linq; 24 using HeuristicLab.Core; 24 using System.Windows.Forms; 25 using HeuristicLab.Common; 25 26 using HeuristicLab.Core.Views; 26 using HeuristicLab.Data;27 27 using HeuristicLab.MainForm; 28 28 29 29 namespace HeuristicLab.Optimization.Views { 30 [Content(typeof( IRunCollectionConstraint))]31 public partial class RunCollectionCon straintView : ItemView {32 public RunCollectionCon straintView() {30 [Content(typeof(RunCollectionContentConstraint), true)] 31 public partial class RunCollectionContentConstraintView : ItemView { 32 public RunCollectionContentConstraintView() { 33 33 InitializeComponent(); 34 runsView.ShowDetails = false; 34 35 } 35 36 36 public new IRunCollectionConstraint Content {37 get { return ( IRunCollectionConstraint)base.Content; }37 public new RunCollectionContentConstraint Content { 38 get { return (RunCollectionContentConstraint)base.Content; } 38 39 set { base.Content = value; } 39 40 } … … 41 42 protected override void OnContentChanged() { 42 43 base.OnContentChanged(); 43 cmbConstraintColumn.Items.Clear();44 cmbConstraintOperation.Items.Clear();45 46 44 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();53 45 chbActive.Checked = Content.Active; 54 46 ReadOnly = Content.Active; 55 } else 47 runsView.RunCollection = Content.ConstrainedValue; 48 runsView.Content = Content.ConstraintData; 49 } else { 56 50 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; 65 53 } 66 54 } … … 68 56 protected override void RegisterContentEvents() { 69 57 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); 74 59 } 75 60 76 61 protected override void DeregisterContentEvents() { 77 62 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); 82 64 } 83 65 84 66 protected override void SetEnabledStateOfControls() { 85 67 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; 113 70 } 114 71 115 72 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; 119 75 } 120 76 protected virtual void chbActive_CheckedChanged(object sender, EventArgs e) { … … 122 78 Content.Active = chbActive.Checked; 123 79 } 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 } 124 100 } 125 101 }
Note: See TracChangeset
for help on using the changeset viewer.