KeyPressEventArgs.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // System.Windows.Forms.KeyPressEventArgs.cs
  3. //
  4. // Author:
  5. // stubbed out by Daniel Carrera ([email protected])
  6. // Dennis Hayes ([email protected])
  7. // Gianandrea Terzi ([email protected])
  8. //
  9. // (C) 2002 Ximian, Inc
  10. //
  11. using System.Runtime.InteropServices;
  12. namespace System.Windows.Forms {
  13. // <summary>
  14. // This is only a template. Nothing is implemented yet.
  15. // </summary>
  16. public class KeyPressEventArgs : EventArgs {
  17. #region Fields
  18. private char keychar;
  19. private bool handled = false; //Gian : Initialize?
  20. #endregion
  21. //
  22. // --- Constructor
  23. //
  24. public KeyPressEventArgs (char keyChar)
  25. {
  26. this.keychar = keyChar;
  27. }
  28. #region Public Properties
  29. [ComVisible(true)]
  30. public bool Handled {
  31. get {
  32. return handled;
  33. }
  34. set {
  35. handled = value;
  36. }
  37. }
  38. [ComVisible(true)]
  39. public char KeyChar {
  40. get {
  41. return keychar;
  42. }
  43. }
  44. #endregion
  45. #region Public Methods
  46. /// <summary>
  47. /// Equality Operator
  48. /// </summary>
  49. ///
  50. /// <remarks>
  51. /// Compares two KeyPressEventArgs objects.
  52. /// The return value is based on the equivalence of
  53. /// Handled and KeyChar Property
  54. /// of the two KeyPressEventArgs.
  55. /// </remarks>
  56. public static bool operator == (KeyPressEventArgs KeyPressEventArgsA, KeyPressEventArgs KeyPressEventArgsB)
  57. {
  58. return (KeyPressEventArgsA.Handled == KeyPressEventArgsB.Handled) && (KeyPressEventArgsA.KeyChar == KeyPressEventArgsB.KeyChar);
  59. }
  60. /// <summary>
  61. /// Inequality Operator
  62. /// </summary>
  63. ///
  64. /// <remarks>
  65. /// Compares two KeyPressEventArgs objects.
  66. /// The return value is based on the equivalence of
  67. /// Handled and KeyChar Property
  68. /// of the two KeyPressEventArgs.
  69. /// </remarks>
  70. public static bool operator != (KeyPressEventArgs KeyPressEventArgsA, KeyPressEventArgs KeyPressEventArgsB)
  71. {
  72. return (KeyPressEventArgsA.Handled != KeyPressEventArgsB.Handled) || (KeyPressEventArgsA.KeyChar != KeyPressEventArgsB.KeyChar);
  73. }
  74. /// <summary>
  75. /// Equals Method
  76. /// </summary>
  77. ///
  78. /// <remarks>
  79. /// Checks equivalence of this
  80. /// KeyPressEventArgs and another
  81. /// object.
  82. /// </remarks>
  83. public override bool Equals (object obj)
  84. {
  85. if (!(obj is KeyPressEventArgs))return false;
  86. return (this == (KeyPressEventArgs) obj);
  87. }
  88. /// <summary>
  89. /// GetHashCode Method
  90. /// </summary>
  91. ///
  92. /// <remarks>
  93. /// Calculates a hashing value.
  94. /// </remarks>
  95. [MonoTODO]
  96. public override int GetHashCode ()
  97. {
  98. //FIXME: add class specific stuff;
  99. return base.GetHashCode();
  100. }
  101. /// <summary>
  102. /// ToString Method
  103. /// </summary>
  104. ///
  105. /// <remarks>
  106. /// Formats the object as a string.
  107. /// </remarks>
  108. [MonoTODO]
  109. public override string ToString ()
  110. {
  111. //FIXME: add class specific stuff;
  112. return base.ToString() + " KeyPressEventArgs";
  113. }
  114. #endregion
  115. }
  116. }