ImageList.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. namespace System.Windows.Forms
  5. {
  6. public class ImageList : IDisposable
  7. {
  8. public ImageCollection Images { get; }
  9. public ColorDepth ColorDepth { get; set; } // TODO? always 32bpp
  10. public System.Drawing.Size ImageSize { get; set; } // TODO?
  11. public void Dispose() { }
  12. public ImageList()
  13. {
  14. Images = new();
  15. }
  16. public class ImageCollection : CollectionBase
  17. {
  18. internal List<System.Windows.Media.ImageSource> ImageSources { get; } = new();
  19. public Image this[int index] => (index < 0 || index >= Count) ? null : List[index] as Image;
  20. public void Add(Image value, Color transparentColor)
  21. {
  22. // TODO: transparent color? we don't use it
  23. List.Add(value);
  24. ImageSources.Add(Helper.GetImage(value));
  25. }
  26. public void Add(Image value) => Add(value, Color.Transparent);
  27. public new void Clear()
  28. {
  29. List.Clear();
  30. ImageSources.Clear();
  31. }
  32. public new void RemoveAt(int index)
  33. {
  34. List.RemoveAt(index);
  35. ImageSources.RemoveAt(index);
  36. }
  37. }
  38. }
  39. }