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

状态条

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Drawing;
  4. namespace UtilityLibrary.Collections
  5. {
  6. /// <summary>
  7. /// Summary description for BitmapCollection.
  8. /// </summary>
  9. public class BitmapCollection : IEnumerable
  10. {
  11. #region Class Variables
  12. public event EventHandler Changed;
  13. ArrayList items = new ArrayList();
  14. #endregion
  15. #region Constructor
  16. public BitmapCollection()
  17. {
  18. }
  19. #endregion
  20. #region Properties
  21. public int Count
  22. {
  23. get { return items.Count; }
  24. }
  25. #endregion
  26. #region Methods
  27. public IEnumerator GetEnumerator()
  28. {
  29. return items.GetEnumerator();
  30. }
  31. public int Add(Bitmap item)
  32. {
  33. if (Contains(item)) return -1;
  34. int index = items.Add(item);
  35. RaiseChanged();
  36. return index;
  37. }
  38. public void Clear()
  39. {
  40. while (Count > 0) RemoveAt(0);
  41. }
  42. public bool Contains(Bitmap item)
  43. {
  44. return items.Contains(item);
  45. }
  46. public int IndexOf(Bitmap item)
  47. {
  48. return items.IndexOf(item);
  49. }
  50. public void Remove(Bitmap item)
  51. {
  52. items.Remove(item);
  53. RaiseChanged();
  54. }
  55. public void RemoveAt(int index)
  56. {
  57. items.RemoveAt(index);
  58. RaiseChanged();
  59. }
  60. public void Insert(int index, Bitmap item)
  61. {
  62. items.Insert(index, item);
  63. RaiseChanged();
  64. }
  65. public Bitmap this[int index]
  66. {
  67. get { return (Bitmap) items[index]; }
  68. set {  items[index] = value; }
  69. }
  70. #endregion 
  71. #region Implementatioin
  72. void RaiseChanged()
  73. {
  74. if (Changed != null) Changed(this, null);
  75. }
  76. #endregion
  77. }
  78. }