#region License Information
/* HeuristicLab
* Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using HEAL.Attic;
using HeuristicLab.Collections;
using HeuristicLab.Common;
namespace HeuristicLab.Core {
[StorableType("BE738F46-3864-42BB-BD29-F3E933B0AC06")]
[Item("ReadOnlyCheckedItemList", "Represents a read-only list of checked items.")]
public class ReadOnlyCheckedItemList : ReadOnlyItemList, ICheckedItemList where T : class, IItem {
private CheckedItemList CheckedItemList {
get { return (CheckedItemList)base.list; }
}
[StorableConstructor]
protected ReadOnlyCheckedItemList(StorableConstructorFlag _) : base(_) { }
protected ReadOnlyCheckedItemList(ReadOnlyCheckedItemList original, Cloner cloner)
: base(original, cloner) {
CheckedItemList.CheckedItemsChanged += new CollectionItemsChangedEventHandler>(list_CheckedItemsChanged);
}
public ReadOnlyCheckedItemList() : base(new CheckedItemList()) { }
public ReadOnlyCheckedItemList(ICheckedItemList list)
: base(list) {
CheckedItemList.CheckedItemsChanged += new CollectionItemsChangedEventHandler>(list_CheckedItemsChanged);
}
[StorableHook(HookType.AfterDeserialization)]
private void AfterDeserialization() {
CheckedItemList.CheckedItemsChanged += new CollectionItemsChangedEventHandler>(list_CheckedItemsChanged);
}
public override IDeepCloneable Clone(Cloner cloner) {
return new ReadOnlyCheckedItemList(this, cloner);
}
#region ICheckedItemList Members
public event CollectionItemsChangedEventHandler> CheckedItemsChanged;
protected virtual void list_CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs> e) {
var handler = CheckedItemsChanged;
if (handler != null)
handler(this, e);
}
public IEnumerable> CheckedItems {
get { return CheckedItemList.CheckedItems; }
}
public bool ItemChecked(T item) {
return CheckedItemList.ItemChecked(item);
}
public bool ItemChecked(int itemIndex) {
return CheckedItemList.ItemChecked(itemIndex);
}
public void SetItemCheckedState(T item, bool checkedState) {
CheckedItemList.SetItemCheckedState(item, checkedState);
}
public void SetItemCheckedState(IEnumerable items, bool checkedState) {
CheckedItemList.SetItemCheckedState(items, checkedState);
}
public void SetItemCheckedState(int itemIndex, bool checkedState) {
CheckedItemList.SetItemCheckedState(itemIndex, checkedState);
}
public void SetItemCheckedState(IEnumerable itemIndices, bool checkedState) {
CheckedItemList.SetItemCheckedState(itemIndices, checkedState);
}
public void Add(T item, bool checkedState) {
throw new NotSupportedException();
}
public void Insert(int index, T item, bool checkedState) {
throw new NotSupportedException();
}
#endregion
}
}