- Timestamp:
- 05/03/10 17:36:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/CheckedItemList.cs
r3575 r3594 33 33 34 34 namespace HeuristicLab.Core { 35 /// <summary> 36 /// Represents a list of checked items. 37 /// </summary> 38 /// <typeparam name="T">The element type (base type is IItem)</typeparam> 35 39 [StorableClass] 36 40 [Item("CheckedItemList<T>", "Represents a list of items that can be checked or unchecked.")] … … 39 43 private Dictionary<T, bool> checkedState; 40 44 45 /// <summary> 46 /// Gets an enumerable of checked items. 47 /// </summary> 41 48 public IEnumerable<IndexedItem<T>> CheckedItems { 42 49 get { … … 46 53 } 47 54 } 55 /// <summary> 56 /// Instantiates an empty CheckedItemList. 57 /// </summary> 48 58 public CheckedItemList() 49 59 : base() { 50 60 checkedState = new Dictionary<T, bool>(); 51 61 } 62 /// <summary> 63 /// Instantiates an empty CheckedItemList with a given initial <paramref name="capacity"/>. 64 /// </summary> 65 /// <param name="capacity">The initial capacity.</param> 52 66 public CheckedItemList(int capacity) 53 67 : base(capacity) { 54 68 checkedState = new Dictionary<T, bool>(); 55 69 } 70 /// <summary> 71 /// Instantiates an CheckedItemList initially filled with the elements of <paramref name="collection"/>. 72 /// </summary> 73 /// <param name="collection">Collection of elements.</param> 56 74 public CheckedItemList(IEnumerable<T> collection) 57 75 : base(collection) { … … 62 80 } 63 81 } 82 /// <summary> 83 /// Instantiates a new CheckedItemList for deserialization. 84 /// </summary> 85 /// <param name="deserializing"></param> 64 86 [StorableConstructor] 65 87 protected CheckedItemList(bool deserializing) : base(deserializing) { } 66 88 89 /// <summary> 90 /// Gets the checked state of <paramref name="item"/>. 91 /// </summary> 92 /// <param name="item">The element to get the checked state for.</param> 93 /// <returns>The checked state of <paramref name="item"/></returns> 67 94 public bool ItemChecked(T item) { 68 95 return checkedState[item]; 69 96 } 70 97 98 /// <summary> 99 /// Gets the checked state of item with <paramref name="index"/>. 100 /// </summary> 101 /// <param name="itemIndex">The index of the element to get the checked state for.</param> 102 /// <returns>The checked state of the element at <paramref name="itemIndex"/>.</returns> 71 103 public bool ItemChecked(int itemIndex) { 72 104 return ItemChecked(this[itemIndex]); 73 105 } 74 106 107 /// <summary> 108 /// Sets the checked state of <paramref name="item"/> to <paramref name="checkedState"/>. 109 /// </summary> 110 /// <param name="item">The item to set the checked state for.</param> 111 /// <param name="checkedState">The new checked state of <paramref name="item"/></param> 75 112 public void SetItemCheckedState(T item, bool checkedState) { 76 113 if (!this.checkedState.ContainsKey(item)) throw new ArgumentException(); … … 81 118 } 82 119 120 /// <summary> 121 /// Sets the checked state of the element with <paramref name="itemIndex"/> to <paramref name="checkedState"/>. 122 /// </summary> 123 /// <param name="itemIndex">The index of the item to set the checked state for.</param> 124 /// <param name="checkedState">The new checked state of the item.</param> 83 125 public void SetItemCheckedState(int itemIndex, bool checkedState) { 84 126 SetItemCheckedState(this[itemIndex], checkedState); 85 127 } 86 128 129 /// <summary> 130 /// Adds a new <paramref name="item"/> with <paramref name="checkedState"/> to the list. 131 /// </summary> 132 /// <param name="item">The item to add to the list.</param> 133 /// <param name="checkedState">The checked state of the item added to the list.</param> 87 134 public void Add(T item, bool checkedState) { 88 135 Add(item); … … 90 137 } 91 138 139 /// <summary> 140 /// Inserts a new <paramref name="item"/> at <paramref name="index"/> with <paramref name="checkedState"/> into the list. 141 /// </summary> 142 /// <param name="index">The insertion index of the new element.</param> 143 /// <param name="item">The element that is inserted into the list.</param> 144 /// <param name="checkedState">The checked state of the inserted element.</param> 92 145 public void Insert(int index, T item, bool checkedState) { 93 146 Insert(index, item); … … 95 148 } 96 149 150 /// <summary> 151 /// Raised after the list has been reset. 152 /// </summary> 153 /// <param name="items">Empty</param> 154 /// <param name="oldItems">The elements of the list before it has been reset.</param> 97 155 protected override void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) { 98 156 foreach (var oldIndexedItem in oldItems) { … … 106 164 } 107 165 166 /// <summary> 167 /// Raised when new items are added to the list. 168 /// </summary> 169 /// <param name="items">The items that are added.</param> 108 170 protected override void OnItemsAdded(IEnumerable<IndexedItem<T>> items) { 109 171 foreach (var indexedItem in items) … … 113 175 } 114 176 177 /// <summary> 178 /// Raised when items are removed from the list. 179 /// </summary> 180 /// <param name="items">Items that are removed.</param> 115 181 protected override void OnItemsRemoved(IEnumerable<IndexedItem<T>> items) { 116 182 foreach (var indexedItem in items) … … 119 185 } 120 186 187 /// <summary> 188 /// Raised when items are replaced. 189 /// </summary> 190 /// <param name="items">The items which replace <paramref name="oldItems"/></param> 191 /// <param name="oldItems">The items that are replaced by <paramref name="items"/></param> 121 192 protected override void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) { 122 193 foreach (var oldIndexedItem in oldItems) … … 128 199 } 129 200 201 /// <summary> 202 /// Raised after the checked state of items has been changed. 203 /// </summary> 204 /// <param name="items">The items whose check state has been changed.</param> 130 205 protected virtual void OnCheckedItemsChanged(IEnumerable<IndexedItem<T>> items) { 131 206 RaiseCheckedItemsChanged(new CollectionItemsChangedEventArgs<IndexedItem<T>>(items)); 132 207 } 133 208 209 /// <summary> 210 /// Raised after the checked state of items has been changed. 211 /// </summary> 134 212 public event CollectionItemsChangedEventHandler<IndexedItem<T>> CheckedItemsChanged; 135 213 private void RaiseCheckedItemsChanged(CollectionItemsChangedEventArgs<IndexedItem<T>> e) { … … 138 216 } 139 217 140 public object Clone() { 141 return Clone(new Cloner()); 142 } 143 public virtual IDeepCloneable Clone(Cloner cloner) { 218 /// <summary> 219 /// Creates a new deep clone of the CheckedItemList. 220 /// </summary> 221 /// <param name="cloner"></param> 222 /// <returns>A deep clone of the CheckedItemList</returns> 223 public override IDeepCloneable Clone(Cloner cloner) { 144 224 CheckedItemList<T> clone = (CheckedItemList<T>)Activator.CreateInstance(this.GetType()); 145 225 cloner.RegisterClonedObject(this, clone);
Note: See TracChangeset
for help on using the changeset viewer.