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