Changeset 4982 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/CheckedValueConfigurationCollection.cs
- Timestamp:
- 11/28/10 23:03:05 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
- Property svn:ignore
-
old new 2 2 bin 3 3 obj 4 HeuristicLabProblemsMetaOptimizationPlugin.cs
-
- Property svn:ignore
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/CheckedValueConfigurationCollection.cs
r4981 r4982 4 4 using System.Text; 5 5 using HeuristicLab.Core; 6 using HeuristicLab.Common; 7 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 6 8 7 9 namespace HeuristicLab.Problems.MetaOptimization { 8 10 // todo: check that at least 1 elements needs to be selected 9 11 // todo: control creatable item types 12 [StorableClass] 10 13 public class CheckedValueConfigurationCollection : CheckedItemCollection<IValueConfiguration>, ICheckedValueConfigurationCollection { 14 [Storable] 15 private int minItemCount = 1; 16 public int MinItemCount { 17 get { return minItemCount; } 18 } 11 19 20 [Storable] 12 21 protected Type valueDataType; 13 22 public Type ValueDataType { … … 17 26 public CheckedValueConfigurationCollection(Type valueDataType) { 18 27 this.valueDataType = valueDataType; 28 RegisterEvents(); 29 } 30 public CheckedValueConfigurationCollection() { 31 RegisterEvents(); 32 } 33 [StorableConstructor] 34 protected CheckedValueConfigurationCollection(bool deserializing) : base(deserializing) { 35 RegisterEvents(); 36 } 37 protected CheckedValueConfigurationCollection(CheckedValueConfigurationCollection original, Cloner cloner) : base(original, cloner) { 38 this.minItemCount = original.MinItemCount; 39 this.valueDataType = original.valueDataType; 40 RegisterEvents(); 41 } 42 public override IDeepCloneable Clone(Cloner cloner) { 43 return new CheckedValueConfigurationCollection(this, cloner); 44 } 45 46 private void RegisterEvents() { 47 this.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved); 48 } 49 private void DeregisterEvents() { 50 this.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<IValueConfiguration>(CheckedValueConfigurationCollection_ItemsRemoved); 51 } 52 53 private void CheckedValueConfigurationCollection_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IValueConfiguration> e) { 54 // auch collectionreset gehört berücksichtigt 55 // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt 56 //if (this.Count < minItemCount) { 57 // foreach (var item in e.Items) { 58 // if (this.Count >= minItemCount) 59 // break; 60 // this.Add(item); 61 // } 62 //} 19 63 } 20 64 }
Note: See TracChangeset
for help on using the changeset viewer.