MenuItemExCollection.cs
上传用户:nnpulika
上传日期:2013-02-15
资源大小:597k
文件大小:1k
源码类别:

状态条

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Windows.Forms;
  4. using UtilityLibrary.WinControls;
  5. using UtilityLibrary.Menus;
  6. namespace UtilityLibrary.Collections
  7. {
  8. /// <summary>
  9. /// Summary description for MenuItemExCollection.
  10. /// </summary>
  11. public class MenuItemExCollection : System.Collections.CollectionBase, IEnumerable
  12. {
  13. #region Events
  14. public event EventHandler Changed;
  15. #endregion
  16. #region Constructors
  17. public MenuItemExCollection()
  18. {
  19. }
  20. #endregion
  21. #region Methods
  22. public int Add(MenuItemEx item)
  23. {
  24. if (Contains(item)) return -1;
  25. int index = InnerList.Add(item);
  26. RaiseChanged();
  27. return index;
  28. }
  29. public bool Contains(MenuItemEx item)
  30. {
  31. return InnerList.Contains(item);
  32. }
  33. public int IndexOf(MenuItemEx item)
  34. {
  35. return InnerList.IndexOf(item);
  36. }
  37. public void Remove(MenuItemEx item)
  38. {
  39. InnerList.Remove(item);
  40. RaiseChanged();
  41. }
  42. public void Insert(int index, MenuItemEx item)
  43. {
  44. InnerList.Insert(index, item);
  45. RaiseChanged();
  46. }
  47. public MenuItemEx this[int index]
  48. {
  49. get { return (MenuItemEx) InnerList[index]; }
  50. set {  InnerList[index] = value; }
  51. }
  52. #endregion
  53. #region Implementation
  54. void RaiseChanged()
  55. {
  56. if (Changed != null) Changed(this, null);
  57. }
  58. #endregion
  59. }
  60. }