AnimationOperations.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. namespace Microsoft.Windows.Forms.Animate
  5. {
  6. /// <summary>
  7. /// 动画操作集合
  8. /// </summary>
  9. internal class AnimationOperations : DisposableMini, IEnumerable<AnimationFrame>
  10. {
  11. //操作集合
  12. private List<AnimationFrame> m_Frames = new List<AnimationFrame>();
  13. private bool m_Cleared;
  14. /// <summary>
  15. /// 获取是否清空关键帧
  16. /// </summary>
  17. public bool Cleared
  18. {
  19. get
  20. {
  21. return this.m_Cleared;
  22. }
  23. }
  24. private Size? m_Size;
  25. /// <summary>
  26. /// 获取要改变的大小
  27. /// </summary>
  28. public Size Size
  29. {
  30. get
  31. {
  32. return this.m_Size.Value;
  33. }
  34. }
  35. /// <summary>
  36. /// 获取是否要改变大小
  37. /// </summary>
  38. public bool Resized
  39. {
  40. get
  41. {
  42. return this.m_Size != null;
  43. }
  44. }
  45. /// <summary>
  46. /// 改变大小操作
  47. /// </summary>
  48. /// <param name="size">要改变的大小</param>
  49. public void Resize(Size size)
  50. {
  51. this.m_Size = size;
  52. }
  53. /// <summary>
  54. /// 添加关键帧操作
  55. /// </summary>
  56. /// <param name="frame">关键帧</param>
  57. public void AddFrame(AnimationFrame frame)
  58. {
  59. this.m_Frames.Add(frame);
  60. }
  61. /// <summary>
  62. /// 清空关键帧操作
  63. /// </summary>
  64. public void ClearFrame()
  65. {
  66. foreach (AnimationFrame frame in this.m_Frames)
  67. frame.Dispose();
  68. this.m_Frames.Clear();
  69. this.m_Cleared = true;
  70. }
  71. /// <summary>
  72. /// 使用完毕,清空操作
  73. /// </summary>
  74. public void Clear()
  75. {
  76. this.m_Frames.Clear();
  77. this.m_Cleared = false;
  78. this.m_Size = null;
  79. }
  80. /// <summary>
  81. /// 获取枚举器
  82. /// </summary>
  83. /// <returns>枚举器</returns>
  84. public IEnumerator<AnimationFrame> GetEnumerator()
  85. {
  86. return this.m_Frames.GetEnumerator();
  87. }
  88. /// <summary>
  89. /// 获取枚举器
  90. /// </summary>
  91. /// <returns>枚举器</returns>
  92. IEnumerator IEnumerable.GetEnumerator()
  93. {
  94. return (this.m_Frames as IEnumerable).GetEnumerator();
  95. }
  96. /// <summary>
  97. /// 释放资源
  98. /// </summary>
  99. /// <param name="disposing">释放托管资源为 true,否则为 false</param>
  100. protected override void Dispose(bool disposing)
  101. {
  102. if (this.m_Frames != null)
  103. {
  104. foreach (AnimationFrame frame in this.m_Frames)
  105. frame.Dispose();
  106. this.m_Frames.Clear();
  107. this.m_Frames = null;
  108. }
  109. }
  110. }
  111. }