/*-------------------------------------------------------------------------
* 功能描述:RevitMenuComponment
* 作者:xulisong
* 创建时间: 2019/3/7 15:38:41
* 版本号:v1.0
* -------------------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FWindSoft.Revit.Menu
{
public class RevitMenuComponment
{
public MenuConfig Config { get; internal set; }
///
/// 名称
///
public string Name { get; set; }
///
/// 显示
///
public string Text { get; set; }
}
///
/// 节点集合
///
public class RevitComponmentCollection : Collection where T: RevitMenuComponment
{
private MenuConfig m_Config;
internal RevitComponmentCollection(MenuConfig config)
{
m_Config = config;
}
protected override void ClearItems()
{
foreach (var item in this)
{
if (item != null)
{
item.Config = null;
}
}
base.ClearItems();
}
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
item.Config = m_Config ;
}
protected override void RemoveItem(int index)
{
if (this[index] != null)
{
this[index].Config = null;
}
base.RemoveItem(index);
}
protected override void SetItem(int index, T item)
{
base.SetItem(index, item);
item.Config = m_Config;
}
public void AddRange(IEnumerable items)
{
foreach (var item in items)
{
this.Add(item);
}
}
}
}