EditCurveState.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //-----------------------------------------------------------------------------
  2. // EditCurveState.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Microsoft.Xna.Framework;
  11. namespace Xna.Tools
  12. {
  13. /// <summary>
  14. /// This class contians curve states which are name, PreLoop, and PostLoop.
  15. /// </summary>
  16. public class EditCurveState : IEquatable<EditCurveState>
  17. {
  18. #region Properties
  19. /// <summary>
  20. /// Gets/Sets Name
  21. /// </summary>
  22. public string Name
  23. {
  24. get { return name; }
  25. set { name = value; }
  26. }
  27. /// <summary>
  28. /// Gets/Sets PreLoop
  29. /// </summary>
  30. public CurveLoopType PreLoop
  31. {
  32. get { return preLoop; }
  33. set { preLoop = value; }
  34. }
  35. /// <summary>
  36. /// Gets/Sets PostLoop
  37. /// </summary>
  38. public CurveLoopType PostLoop
  39. {
  40. get { return postLoop; }
  41. set { postLoop = value; }
  42. }
  43. #endregion
  44. #region Equatable related override methods.
  45. public override int GetHashCode()
  46. {
  47. return String.IsNullOrEmpty(Name) ? 0 : Name.GetHashCode() +
  48. PreLoop.GetHashCode() + +PostLoop.GetHashCode();
  49. }
  50. public override bool Equals(object obj)
  51. {
  52. EditCurveState other = obj as EditCurveState;
  53. bool isSame = false;
  54. if (other != null)
  55. isSame = Equals(other);
  56. return isSame;
  57. }
  58. public bool Equals(EditCurveState other)
  59. {
  60. if (other == null) return false;
  61. return (Name == other.Name &&
  62. PreLoop == other.PreLoop &&
  63. PostLoop == other.PostLoop);
  64. }
  65. #endregion
  66. /// <summary>
  67. /// Create close of this state.
  68. /// </summary>
  69. /// <returns></returns>
  70. public EditCurveState Clone()
  71. {
  72. EditCurveState newState = new EditCurveState();
  73. newState.Name = Name;
  74. newState.PreLoop = PreLoop;
  75. newState.PostLoop = PostLoop;
  76. return newState;
  77. }
  78. #region Operator override
  79. public static bool operator ==(EditCurveState value1, EditCurveState value2)
  80. {
  81. return Object.Equals(value1, value2);
  82. }
  83. public static bool operator !=(EditCurveState value1, EditCurveState value2)
  84. {
  85. return !Object.Equals(value1, value2);
  86. }
  87. #endregion
  88. #region Private property members
  89. private string name;
  90. private CurveLoopType preLoop;
  91. private CurveLoopType postLoop;
  92. #endregion
  93. }
  94. }