Changeset 3614 for trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs
- Timestamp:
- 05/05/10 00:10:13 (14 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs
r3604 r3614 24 24 using HeuristicLab.Collections; 25 25 using HeuristicLab.MainForm; 26 using HeuristicLab.Optimization; 27 using System.Drawing; 26 28 27 29 namespace HeuristicLab.Core.Views { 28 30 [View("ConstraintCollection View")] 29 [Content(typeof( ConstraintCollection), true)]30 [Content(typeof(IItemCollection<I Constraint>), false)]31 public partial class ConstraintCollectionView : ItemCollectionView<IConstraint> {31 [Content(typeof(RunCollectionConstraintCollection), true)] 32 [Content(typeof(IItemCollection<IRunCollectionConstraint>), false)] 33 public partial class RunCollectionConstraintCollectionView : ItemCollectionView<IRunCollectionConstraint> { 32 34 protected CreateParameterDialog createParameterDialog; 33 35 /// <summary> 34 36 /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View". 35 37 /// </summary> 36 public ConstraintCollectionView() {38 public RunCollectionConstraintCollectionView() { 37 39 InitializeComponent(); 38 Caption = " ConstraintCollection";39 itemsGroupBox.Text = " Constraints";40 Caption = "RunCollectionConstraintCollection"; 41 itemsGroupBox.Text = "RunCollection Constraints"; 40 42 } 41 43 42 protected override I Constraint CreateItem() {44 protected override IRunCollectionConstraint CreateItem() { 43 45 if (typeSelectorDialog == null) { 44 46 typeSelectorDialog = new TypeSelectorDialog(); 45 typeSelectorDialog.Caption = "Select Operator";46 typeSelectorDialog.TypeSelector.Caption = "Available Operators";47 typeSelectorDialog.TypeSelector.Configure(typeof(I Constraint), false, true);47 typeSelectorDialog.Caption = "Select RunCollection Constraint"; 48 typeSelectorDialog.TypeSelector.Caption = "Available Constraints"; 49 typeSelectorDialog.TypeSelector.Configure(typeof(IRunCollectionConstraint), false, true); 48 50 } 49 51 50 52 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 51 53 try { 52 return (I Constraint)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();54 return (IRunCollectionConstraint)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 53 55 } 54 56 catch (Exception ex) { … … 58 60 return null; 59 61 } 62 63 protected override void RegisterContentEvents() { 64 base.RegisterContentEvents(); 65 foreach (IRunCollectionConstraint constraint in Content) 66 constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged); 67 } 68 protected override void DeregisterContentEvents() { 69 base.DeregisterContentEvents(); 70 foreach (IRunCollectionConstraint constraint in Content) 71 constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged); 72 } 73 protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 74 base.Content_ItemsAdded(sender, e); 75 foreach (IRunCollectionConstraint constraint in e.Items) 76 constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged); 77 } 78 protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 79 base.Content_ItemsRemoved(sender, e); 80 foreach (IRunCollectionConstraint constraint in e.Items) 81 constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged); 82 } 83 protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 84 base.Content_CollectionReset(sender, e); 85 foreach (IRunCollectionConstraint constraint in e.OldItems) 86 constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged); 87 foreach (IRunCollectionConstraint constraint in e.Items) 88 constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged); 89 } 90 91 protected virtual void constraint_ActiveChanged(object sender, EventArgs e) { 92 IRunCollectionConstraint constraint = sender as IRunCollectionConstraint; 93 if (constraint != null) { 94 foreach (ListViewItem listViewItem in GetListViewItemsForItem(constraint)) { 95 if (constraint.Active) 96 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Bold); 97 else 98 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 99 } 100 } 101 } 102 103 60 104 } 61 105 }
Note: See TracChangeset
for help on using the changeset viewer.