Sprite.Property.02.State.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. namespace Microsoft.Windows.Forms
  3. {
  4. public partial class Sprite
  5. {
  6. /// <summary>
  7. /// 状态改变事件索引标记
  8. /// </summary>
  9. private static readonly object EVENT_STATE_CHANGED = new object();
  10. private State m_State = State.Normal;
  11. /// <summary>
  12. /// 按钮状态
  13. /// </summary>
  14. public State State
  15. {
  16. get
  17. {
  18. return this.m_State;
  19. }
  20. set
  21. {
  22. if (value != this.m_State)
  23. {
  24. this.m_State = value;
  25. this.Feedback();
  26. this.OnStateChanged(EventArgs.Empty);
  27. }
  28. }
  29. }
  30. /// <summary>
  31. /// 按钮状态改变后发生
  32. /// </summary>
  33. public event EventHandler StateChanged
  34. {
  35. add { this.Events.AddHandler(EVENT_STATE_CHANGED, value); }
  36. remove { this.Events.RemoveHandler(EVENT_STATE_CHANGED, value); }
  37. }
  38. /// <summary>
  39. /// 按钮状态改变事件函数
  40. /// </summary>
  41. /// <param name="e">数据</param>
  42. protected virtual void OnStateChanged(EventArgs e)
  43. {
  44. EventHandler handler = this.Events[EVENT_STATE_CHANGED] as EventHandler;
  45. if (handler != null)
  46. handler(this, e);
  47. }
  48. }
  49. }