AnimationFrame.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Drawing;
  3. namespace Microsoft.Windows.Forms.Animate
  4. {
  5. /// <summary>
  6. /// 动画帧
  7. /// </summary>
  8. internal sealed class AnimationFrame : DisposableMini
  9. {
  10. private AnimationFrameType m_FrameType;
  11. /// <summary>
  12. /// 获取帧类型
  13. /// </summary>
  14. public AnimationFrameType FrameType
  15. {
  16. get
  17. {
  18. return this.m_FrameType;
  19. }
  20. }
  21. private object m_Value;
  22. /// <summary>
  23. /// 帧值,通常为图片或颜色
  24. /// </summary>
  25. public object Value
  26. {
  27. get
  28. {
  29. return this.m_Value;
  30. }
  31. }
  32. /// <summary>
  33. /// 创建一个颜色帧
  34. /// </summary>
  35. /// <param name="color">颜色</param>
  36. public AnimationFrame(Color color)
  37. {
  38. this.m_Value = color;
  39. this.m_FrameType = AnimationFrameType.Color;
  40. }
  41. /// <summary>
  42. /// 创建一个图像帧
  43. /// </summary>
  44. /// <param name="image">图像</param>
  45. public AnimationFrame(Image image)
  46. {
  47. this.m_Value = image;
  48. this.m_FrameType = AnimationFrameType.Image;
  49. }
  50. /// <summary>
  51. /// 释放资源
  52. /// </summary>
  53. /// <param name="disposing">释放托管资源为true,否则为false</param>
  54. protected override void Dispose(bool disposing)
  55. {
  56. if (this.m_Value != null)
  57. {
  58. IDisposable disposable = this.m_Value as IDisposable;
  59. if (disposable != null)
  60. disposable.Dispose();
  61. this.m_Value = null;
  62. }
  63. }
  64. }
  65. }