#region License Information /* HeuristicLab * Copyright (C) 2002-2019 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 HeuristicLab.Collections; using HeuristicLab.Common; using HEAL.Attic; 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 void SetItemCheckedState(T item, bool checkedState) { CheckedItemList.SetItemCheckedState(item, checkedState); } public void Add(T item, bool checkedState) { throw new NotSupportedException(); } public void Insert(int index, T item, bool checkedState) { throw new NotSupportedException(); } #endregion } }