123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*-------------------------------------------------------------------------
- * 功能描述: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; }
- /// <summary>
- /// 名称
- /// </summary>
- public string Name { get; set; }
- /// <summary>
- /// 显示
- /// </summary>
- public string Text { get; set; }
- }
- /// <summary>
- /// 节点集合
- /// </summary>
- public class RevitComponmentCollection<T> : Collection<T> 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<T> items)
- {
- foreach (var item in items)
- {
- this.Add(item);
- }
- }
- }
- }
|