[InputMethod] Base Code
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.InputMethod / Tizen.Uix.InputMethod / InputMethodEditor.cs
1 /*\r
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved\r
3 *\r
4 * Licensed under the Apache License, Version 2.0 (the License);\r
5 * you may not use this file except in compliance with the License.\r
6 * You may obtain a copy of the License at\r
7 *\r
8 * http://www.apache.org/licenses/LICENSE-2.0\r
9 *\r
10 * Unless required by applicable law or agreed to in writing, software\r
11 * distributed under the License is distributed on an AS IS BASIS,\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13 * See the License for the specific language governing permissions and\r
14 * limitations under the License.\r
15 */\r
16 \r
17 \r
18 using System;\r
19 using System.Collections.Generic;\r
20 using System.Runtime.InteropServices;\r
21 using static Interop.InputMethod;\r
22 \r
23 namespace Tizen.Uix.InputMethod\r
24 {\r
25     /// <summary>\r
26     /// Enumeration of the key codes.\r
27     /// If keycode & 0xff000000 == 0x01000000 then this key code is directly encoded 24-bit UCS character.The UCS value is keycode & 0x00ffffff.\r
28     /// Defines the list of keys supported by the system.Note that certain keys may not be available on all devices.\r
29     /// </summary>\r
30     public enum KeyCode\r
31     {\r
32         /// <summary>\r
33         /// The backspace key\r
34         /// </summary>\r
35         IME_KEY_BackSpace = 0xFF08,\r
36         /// <summary>\r
37         /// The tab key\r
38         /// </summary>\r
39         IME_KEY_Tab = 0xFF09,\r
40         /// <summary>\r
41         /// The linefeed key\r
42         /// </summary>\r
43         IME_KEY_Linefeed = 0xFF0A,\r
44         /// <summary>\r
45         /// The clear key\r
46         /// </summary>\r
47         IME_KEY_Clear = 0xFF0B,\r
48         /// <summary>\r
49         /// The return key\r
50         /// </summary>\r
51         IME_KEY_Return = 0xFF0D,\r
52         /// <summary>\r
53         /// The pause key\r
54         /// </summary>\r
55         IME_KEY_Pause = 0xFF13,\r
56         /// <summary>\r
57         /// The scroll lock key\r
58         /// </summary>\r
59         IME_KEY_Scroll_Lock = 0xFF14,\r
60         /// <summary>\r
61         /// The sys req key\r
62         /// </summary>\r
63         IME_KEY_Sys_Req = 0xFF15,\r
64         /// <summary>\r
65         /// The escape key\r
66         /// </summary>\r
67         IME_KEY_Escape = 0xFF1B,\r
68         /// <summary>\r
69         /// The delete key\r
70         /// </summary>\r
71         IME_KEY_Delete = 0xFFFF,\r
72 \r
73         /* Cursor control & motion */\r
74         /// <summary>\r
75         /// The home key\r
76         /// </summary>\r
77         IME_KEY_Home = 0xFF50,\r
78         /// <summary>\r
79         /// The left directional key\r
80         /// </summary>\r
81         IME_KEY_Left = 0xFF51,\r
82         /// <summary>\r
83         /// The up directional key\r
84         /// </summary>\r
85         IME_KEY_Up = 0xFF52,\r
86         /// <summary>\r
87         /// The right directional key\r
88         /// </summary>\r
89         IME_KEY_Right = 0xFF53,\r
90         /// <summary>\r
91         /// The down directional key\r
92         /// </summary>\r
93         IME_KEY_Down = 0xFF54,\r
94         /// <summary>\r
95         /// The prior, previous key\r
96         /// </summary>\r
97         IME_KEY_Prior = 0xFF55,\r
98         /// <summary>\r
99         /// The page up key\r
100         /// </summary>\r
101         IME_KEY_Page_Up = 0xFF55,\r
102         /// <summary>\r
103         /// The next key\r
104         /// </summary>\r
105         IME_KEY_Next = 0xFF56,\r
106         /// <summary>\r
107         /// The page down key\r
108         /// </summary>\r
109         IME_KEY_Page_Down = 0xFF56,\r
110         /// <summary>\r
111         /// The end key\r
112         /// </summary>\r
113         IME_KEY_End = 0xFF57,\r
114         /// <summary>\r
115         /// The begin key\r
116         /// </summary>\r
117         IME_KEY_Begin = 0xFF58,\r
118 \r
119         /* Misc Functions */\r
120         /// <summary>\r
121         /// The select key\r
122         /// </summary>\r
123         IME_KEY_Select = 0xFF60,\r
124         /// <summary>\r
125         /// The print key\r
126         /// </summary>\r
127         IME_KEY_Print = 0xFF61,\r
128         /// <summary>\r
129         /// The execute, run, do key\r
130         /// </summary>\r
131         IME_KEY_Execute = 0xFF62,\r
132         /// <summary>\r
133         /// The insert key\r
134         /// </summary>\r
135         IME_KEY_Insert = 0xFF63,\r
136         /// <summary>\r
137         /// The undo key\r
138         /// </summary>\r
139         IME_KEY_Undo = 0xFF65,\r
140         /// <summary>\r
141         /// The redo key\r
142         /// </summary>\r
143         IME_KEY_Redo = 0xFF66,\r
144         /// <summary>\r
145         /// The menu key\r
146         /// </summary>\r
147         IME_KEY_Menu = 0xFF67,\r
148         /// <summary>\r
149         /// The find key\r
150         /// </summary>\r
151         IME_KEY_Find = 0xFF68,\r
152         /// <summary>\r
153         /// The cancel, stop, abort, exit key\r
154         /// </summary>\r
155         IME_KEY_Cancel = 0xFF69,\r
156         /// <summary>\r
157         /// The help key\r
158         /// </summary>\r
159         IME_KEY_Help = 0xFF6A,\r
160         /// <summary>\r
161         /// The break key\r
162         /// </summary>\r
163         IME_KEY_Break = 0xFF6B,\r
164         /// <summary>\r
165         /// The character set switch key\r
166         /// </summary>\r
167         IME_KEY_Mode_switch = 0xFF7E,\r
168         /// <summary>\r
169         /// The num lock key\r
170         /// </summary>\r
171         IME_KEY_Num_Lock = 0xFF7F,\r
172 \r
173         /* Keypad */\r
174         /// <summary>\r
175         /// The Numpad space key\r
176         /// </summary>\r
177         IME_KEY_KP_Space = 0xFF80,\r
178         /// <summary>\r
179         /// The Numpad tab key\r
180         /// </summary>\r
181         IME_KEY_KP_Tab = 0xFF89,\r
182         /// <summary>\r
183         /// The Numpad enter key\r
184         /// </summary>\r
185         IME_KEY_KP_Enter = 0xFF8D,\r
186         /// <summary>\r
187         /// The Numpad function 1 key\r
188         /// </summary>\r
189         IME_KEY_KP_F1 = 0xFF91,\r
190         /// <summary>\r
191         /// The Numpad function 2 key\r
192         /// </summary>\r
193         IME_KEY_KP_F2 = 0xFF92,\r
194         /// <summary>\r
195         /// The Numpad function 3 key\r
196         /// </summary>\r
197         IME_KEY_KP_F3 = 0xFF93,\r
198         /// <summary>\r
199         /// The Numpad function 4 key\r
200         /// </summary>\r
201         IME_KEY_KP_F4 = 0xFF94,\r
202         /// <summary>\r
203         /// The Numpad home key\r
204         /// </summary>\r
205         IME_KEY_KP_Home = 0xFF95,\r
206         /// <summary>\r
207         /// The Numpad left key\r
208         /// </summary>\r
209         IME_KEY_KP_Left = 0xFF96,\r
210         /// <summary>\r
211         /// The Numpad up key\r
212         /// </summary>\r
213         IME_KEY_KP_Up = 0xFF97,\r
214         /// <summary>\r
215         /// The Numpad right key\r
216         /// </summary>\r
217         IME_KEY_KP_Right = 0xFF98,\r
218         /// <summary>\r
219         /// The Numpad down key\r
220         /// </summary>\r
221         IME_KEY_KP_Down = 0xFF99,\r
222         /// <summary>\r
223         /// The Numpad prior, previous key\r
224         /// </summary>\r
225         IME_KEY_KP_Prior = 0xFF9A,\r
226         /// <summary>\r
227         /// The Numpad page up key\r
228         /// </summary>\r
229         IME_KEY_KP_Page_Up = 0xFF9A,\r
230         /// <summary>\r
231         /// The Numpad next key\r
232         /// </summary>\r
233         IME_KEY_KP_Next = 0xFF9B,\r
234         /// <summary>\r
235         /// The Numpad page down key\r
236         /// </summary>\r
237         IME_KEY_KP_Page_Down = 0xFF9B,\r
238         /// <summary>\r
239         /// The Numpad end key\r
240         /// </summary>\r
241         IME_KEY_KP_End = 0xFF9C,\r
242         /// <summary>\r
243         /// The Numpad begin key\r
244         /// </summary>\r
245         IME_KEY_KP_Begin = 0xFF9D,\r
246         /// <summary>\r
247         /// The Numpad insert key\r
248         /// </summary>\r
249         IME_KEY_KP_Insert = 0xFF9E,\r
250         /// <summary>\r
251         /// The Numpad delete key\r
252         /// </summary>\r
253         IME_KEY_KP_Delete = 0xFF9F,\r
254         /// <summary>\r
255         /// The Numpad equal key\r
256         /// </summary>\r
257         IME_KEY_KP_Equal = 0xFFBD,\r
258         /// <summary>\r
259         /// The Numpad multiply key\r
260         /// </summary>\r
261         IME_KEY_KP_Multiply = 0xFFAA,\r
262         /// <summary>\r
263         /// The Numpad add key\r
264         /// </summary>\r
265         IME_KEY_KP_Add = 0xFFAB,\r
266         /// <summary>\r
267         /// The Numpad separator key\r
268         /// </summary>\r
269         IME_KEY_KP_Separator = 0xFFAC,\r
270         /// <summary>\r
271         /// The Numpad subtract key\r
272         /// </summary>\r
273         IME_KEY_KP_Subtract = 0xFFAD,\r
274         /// <summary>\r
275         /// The Numpad decimal key\r
276         /// </summary>\r
277         IME_KEY_KP_Decimal = 0xFFAE,\r
278         /// <summary>\r
279         /// The Numpad divide key\r
280         /// </summary>\r
281         IME_KEY_KP_Divide = 0xFFAF,\r
282         /// <summary>\r
283         /// The Numpad 0 key\r
284         /// </summary>\r
285         IME_KEY_KP_0 = 0xFFB0,\r
286         /// <summary>\r
287         /// The Numpad 1 key\r
288         /// </summary>\r
289         IME_KEY_KP_1 = 0xFFB1,\r
290         /// <summary>\r
291         /// The Numpad 2 key\r
292         /// </summary>\r
293         IME_KEY_KP_2 = 0xFFB2,\r
294         /// <summary>\r
295         /// The Numpad 3 key\r
296         /// </summary>\r
297         IME_KEY_KP_3 = 0xFFB3,\r
298         /// <summary>\r
299         /// The Numpad 4 key\r
300         /// </summary>\r
301         IME_KEY_KP_4 = 0xFFB4,\r
302         /// <summary>\r
303         /// The Numpad 5 key\r
304         /// </summary>\r
305         IME_KEY_KP_5 = 0xFFB5,\r
306         /// <summary>\r
307         /// The Numpad 6 key\r
308         /// </summary>\r
309         IME_KEY_KP_6 = 0xFFB6,\r
310         /// <summary>\r
311         /// The Numpad 7 key\r
312         /// </summary>\r
313         IME_KEY_KP_7 = 0xFFB7,\r
314         /// <summary>\r
315         /// The Numpad 8 key\r
316         /// </summary>\r
317         IME_KEY_KP_8 = 0xFFB8,\r
318         /// <summary>\r
319         /// The Numpad 9 key\r
320         /// </summary>\r
321         IME_KEY_KP_9 = 0xFFB9,\r
322 \r
323         /* Auxilliary Functions */\r
324         /// <summary>\r
325         /// The function 1 key\r
326         /// </summary>\r
327         IME_KEY_F1 = 0xFFBE,\r
328         /// <summary>\r
329         /// The function 2 key\r
330         /// </summary>\r
331         IME_KEY_F2 = 0xFFBF,\r
332         /// <summary>\r
333         /// The function 3 key\r
334         /// </summary>\r
335         IME_KEY_F3 = 0xFFC0,\r
336         /// <summary>\r
337         /// The function 4 key\r
338         /// </summary>\r
339         IME_KEY_F4 = 0xFFC1,\r
340         /// <summary>\r
341         /// The function 5 key\r
342         /// </summary>\r
343         IME_KEY_F5 = 0xFFC2,\r
344         /// <summary>\r
345         /// The function 6 key\r
346         /// </summary>\r
347         IME_KEY_F6 = 0xFFC3,\r
348         /// <summary>\r
349         /// The function 7 key\r
350         /// </summary>\r
351         IME_KEY_F7 = 0xFFC4,\r
352         /// <summary>\r
353         /// The function 8 key\r
354         /// </summary>\r
355         IME_KEY_F8 = 0xFFC5,\r
356         /// <summary>\r
357         /// The function 9 key\r
358         /// </summary>\r
359         IME_KEY_F9 = 0xFFC6,\r
360         /// <summary>\r
361         /// The function 10 key\r
362         /// </summary>\r
363         IME_KEY_F10 = 0xFFC7,\r
364         /// <summary>\r
365         /// The function 11 key\r
366         /// </summary>\r
367         IME_KEY_F11 = 0xFFC8,\r
368         /// <summary>\r
369         /// The function 12 key\r
370         /// </summary>\r
371         IME_KEY_F12 = 0xFFC9,\r
372         /// <summary>\r
373         /// The function 13 key\r
374         /// </summary>\r
375         IME_KEY_F13 = 0xFFCA,\r
376         /// <summary>\r
377         /// The function 14 key\r
378         /// </summary>\r
379         IME_KEY_F14 = 0xFFCB,\r
380         /// <summary>\r
381         /// The function 15 key\r
382         /// </summary>\r
383         IME_KEY_F15 = 0xFFCC,\r
384         /// <summary>\r
385         /// The function 16 key\r
386         /// </summary>\r
387         IME_KEY_F16 = 0xFFCD,\r
388         /// <summary>\r
389         /// The function 17 key\r
390         /// </summary>\r
391         IME_KEY_F17 = 0xFFCE,\r
392         /// <summary>\r
393         /// The function 18 key\r
394         /// </summary>\r
395         IME_KEY_F18 = 0xFFCF,\r
396         /// <summary>\r
397         /// The function 19 key\r
398         /// </summary>\r
399         IME_KEY_F19 = 0xFFD0,\r
400         /// <summary>\r
401         /// The function 20 key\r
402         /// </summary>\r
403         IME_KEY_F20 = 0xFFD1,\r
404         /// <summary>\r
405         /// The function 21 key\r
406         /// </summary>\r
407         IME_KEY_F21 = 0xFFD2,\r
408         /// <summary>\r
409         /// The function 22 key\r
410         /// </summary>\r
411         IME_KEY_F22 = 0xFFD3,\r
412         /// <summary>\r
413         /// The function 23 key\r
414         /// </summary>\r
415         IME_KEY_F23 = 0xFFD4,\r
416         /// <summary>\r
417         /// The function 24 key\r
418         /// </summary>\r
419         IME_KEY_F24 = 0xFFD5,\r
420         /// <summary>\r
421         /// The function 25 key\r
422         /// </summary>\r
423         IME_KEY_F25 = 0xFFD6,\r
424         /// <summary>\r
425         /// The function 26 key\r
426         /// </summary>\r
427         IME_KEY_F26 = 0xFFD7,\r
428         /// <summary>\r
429         /// The function 27 key\r
430         /// </summary>\r
431         IME_KEY_F27 = 0xFFD8,\r
432         /// <summary>\r
433         /// The function 28 key\r
434         /// </summary>\r
435         IME_KEY_F28 = 0xFFD9,\r
436         /// <summary>\r
437         /// The function 29 key\r
438         /// </summary>\r
439         IME_KEY_F29 = 0xFFDA,\r
440         /// <summary>\r
441         /// The function 30 key\r
442         /// </summary>\r
443         IME_KEY_F30 = 0xFFDB,\r
444         /// <summary>\r
445         /// The function 31 key\r
446         /// </summary>\r
447         IME_KEY_F31 = 0xFFDC,\r
448         /// <summary>\r
449         /// The function 32 key\r
450         /// </summary>\r
451         IME_KEY_F32 = 0xFFDD,\r
452         /// <summary>\r
453         /// The function 33 key\r
454         /// </summary>\r
455         IME_KEY_F33 = 0xFFDE,\r
456         /// <summary>\r
457         /// The function 34 key\r
458         /// </summary>\r
459         IME_KEY_F34 = 0xFFDF,\r
460         /// <summary>\r
461         /// The function 35 key\r
462         /// </summary>\r
463         IME_KEY_F35 = 0xFFE0,\r
464 \r
465         /* Modifier keys */\r
466         /// <summary>\r
467         /// The left shift key\r
468         /// </summary>\r
469         IME_KEY_Shift_L = 0xFFE1,\r
470         /// <summary>\r
471         /// The right shift key\r
472         /// </summary>\r
473         IME_KEY_Shift_R = 0xFFE2,\r
474         /// <summary>\r
475         /// The left control key\r
476         /// </summary>\r
477         IME_KEY_Control_L = 0xFFE3,\r
478         /// <summary>\r
479         /// The right control key\r
480         /// </summary>\r
481         IME_KEY_Control_R = 0xFFE4,\r
482         /// <summary>\r
483         /// The caps lock key\r
484         /// </summary>\r
485         IME_KEY_Caps_Lock = 0xFFE5,\r
486         /// <summary>\r
487         /// The shift lock key\r
488         /// </summary>\r
489         IME_KEY_Shift_Lock = 0xFFE6,\r
490         /// <summary>\r
491         /// The left meta key\r
492         /// </summary>\r
493         IME_KEY_Meta_L = 0xFFE7,\r
494         /// <summary>\r
495         /// The right meta key\r
496         /// </summary>\r
497         IME_KEY_Meta_R = 0xFFE8,\r
498         /// <summary>\r
499         /// The left alt key\r
500         /// </summary>\r
501         IME_KEY_Alt_L = 0xFFE9,\r
502         /// <summary>\r
503         /// The right alt key\r
504         /// </summary>\r
505         IME_KEY_Alt_R = 0xFFEA,\r
506         /// <summary>\r
507         /// The left super key\r
508         /// </summary>\r
509         IME_KEY_Super_L = 0xFFEB,\r
510         /// <summary>\r
511         /// The right super key\r
512         /// </summary>\r
513         IME_KEY_Super_R = 0xFFEC,\r
514         /// <summary>\r
515         /// The left hyper key\r
516         /// </summary>\r
517         IME_KEY_Hyper_L = 0xFFED,\r
518         /// <summary>\r
519         /// The right hyper key\r
520         /// </summary>\r
521         IME_KEY_Hyper_R = 0xFFEE,\r
522 \r
523         /* Latin 1 */\r
524         /// <summary>\r
525         /// The space key\r
526         /// </summary>\r
527         IME_KEY_space = 0x020,\r
528         /// <summary>\r
529         /// The exclamation key\r
530         /// </summary>\r
531         IME_KEY_exclam = 0x021,\r
532         /// <summary>\r
533         /// The quotedbl key\r
534         /// </summary>\r
535         IME_KEY_quotedbl = 0x022,\r
536         /// <summary>\r
537         /// The number sign key\r
538         /// </summary>\r
539         IME_KEY_numbersign = 0x023,\r
540         /// <summary>\r
541         /// The dollar key\r
542         /// </summary>\r
543         IME_KEY_dollar = 0x024,\r
544         /// <summary>\r
545         /// The percent key\r
546         /// </summary>\r
547         IME_KEY_percent = 0x025,\r
548         /// <summary>\r
549         /// The ampersand key\r
550         /// </summary>\r
551         IME_KEY_ampersand = 0x026,\r
552         /// <summary>\r
553         /// The apostrophe key\r
554         /// </summary>\r
555         IME_KEY_apostrophe = 0x027,\r
556         /// <summary>\r
557         /// The parenleft key\r
558         /// </summary>\r
559         IME_KEY_parenleft = 0x028,\r
560         /// <summary>\r
561         /// The parenright key\r
562         /// </summary>\r
563         IME_KEY_parenright = 0x029,\r
564         /// <summary>\r
565         /// The asterisk key\r
566         /// </summary>\r
567         IME_KEY_asterisk = 0x02a,\r
568         /// <summary>\r
569         /// The plus key\r
570         /// </summary>\r
571         IME_KEY_plus = 0x02b,\r
572         /// <summary>\r
573         /// The comma key\r
574         /// </summary>\r
575         IME_KEY_comma = 0x02c,\r
576         /// <summary>\r
577         /// The minus key\r
578         /// </summary>\r
579         IME_KEY_minus = 0x02d,\r
580         /// <summary>\r
581         /// The period key\r
582         /// </summary>\r
583         IME_KEY_period = 0x02e,\r
584         /// <summary>\r
585         /// The slash key\r
586         /// </summary>\r
587         IME_KEY_slash = 0x02f,\r
588         /// <summary>\r
589         /// The 0 key\r
590         /// </summary>\r
591         IME_KEY_0 = 0x030,\r
592         /// <summary>\r
593         /// The 1 key\r
594         /// </summary>\r
595         IME_KEY_1 = 0x031,\r
596         /// <summary>\r
597         /// The 2 key\r
598         /// </summary>\r
599         IME_KEY_2 = 0x032,\r
600         /// <summary>\r
601         /// The 3 key\r
602         /// </summary>\r
603         IME_KEY_3 = 0x033,\r
604         /// <summary>\r
605         /// The 4 key\r
606         /// </summary>\r
607         IME_KEY_4 = 0x034,\r
608         /// <summary>\r
609         /// The 5 key\r
610         /// </summary>\r
611         IME_KEY_5 = 0x035,\r
612         /// <summary>\r
613         /// The 6 key\r
614         /// </summary>\r
615         IME_KEY_6 = 0x036,\r
616         /// <summary>\r
617         /// The 7 key\r
618         /// </summary>\r
619         IME_KEY_7 = 0x037,\r
620         /// <summary>\r
621         /// The 8 key\r
622         /// </summary>\r
623         IME_KEY_8 = 0x038,\r
624         /// <summary>\r
625         /// The 9 key\r
626         /// </summary>\r
627         IME_KEY_9 = 0x039,\r
628         /// <summary>\r
629         /// The colon key\r
630         /// </summary>\r
631         IME_KEY_colon = 0x03a,\r
632         /// <summary>\r
633         /// The semicolon key\r
634         /// </summary>\r
635         IME_KEY_semicolon = 0x03b,\r
636         /// <summary>\r
637         /// The less key\r
638         /// </summary>\r
639         IME_KEY_less = 0x03c,\r
640         /// <summary>\r
641         /// The equal key\r
642         /// </summary>\r
643         IME_KEY_equal = 0x03d,\r
644         /// <summary>\r
645         /// The greater key\r
646         /// </summary>\r
647         IME_KEY_greater = 0x03e,\r
648         /// <summary>\r
649         /// The question key\r
650         /// </summary>\r
651         IME_KEY_question = 0x03f,\r
652         /// <summary>\r
653         /// The at key\r
654         /// </summary>\r
655         IME_KEY_at = 0x040,\r
656         /// <summary>\r
657         /// The A key\r
658         /// </summary>\r
659         IME_KEY_A = 0x041,\r
660         /// <summary>\r
661         /// The B key\r
662         /// </summary>\r
663         IME_KEY_B = 0x042,\r
664         /// <summary>\r
665         /// The C key\r
666         /// </summary>\r
667         IME_KEY_C = 0x043,\r
668         /// <summary>\r
669         /// The D key\r
670         /// </summary>\r
671         IME_KEY_D = 0x044,\r
672         /// <summary>\r
673         /// The E key\r
674         /// </summary>\r
675         IME_KEY_E = 0x045,\r
676         /// <summary>\r
677         /// The F key\r
678         /// </summary>\r
679         IME_KEY_F = 0x046,\r
680         /// <summary>\r
681         /// The G key\r
682         /// </summary>\r
683         IME_KEY_G = 0x047,\r
684         /// <summary>\r
685         /// The H key\r
686         /// </summary>\r
687         IME_KEY_H = 0x048,\r
688         /// <summary>\r
689         /// The I key\r
690         /// </summary>\r
691         IME_KEY_I = 0x049,\r
692         /// <summary>\r
693         /// The J key\r
694         /// </summary>\r
695         IME_KEY_J = 0x04a,\r
696         /// <summary>\r
697         /// The K key\r
698         /// </summary>\r
699         IME_KEY_K = 0x04b,\r
700         /// <summary>\r
701         /// The L key\r
702         /// </summary>\r
703         IME_KEY_L = 0x04c,\r
704         /// <summary>\r
705         /// The M key\r
706         /// </summary>\r
707         IME_KEY_M = 0x04d,\r
708         /// <summary>\r
709         /// The N key\r
710         /// </summary>\r
711         IME_KEY_N = 0x04e,\r
712         /// <summary>\r
713         /// The O key\r
714         /// </summary>\r
715         IME_KEY_O = 0x04f,\r
716         /// <summary>\r
717         /// The P key\r
718         /// </summary>\r
719         IME_KEY_P = 0x050,\r
720         /// <summary>\r
721         /// The Q key\r
722         /// </summary>\r
723         IME_KEY_Q = 0x051,\r
724         /// <summary>\r
725         /// The R key\r
726         /// </summary>\r
727         IME_KEY_R = 0x052,\r
728         /// <summary>\r
729         /// The S key\r
730         /// </summary>\r
731         IME_KEY_S = 0x053,\r
732         /// <summary>\r
733         /// The T key\r
734         /// </summary>\r
735         IME_KEY_T = 0x054,\r
736         /// <summary>\r
737         /// The U key\r
738         /// </summary>\r
739         IME_KEY_U = 0x055,\r
740         /// <summary>\r
741         /// The V key\r
742         /// </summary>\r
743         IME_KEY_V = 0x056,\r
744         /// <summary>\r
745         /// The W key\r
746         /// </summary>\r
747         IME_KEY_W = 0x057,\r
748         /// <summary>\r
749         /// The X key\r
750         /// </summary>\r
751         IME_KEY_X = 0x058,\r
752         /// <summary>\r
753         /// The Y key\r
754         /// </summary>\r
755         IME_KEY_Y = 0x059,\r
756         /// <summary>\r
757         /// The Z key\r
758         /// </summary>\r
759         IME_KEY_Z = 0x05a,\r
760         /// <summary>\r
761         /// The left bracket key\r
762         /// </summary>\r
763         IME_KEY_bracketleft = 0x05b,\r
764         /// <summary>\r
765         /// The backslash key\r
766         /// </summary>\r
767         IME_KEY_backslash = 0x05c,\r
768         /// <summary>\r
769         /// The right bracket key\r
770         /// </summary>\r
771         IME_KEY_bracketright = 0x05d,\r
772         /// <summary>\r
773         /// The circumflex key\r
774         /// </summary>\r
775         IME_KEY_asciicircum = 0x05e,\r
776         /// <summary>\r
777         /// The underscore key\r
778         /// </summary>\r
779         IME_KEY_underscore = 0x05f,\r
780         /// <summary>\r
781         /// The grave key\r
782         /// </summary>\r
783         IME_KEY_grave = 0x060,\r
784         /// <summary>\r
785         /// The a key\r
786         /// </summary>\r
787         IME_KEY_a = 0x061,\r
788         /// <summary>\r
789         /// The b key\r
790         /// </summary>\r
791         IME_KEY_b = 0x062,\r
792         /// <summary>\r
793         /// The c key\r
794         /// </summary>\r
795         IME_KEY_c = 0x063,\r
796         /// <summary>\r
797         /// The d key\r
798         /// </summary>\r
799         IME_KEY_d = 0x064,\r
800         /// <summary>\r
801         /// The e key\r
802         /// </summary>\r
803         IME_KEY_e = 0x065,\r
804         /// <summary>\r
805         /// The f key\r
806         /// </summary>\r
807         IME_KEY_f = 0x066,\r
808         /// <summary>\r
809         /// The g key\r
810         /// </summary>\r
811         IME_KEY_g = 0x067,\r
812         /// <summary>\r
813         /// The h key\r
814         /// </summary>\r
815         IME_KEY_h = 0x068,\r
816         /// <summary>\r
817         /// The i key\r
818         /// </summary>\r
819         IME_KEY_i = 0x069,\r
820         /// <summary>\r
821         /// The j key\r
822         /// </summary>\r
823         IME_KEY_j = 0x06a,\r
824         /// <summary>\r
825         /// The k key\r
826         /// </summary>\r
827         IME_KEY_k = 0x06b,\r
828         /// <summary>\r
829         /// The l key\r
830         /// </summary>\r
831         IME_KEY_l = 0x06c,\r
832         /// <summary>\r
833         /// The m key\r
834         /// </summary>\r
835         IME_KEY_m = 0x06d,\r
836         /// <summary>\r
837         /// The n key\r
838         /// </summary>\r
839         IME_KEY_n = 0x06e,\r
840         /// <summary>\r
841         /// The o key\r
842         /// </summary>\r
843         IME_KEY_o = 0x06f,\r
844         /// <summary>\r
845         /// The p key\r
846         /// </summary>\r
847         IME_KEY_p = 0x070,\r
848         /// <summary>\r
849         /// The q key\r
850         /// </summary>\r
851         IME_KEY_q = 0x071,\r
852         /// <summary>\r
853         /// The r key\r
854         /// </summary>\r
855         IME_KEY_r = 0x072,\r
856         /// <summary>\r
857         /// The s key\r
858         /// </summary>\r
859         IME_KEY_s = 0x073,\r
860         /// <summary>\r
861         /// The t key\r
862         /// </summary>\r
863         IME_KEY_t = 0x074,\r
864         /// <summary>\r
865         /// The u key\r
866         /// </summary>\r
867         IME_KEY_u = 0x075,\r
868         /// <summary>\r
869         /// The v key\r
870         /// </summary>\r
871         IME_KEY_v = 0x076,\r
872         /// <summary>\r
873         /// The w key\r
874         /// </summary>\r
875         IME_KEY_w = 0x077,\r
876         /// <summary>\r
877         /// The x key\r
878         /// </summary>\r
879         IME_KEY_x = 0x078,\r
880         /// <summary>\r
881         /// The y key\r
882         /// </summary>\r
883         IME_KEY_y = 0x079,\r
884         /// <summary>\r
885         /// The z key\r
886         /// </summary>\r
887         IME_KEY_z = 0x07a,\r
888         /// <summary>\r
889         /// The left brace key\r
890         /// </summary>\r
891         IME_KEY_braceleft = 0x07b,\r
892         /// <summary>\r
893         /// The bar key\r
894         /// </summary>\r
895         IME_KEY_bar = 0x07c,\r
896         /// <summary>\r
897         /// The right brace key\r
898         /// </summary>\r
899         IME_KEY_braceright = 0x07d,\r
900         /// <summary>\r
901         /// The tilde key\r
902         /// </summary>\r
903         IME_KEY_asciitilde = 0x07e,\r
904     };\r
905 \r
906     /// <summary>\r
907     /// Enumeration of the key masks.\r
908     /// The key masks indicate which modifier keys is pressed down during the keyboard hit.The special IME_KEY_MASK_RELEASED indicates the key release event.\r
909     /// </summary>\r
910     public enum KeyMask\r
911     {\r
912         /// <summary>\r
913         /// Key press event without modifier key\r
914         /// </summary>\r
915         IME_KEY_MASK_PRESSED = 0,\r
916         /// <summary>\r
917         /// The Shift key is pressed down\r
918         /// </summary>\r
919         IME_KEY_MASK_SHIFT = (1 << 0),\r
920         /// <summary>\r
921         /// The CapsLock key is pressed down\r
922         /// </summary>\r
923         IME_KEY_MASK_CAPSLOCK = (1 << 1),\r
924         /// <summary>\r
925         /// The Control key is pressed down\r
926         /// </summary>\r
927         IME_KEY_MASK_CONTROL = (1 << 2),\r
928         /// <summary>\r
929         /// The Alt key is pressed down\r
930         /// </summary>\r
931         IME_KEY_MASK_ALT = (1 << 3),\r
932         /// <summary>\r
933         /// The Meta key is pressed down\r
934         /// </summary>\r
935         IME_KEY_MASK_META = (1 << 4),\r
936         /// <summary>\r
937         /// The Win (between Control and Alt) is pressed down\r
938         /// </summary>\r
939         IME_KEY_MASK_WIN = (1 << 5),\r
940         /// <summary>\r
941         /// The Hyper key is pressed down\r
942         /// </summary>\r
943         IME_KEY_MASK_HYPER = (1 << 6),\r
944         /// <summary>\r
945         /// The NumLock key is pressed down\r
946         /// </summary>\r
947         IME_KEY_MASK_NUMLOCK = (1 << 7),\r
948         /// <summary>\r
949         /// Key release event\r
950         /// </summary>\r
951         IME_KEY_MASK_RELEASED = (1 << 15),\r
952     }\r
953 \r
954     /// <summary>\r
955     /// This class contains api's related to IME(Input method editor)\r
956     /// </summary>\r
957     public static class InputMethodEditor\r
958     {\r
959         private static Object thisLock = new Object();\r
960         private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();\r
961         private static event EventHandler<FocusInEventArgs> _focusIn;\r
962         private static ImeFocusInCb _imeFocusInDelegate;\r
963         private static event EventHandler<FocusOutEventArgs> _focusOut;\r
964         private static ImeFocusOutCb _imeFocusOutDelegate;\r
965         private static event EventHandler<SurroundingTextUpdatedEventArgs> _surroundingTextUpdated;\r
966         private static ImeSurroundingTextUpdatedCb _imeSurroundingTextUpdatedDelegate;\r
967         private static event EventHandler<System.EventArgs> _inputContextReset;\r
968         private static ImeInputContextResetCb _imeInputContextResetDelegate;\r
969         private static event EventHandler<CursorPositionUpdatedEventArgs> _cursorPositionUpdated;\r
970         private static ImeCursorPositionUpdatedCb _imeCursorPositionUpdatedDelegate;\r
971         private static event EventHandler<LangaugeSetEventArgs> _langaugeSet;\r
972         private static ImeLanguageSetCb _imeLangaugeSetDelegate;\r
973         private static event EventHandler<ImDataSetEventArgs> _imDataSet;\r
974         private static ImeImdataSetCb _imeImDataSetDelegate;\r
975         private static event EventHandler<LayoutSetEventArgs> _layoutSet;\r
976         private static ImeLayoutSetCb _imeLayoutSetDelegate;\r
977         private static event EventHandler<ReturnKeyTypeSetEventArgs> _returnKeyTypeSet;\r
978         private static ImeReturnKeyTypeSetCb _imeReturnKeyTypeSetDelegate;\r
979         private static event EventHandler<ReturnKeyStateSetEventArgs> _returnKeyStateSet;\r
980         private static ImeReturnKeyStateSetCb _imeReturnKeyStateSetDelegate;\r
981         private static event ProcessKeyEventHandler _processKey;\r
982         private static ImeProcessKeyEventCb _imeProcessKeyDelegate;\r
983         private static event EventHandler<DisplayLanaguageChangedEventArgs> _displayLanaguageChanged;\r
984         private static ImeDisplayLanguageChangedCb _imeDisplayLanaguageChangedDelegate;\r
985         private static event EventHandler<RotationDegreeChangedEventArgs> _rotationDegreeChanged;\r
986         private static ImeRotationDegreeChangedCb _imeRotationDegreeChangedDelegate;\r
987         private static event EventHandler<AccessibilityStateChangedEventArgs> _accessibilityStateChanged;\r
988         private static ImeAccessibilityStateChangedCb _imeAccessibilityStateChangedDelegate;\r
989         private static event EventHandler<OptionWindowCreatedEventArgs> _optionWindowCreated;\r
990         private static ImeOptionWindowCreatedCb _imeOptionWindowCreatedDelegate;\r
991         private static event EventHandler<OptionWindowDestroyedEventArgs> _optionWindowDestroyed;\r
992         private static ImeOptionWindowDestroyedCb _imeOptionWindowDestroyedDelegate;\r
993         private static ImeLanguageRequestedCb _imeLanguageRequestedDelegate;\r
994         private static OutAction<string> _languageRequestedDelegate;\r
995         private static ImeImdataRequestedCb _imeImDataRequestedDelegate;\r
996         private static OutAction<byte, uint> _imDataRequestedDelegate;\r
997         private static ImeGeometryRequestedCb _imeGeometryRequestedDelegate;\r
998         private static OutAction1<int> _geometryRequestedDelegate;\r
999         private static Action _userCreate;\r
1000         private static Action _userTerminate;\r
1001         private static Action<int, InputMethodContext> _userShow;\r
1002         private static Action<int> _userHide;\r
1003         private static ImeCreateCb _create = (IntPtr userData) =>\r
1004         {\r
1005             Log.Info(LogTag, "In Create Delegate");\r
1006             _userCreate?.Invoke();\r
1007         };\r
1008         private static ImeTerminateCb _terminate = (IntPtr userData) =>\r
1009         {\r
1010             Log.Info(LogTag, "In terminate Delegate");\r
1011             _userTerminate?.Invoke();\r
1012         };\r
1013         private static ImeShowCb _show = (int contextId, IntPtr context, IntPtr userData) =>\r
1014         {\r
1015             Log.Info(LogTag, "In Show Delegate");\r
1016             _userShow?.Invoke(contextId, new InputMethodContext(context));\r
1017         };\r
1018         private static ImeHideCb _hide = (int contextId, IntPtr userData) =>\r
1019         {\r
1020             Log.Info(LogTag, "In Hide Delegate");\r
1021             _userHide?.Invoke(contextId);\r
1022         };\r
1023 \r
1024 \r
1025         /// <summary>\r
1026         /// An Action with 1 out parameter\r
1027         /// </summary>\r
1028         /// <typeparam name="T">Generic Type</typeparam>\r
1029         /// <param name="a">The out parameter</param>\r
1030         public delegate void OutAction<T>(out T a);\r
1031 \r
1032         /// <summary>\r
1033         /// An Action with 2 out parameter's\r
1034         /// </summary>\r
1035         /// <typeparam name="T">Generic Type</typeparam>\r
1036         /// <typeparam name="T1">Generic Type</typeparam>\r
1037         /// <param name="a">The out parameter 1</param>\r
1038         /// <param name="b">The out parameter 2</param>\r
1039         public delegate void OutAction<T,T1>(out T[] a, out T1 b);\r
1040 \r
1041         /// <summary>\r
1042         /// An Action with 4 out parameter's\r
1043         /// </summary>\r
1044         /// <typeparam name="T">Generic Type</typeparam>\r
1045         /// <param name="a">The out parameter 1</param>\r
1046         /// <param name="b">The out parameter 2</param>\r
1047         /// <param name="c">The out parameter 3</param>\r
1048         /// <param name="d">The out parameter 4</param>\r
1049         public delegate void OutAction1<T>(out T a, out T b, out T c, out T d);\r
1050 \r
1051 \r
1052         /// <summary>\r
1053         /// Called when an associated text input UI control has focus.\r
1054         /// </summary>\r
1055         public static event EventHandler<FocusInEventArgs> FocusIn\r
1056         {\r
1057             add\r
1058             {\r
1059                 lock (thisLock)\r
1060                 {\r
1061                     _imeFocusInDelegate = (int contextId, IntPtr userData) =>\r
1062                     {\r
1063                         FocusInEventArgs args = new FocusInEventArgs(contextId);\r
1064                         _focusIn?.Invoke(null, args);\r
1065                     };\r
1066                     ErrorCode error = ImeEventSetFocusInCb(_imeFocusInDelegate, IntPtr.Zero);\r
1067                     if (error != ErrorCode.None)\r
1068                     {\r
1069                         Log.Error(LogTag, "Add FocusIn Failed with error " + error);\r
1070                     }\r
1071                     else\r
1072                     {\r
1073                         _focusIn += value;\r
1074                     }\r
1075                 }\r
1076             }\r
1077             remove\r
1078             {\r
1079                 lock (thisLock)\r
1080                 {\r
1081                     _focusIn -= value;\r
1082                 }\r
1083             }\r
1084         }\r
1085 \r
1086         /// <summary>\r
1087         /// Called when an associated text input UI control loses focus.\r
1088         /// </summary>\r
1089         public static event EventHandler<FocusOutEventArgs> FocusOut\r
1090         {\r
1091             add\r
1092             {\r
1093                 lock (thisLock)\r
1094                 {\r
1095                     _imeFocusOutDelegate = (int contextId, IntPtr userData) =>\r
1096                     {\r
1097                         FocusOutEventArgs args = new FocusOutEventArgs(contextId);\r
1098                         _focusOut?.Invoke(null, args);\r
1099                     };\r
1100                     ErrorCode error = ImeEventSetFocusOutCb(_imeFocusOutDelegate, IntPtr.Zero);\r
1101                     if (error != ErrorCode.None)\r
1102                     {\r
1103                         Log.Error(LogTag, "Add FocusOut Failed with error " + error);\r
1104                     }\r
1105                     else\r
1106                     {\r
1107                         _focusOut += value;\r
1108                     }\r
1109                 }\r
1110             }\r
1111             remove\r
1112             {\r
1113                 lock (thisLock)\r
1114                 {\r
1115                     _focusOut -= value;\r
1116                 }\r
1117             }\r
1118         }\r
1119 \r
1120         /// <summary>\r
1121         /// Called when an associated text input UI control responds to a request with the surrounding text.\r
1122         /// </summary>\r
1123         public static event EventHandler<SurroundingTextUpdatedEventArgs> SurroundingTextUpdated\r
1124         {\r
1125             add\r
1126             {\r
1127                 lock (thisLock)\r
1128                 {\r
1129                     _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>\r
1130                     {\r
1131                         SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);\r
1132                         _surroundingTextUpdated?.Invoke(null, args);\r
1133                     };\r
1134                     ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);\r
1135                     if (error != ErrorCode.None)\r
1136                     {\r
1137                         Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);\r
1138                     }\r
1139                     else\r
1140                     {\r
1141                         _surroundingTextUpdated += value;\r
1142                     }\r
1143                 }\r
1144             }\r
1145             remove\r
1146             {\r
1147                 lock (thisLock)\r
1148                 {\r
1149                     _surroundingTextUpdated -= value;\r
1150                 }\r
1151             }\r
1152         }\r
1153 \r
1154         /// <summary>\r
1155         /// Called to reset the input context of an associated text input UI control.\r
1156         /// </summary>\r
1157         public static event EventHandler<System.EventArgs> InputContextReset\r
1158         {\r
1159             add\r
1160             {\r
1161                 lock (thisLock)\r
1162                 {\r
1163                     _imeInputContextResetDelegate = (IntPtr userData) =>\r
1164                     {\r
1165                         _inputContextReset?.Invoke(null, System.EventArgs.Empty);\r
1166                     };\r
1167                     ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);\r
1168                     if (error != ErrorCode.None)\r
1169                     {\r
1170                         Log.Error(LogTag, "Add InputContextReset Failed with error " + error);\r
1171                     }\r
1172                     else\r
1173                     {\r
1174                         _inputContextReset += value;\r
1175                     }\r
1176                 }\r
1177             }\r
1178             remove\r
1179             {\r
1180                 lock (thisLock)\r
1181                 {\r
1182                     _inputContextReset -= value;\r
1183                 }\r
1184             }\r
1185         }\r
1186 \r
1187         /// <summary>\r
1188         /// Called when the position of the cursor in an associated text input UI control changes.\r
1189         /// </summary>\r
1190         public static event EventHandler<CursorPositionUpdatedEventArgs> CursorPositionUpdated\r
1191         {\r
1192             add\r
1193             {\r
1194                 lock (thisLock)\r
1195                 {\r
1196                     _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>\r
1197                     {\r
1198                         CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);\r
1199                         _cursorPositionUpdated?.Invoke(null, args);\r
1200                     };\r
1201                     ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);\r
1202                     if (error != ErrorCode.None)\r
1203                     {\r
1204                         Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);\r
1205                     }\r
1206                     else\r
1207                     {\r
1208                         _cursorPositionUpdated += value;\r
1209                     }\r
1210                 }\r
1211             }\r
1212             remove\r
1213             {\r
1214                 lock (thisLock)\r
1215                 {\r
1216                     _cursorPositionUpdated -= value;\r
1217                 }\r
1218             }\r
1219         }\r
1220 \r
1221         /// <summary>\r
1222         /// Called to set the preferred language to the input panel.\r
1223         /// It will be only called when the client application changes the edit field's language attribute after the input panel is shown.\r
1224         /// </summary>\r
1225         public static event EventHandler<LangaugeSetEventArgs> LangaugeSet\r
1226         {\r
1227             add\r
1228             {\r
1229                 lock (thisLock)\r
1230                 {\r
1231                     _imeLangaugeSetDelegate = (EcoreIMFInputPanelLang language, IntPtr userData) =>\r
1232                     {\r
1233                         LangaugeSetEventArgs args = new LangaugeSetEventArgs(language);\r
1234                         _langaugeSet?.Invoke(null, args);\r
1235                     };\r
1236                     ErrorCode error = ImeEventSetLanguageSetCb(_imeLangaugeSetDelegate, IntPtr.Zero);\r
1237                     if (error != ErrorCode.None)\r
1238                     {\r
1239                         Log.Error(LogTag, "Add LangaugeSet Failed with error " + error);\r
1240                     }\r
1241                     else\r
1242                     {\r
1243                         _langaugeSet += value;\r
1244                     }\r
1245                 }\r
1246             }\r
1247             remove\r
1248             {\r
1249                 lock (thisLock)\r
1250                 {\r
1251                     _langaugeSet -= value;\r
1252                 }\r
1253             }\r
1254         }\r
1255 \r
1256         /// <summary>\r
1257         /// Called to set the application specific data to deliver to the input panel.\r
1258         /// </summary>\r
1259         public static event EventHandler<ImDataSetEventArgs> ImDataSet\r
1260         {\r
1261             add\r
1262             {\r
1263                 lock (thisLock)\r
1264                 {\r
1265                     _imeImDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>\r
1266                     {\r
1267                         byte[] destination = new byte[dataLength];\r
1268                         Marshal.Copy(data, destination, 0, (int)dataLength);\r
1269                         ImDataSetEventArgs args = new ImDataSetEventArgs(destination, dataLength);\r
1270                         _imDataSet?.Invoke(null, args);\r
1271                     };\r
1272                     ErrorCode error = ImeEventSetImdataSetCb(_imeImDataSetDelegate, IntPtr.Zero);\r
1273                     if (error != ErrorCode.None)\r
1274                     {\r
1275                         Log.Error(LogTag, "Add ImDataSet Failed with error " + error);\r
1276                     }\r
1277                     else\r
1278                     {\r
1279                         _imDataSet += value;\r
1280                     }\r
1281                 }\r
1282             }\r
1283             remove\r
1284             {\r
1285                 lock (thisLock)\r
1286                 {\r
1287                     _imDataSet -= value;\r
1288                 }\r
1289             }\r
1290         }\r
1291 \r
1292         /// <summary>\r
1293         /// Called when an associated text input UI control requests the input panel to set its layout.\r
1294         /// It will be only called when the client application changes the edit field's layout attribute after the input panel is shown.\r
1295         /// </summary>\r
1296         public static event EventHandler<LayoutSetEventArgs> LayoutSet\r
1297         {\r
1298             add\r
1299             {\r
1300                 lock (thisLock)\r
1301                 {\r
1302                     _imeLayoutSetDelegate = (EcoreIMFInputPanelLayout layout, IntPtr userData) =>\r
1303                     {\r
1304                         LayoutSetEventArgs args = new LayoutSetEventArgs(layout);\r
1305                         _layoutSet?.Invoke(null, args);\r
1306                     };\r
1307                     ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);\r
1308                     if (error != ErrorCode.None)\r
1309                     {\r
1310                         Log.Error(LogTag, "Add LayoutSet Failed with error " + error);\r
1311                     }\r
1312                     else\r
1313                     {\r
1314                         _layoutSet += value;\r
1315                     }\r
1316                 }\r
1317             }\r
1318             remove\r
1319             {\r
1320                 lock (thisLock)\r
1321                 {\r
1322                     _layoutSet -= value;\r
1323                 }\r
1324             }\r
1325         }\r
1326 \r
1327         /// <summary>\r
1328         /// Called when an associated text input UI control requests the input panel to set the Return key label.\r
1329         /// The input panel can show text or image on the Return button according to the Return key action.\r
1330         /// </summary>\r
1331         public static event EventHandler<ReturnKeyTypeSetEventArgs> ReturnKeyTypeSet\r
1332         {\r
1333             add\r
1334             {\r
1335                 lock (thisLock)\r
1336                 {\r
1337                     _imeReturnKeyTypeSetDelegate = (EcoreIMFInputPanelReturnKeyType type, IntPtr userData) =>\r
1338                     {\r
1339                         ReturnKeyTypeSetEventArgs args = new ReturnKeyTypeSetEventArgs(type);\r
1340                         _returnKeyTypeSet?.Invoke(null, args);\r
1341                     };\r
1342                     ErrorCode error = ImeEventSetReturnKeyTypeSetCb(_imeReturnKeyTypeSetDelegate, IntPtr.Zero);\r
1343                     if (error != ErrorCode.None)\r
1344                     {\r
1345                         Log.Error(LogTag, "Add ReturnKeyTypeSet Failed with error " + error);\r
1346                     }\r
1347                     else\r
1348                     {\r
1349                         _returnKeyTypeSet += value;\r
1350                     }\r
1351                 }\r
1352             }\r
1353             remove\r
1354             {\r
1355                 lock (thisLock)\r
1356                 {\r
1357                     _returnKeyTypeSet -= value;\r
1358                 }\r
1359             }\r
1360         }\r
1361 \r
1362         /// <summary>\r
1363         /// Called when an associated text input UI control requests the input panel to enable or disable the Return key state.\r
1364         /// </summary>\r
1365         public static event EventHandler<ReturnKeyStateSetEventArgs> ReturnKeyStateSet\r
1366         {\r
1367             add\r
1368             {\r
1369                 lock (thisLock)\r
1370                 {\r
1371                     _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>\r
1372                     {\r
1373                         ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);\r
1374                         _returnKeyStateSet?.Invoke(null, args);\r
1375                     };\r
1376                     ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);\r
1377                     if (error != ErrorCode.None)\r
1378                     {\r
1379                         Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);\r
1380                     }\r
1381                     else\r
1382                     {\r
1383                         _returnKeyStateSet += value;\r
1384                     }\r
1385                 }\r
1386             }\r
1387             remove\r
1388             {\r
1389                 lock (thisLock)\r
1390                 {\r
1391                     _returnKeyStateSet -= value;\r
1392                 }\r
1393             }\r
1394         }\r
1395 \r
1396         /// <summary>\r
1397         /// This Handler is associated with ProcessKey\r
1398         /// </summary>\r
1399         /// <param name="sender">The object raising the event</param>\r
1400         /// <param name="e">An object of ProcessKeyEventArgs class</param>\r
1401         /// <returns>true if the event is processed, otherwise the event is not processed and is forwarded to the client application.</returns>\r
1402         public delegate bool ProcessKeyEventHandler(object sender, ProcessKeyEventArgs e);\r
1403 \r
1404         /// <summary>\r
1405         /// Called when the key event is received from the external devices or SendKey function.\r
1406         /// This Event processes the key event before an associated text input UI control does.\r
1407         /// </summary>\r
1408         /// <remarks>\r
1409         /// If the key event is from the external device, DeviceInfo will have its name, class and subclass information.\r
1410         /// </remarks>\r
1411         public static event ProcessKeyEventHandler ProcessKey\r
1412         {\r
1413             add\r
1414             {\r
1415                 lock (thisLock)\r
1416                 {\r
1417                     _imeProcessKeyDelegate = (KeyCode keycode, KeyMask keymask, IntPtr devInfo, IntPtr userData) =>\r
1418                     {\r
1419                         ProcessKeyEventArgs args = new ProcessKeyEventArgs(keycode, keymask, devInfo);\r
1420                         bool res = _processKey.Invoke(null, args);\r
1421                         return res;\r
1422                     };\r
1423                     ErrorCode error = ImeEventSetProcessKeyEventCb(_imeProcessKeyDelegate, IntPtr.Zero);\r
1424                     if (error != ErrorCode.None)\r
1425                     {\r
1426                         Log.Error(LogTag, "Add ProcessKey Failed with error " + error);\r
1427                     }\r
1428                     else\r
1429                     {\r
1430                         _processKey += value;\r
1431                     }\r
1432                 }\r
1433             }\r
1434             remove\r
1435             {\r
1436                 lock (thisLock)\r
1437                 {\r
1438                     _processKey -= value;\r
1439                 }\r
1440             }\r
1441         }\r
1442 \r
1443         /// <summary>\r
1444         /// Called when the system display language is changed.\r
1445         /// </summary>\r
1446         public static event EventHandler<DisplayLanaguageChangedEventArgs> DisplayLanaguageChanged\r
1447         {\r
1448             add\r
1449             {\r
1450                 lock (thisLock)\r
1451                 {\r
1452                     _imeDisplayLanaguageChangedDelegate = (IntPtr language, IntPtr userData) =>\r
1453                     {\r
1454                         DisplayLanaguageChangedEventArgs args = new DisplayLanaguageChangedEventArgs(Marshal.PtrToStringAnsi(language));\r
1455                         _displayLanaguageChanged?.Invoke(null, args);\r
1456                     };\r
1457                     ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanaguageChangedDelegate, IntPtr.Zero);\r
1458                     if (error != ErrorCode.None)\r
1459                     {\r
1460                         Log.Error(LogTag, "Add DisplayLanaguageChanged Failed with error " + error);\r
1461                     }\r
1462                     else\r
1463                     {\r
1464                         _displayLanaguageChanged += value;\r
1465                     }\r
1466                 }\r
1467             }\r
1468             remove\r
1469             {\r
1470                 lock (thisLock)\r
1471                 {\r
1472                     _displayLanaguageChanged -= value;\r
1473                 }\r
1474             }\r
1475         }\r
1476 \r
1477         /// <summary>\r
1478         /// Called when the device is rotated.\r
1479         /// </summary>\r
1480         public static event EventHandler<RotationDegreeChangedEventArgs> RotationDegreeChanged\r
1481         {\r
1482             add\r
1483             {\r
1484                 lock (thisLock)\r
1485                 {\r
1486                     _imeRotationDegreeChangedDelegate = (int degree, IntPtr userData) =>\r
1487                     {\r
1488                         RotationDegreeChangedEventArgs args = new RotationDegreeChangedEventArgs(degree);\r
1489                         _rotationDegreeChanged?.Invoke(null, args);\r
1490                     };\r
1491                     ErrorCode error = ImeEventSetRotationDegreeChangedCb(_imeRotationDegreeChangedDelegate, IntPtr.Zero);\r
1492                     if (error != ErrorCode.None)\r
1493                     {\r
1494                         Log.Error(LogTag, "Add RotationDegreeChanged Failed with error " + error);\r
1495                     }\r
1496                     else\r
1497                     {\r
1498                         _rotationDegreeChanged += value;\r
1499                     }\r
1500                 }\r
1501             }\r
1502             remove\r
1503             {\r
1504                 lock (thisLock)\r
1505                 {\r
1506                     _rotationDegreeChanged -= value;\r
1507                 }\r
1508             }\r
1509         }\r
1510 \r
1511         /// <summary>\r
1512         /// Called when Accessibility in Settings application is on or off.\r
1513         /// </summary>\r
1514         public static event EventHandler<AccessibilityStateChangedEventArgs> AccessibilityStateChanged\r
1515         {\r
1516             add\r
1517             {\r
1518                 lock (thisLock)\r
1519                 {\r
1520                     _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>\r
1521                     {\r
1522                         AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);\r
1523                         _accessibilityStateChanged?.Invoke(null, args);\r
1524                     };\r
1525                     ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);\r
1526                     if (error != ErrorCode.None)\r
1527                     {\r
1528                         Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);\r
1529                     }\r
1530                     else\r
1531                     {\r
1532                         _accessibilityStateChanged += value;\r
1533                     }\r
1534                 }\r
1535             }\r
1536             remove\r
1537             {\r
1538                 lock (thisLock)\r
1539                 {\r
1540                     _accessibilityStateChanged -= value;\r
1541                 }\r
1542             }\r
1543         }\r
1544 \r
1545         /// <summary>\r
1546         /// Called to create the option window.\r
1547         /// </summary>\r
1548         /// <remarks>\r
1549         /// if Input panel requests to open the option window, type will be ImeOptionWindowType.Keyboard.\r
1550         /// And if Settings application requests to open it, type will be ImeOptionWindowType.SettingApplication.\r
1551         /// </remarks>\r
1552         public static event EventHandler<OptionWindowCreatedEventArgs> OptionWindowCreated\r
1553         {\r
1554             add\r
1555             {\r
1556                 lock (thisLock)\r
1557                 {\r
1558                     _imeOptionWindowCreatedDelegate = (IntPtr window, ImeOptionWindowType type, IntPtr userData) =>\r
1559                     {\r
1560                         OptionWindowCreatedEventArgs args = new OptionWindowCreatedEventArgs(new EditorWindow(window), type);\r
1561                         _optionWindowCreated?.Invoke(null, args);\r
1562                     };\r
1563                     ErrorCode error = ImeEventSetOptionWindowCreatedCb(_imeOptionWindowCreatedDelegate, IntPtr.Zero);\r
1564                     if (error != ErrorCode.None)\r
1565                     {\r
1566                         Log.Error(LogTag, "Add OptionWindowCreated Failed with error " + error);\r
1567                     }\r
1568                     else\r
1569                     {\r
1570                         _optionWindowCreated += value;\r
1571                     }\r
1572                 }\r
1573             }\r
1574             remove\r
1575             {\r
1576                 lock (thisLock)\r
1577                 {\r
1578                     _optionWindowCreated -= value;\r
1579                 }\r
1580             }\r
1581         }\r
1582 \r
1583         /// <summary>\r
1584         /// Called to destroy the option window.\r
1585         /// </summary>\r
1586         public static event EventHandler<OptionWindowDestroyedEventArgs> OptionWindowDestroyed\r
1587         {\r
1588             add\r
1589             {\r
1590                 lock (thisLock)\r
1591                 {\r
1592                     _imeOptionWindowDestroyedDelegate = (IntPtr window, IntPtr userData) =>\r
1593                     {\r
1594                         OptionWindowDestroyedEventArgs args = new OptionWindowDestroyedEventArgs(new EditorWindow(window));\r
1595                         _optionWindowDestroyed?.Invoke(null, args);\r
1596                     };\r
1597                     ErrorCode error = ImeEventSetOptionWindowDestroyedCb(_imeOptionWindowDestroyedDelegate, IntPtr.Zero);\r
1598                     if (error != ErrorCode.None)\r
1599                     {\r
1600                         Log.Error(LogTag, "Add OptionWindowDestroyed Failed with error " + error);\r
1601                     }\r
1602                     else\r
1603                     {\r
1604                         _optionWindowDestroyed += value;\r
1605                     }\r
1606                 }\r
1607             }\r
1608             remove\r
1609             {\r
1610                 lock (thisLock)\r
1611                 {\r
1612                     _optionWindowDestroyed -= value;\r
1613                 }\r
1614             }\r
1615         }\r
1616 \r
1617         /// <summary>\r
1618         /// Sets the languageRequested Action\r
1619         /// </summary>\r
1620         /// <param name="languageRequested">\r
1621         /// Called when an associated text input UI control requests the language from the input panel, requesting for language code.\r
1622         /// </param>\r
1623         public static void SetLanguageRequested(OutAction<string> languageRequested)\r
1624         {\r
1625             _imeLanguageRequestedDelegate = (IntPtr userData, out IntPtr langCode) =>\r
1626             {\r
1627                 string langauage;\r
1628                 _languageRequestedDelegate(out langauage);\r
1629                 char[] languageArray = langauage.ToCharArray();\r
1630                 langCode = new IntPtr();\r
1631                 Marshal.Copy(languageArray, 0, langCode, languageArray.Length);\r
1632             };\r
1633             ErrorCode error = ImeEventSetLanguageRequestedCb(_imeLanguageRequestedDelegate, IntPtr.Zero);\r
1634             if (error != ErrorCode.None)\r
1635             {\r
1636                 Log.Error(LogTag, "Add SetLanguageRequested Failed with error " + error);\r
1637             }\r
1638             _languageRequestedDelegate = languageRequested;\r
1639         }\r
1640 \r
1641         /// <summary>\r
1642         /// Sets the imDataRequested Action\r
1643         /// </summary>\r
1644         /// <param name="imDataRequested">\r
1645         /// Called when an associated text input UI control requests the application specific data from the input panel, requesting for data array and it's length.\r
1646         /// </param>\r
1647         public static void SetImDataRequested(OutAction<byte, uint> imDataRequested)\r
1648         {\r
1649             _imeImDataRequestedDelegate = (IntPtr userData, out IntPtr data, out uint dataLength) =>\r
1650             {\r
1651                 byte[] dataArr;\r
1652                 uint lenghtArr;\r
1653                 _imDataRequestedDelegate(out dataArr, out lenghtArr);\r
1654                 data = new IntPtr();\r
1655                 Marshal.Copy(dataArr, 0, data, (int)lenghtArr);\r
1656                 dataLength = lenghtArr;\r
1657             };\r
1658             ErrorCode error = ImeEventSetImdataRequestedCb(_imeImDataRequestedDelegate, IntPtr.Zero);\r
1659             if (error != ErrorCode.None)\r
1660             {\r
1661                 Log.Error(LogTag, "Add SetImDataRequested Failed with error " + error);\r
1662             }\r
1663             _imDataRequestedDelegate = imDataRequested;\r
1664         }\r
1665 \r
1666         /// <summary>\r
1667         /// Sets the GeometryRequested Action\r
1668         /// </summary>\r
1669         /// <param name="GeometryRequested">\r
1670         /// Called when an associated text input UI control requests the position and size from the input panel, requesting for x,y,w,h values.\r
1671         /// </param>\r
1672         public static void SetGeometryRequested(OutAction1<int> GeometryRequested)\r
1673         {\r
1674             _imeGeometryRequestedDelegate = (IntPtr userData, out int x, out int y, out int w, out int h) =>\r
1675             {\r
1676                 int x1, y1, w1, h1;\r
1677                 _geometryRequestedDelegate(out x1, out y1, out w1, out h1);\r
1678                 x = x1;\r
1679                 y = y1;\r
1680                 w = w1;\r
1681                 h = h1;\r
1682             };\r
1683             ErrorCode error = ImeEventSetGeometryRequestedCb(_imeGeometryRequestedDelegate, IntPtr.Zero);\r
1684             if (error != ErrorCode.None)\r
1685             {\r
1686                 Log.Error(LogTag, "Add SetGeometryRequested Failed with error " + error);\r
1687             }\r
1688             _geometryRequestedDelegate = GeometryRequested;\r
1689         }\r
1690 \r
1691         /// <summary>\r
1692         /// Runs the main loop of IME application.\r
1693         /// This function starts to run IME application's main loop.\r
1694         /// </summary>\r
1695         /// <priviledge>\r
1696         /// http://tizen.org/privilege/ime\r
1697         /// </priviledge>\r
1698         /// <param name="create">This is called to initialize IME application before the main loop starts up</param>\r
1699         /// <param name="terminate">This is called when IME application is terminated</param>\r
1700         /// <param name="show">This is called when IME application is shown</param>\r
1701         /// <param name="hide">This is called when IME application is hidden</param>\r
1702         /// <exception cref="InvalidOperationException">\r
1703         /// This can occur due to the following reasons:\r
1704         /// 1) The application does not have the privilege to call this function\r
1705         /// 2) Operation failed\r
1706         /// </exception>\r
1707         public static void Run(Action create, Action terminate, Action<int, InputMethodContext> show, Action<int> hide)\r
1708         {\r
1709             _userCreate = create;\r
1710             _userTerminate = terminate;\r
1711             _userShow = show;\r
1712             _userHide = hide;\r
1713 \r
1714             ImeCallbackStruct _imeCallbackStruct = _imeCallbackStructGCHandle._imeCallbackStruct;\r
1715             _imeCallbackStruct.create = _create;\r
1716             _imeCallbackStruct.terminate = _terminate;\r
1717             _imeCallbackStruct.hide = _hide;\r
1718             _imeCallbackStruct.show = _show;\r
1719 \r
1720             ErrorCode error = ImeRun(GCHandle.ToIntPtr(_imeCallbackStructGCHandle._imeCallbackStructHandle), IntPtr.Zero);\r
1721             if (error != ErrorCode.None)\r
1722             {\r
1723                 Log.Error(LogTag, "Run Failed with error " + error);\r
1724                 throw InputMethodExceptionFactory.CreateException(error);\r
1725             }\r
1726         }\r
1727 \r
1728         /// <summary>\r
1729         /// Sends a key event to the associated text input UI control.\r
1730         /// </summary>\r
1731         /// <remarks>\r
1732         /// This function sends key down or up event with key mask to the client application. If forwardKey is true, this key event goes to the edit filed directly.\r
1733         /// And if forwardKey is false, the ProcessKey event receives the key event before the edit field.\r
1734         /// </remarks>\r
1735         /// <priviledge>\r
1736         /// http://tizen.org/privilege/ime\r
1737         /// </priviledge>\r
1738         /// <param name="keyCode">The key code to be sent</param>\r
1739         /// <param name="keyMask">The modifier key mask</param>\r
1740         /// <param name="forwardKey">The flag to send the key event directly to the edit field</param>\r
1741         /// <exception cref="InvalidOperationException">\r
1742         /// This can occur due to the following reasons:\r
1743         /// 1) The application does not have the privilege to call this function\r
1744         /// 2) IME main loop isn't started yet\r
1745         /// </exception>\r
1746         public static void SendKeyEvent(KeyCode keyCode, KeyMask keyMask, bool forwardKey)\r
1747         {\r
1748             ErrorCode error = ImeSendKeyEvent(keyCode, keyMask, forwardKey);\r
1749             if (error != ErrorCode.None)\r
1750             {\r
1751                 Log.Error(LogTag, "SendEvent Failed with error " + error);\r
1752                 throw InputMethodExceptionFactory.CreateException(error);\r
1753             }\r
1754         }\r
1755 \r
1756         /// <summary>\r
1757         /// Sends the text to the associated text input UI control.\r
1758         /// </summary>\r
1759         /// <priviledge>\r
1760         /// http://tizen.org/privilege/ime\r
1761         /// </priviledge>\r
1762         /// <param name="str">The UTF-8 string to be committed</param>\r
1763         /// <exception cref="InvalidOperationException">\r
1764         /// This can occur due to the following reasons:\r
1765         /// 1) The application does not have the privilege to call this function\r
1766         /// 2) IME main loop isn't started yet\r
1767         /// </exception>\r
1768         public static void CommitString(string str)\r
1769         {\r
1770             ErrorCode error = ImeCommitString(str);\r
1771             if (error != ErrorCode.None)\r
1772             {\r
1773                 Log.Error(LogTag, "CommitString Failed with error " + error);\r
1774                 throw InputMethodExceptionFactory.CreateException(error);\r
1775             }\r
1776         }\r
1777 \r
1778         /// <summary>\r
1779         /// Requests to show preedit string.\r
1780         /// </summary>\r
1781         /// <priviledge>\r
1782         /// http://tizen.org/privilege/ime\r
1783         /// </priviledge>\r
1784         /// <exception cref="InvalidOperationException">\r
1785         /// This can occur due to the following reasons:\r
1786         /// 1) The application does not have the privilege to call this function\r
1787         /// 2) IME main loop isn't started yet\r
1788         /// </exception>\r
1789         public static void ShowPreEditString()\r
1790         {\r
1791             ErrorCode error = ImeShowPreeditString();\r
1792             if (error != ErrorCode.None)\r
1793             {\r
1794                 Log.Error(LogTag, "ShowPreEditString Failed with error " + error);\r
1795                 throw InputMethodExceptionFactory.CreateException(error);\r
1796             }\r
1797         }\r
1798 \r
1799         /// <summary>\r
1800         /// Requests to hide preedit string.\r
1801         /// </summary>\r
1802         /// <priviledge>\r
1803         /// http://tizen.org/privilege/ime\r
1804         /// </priviledge>\r
1805         /// <exception cref="InvalidOperationException">\r
1806         /// This can occur due to the following reasons:\r
1807         /// 1) The application does not have the privilege to call this function\r
1808         /// 2) IME main loop isn't started yet\r
1809         /// </exception>\r
1810         public static void HidePreEditString()\r
1811         {\r
1812             ErrorCode error = ImeHidePreeditString();\r
1813             if (error != ErrorCode.None)\r
1814             {\r
1815                 Log.Error(LogTag, "HidePreEditString Failed with error " + error);\r
1816                 throw InputMethodExceptionFactory.CreateException(error);\r
1817             }\r
1818         }\r
1819 \r
1820         /// <summary>\r
1821         /// Updates a new preedit string.\r
1822         /// </summary>\r
1823         /// <priviledge>\r
1824         /// http://tizen.org/privilege/ime\r
1825         /// </priviledge>\r
1826         /// <param name="str">The UTF-8 string to be updated in preedit</param>\r
1827         /// <param name="attrs">\r
1828         /// The list which has ime_preedit_attribute lists, strings can be composed of multiple string attributes: underline, highlight color and reversal color.\r
1829         /// The attrs can be null if no attributes to set\r
1830         /// </param>\r
1831         /// <exception cref="InvalidOperationException">\r
1832         /// This can occur due to the following reasons:\r
1833         /// 1) The application does not have the privilege to call this function\r
1834         /// 2) IME main loop isn't started yet\r
1835         /// 3) Invalid Parameter\r
1836         /// </exception>\r
1837         public static void UpdatePreEditString(string str, List<PreEditAttribute> attrs)\r
1838         {\r
1839             IntPtr einaList = IntPtr.Zero;\r
1840             GCHandle einaListHandle = GCHandle.Alloc(einaList);\r
1841             List<GCHandle> attributeHandleList = new List<GCHandle>();\r
1842             foreach (PreEditAttribute attribute in attrs)\r
1843             {\r
1844                 ImePreEditAttributeStruct imePreEditAttribute = new ImePreEditAttributeStruct();\r
1845                 imePreEditAttribute.start = attribute.Start;\r
1846                 imePreEditAttribute.length = attribute.Length;\r
1847                 imePreEditAttribute.type = (int)attribute.Type;\r
1848                 imePreEditAttribute.value = attribute.Value;\r
1849                 GCHandle attributeHandle = GCHandle.Alloc(imePreEditAttribute);\r
1850                 attributeHandleList.Add(attributeHandle);\r
1851                 einaList = Interop.EinaList.EinaListAppend(einaListHandle.AddrOfPinnedObject(),attributeHandle.AddrOfPinnedObject());\r
1852             }\r
1853             ErrorCode error = ImeUpdatePreeditString(str, einaListHandle.AddrOfPinnedObject());\r
1854             einaListHandle.Free();\r
1855             foreach(GCHandle handle in attributeHandleList)\r
1856             {\r
1857                 handle.Free();\r
1858             }\r
1859             if (error != ErrorCode.None)\r
1860             {\r
1861                 Log.Error(LogTag, "UpdatePreEditString Failed with error " + error);\r
1862                 throw InputMethodExceptionFactory.CreateException(error);\r
1863             }\r
1864         }\r
1865 \r
1866         /// <summary>\r
1867         /// Requests the surrounding text from the position of the cursor, asynchronously.\r
1868         /// </summary>\r
1869         /// <priviledge>\r
1870         /// http://tizen.org/privilege/ime\r
1871         /// </priviledge>\r
1872         /// <param name="maxLenBefore">The maximum length of string to be retrieved before the cursor, -1 means unlimited</param>\r
1873         /// <param name="maxLenAfter">The maximum length of string to be retrieved after the cursor, -1 means unlimited</param>\r
1874         /// <exception cref="InvalidOperationException">\r
1875         /// This can occur due to the following reasons:\r
1876         /// 1) The application does not have the privilege to call this function\r
1877         /// 2) IME main loop isn't started yet\r
1878         /// </exception>\r
1879         public static void RequestSurroundingText(int maxLenBefore, int maxLenAfter)\r
1880         {\r
1881             ErrorCode error = ImeRequestSurroundingText(maxLenBefore, maxLenAfter);\r
1882             if (error != ErrorCode.None)\r
1883             {\r
1884                 Log.Error(LogTag, "RequestSurroundingText Failed with error " + error);\r
1885                 throw InputMethodExceptionFactory.CreateException(error);\r
1886             }\r
1887         }\r
1888 \r
1889         /// <summary>\r
1890         /// Requests to delete surrounding text.\r
1891         /// </summary>\r
1892         /// <priviledge>\r
1893         /// http://tizen.org/privilege/ime\r
1894         /// </priviledge>\r
1895         /// <param name="offset">The offset value from the cursor position</param>\r
1896         /// <param name="len">The length of the text to delete</param>\r
1897         /// <exception cref="InvalidOperationException">\r
1898         /// This can occur due to the following reasons:\r
1899         /// 1) The application does not have the privilege to call this function\r
1900         /// 2) IME main loop isn't started yet\r
1901         /// 3) Invalid Parameter\r
1902         /// </exception>\r
1903         public static void DeleteSurroundingText(int offset, int len)\r
1904         {\r
1905             ErrorCode error = ImeDeleteSurroundingText(offset, len);\r
1906             if (error != ErrorCode.None)\r
1907             {\r
1908                 Log.Error(LogTag, "DeleteSurroundingText Failed with error " + error);\r
1909                 throw InputMethodExceptionFactory.CreateException(error);\r
1910             }\r
1911         }\r
1912 \r
1913         /// <summary>\r
1914         /// Gets the surrounding text from the position of the cursor, synchronously.\r
1915         /// </summary>\r
1916         /// <priviledge>\r
1917         /// http://tizen.org/privilege/ime\r
1918         /// </priviledge>\r
1919         /// <param name="maxLenBefore">The maximum length of string to be retrieved before the cursor, -1 means unlimited</param>\r
1920         /// <param name="maxLenAfter">The maximum length of string to be retrieved after the cursor, -1 means unlimited</param>\r
1921         /// <param name="text">The surrounding text</param>\r
1922         /// <param name="cursorPosition">The cursor position</param>\r
1923         /// <exception cref="InvalidOperationException">\r
1924         /// This can occur due to the following reasons:\r
1925         /// 1) The application does not have the privilege to call this function\r
1926         /// 2) IME main loop isn't started yet\r
1927         /// 3) Invalid Parameter\r
1928         /// 4) Failed to obtain text due to out of memory\r
1929         /// </exception>\r
1930         public static void GetSurroundingText(int maxLenBefore, int maxLenAfter, out string text, out int cursorPosition)\r
1931         {\r
1932             IntPtr txt;\r
1933             ErrorCode error = ImeGetSurroundingText(maxLenBefore, maxLenAfter, out txt, out cursorPosition);\r
1934             if (error != ErrorCode.None)\r
1935             {\r
1936                 Log.Error(LogTag, "GetSurroundingText Failed with error " + error);\r
1937                 throw InputMethodExceptionFactory.CreateException(error);\r
1938             }\r
1939             text = Marshal.PtrToStringAnsi(txt);\r
1940         }\r
1941 \r
1942         /// <summary>\r
1943         /// Requests to set selection.\r
1944         /// </summary>\r
1945         /// <priviledge>\r
1946         /// http://tizen.org/privilege/ime\r
1947         /// </priviledge>\r
1948         /// <param name="start">The start cursor position in text (in characters not bytes)</param>\r
1949         /// <param name="end">The end cursor position in text (in characters not bytes)</param>\r
1950         /// <exception cref="InvalidOperationException">\r
1951         /// This can occur due to the following reasons:\r
1952         /// 1) The application does not have the privilege to call this function\r
1953         /// 2) IME main loop isn't started yet\r
1954         /// 3) Invalid Parameter\r
1955         /// </exception>\r
1956         public static void SetSelection(int start, int end)\r
1957         {\r
1958             ErrorCode error = ImeSetSelection(start, end);\r
1959             if (error != ErrorCode.None)\r
1960             {\r
1961                 Log.Error(LogTag, "SetSelection Failed with error " + error);\r
1962                 throw InputMethodExceptionFactory.CreateException(error);\r
1963             }\r
1964         }\r
1965 \r
1966         /// <summary>\r
1967         /// This API returns the input panel main window.\r
1968         /// </summary>\r
1969         /// <priviledge>\r
1970         /// http://tizen.org/privilege/ime\r
1971         /// </priviledge>\r
1972         /// <returns>The input panel main window object on success, otherwise null</returns>\r
1973         /// <exception cref="InvalidOperationException">\r
1974         /// This can occur due to the following reasons:\r
1975         /// 1) The application does not have the privilege to call this function\r
1976         /// 2) IME main loop isn't started yet\r
1977         /// 3) Operation Failed\r
1978         /// </exception>\r
1979         public static EditorWindow GetMainWindow()\r
1980         {\r
1981             EditorWindow obj = new EditorWindow(ImeGetMainWindow());\r
1982             ErrorCode error = (ErrorCode)Tizen.Internals.Errors.ErrorFacts.GetLastResult();\r
1983             if (error != ErrorCode.None)\r
1984             {\r
1985                 Log.Error(LogTag, "GetMainWindow Failed with error " + error);\r
1986                 throw InputMethodExceptionFactory.CreateException(error);\r
1987             }\r
1988             return obj;\r
1989         }\r
1990 \r
1991         /// <summary>\r
1992         /// This API updates the input panel window's size information.\r
1993         /// </summary>\r
1994         /// <priviledge>\r
1995         /// http://tizen.org/privilege/ime\r
1996         /// </priviledge>\r
1997         /// <param name="portraitWidth">The width in portrait mode</param>\r
1998         /// <param name="portraitHeight">The height in portrait mode</param>\r
1999         /// <param name="landscapeWidth">The width in landscape mode</param>\r
2000         /// <param name="landscapeHeight">The height in landscape mode</param>\r
2001         /// <exception cref="InvalidOperationException">\r
2002         /// This can occur due to the following reasons:\r
2003         /// 1) The application does not have the privilege to call this function\r
2004         /// 2) IME main loop isn't started yet\r
2005         /// </exception>\r
2006         public static void SetSize(int portraitWidth, int portraitHeight, int landscapeWidth, int landscapeHeight)\r
2007         {\r
2008             ErrorCode error = ImeSetSize(portraitWidth, portraitHeight, landscapeWidth, landscapeHeight);\r
2009             if (error != ErrorCode.None)\r
2010             {\r
2011                 Log.Error(LogTag, "SetSize Failed with error " + error);\r
2012                 throw InputMethodExceptionFactory.CreateException(error);\r
2013             }\r
2014         }\r
2015 \r
2016         /// <summary>\r
2017         /// Requests to create an option window from the input panel.\r
2018         /// The input panel can call this function to open the option window. This function calls OptionWindowCreated Event with ImeOptionWindowType.Keyboard.\r
2019         /// </summary>\r
2020         /// <priviledge>\r
2021         /// http://tizen.org/privilege/ime\r
2022         /// </priviledge>\r
2023         /// <exception cref="InvalidOperationException">\r
2024         /// This can occur due to the following reasons:\r
2025         /// 1) The application does not have the privilege to call this function\r
2026         /// 2) Operation failed\r
2027         /// 3) IME main loop isn't started yet\r
2028         /// 4) OptionWindowCreated event has not been set\r
2029         /// </exception>\r
2030         /// <precondition>\r
2031         /// OptionWindowCreated and OptionWindowDestroyed event should be set\r
2032         /// </precondition>\r
2033         public static void CreateOptionWindow()\r
2034         {\r
2035             ErrorCode error = ImeCreateOptionWindow();\r
2036             if (error != ErrorCode.None)\r
2037             {\r
2038                 Log.Error(LogTag, "CreapteOptionWindow Failed with error " + error);\r
2039                 throw InputMethodExceptionFactory.CreateException(error);\r
2040             }\r
2041         }\r
2042 \r
2043         /// <summary>\r
2044         /// Requests to destroy an option window.\r
2045         /// The input panel can call this function to close the option window which is created from either the input panel or Settings application.\r
2046         /// </summary>\r
2047         /// <priviledge>\r
2048         /// http://tizen.org/privilege/ime\r
2049         /// </priviledge>\r
2050         /// <param name="window">The option window to destroy</param>\r
2051         /// <exception cref="InvalidOperationException">\r
2052         /// This can occur due to the following reasons:\r
2053         /// 1) The application does not have the privilege to call this function\r
2054         /// 2) Invalid Parameter\r
2055         /// 3) IME main loop isn't started yet\r
2056         /// </exception>\r
2057         public static void DestroyOptionWindow(EditorWindow window)\r
2058         {\r
2059             ErrorCode error = ImeDestroyOptionWindow(window._handle);\r
2060             if (error != ErrorCode.None)\r
2061             {\r
2062                 Log.Error(LogTag, "DestroyOptionWindow Failed with error " + error);\r
2063                 throw InputMethodExceptionFactory.CreateException(error);\r
2064             }\r
2065         }\r
2066     }\r
2067 }\r