123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- namespace TSZ.DotNetDll.WinForms
- {
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Reflection;
- public class MultiEditorItemSet : IEnumerable<MultiEditorItem>, IEnumerable
- {
- private List<MultiEditorItem> _Items = new List<MultiEditorItem>();
- public MultiEditorItem Add(MultiEditorItem item)
- {
- this._Items.Add(item);
- return item;
- }
- public IEnumerable<MultiEditorItem> AddRang(IEnumerable<MultiEditorItem> items)
- {
- this._Items.AddRange(items);
- return items;
- }
- public T AddT<T>(T item) where T: MultiEditorItem
- {
- this._Items.Add(item);
- return item;
- }
- public MultiEditorItem[] Clear()
- {
- MultiEditorItem[] itemArray = this._Items.ToArray();
- this._Items.Clear();
- return itemArray;
- }
- public IEnumerator<MultiEditorItem> GetEnumerator()
- {
- return this._Items.GetEnumerator();
- }
- public MultiEditorItem IndexOf(string itemLable)
- {
- for (int i = 0; i < this._Items.Count; i++)
- {
- if (this._Items[i].Label == itemLable)
- {
- return this._Items[i];
- }
- }
- return null;
- }
- public int IndexOf(MultiEditorItem item)
- {
- return this._Items.IndexOf(item);
- }
- public MultiEditorItem Insert(int index, MultiEditorItem item)
- {
- this._Items.Insert(index, item);
- return item;
- }
- public bool Remove(string itemLable)
- {
- MultiEditorItem index = this.IndexOf(itemLable);
- if (index != null)
- {
- this.Remove(index);
- return true;
- }
- return false;
- }
- public bool Remove(MultiEditorItem item)
- {
- return this._Items.Remove(item);
- }
- public MultiEditorItem RemoveAt(int index)
- {
- if ((index >= 0) && (index < this._Items.Count))
- {
- MultiEditorItem item = this._Items[index];
- this._Items.RemoveAt(index);
- return item;
- }
- return null;
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this._Items.GetEnumerator();
- }
- public MultiEditorItem[] ToArray()
- {
- return this._Items.ToArray();
- }
- public int Count
- {
- get
- {
- return this._Items.Count;
- }
- }
- public MultiEditorItem this[int index]
- {
- get
- {
- return this._Items[index];
- }
- }
- public MultiEditorItem[] Items
- {
- get
- {
- return this._Items.ToArray();
- }
- }
- }
- }
|