Modified to appropriate exception type (#4170)
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.InputMethod / Tizen.Uix.InputMethod / InputMethodEditor.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18 using System;
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
21 using System.ComponentModel;
22 using static Interop.InputMethod;
23
24 namespace Tizen.Uix.InputMethod
25 {
26     /// <summary>
27     /// Enumeration for the key codes.
28     /// If keycode &amp; 0xff000000 == 0x01000000 then this key code is directly encoded to 24-bit UCS character. The UCS value is keycode &amp; 0x00ffffff.
29     /// Defines the list of keys supported by the system. Note that certain keys may not be available on all the devices.
30     /// </summary>
31     /// <since_tizen> 4 </since_tizen>
32     public enum KeyCode
33     {
34         /// <summary>
35         /// The Backspace key.
36         /// </summary>
37         BackSpace = 0xFF08,
38         /// <summary>
39         /// The Tab key.
40         /// </summary>
41         Tab = 0xFF09,
42         /// <summary>
43         /// The Linefeed key.
44         /// </summary>
45         Linefeed = 0xFF0A,
46         /// <summary>
47         /// The Clear key.
48         /// </summary>
49         Clear = 0xFF0B,
50         /// <summary>
51         /// The Return key.
52         /// </summary>
53         Return = 0xFF0D,
54         /// <summary>
55         /// The Pause key.
56         /// </summary>
57         Pause = 0xFF13,
58         /// <summary>
59         /// The Scroll lock key.
60         /// </summary>
61         ScrollLock = 0xFF14,
62         /// <summary>
63         /// The System Request key.
64         /// </summary>
65         SysReq = 0xFF15,
66         /// <summary>
67         /// The Escape key.
68         /// </summary>
69         Escape = 0xFF1B,
70         /// <summary>
71         /// The Delete key.
72         /// </summary>
73         Delete = 0xFFFF,
74
75         /* Cursor control & motion */
76         /// <summary>
77         /// The Home key.
78         /// </summary>
79         Home = 0xFF50,
80         /// <summary>
81         /// The Left directional key.
82         /// </summary>
83         Left = 0xFF51,
84         /// <summary>
85         /// The Up directional key.
86         /// </summary>
87         Up = 0xFF52,
88         /// <summary>
89         /// The Right directional key.
90         /// </summary>
91         Right = 0xFF53,
92         /// <summary>
93         /// The Down directional key.
94         /// </summary>
95         Down = 0xFF54,
96         /// <summary>
97         /// The Prior, Previous key.
98         /// </summary>
99         Prior = 0xFF55,
100         /// <summary>
101         /// The Page Up key.
102         /// </summary>
103         Page_Up = 0xFF55,
104         /// <summary>
105         /// The Next key.
106         /// </summary>
107         Next = 0xFF56,
108         /// <summary>
109         /// The Page Down key.
110         /// </summary>
111         Page_Down = 0xFF56,
112         /// <summary>
113         /// The End key.
114         /// </summary>
115         End = 0xFF57,
116         /// <summary>
117         /// The Begin key.
118         /// </summary>
119         Begin = 0xFF58,
120
121         /* Misc Functions */
122         /// <summary>
123         /// The Select key.
124         /// </summary>
125         Select = 0xFF60,
126         /// <summary>
127         /// The Print key.
128         /// </summary>
129         Print = 0xFF61,
130         /// <summary>
131         /// The Execute, Run, Do key.
132         /// </summary>
133         Execute = 0xFF62,
134         /// <summary>
135         /// The Insert key.
136         /// </summary>
137         Insert = 0xFF63,
138         /// <summary>
139         /// The Undo key.
140         /// </summary>
141         Undo = 0xFF65,
142         /// <summary>
143         /// The Redo key.
144         /// </summary>
145         Redo = 0xFF66,
146         /// <summary>
147         /// The Menu key.
148         /// </summary>
149         Menu = 0xFF67,
150         /// <summary>
151         /// The Find key.
152         /// </summary>
153         Find = 0xFF68,
154         /// <summary>
155         /// The Cancel, Stop, Abort, Exit key.
156         /// </summary>
157         Cancel = 0xFF69,
158         /// <summary>
159         /// The Help key.
160         /// </summary>
161         Help = 0xFF6A,
162         /// <summary>
163         /// The Break key.
164         /// </summary>
165         Break = 0xFF6B,
166         /// <summary>
167         /// The character set switch key.
168         /// </summary>
169         Mode_switch = 0xFF7E,
170         /// <summary>
171         /// The Number Lock key.
172         /// </summary>
173         Num_Lock = 0xFF7F,
174
175         /* Keypad */
176         /// <summary>
177         /// The Numpad Space key.
178         /// </summary>
179         KPSpace = 0xFF80,
180         /// <summary>
181         /// The Numpad Tab key.
182         /// </summary>
183         KPTab = 0xFF89,
184         /// <summary>
185         /// The Numpad Enter key.
186         /// </summary>
187         KPEnter = 0xFF8D,
188         /// <summary>
189         /// The Numpad Function 1 key.
190         /// </summary>
191         KPF1 = 0xFF91,
192         /// <summary>
193         /// The Numpad Function 2 key.
194         /// </summary>
195         KPF2 = 0xFF92,
196         /// <summary>
197         /// The Numpad Function 3 key.
198         /// </summary>
199         KPF3 = 0xFF93,
200         /// <summary>
201         /// The Numpad Function 4 key.
202         /// </summary>
203         KPF4 = 0xFF94,
204         /// <summary>
205         /// The Numpad Home key.
206         /// </summary>
207         KPHome = 0xFF95,
208         /// <summary>
209         /// The Numpad Left key.
210         /// </summary>
211         KPLeft = 0xFF96,
212         /// <summary>
213         /// The Numpad Up key.
214         /// </summary>
215         KPUp = 0xFF97,
216         /// <summary>
217         /// The Numpad Right key.
218         /// </summary>
219         KPRight = 0xFF98,
220         /// <summary>
221         /// The Numpad Down key.
222         /// </summary>
223         KPDown = 0xFF99,
224         /// <summary>
225         /// The Numpad Prior, Previous key.
226         /// </summary>
227         KPPrior = 0xFF9A,
228         /// <summary>
229         /// The Numpad Page Up key.
230         /// </summary>
231         KPPage_Up = 0xFF9A,
232         /// <summary>
233         /// The Numpad Next key.
234         /// </summary>
235         KPNext = 0xFF9B,
236         /// <summary>
237         /// The Numpad Page Down key.
238         /// </summary>
239         KPPage_Down = 0xFF9B,
240         /// <summary>
241         /// The Numpad End key.
242         /// </summary>
243         KPEnd = 0xFF9C,
244         /// <summary>
245         /// The Numpad Begin key.
246         /// </summary>
247         KPBegin = 0xFF9D,
248         /// <summary>
249         /// The Numpad Insert key.
250         /// </summary>
251         KPInsert = 0xFF9E,
252         /// <summary>
253         /// The Numpad Delete key.
254         /// </summary>
255         KPDelete = 0xFF9F,
256         /// <summary>
257         /// The Numpad Equal key.
258         /// </summary>
259         KPEqual = 0xFFBD,
260         /// <summary>
261         /// The Numpad Multiply key.
262         /// </summary>
263         KPMultiply = 0xFFAA,
264         /// <summary>
265         /// The Numpad Add key.
266         /// </summary>
267         KPAdd = 0xFFAB,
268         /// <summary>
269         /// The Numpad Separator key.
270         /// </summary>
271         KPSeparator = 0xFFAC,
272         /// <summary>
273         /// The Numpad Subtract key.
274         /// </summary>
275         KPSubtract = 0xFFAD,
276         /// <summary>
277         /// The Numpad Decimal key.
278         /// </summary>
279         KPDecimal = 0xFFAE,
280         /// <summary>
281         /// The Numpad Divide key.
282         /// </summary>
283         KPDivide = 0xFFAF,
284         /// <summary>
285         /// The Numpad 0 key.
286         /// </summary>
287         KP0 = 0xFFB0,
288         /// <summary>
289         /// The Numpad 1 key.
290         /// </summary>
291         KP1 = 0xFFB1,
292         /// <summary>
293         /// The Numpad 2 key.
294         /// </summary>
295         KP2 = 0xFFB2,
296         /// <summary>
297         /// The Numpad 3 key.
298         /// </summary>
299         KP3 = 0xFFB3,
300         /// <summary>
301         /// The Numpad 4 key.
302         /// </summary>
303         KP4 = 0xFFB4,
304         /// <summary>
305         /// The Numpad 5 key.
306         /// </summary>
307         KP5 = 0xFFB5,
308         /// <summary>
309         /// The Numpad 6 key.
310         /// </summary>
311         KP6 = 0xFFB6,
312         /// <summary>
313         /// The Numpad 7 key.
314         /// </summary>
315         KP7 = 0xFFB7,
316         /// <summary>
317         /// The Numpad 8 key.
318         /// </summary>
319         KP8 = 0xFFB8,
320         /// <summary>
321         /// The Numpad 9 key.
322         /// </summary>
323         KP9 = 0xFFB9,
324
325         /* Auxiliary Functions */
326         /// <summary>
327         /// The Function 1 key.
328         /// </summary>
329         F1 = 0xFFBE,
330         /// <summary>
331         /// The Function 2 key.
332         /// </summary>
333         F2 = 0xFFBF,
334         /// <summary>
335         /// The Function 3 key.
336         /// </summary>
337         F3 = 0xFFC0,
338         /// <summary>
339         /// The Function 4 key.
340         /// </summary>
341         F4 = 0xFFC1,
342         /// <summary>
343         /// The Function 5 key.
344         /// </summary>
345         F5 = 0xFFC2,
346         /// <summary>
347         /// The Function 6 key.
348         /// </summary>
349         F6 = 0xFFC3,
350         /// <summary>
351         /// The Function 7 key.
352         /// </summary>
353         F7 = 0xFFC4,
354         /// <summary>
355         /// The Function 8 key.
356         /// </summary>
357         F8 = 0xFFC5,
358         /// <summary>
359         /// The Function 9 key.
360         /// </summary>
361         F9 = 0xFFC6,
362         /// <summary>
363         /// The Function 10 key.
364         /// </summary>
365         F10 = 0xFFC7,
366         /// <summary>
367         /// The Function 11 key.
368         /// </summary>
369         F11 = 0xFFC8,
370         /// <summary>
371         /// The Function 12 key.
372         /// </summary>
373         F12 = 0xFFC9,
374         /// <summary>
375         /// The Function 13 key.
376         /// </summary>
377         F13 = 0xFFCA,
378         /// <summary>
379         /// The Function 14 key.
380         /// </summary>
381         F14 = 0xFFCB,
382         /// <summary>
383         /// The Function 15 key.
384         /// </summary>
385         F15 = 0xFFCC,
386         /// <summary>
387         /// The Function 16 key.
388         /// </summary>
389         F16 = 0xFFCD,
390         /// <summary>
391         /// The Function 17 key.
392         /// </summary>
393         F17 = 0xFFCE,
394         /// <summary>
395         /// The Function 18 key.
396         /// </summary>
397         F18 = 0xFFCF,
398         /// <summary>
399         /// The Function 19 key.
400         /// </summary>
401         F19 = 0xFFD0,
402         /// <summary>
403         /// The Function 20 key.
404         /// </summary>
405         F20 = 0xFFD1,
406         /// <summary>
407         /// The Function 21 key.
408         /// </summary>
409         F21 = 0xFFD2,
410         /// <summary>
411         /// The Function 22 key.
412         /// </summary>
413         F22 = 0xFFD3,
414         /// <summary>
415         /// The Function 23 key.
416         /// </summary>
417         F23 = 0xFFD4,
418         /// <summary>
419         /// The Function 24 key.
420         /// </summary>
421         F24 = 0xFFD5,
422         /// <summary>
423         /// The Function 25 key.
424         /// </summary>
425         F25 = 0xFFD6,
426         /// <summary>
427         /// The Function 26 key.
428         /// </summary>
429         F26 = 0xFFD7,
430         /// <summary>
431         /// The Function 27 key.
432         /// </summary>
433         F27 = 0xFFD8,
434         /// <summary>
435         /// The Function 28 key.
436         /// </summary>
437         F28 = 0xFFD9,
438         /// <summary>
439         /// The Function 29 key.
440         /// </summary>
441         F29 = 0xFFDA,
442         /// <summary>
443         /// The Function 30 key.
444         /// </summary>
445         F30 = 0xFFDB,
446         /// <summary>
447         /// The Function 31 key.
448         /// </summary>
449         F31 = 0xFFDC,
450         /// <summary>
451         /// The Function 32 key.
452         /// </summary>
453         F32 = 0xFFDD,
454         /// <summary>
455         /// The Function 33 key.
456         /// </summary>
457         F33 = 0xFFDE,
458         /// <summary>
459         /// The Function 34 key.
460         /// </summary>
461         F34 = 0xFFDF,
462         /// <summary>
463         /// The Function 35 key.
464         /// </summary>
465         F35 = 0xFFE0,
466
467         /* Modifier keys */
468         /// <summary>
469         /// The Left Shift key.
470         /// </summary>
471         ShiftL = 0xFFE1,
472         /// <summary>
473         /// The Right Shift key.
474         /// </summary>
475         ShiftR = 0xFFE2,
476         /// <summary>
477         /// The Left Control key.
478         /// </summary>
479         ControlL = 0xFFE3,
480         /// <summary>
481         /// The Right Control key.
482         /// </summary>
483         ControlR = 0xFFE4,
484         /// <summary>
485         /// The Caps Lock key.
486         /// </summary>
487         CapsLock = 0xFFE5,
488         /// <summary>
489         /// The Shift Lock key.
490         /// </summary>
491         ShiftLock = 0xFFE6,
492         /// <summary>
493         /// The Left Meta key.
494         /// </summary>
495         MetaL = 0xFFE7,
496         /// <summary>
497         /// The Right Meta key.
498         /// </summary>
499         MetaR = 0xFFE8,
500         /// <summary>
501         /// The Left Alt key.
502         /// </summary>
503         AltL = 0xFFE9,
504         /// <summary>
505         /// The Right Alt key.
506         /// </summary>
507         AltR = 0xFFEA,
508         /// <summary>
509         /// The Left Super key.
510         /// </summary>
511         SuperL = 0xFFEB,
512         /// <summary>
513         /// The Right Super key.
514         /// </summary>
515         SuperR = 0xFFEC,
516         /// <summary>
517         /// The Left Hyper key.
518         /// </summary>
519         HyperL = 0xFFED,
520         /// <summary>
521         /// The Right Hyper key.
522         /// </summary>
523         HyperR = 0xFFEE,
524
525         /* Latin 1 */
526         /// <summary>
527         /// The Space key.
528         /// </summary>
529         Space = 0x020,
530         /// <summary>
531         /// The Exclamation key.
532         /// </summary>
533         Exclam = 0x021,
534         /// <summary>
535         /// The Quotedbl key.
536         /// </summary>
537         Quotedbl = 0x022,
538         /// <summary>
539         /// The Number Sign key.
540         /// </summary>
541         NumberSign = 0x023,
542         /// <summary>
543         /// The Dollar key.
544         /// </summary>
545         Dollar = 0x024,
546         /// <summary>
547         /// The Percent key.
548         /// </summary>
549         Percent = 0x025,
550         /// <summary>
551         /// The Ampersand key.
552         /// </summary>
553         Ampersand = 0x026,
554         /// <summary>
555         /// The Apostrophe key.
556         /// </summary>
557         Apostrophe = 0x027,
558         /// <summary>
559         /// The Parenleft key.
560         /// </summary>
561         Parenleft = 0x028,
562         /// <summary>
563         /// The Parenright key.
564         /// </summary>
565         Parenright = 0x029,
566         /// <summary>
567         /// The Asterisk key.
568         /// </summary>
569         Asterisk = 0x02a,
570         /// <summary>
571         /// The Plus key.
572         /// </summary>
573         Plus = 0x02b,
574         /// <summary>
575         /// The Comma key.
576         /// </summary>
577         Comma = 0x02c,
578         /// <summary>
579         /// The Minus key.
580         /// </summary>
581         Minus = 0x02d,
582         /// <summary>
583         /// The Period key.
584         /// </summary>
585         Period = 0x02e,
586         /// <summary>
587         /// The Slash key.
588         /// </summary>
589         Slash = 0x02f,
590         /// <summary>
591         /// The 0 key.
592         /// </summary>
593         Keypad0 = 0x030,
594         /// <summary>
595         /// The 1 key.
596         /// </summary>
597         Keypad1 = 0x031,
598         /// <summary>
599         /// The 2 key.
600         /// </summary>
601         Keypad2 = 0x032,
602         /// <summary>
603         /// The 3 key.
604         /// </summary>
605         Keypad3 = 0x033,
606         /// <summary>
607         /// The 4 key.
608         /// </summary>
609         Keypad4 = 0x034,
610         /// <summary>
611         /// The 5 key.
612         /// </summary>
613         Keypad5 = 0x035,
614         /// <summary>
615         /// The 6 key.
616         /// </summary>
617         Keypad6 = 0x036,
618         /// <summary>
619         /// The 7 key.
620         /// </summary>
621         Keypad7 = 0x037,
622         /// <summary>
623         /// The 8 key.
624         /// </summary>
625         Keypad8 = 0x038,
626         /// <summary>
627         /// The 9 key.
628         /// </summary>
629         Keypad9 = 0x039,
630         /// <summary>
631         /// The Colon key.
632         /// </summary>
633         Colon = 0x03a,
634         /// <summary>
635         /// The Semicolon key.
636         /// </summary>
637         Semicolon = 0x03b,
638         /// <summary>
639         /// The Less key.
640         /// </summary>
641         Less = 0x03c,
642         /// <summary>
643         /// The Equal key.
644         /// </summary>
645         Equal = 0x03d,
646         /// <summary>
647         /// The Greater key.
648         /// </summary>
649         Greater = 0x03e,
650         /// <summary>
651         /// The Question key.
652         /// </summary>
653         Question = 0x03f,
654         /// <summary>
655         /// The At key.
656         /// </summary>
657         At = 0x040,
658         /// <summary>
659         /// The A key.
660         /// </summary>
661         KeypadA = 0x041,
662         /// <summary>
663         /// The B key.
664         /// </summary>
665         KeypadB = 0x042,
666         /// <summary>
667         /// The C key.
668         /// </summary>
669         KeypadC = 0x043,
670         /// <summary>
671         /// The D key.
672         /// </summary>
673         KeypadD = 0x044,
674         /// <summary>
675         /// The E key.
676         /// </summary>
677         KeypadE = 0x045,
678         /// <summary>
679         /// The F key.
680         /// </summary>
681         KeypadF = 0x046,
682         /// <summary>
683         /// The G key.
684         /// </summary>
685         KeypadG = 0x047,
686         /// <summary>
687         /// The H key.
688         /// </summary>
689         KeypadH = 0x048,
690         /// <summary>
691         /// The I key.
692         /// </summary>
693         KeypadI = 0x049,
694         /// <summary>
695         /// The J key.
696         /// </summary>
697         KeypadJ = 0x04a,
698         /// <summary>
699         /// The K key.
700         /// </summary>
701         KeypadK = 0x04b,
702         /// <summary>
703         /// The L key.
704         /// </summary>
705         KeypadL = 0x04c,
706         /// <summary>
707         /// The M key.
708         /// </summary>
709         KeypadM = 0x04d,
710         /// <summary>
711         /// The N key.
712         /// </summary>
713         KeypadN = 0x04e,
714         /// <summary>
715         /// The O key.
716         /// </summary>
717         KeypadO = 0x04f,
718         /// <summary>
719         /// The P key.
720         /// </summary>
721         KeypadP = 0x050,
722         /// <summary>
723         /// The Q key.
724         /// </summary>
725         KeypadQ = 0x051,
726         /// <summary>
727         /// The R key.
728         /// </summary>
729         KeypadR = 0x052,
730         /// <summary>
731         /// The S key.
732         /// </summary>
733         KeypadS = 0x053,
734         /// <summary>
735         /// The T key.
736         /// </summary>
737         KeypadT = 0x054,
738         /// <summary>
739         /// The U key.
740         /// </summary>
741         KeypadU = 0x055,
742         /// <summary>
743         /// The V key.
744         /// </summary>
745         KeypadV = 0x056,
746         /// <summary>
747         /// The W key.
748         /// </summary>
749         KeypadW = 0x057,
750         /// <summary>
751         /// The X key.
752         /// </summary>
753         KeypadX = 0x058,
754         /// <summary>
755         /// The Y key.
756         /// </summary>
757         KeypadY = 0x059,
758         /// <summary>
759         /// The Z key.
760         /// </summary>
761         KeypadZ = 0x05a,
762         /// <summary>
763         /// The Left Bracket key.
764         /// </summary>
765         BracketLeft = 0x05b,
766         /// <summary>
767         /// The Backslash key.
768         /// </summary>
769         Backslash = 0x05c,
770         /// <summary>
771         /// The Right Bracket key.
772         /// </summary>
773         BracketRight = 0x05d,
774         /// <summary>
775         /// The Circumflex key.
776         /// </summary>
777         AsciiCircum = 0x05e,
778         /// <summary>
779         /// The Underscore key.
780         /// </summary>
781         Underscore = 0x05f,
782         /// <summary>
783         /// The Grave key.
784         /// </summary>
785         Grave = 0x060,
786         /// <summary>
787         /// The a key.
788         /// </summary>
789         Keypada = 0x061,
790         /// <summary>
791         /// The b key.
792         /// </summary>
793         Keypadb = 0x062,
794         /// <summary>
795         /// The c key.
796         /// </summary>
797         Keypadc = 0x063,
798         /// <summary>
799         /// The d key.
800         /// </summary>
801         Keypadd = 0x064,
802         /// <summary>
803         /// The e key.
804         /// </summary>
805         Keypade = 0x065,
806         /// <summary>
807         /// The f key.
808         /// </summary>
809         Keypadf = 0x066,
810         /// <summary>
811         /// The g key.
812         /// </summary>
813         Keypadg = 0x067,
814         /// <summary>
815         /// The h key.
816         /// </summary>
817         Keypadh = 0x068,
818         /// <summary>
819         /// The i key.
820         /// </summary>
821         Keypadi = 0x069,
822         /// <summary>
823         /// The j key.
824         /// </summary>
825         Keypadj = 0x06a,
826         /// <summary>
827         /// The k key.
828         /// </summary>
829         Keypadk = 0x06b,
830         /// <summary>
831         /// The l key.
832         /// </summary>
833         Keypadl = 0x06c,
834         /// <summary>
835         /// The m key.
836         /// </summary>
837         Keypadm = 0x06d,
838         /// <summary>
839         /// The n key.
840         /// </summary>
841         Keypadn = 0x06e,
842         /// <summary>
843         /// The o key.
844         /// </summary>
845         Keypado = 0x06f,
846         /// <summary>
847         /// The p key.
848         /// </summary>
849         Keypadp = 0x070,
850         /// <summary>
851         /// The q key.
852         /// </summary>
853         Keypadq = 0x071,
854         /// <summary>
855         /// The r key.
856         /// </summary>
857         Keypadr = 0x072,
858         /// <summary>
859         /// The s key.
860         /// </summary>
861         Keypads = 0x073,
862         /// <summary>
863         /// The t key.
864         /// </summary>
865         Keypadt = 0x074,
866         /// <summary>
867         /// The u key.
868         /// </summary>
869         Keypadu = 0x075,
870         /// <summary>
871         /// The v key.
872         /// </summary>
873         Keypadv = 0x076,
874         /// <summary>
875         /// The w key.
876         /// </summary>
877         Keypadw = 0x077,
878         /// <summary>
879         /// The x key.
880         /// </summary>
881         Keypadx = 0x078,
882         /// <summary>
883         /// The y key.
884         /// </summary>
885         Keypady = 0x079,
886         /// <summary>
887         /// The z key.
888         /// </summary>
889         Keypadz = 0x07a,
890         /// <summary>
891         /// The Left Brace key.
892         /// </summary>
893         BraceLeft = 0x07b,
894         /// <summary>
895         /// The Bar key.
896         /// </summary>
897         Bar = 0x07c,
898         /// <summary>
899         /// The Right Brace key.
900         /// </summary>
901         BraceRight = 0x07d,
902         /// <summary>
903         /// The Tilde key.
904         /// </summary>
905         AsciiTilde = 0x07e,
906     };
907
908     /// <summary>
909     /// Enumeration for the key masks.
910     /// The key masks indicate which modifier keys are pressed down during the keyboard hit. The special MASK_RELEASED indicates the key release event.
911     /// </summary>
912     /// <since_tizen> 4 </since_tizen>
913     public enum KeyMask
914     {
915         /// <summary>
916         /// Key press event without the modifier key.
917         /// </summary>
918         Pressed = 0,
919         /// <summary>
920         /// The Shift key is pressed down.
921         /// </summary>
922         Shift = (1 << 0),
923         /// <summary>
924         /// The CapsLock key is pressed down.
925         /// </summary>
926         CapsLock = (1 << 1),
927         /// <summary>
928         /// The Control key is pressed down.
929         /// </summary>
930         Control = (1 << 2),
931         /// <summary>
932         /// The Alt key is pressed down.
933         /// </summary>
934         Alt = (1 << 3),
935         /// <summary>
936         /// The Meta key is pressed down.
937         /// </summary>
938         Meta = (1 << 4),
939         /// <summary>
940         /// The Win key (between Control and Alt) is pressed down.
941         /// </summary>
942         Win = (1 << 5),
943         /// <summary>
944         /// The Hyper key is pressed down.
945         /// </summary>
946         Hyper = (1 << 6),
947         /// <summary>
948         /// The NumLock key is pressed down.
949         /// </summary>
950         NumLock = (1 << 7),
951         /// <summary>
952         /// Key release event.
953         /// </summary>
954         Released = (1 << 15),
955     }
956
957     /// <summary>
958     /// This class contains the API's related to the IME (Input method editor).
959     /// </summary>
960     /// <since_tizen> 4 </since_tizen>
961     public static class InputMethodEditor
962     {
963         private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();
964         private static event EventHandler<FocusedInEventArgs> _focusIn;
965         private static ImeFocusedInCb _imeFocusedInDelegate;
966         private static event EventHandler<FocusedOutEventArgs> _focusOut;
967         private static ImeFocusedOutCb _imeFocusedOutDelegate;
968         private static event EventHandler<SurroundingTextUpdatedEventArgs> _surroundingTextUpdated;
969         private static ImeSurroundingTextUpdatedCb _imeSurroundingTextUpdatedDelegate;
970         private static event EventHandler<EventArgs> _inputContextReset;
971         private static ImeInputContextResetCb _imeInputContextResetDelegate;
972         private static event EventHandler<CursorPositionUpdatedEventArgs> _cursorPositionUpdated;
973         private static ImeCursorPositionUpdatedCb _imeCursorPositionUpdatedDelegate;
974         private static event EventHandler<LanguageSetEventArgs> _langaugeSet;
975         private static ImeLanguageSetCb _imeLanguageSetDelegate;
976         private static event EventHandler<SetDataEventArgs> _imDataSet;
977         private static ImeImdataSetCb _imeDataSetDelegate;
978         private static event EventHandler<LayoutSetEventArgs> _layoutSet;
979         private static ImeLayoutSetCb _imeLayoutSetDelegate;
980         private static event EventHandler<ReturnKeySetEventArgs> _returnKeyTypeSet;
981         private static ImeReturnKeySetCb _imeReturnKeySetDelegate;
982         private static event EventHandler<ReturnKeyStateSetEventArgs> _returnKeyStateSet;
983         private static ImeReturnKeyStateSetCb _imeReturnKeyStateSetDelegate;
984         private static ImeProcessKeyEventCb _imeProcessKeyDelegate;
985         private static event EventHandler<DisplayLanguageChangedEventArgs> _displayLanguageChanged;
986         private static ImeDisplayLanguageChangedCb _imeDisplayLanguageChangedDelegate;
987         private static event EventHandler<RotationChangedEventArgs> _rotationDegreeChanged;
988         private static ImeRotationChangedCb _imeRotationChangedDelegate;
989         private static event EventHandler<AccessibilityStateChangedEventArgs> _accessibilityStateChanged;
990         private static ImeAccessibilityStateChangedCb _imeAccessibilityStateChangedDelegate;
991         private static event EventHandler<PredictionHintUpdatedEventArgs> _predictionHintUpdated;
992         private static ImePredictionHintSetCb _imePredictionHintSetDelegate;
993         private static event EventHandler<PredictionHintDataUpdatedEventArgs> _predictionHintDataUpdated;
994         private static ImePredictionHintDataSetCb _imePredictionHintDataSetDelegate;
995         private static event EventHandler<MimeTypeUpdateRequestedEventArgs> _mimeTypeUpdateRequested;
996         private static ImeMimeTypeSetRequestCb _imeMimeTypeSetRequestDelegate;
997         private static ImeLanguageRequestedCb _imeLanguageRequestedDelegate;
998         private static OutAction<string> _languageRequestedDelegate;
999         private static BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> _processKeyDelagate;
1000         private static ImeImdataRequestedCb _imeImDataRequestedDelegate;
1001         private static OutArrayAction<byte> _imDataRequestedDelegate;
1002         private static ImeGeometryRequestedCb _imeGeometryRequestedDelegate;
1003         private static OutAction<Rect> _geometryRequestedDelegate;
1004         private static ImeProcessKeyEventWithKeycodeCb _imeProcessKeyWithKeycodeDelegate;
1005         private static BoolAction<uint, KeyCode, KeyMask, InputMethodDeviceInformation> _processKeyWithKeycodeDelagate;
1006         private static event EventHandler<InputHintSetEventArgs> _inputHintSet;
1007         private static ImeInputHintSetCb _imeInputHintSetDelegate;
1008         private static Action _userCreate;
1009         private static Action _userTerminate;
1010         private static Action<ContextId, InputMethodContext> _userShow;
1011         private static Action<ContextId> _userHide;
1012         private static ImeCreateCb _create = (IntPtr userData) =>
1013         {
1014             Log.Info(LogTag, "In Create Delegate");
1015             _userCreate?.Invoke();
1016         };
1017         private static ImeTerminateCb _terminate = (IntPtr userData) =>
1018         {
1019             Log.Info(LogTag, "In terminate Delegate");
1020             _userTerminate?.Invoke();
1021             _imeCallbackStructGCHandle.Dispose();
1022         };
1023         private static ImeShowCb _show = (int contextId, IntPtr context, IntPtr userData) =>
1024         {
1025             Log.Info(LogTag, "In Show Delegate");
1026             _userShow?.Invoke(new ContextId(contextId), new InputMethodContext(context));
1027         };
1028         private static ImeHideCb _hide = (int contextId, IntPtr userData) =>
1029         {
1030             Log.Info(LogTag, "In Hide Delegate");
1031             _userHide?.Invoke(new ContextId(contextId));
1032         };
1033
1034         /// <summary>
1035         /// Structure representing the ContextId.
1036         /// </summary>
1037         /// <since_tizen> 4 </since_tizen>
1038         public struct ContextId : IEquatable<ContextId>
1039         {
1040             internal ContextId(int id)
1041             {
1042                 Id = id;
1043             }
1044
1045             internal int Id
1046             {
1047                 get;
1048                 private set;
1049             }
1050
1051             /// <summary>
1052             /// Compares whether the ContextIds are equal.
1053             /// </summary>
1054             /// <param name="other">The ContextId to compare with this instance.</param>
1055             /// <returns>true if the ContextIds is the same; otherwise, false.</returns>
1056             /// <since_tizen> 4 </since_tizen>
1057             public bool Equals(ContextId other)
1058             {
1059                 return this.Id == other.Id;
1060             }
1061         }
1062
1063         /// <summary>
1064         /// Rectangle representing the position and size of the UI control.
1065         /// </summary>
1066         /// <since_tizen> 4 </since_tizen>
1067         public struct Rect
1068         {
1069             /// <summary>
1070             /// The X position in the screen.
1071             /// </summary>
1072             /// <since_tizen> 4 </since_tizen>
1073             public int x;
1074
1075             /// <summary>
1076             /// The Y position in the screen.
1077             /// </summary>
1078             /// <since_tizen> 4 </since_tizen>
1079             public int y;
1080
1081             /// <summary>
1082             /// The window width.
1083             /// </summary>
1084             /// <since_tizen> 4 </since_tizen>
1085             public int w;
1086
1087             /// <summary>
1088             /// The window height.
1089             /// </summary>
1090             /// <since_tizen> 4 </since_tizen>
1091             public int h;
1092         }
1093
1094         /// <summary>
1095         /// An action with 1 out parameter.
1096         /// </summary>
1097         /// <typeparam name="T">Generic Type.</typeparam>
1098         /// <param name="a">The out parameter.</param>
1099         /// <since_tizen> 4 </since_tizen>
1100         public delegate void OutAction<T>(out T a);
1101
1102         /// <summary>
1103         /// An action with an array out parameter.
1104         /// </summary>
1105         /// <typeparam name="T">Generic Type.</typeparam>
1106         /// <param name="a">The out parameter 1.</param>
1107         /// <since_tizen> 4 </since_tizen>
1108         public delegate void OutArrayAction<T>(out T[] a);
1109
1110         /// <summary>
1111         /// An action with 3 input parameters returning a bool.
1112         /// </summary>
1113         /// <typeparam name="T">Generic type for parameter 1.</typeparam>
1114         /// <typeparam name="T1">Generic type for parameter 2.</typeparam>
1115         /// <typeparam name="T2">Generic type for parameter 3.</typeparam>
1116         /// <param name="a">The input parameter 1.</param>
1117         /// <param name="b">The input parameter 2.</param>
1118         /// <param name="c">The input parameter 3.</param>
1119         /// <returns></returns>
1120         /// <since_tizen> 4 </since_tizen>
1121         public delegate bool BoolAction<T, T1, T2>(T a, T1 b, T2 c);
1122
1123         /// <summary>
1124         /// An action with 4 input parameters returning a bool.
1125         /// </summary>
1126         /// <typeparam name="T">Generic type for parameter 1.</typeparam>
1127         /// <typeparam name="T1">Generic type for parameter 2.</typeparam>
1128         /// <typeparam name="T2">Generic type for parameter 3.</typeparam>
1129         /// <typeparam name="T3">Generic type for parameter 4.</typeparam>
1130         /// <param name="a">The input parameter 1.</param>
1131         /// <param name="b">The input parameter 2.</param>
1132         /// <param name="c">The input parameter 3.</param>
1133         /// <param name="d">The input parameter 4.</param>
1134         /// <returns></returns>
1135         /// <since_tizen> 10 </since_tizen>
1136         public delegate bool BoolAction<T, T1, T2, T3>(T a, T1 b, T2 c, T3 d);
1137
1138         /// <summary>
1139         /// Called when an associated text input UI control has focus.
1140         /// </summary>
1141         /// <since_tizen> 4 </since_tizen>
1142         public static event EventHandler<FocusedInEventArgs> FocusedIn
1143         {
1144             add
1145             {
1146                 _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
1147                 {
1148                     FocusedInEventArgs args = new FocusedInEventArgs(contextId);
1149                     _focusIn?.Invoke(null, args);
1150                 };
1151                 ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
1152                 if (error != ErrorCode.None)
1153                 {
1154                     Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
1155                 }
1156                 else
1157                 {
1158                     _focusIn += value;
1159                 }
1160             }
1161             remove
1162             {
1163                 _focusIn -= value;
1164             }
1165         }
1166
1167         /// <summary>
1168         /// Called when an associated text input UI control loses focus.
1169         /// </summary>
1170         /// <since_tizen> 4 </since_tizen>
1171         public static event EventHandler<FocusedOutEventArgs> FocusedOut
1172         {
1173             add
1174             {
1175                 _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
1176                 {
1177                     FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
1178                     _focusOut?.Invoke(null, args);
1179                 };
1180                 ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
1181                 if (error != ErrorCode.None)
1182                 {
1183                     Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
1184                 }
1185                 else
1186                 {
1187                     _focusOut += value;
1188                 }
1189             }
1190             remove
1191             {
1192                 _focusOut -= value;
1193             }
1194         }
1195
1196         /// <summary>
1197         /// Called when an associated text input UI control responds to a request with the surrounding text.
1198         /// </summary>
1199         /// <since_tizen> 4 </since_tizen>
1200         public static event EventHandler<SurroundingTextUpdatedEventArgs> SurroundingTextUpdated
1201         {
1202             add
1203             {
1204                 _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
1205                 {
1206                     SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
1207                     _surroundingTextUpdated?.Invoke(null, args);
1208                 };
1209                 ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
1210                 if (error != ErrorCode.None)
1211                 {
1212                     Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
1213                 }
1214                 else
1215                 {
1216                     _surroundingTextUpdated += value;
1217                 }
1218             }
1219             remove
1220             {
1221                 _surroundingTextUpdated -= value;
1222             }
1223         }
1224
1225         /// <summary>
1226         /// Called to reset the input context of an associated text input UI control.
1227         /// </summary>
1228         /// <since_tizen> 4 </since_tizen>
1229         public static event EventHandler<EventArgs> InputContextReset
1230         {
1231             add
1232             {
1233                 _imeInputContextResetDelegate = (IntPtr userData) =>
1234                 {
1235                     _inputContextReset?.Invoke(null, EventArgs.Empty);
1236                 };
1237                 ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
1238                 if (error != ErrorCode.None)
1239                 {
1240                     Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
1241                 }
1242                 else
1243                 {
1244                     _inputContextReset += value;
1245                 }
1246             }
1247             remove
1248             {
1249                 _inputContextReset -= value;
1250             }
1251         }
1252
1253         /// <summary>
1254         /// Called when the position of the cursor in an associated text input UI control changes.
1255         /// </summary>
1256         /// <since_tizen> 4 </since_tizen>
1257         public static event EventHandler<CursorPositionUpdatedEventArgs> CursorPositionUpdated
1258         {
1259             add
1260             {
1261                 _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
1262                 {
1263                     CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
1264                     _cursorPositionUpdated?.Invoke(null, args);
1265                 };
1266                 ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
1267                 if (error != ErrorCode.None)
1268                 {
1269                     Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
1270                 }
1271                 else
1272                 {
1273                     _cursorPositionUpdated += value;
1274                 }
1275             }
1276             remove
1277             {
1278                 _cursorPositionUpdated -= value;
1279             }
1280         }
1281
1282         /// <summary>
1283         /// Called to set the preferred language to the input panel.
1284         /// It will only be called when the client application changes the edit field's language attribute after the input panel is shown.
1285         /// </summary>
1286         /// <since_tizen> 4 </since_tizen>
1287         public static event EventHandler<LanguageSetEventArgs> LanguageSet
1288         {
1289             add
1290             {
1291                 _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
1292                 {
1293                     LanguageSetEventArgs args = new LanguageSetEventArgs(language);
1294                     _langaugeSet?.Invoke(null, args);
1295                 };
1296                 ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
1297                 if (error != ErrorCode.None)
1298                 {
1299                     Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
1300                 }
1301                 else
1302                 {
1303                     _langaugeSet += value;
1304                 }
1305             }
1306             remove
1307             {
1308                 _langaugeSet -= value;
1309             }
1310         }
1311
1312         /// <summary>
1313         /// Called to set the application specific data to deliver to the input panel.
1314         /// </summary>
1315         /// <since_tizen> 4 </since_tizen>
1316         public static event EventHandler<SetDataEventArgs> DataSet
1317         {
1318             add
1319             {
1320                 _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
1321                 {
1322                     byte[] destination = new byte[dataLength];
1323                     Marshal.Copy(data, destination, 0, (int)dataLength);
1324                     SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
1325                     _imDataSet?.Invoke(null, args);
1326                 };
1327                 ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
1328                 if (error != ErrorCode.None)
1329                 {
1330                     Log.Error(LogTag, "Add DataSet Failed with error " + error);
1331                 }
1332                 else
1333                 {
1334                     _imDataSet += value;
1335                 }
1336             }
1337             remove
1338             {
1339                 _imDataSet -= value;
1340             }
1341         }
1342
1343         /// <summary>
1344         /// Called when an associated text input UI control requests the input panel to set its layout.
1345         /// It will only be called when the client application changes the edit field's layout attribute after the input panel is shown.
1346         /// </summary>
1347         /// <since_tizen> 4 </since_tizen>
1348         public static event EventHandler<LayoutSetEventArgs> LayoutSet
1349         {
1350             add
1351             {
1352                 _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
1353                 {
1354                     LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
1355                     _layoutSet?.Invoke(null, args);
1356                 };
1357                 ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
1358                 if (error != ErrorCode.None)
1359                 {
1360                     Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
1361                 }
1362                 else
1363                 {
1364                     _layoutSet += value;
1365                 }
1366             }
1367             remove
1368             {
1369                 _layoutSet -= value;
1370             }
1371         }
1372
1373         /// <summary>
1374         /// Called when an associated text input UI control requests the input panel to set the Return key label.
1375         /// The input panel can show the text or an image on the Return button, according to the Return key action.
1376         /// </summary>
1377         /// <since_tizen> 4 </since_tizen>
1378         public static event EventHandler<ReturnKeySetEventArgs> ReturnKeySet
1379         {
1380             add
1381             {
1382                 _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
1383                 {
1384                     ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
1385                     _returnKeyTypeSet?.Invoke(null, args);
1386                 };
1387                 ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
1388                 if (error != ErrorCode.None)
1389                 {
1390                     Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
1391                 }
1392                 else
1393                 {
1394                     _returnKeyTypeSet += value;
1395                 }
1396             }
1397             remove
1398             {
1399                 _returnKeyTypeSet -= value;
1400             }
1401         }
1402
1403         /// <summary>
1404         /// Called when an associated text input UI control requests the input panel to enable or disable the Return key state.
1405         /// </summary>
1406         /// <since_tizen> 4 </since_tizen>
1407         public static event EventHandler<ReturnKeyStateSetEventArgs> ReturnKeyStateSet
1408         {
1409             add
1410             {
1411                 _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
1412                 {
1413                     ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
1414                     _returnKeyStateSet?.Invoke(null, args);
1415                 };
1416                 ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
1417                 if (error != ErrorCode.None)
1418                 {
1419                     Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
1420                 }
1421                 else
1422                 {
1423                     _returnKeyStateSet += value;
1424                 }
1425             }
1426             remove
1427             {
1428                 _returnKeyStateSet -= value;
1429             }
1430         }
1431
1432         /// <summary>
1433         /// Called when the system display language is changed.
1434         /// </summary>
1435         /// <since_tizen> 4 </since_tizen>
1436         public static event EventHandler<DisplayLanguageChangedEventArgs> DisplayLanguageChanged
1437         {
1438             add
1439             {
1440                 _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
1441                 {
1442                     DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
1443                     _displayLanguageChanged?.Invoke(null, args);
1444                 };
1445                 ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
1446                 if (error != ErrorCode.None)
1447                 {
1448                     Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
1449                 }
1450                 else
1451                 {
1452                     _displayLanguageChanged += value;
1453                 }
1454             }
1455             remove
1456             {
1457                 _displayLanguageChanged -= value;
1458             }
1459         }
1460
1461         /// <summary>
1462         /// Called when the device is rotated.
1463         /// </summary>
1464         /// <since_tizen> 4 </since_tizen>
1465         public static event EventHandler<RotationChangedEventArgs> RotationChanged
1466         {
1467             add
1468             {
1469                 _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
1470                 {
1471                     RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
1472                     _rotationDegreeChanged?.Invoke(null, args);
1473                 };
1474                 ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
1475                 if (error != ErrorCode.None)
1476                 {
1477                     Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
1478                 }
1479                 else
1480                 {
1481                     _rotationDegreeChanged += value;
1482                 }
1483             }
1484             remove
1485             {
1486                 _rotationDegreeChanged -= value;
1487             }
1488         }
1489
1490         /// <summary>
1491         /// Called when Accessibility in settings application is on or off.
1492         /// </summary>
1493         /// <since_tizen> 4 </since_tizen>
1494         public static event EventHandler<AccessibilityStateChangedEventArgs> AccessibilityStateChanged
1495         {
1496             add
1497             {
1498                 _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
1499                 {
1500                     AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
1501                     _accessibilityStateChanged?.Invoke(null, args);
1502                 };
1503                 ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
1504                 if (error != ErrorCode.None)
1505                 {
1506                     Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
1507                 }
1508                 else
1509                 {
1510                     _accessibilityStateChanged += value;
1511                 }
1512             }
1513             remove
1514             {
1515                 _accessibilityStateChanged -= value;
1516             }
1517         }
1518
1519         /// <summary>
1520         /// Sets the languageRequested action.
1521         /// </summary>
1522         /// <param name="languageRequested">
1523         /// Called when an associated text input UI control requests the language from the input panel, requesting for language code.
1524         /// </param>
1525         /// <since_tizen> 4 </since_tizen>
1526         public static void SetLanguageRequestedCallback(OutAction<string> languageRequested)
1527         {
1528             _imeLanguageRequestedDelegate = (IntPtr userData, out IntPtr langCode) =>
1529             {
1530                 string language;
1531                 _languageRequestedDelegate(out language);
1532                 langCode = (IntPtr)Marshal.StringToHGlobalAnsi(language);
1533             };
1534             ErrorCode error = ImeEventSetLanguageRequestedCallbackCb(_imeLanguageRequestedDelegate, IntPtr.Zero);
1535             if (error != ErrorCode.None)
1536             {
1537                 Log.Error(LogTag, "Add SetLanguageRequestedCallback Failed with error " + error);
1538             }
1539             _languageRequestedDelegate = languageRequested;
1540         }
1541
1542         /// <summary>
1543         /// Sets the processKey action.
1544         /// If the key event is from the external device, DeviceInfo will have its name, class, and subclass information.
1545         /// </summary>
1546         /// <param name="processKey">
1547         /// The action is called when the key event is received from the external devices or the SendKey function.
1548         /// This Event processes the key event before an associated text input UI control does.
1549         /// </param>
1550         /// <since_tizen> 4 </since_tizen>
1551         public static void SetProcessKeyCallback(BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> processKey)
1552         {
1553             _imeProcessKeyDelegate = (KeyCode keyCode, KeyMask keyMask, IntPtr devInfo, IntPtr userData) =>
1554             {
1555                 return _processKeyDelagate(keyCode, keyMask, new InputMethodDeviceInformation(devInfo));
1556             };
1557             ErrorCode error = ImeEventSetProcessKeyEventCb(_imeProcessKeyDelegate, IntPtr.Zero);
1558             if (error != ErrorCode.None)
1559             {
1560                 Log.Error(LogTag, "Add ProcessKey Failed with error " + error);
1561             }
1562             _processKeyDelagate = processKey;
1563         }
1564
1565         /// <summary>
1566         /// Sets the imDataRequested action.
1567         /// </summary>
1568         /// <param name="imDataRequested">
1569         /// 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.
1570         /// </param>
1571         /// <since_tizen> 4 </since_tizen>
1572         public static void SetDataRequestedCallback(OutArrayAction<byte> imDataRequested)
1573         {
1574             _imeImDataRequestedDelegate = (IntPtr userData, out IntPtr data, out uint dataLength) =>
1575             {
1576                 byte[] dataArr;
1577                 _imDataRequestedDelegate(out dataArr);
1578                 data = Marshal.AllocHGlobal(dataArr.Length);
1579                 Marshal.Copy(dataArr, 0, data, dataArr.Length);
1580                 dataLength = (uint)dataArr.Length;
1581             };
1582             ErrorCode error = ImeEventSetImdataRequestedCb(_imeImDataRequestedDelegate, IntPtr.Zero);
1583             if (error != ErrorCode.None)
1584             {
1585                 Log.Error(LogTag, "Add SetDataRequestedCallback Failed with error " + error);
1586             }
1587             _imDataRequestedDelegate = imDataRequested;
1588         }
1589
1590         /// <summary>
1591         /// Sets the GeometryRequested action.
1592         /// </summary>
1593         /// <param name="geometryRequested">
1594         /// Called when an associated text input UI control requests the position and size from the input panel, requesting for x, y, w, h values.
1595         /// </param>
1596         /// <since_tizen> 4 </since_tizen>
1597         public static void SetGeometryRequestedCallback(OutAction<Rect> geometryRequested)
1598         {
1599             _imeGeometryRequestedDelegate = (IntPtr userData, out int x, out int y, out int w, out int h) =>
1600             {
1601                 Rect rect = new Rect();
1602                 _geometryRequestedDelegate(out rect);
1603                 x = rect.x;
1604                 y = rect.y;
1605                 w = rect.w;
1606                 h = rect.h;
1607             };
1608             ErrorCode error = ImeEventSetGeometryRequestedCallbackCb(_imeGeometryRequestedDelegate, IntPtr.Zero);
1609             if (error != ErrorCode.None)
1610             {
1611                 Log.Error(LogTag, "Add SetGeometryRequestedCallback Failed with error " + error);
1612             }
1613             _geometryRequestedDelegate = geometryRequested;
1614         }
1615
1616         /// <summary>
1617         /// Runs the main loop of the IME application.
1618         /// This function starts to run the IME application's main loop.
1619         /// </summary>
1620         /// <privilege>
1621         /// http://tizen.org/privilege/ime
1622         /// </privilege>
1623         /// <remarks>
1624         /// This API is a blocking call, as it starts the main loop of the application.
1625         /// </remarks>
1626         /// <param name="create">This is called to initialize the IME application before the main loop starts up.</param>
1627         /// <param name="terminate">This is called when the IME application is terminated.</param>
1628         /// <param name="show">
1629         /// This is called when the IME application is shown.
1630         /// It provides the context information and the context ID.
1631         /// </param>
1632         /// <param name="hide">
1633         /// This is called when the IME application is hidden.
1634         /// It provides the context ID.
1635         /// </param>
1636         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1637         /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
1638         /// <since_tizen> 4 </since_tizen>
1639         public static void Run(Action create, Action terminate, Action<ContextId, InputMethodContext> show, Action<ContextId> hide)
1640         {
1641             _userCreate = create;
1642             _userTerminate = terminate;
1643             _userShow = show;
1644             _userHide = hide;
1645             _imeCallbackStructGCHandle._imeCallbackStruct.create = _create;
1646             _imeCallbackStructGCHandle._imeCallbackStruct.terminate = _terminate;
1647             _imeCallbackStructGCHandle._imeCallbackStruct.hide = _hide;
1648             _imeCallbackStructGCHandle._imeCallbackStruct.show = _show;
1649
1650             ImeSetDotnetFlag(true);
1651             ErrorCode error = ImeRun(ref _imeCallbackStructGCHandle._imeCallbackStruct, IntPtr.Zero);
1652             if (error != ErrorCode.None)
1653             {
1654                 Log.Error(LogTag, "Run Failed with error " + error);
1655                 throw InputMethodExceptionFactory.CreateException(error);
1656             }
1657
1658         }
1659
1660         /// <summary>
1661         /// Sends a key event to the associated text input UI control.
1662         /// </summary>
1663         /// <remarks>
1664         /// This function sends a key down or up event with the key mask to the client application. If forwardKey is true, this key event goes to the edit filed directly.
1665         /// And if forwardKey is false, the ProcessKey event receives the key event before the edit field.
1666         /// </remarks>
1667         /// <privilege>
1668         /// http://tizen.org/privilege/ime
1669         /// </privilege>
1670         /// <param name="keyCode">The key code to be sent.</param>
1671         /// <param name="keyMask">The modifier key mask.</param>
1672         /// <param name="forwardKey">The flag to send the key event directly to the edit field.</param>
1673         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1674         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1675         /// <since_tizen> 4 </since_tizen>
1676         public static void SendKeyEvent(KeyCode keyCode, KeyMask keyMask, bool forwardKey = false)
1677         {
1678             ErrorCode error = ImeSendKeyEvent(keyCode, keyMask, forwardKey);
1679             if (error != ErrorCode.None)
1680             {
1681                 Log.Error(LogTag, "SendEvent Failed with error " + error);
1682                 throw InputMethodExceptionFactory.CreateException(error);
1683             }
1684         }
1685
1686         /// <summary>
1687         /// Sends the text to the associated text input UI control.
1688         /// </summary>
1689         /// <privilege>
1690         /// http://tizen.org/privilege/ime
1691         /// </privilege>
1692         /// <param name="str">The string to be committed.</param>
1693         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1694         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1695         /// <since_tizen> 4 </since_tizen>
1696         public static void CommitString(string str)
1697         {
1698             ErrorCode error = ImeCommitString(str);
1699             if (error != ErrorCode.None)
1700             {
1701                 Log.Error(LogTag, "CommitString Failed with error " + error);
1702                 throw InputMethodExceptionFactory.CreateException(error);
1703             }
1704         }
1705
1706         /// <summary>
1707         /// Requests to show the pre-edit string.
1708         /// </summary>
1709         /// <privilege>
1710         /// http://tizen.org/privilege/ime
1711         /// </privilege>
1712         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1713         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1714         /// <since_tizen> 4 </since_tizen>
1715         public static void ShowPreEditString()
1716         {
1717             ErrorCode error = ImeShowPreeditString();
1718             if (error != ErrorCode.None)
1719             {
1720                 Log.Error(LogTag, "ShowPreEditString Failed with error " + error);
1721                 throw InputMethodExceptionFactory.CreateException(error);
1722             }
1723         }
1724
1725         /// <summary>
1726         /// Requests to hide the pre-edit string.
1727         /// </summary>
1728         /// <privilege>
1729         /// http://tizen.org/privilege/ime
1730         /// </privilege>
1731         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1732         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1733         /// <since_tizen> 4 </since_tizen>
1734         public static void HidePreEditString()
1735         {
1736             ErrorCode error = ImeHidePreeditString();
1737             if (error != ErrorCode.None)
1738             {
1739                 Log.Error(LogTag, "HidePreEditString Failed with error " + error);
1740                 throw InputMethodExceptionFactory.CreateException(error);
1741             }
1742         }
1743
1744         /// <summary>
1745         /// Updates a new pre-edit string.
1746         /// </summary>
1747         /// <privilege>
1748         /// http://tizen.org/privilege/ime
1749         /// </privilege>
1750         /// <param name="str">The string to be updated in pre-edit.</param>
1751         /// <param name="attrs">
1752         /// The list which has ime_preedit_attribute lists, strings can be composed of multiple string attributes: underline, highlight color, and reversal color.
1753         /// The attrs list can be empty if no attributes to set.
1754         /// </param>
1755         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1756         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1757         /// <since_tizen> 4 </since_tizen>
1758         public static void UpdatePreEditString(string str, IEnumerable<PreEditAttribute> attrs)
1759         {
1760             IntPtr einaList = IntPtr.Zero;
1761             foreach (PreEditAttribute attribute in attrs)
1762             {
1763                 IntPtr attr = IntPtr.Zero;
1764                 ImePreEditAttributeStruct imePreEditAttribute = new ImePreEditAttributeStruct();
1765                 imePreEditAttribute.start = attribute.Start;
1766                 imePreEditAttribute.length = attribute.Length;
1767                 imePreEditAttribute.type = (int)attribute.Type;
1768                 imePreEditAttribute.value = attribute.Value;
1769                 attr = Marshal.AllocHGlobal(Marshal.SizeOf(imePreEditAttribute));
1770                 Marshal.WriteIntPtr(attr, IntPtr.Zero);
1771                 Marshal.StructureToPtr(imePreEditAttribute, attr, false);
1772                 einaList = Interop.EinaList.EinaListAppend(einaList, attr);
1773             }
1774             ErrorCode error = ImeUpdatePreeditString(str, einaList);
1775             if (error != ErrorCode.None)
1776             {
1777                 Log.Error(LogTag, "UpdatePreEditString Failed with error " + error);
1778                 throw InputMethodExceptionFactory.CreateException(error);
1779             }
1780         }
1781
1782         /// <summary>
1783         /// Requests the surrounding text from the position of the cursor, asynchronously.
1784         /// </summary>
1785         /// <privilege>
1786         /// http://tizen.org/privilege/ime
1787         /// </privilege>
1788         /// <param name="maxLenBefore">The maximum length of the string to be retrieved before the cursor, -1 means unlimited.</param>
1789         /// <param name="maxLenAfter">The maximum length of the string to be retrieved after the cursor, -1 means unlimited.</param>
1790         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1791         /// <exception cref="InvalidOperationException">
1792         /// This can occur due to the following reasons:
1793         /// 1) The IME main loop has not started yet.
1794         /// 2) The necessary event is not set.
1795         /// </exception>
1796         /// <postcondition>
1797         /// The requested surrounding text can be received using the SurroundingTextUpdated event, only if it is set.
1798         /// </postcondition>
1799         /// <since_tizen> 4 </since_tizen>
1800         public static void RequestSurroundingText(int maxLenBefore, int maxLenAfter)
1801         {
1802             ErrorCode error = ImeRequestSurroundingText(maxLenBefore, maxLenAfter);
1803             if (error != ErrorCode.None)
1804             {
1805                 Log.Error(LogTag, "RequestSurroundingText Failed with error " + error);
1806                 throw InputMethodExceptionFactory.CreateException(error);
1807             }
1808         }
1809
1810         /// <summary>
1811         /// Requests to delete the surrounding text.
1812         /// </summary>
1813         /// <privilege>
1814         /// http://tizen.org/privilege/ime
1815         /// </privilege>
1816         /// <param name="offset">The offset value from the cursor position.</param>
1817         /// <param name="len">The length of the text to delete.</param>
1818         /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
1819         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1820         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1821         /// <since_tizen> 4 </since_tizen>
1822         public static void DeleteSurroundingText(int offset, int len)
1823         {
1824             ErrorCode error = ImeDeleteSurroundingText(offset, len);
1825             if (error != ErrorCode.None)
1826             {
1827                 Log.Error(LogTag, "DeleteSurroundingText Failed with error " + error);
1828                 throw InputMethodExceptionFactory.CreateException(error);
1829             }
1830         }
1831
1832         /// <summary>
1833         /// Gets the surrounding text from the position of the cursor, synchronously.
1834         /// </summary>
1835         /// <privilege>
1836         /// http://tizen.org/privilege/ime
1837         /// </privilege>
1838         /// <param name="maxLenBefore">The maximum length of the string to be retrieved before the cursor, -1 means unlimited.</param>
1839         /// <param name="maxLenAfter">The maximum length of the string to be retrieved after the cursor, -1 means unlimited.</param>
1840         /// <param name="text">The surrounding text.</param>
1841         /// <param name="cursorPosition">The cursor position.</param>
1842         /// <exception cref="OutOfMemoryException">This exception can be due to out of memory.</exception>
1843         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1844         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1845         /// <since_tizen> 4 </since_tizen>
1846         public static void GetSurroundingText(int maxLenBefore, int maxLenAfter, out string text, out int cursorPosition)
1847         {
1848             IntPtr txt;
1849             ErrorCode error = ImeGetSurroundingText(maxLenBefore, maxLenAfter, out txt, out cursorPosition);
1850             if (error != ErrorCode.None)
1851             {
1852                 Log.Error(LogTag, "GetSurroundingText Failed with error " + error);
1853                 throw InputMethodExceptionFactory.CreateException(error);
1854             }
1855             text = Marshal.PtrToStringAnsi(txt);
1856         }
1857
1858         /// <summary>
1859         /// Requests to set the selection.
1860         /// </summary>
1861         /// <privilege>
1862         /// http://tizen.org/privilege/ime
1863         /// </privilege>
1864         /// <param name="start">The start cursor position in text (in characters not bytes).</param>
1865         /// <param name="end">The end cursor position in text (in characters not bytes).</param>
1866         /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
1867         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1868         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1869         /// <since_tizen> 4 </since_tizen>
1870         public static void SetSelection(int start, int end)
1871         {
1872             ErrorCode error = ImeSetSelection(start, end);
1873             if (error != ErrorCode.None)
1874             {
1875                 Log.Error(LogTag, "SetSelection Failed with error " + error);
1876                 throw InputMethodExceptionFactory.CreateException(error);
1877             }
1878         }
1879
1880         /// <summary>
1881         /// This API returns the input panel main window.
1882         /// </summary>
1883         /// <privilege>
1884         /// http://tizen.org/privilege/ime
1885         /// </privilege>
1886         /// <returns>The input panel main window object on success, otherwise null.</returns>
1887         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1888         /// <exception cref="InvalidOperationException">
1889         /// This can occur due to the following reasons:
1890         /// 1) The IME main loop has not started yet.
1891         /// 2) Operation failed.
1892         /// </exception>
1893         /// <since_tizen> 4 </since_tizen>
1894         public static EditorWindow GetMainWindow()
1895         {
1896             EditorWindow._handle = ImeGetMainWindow();
1897             EditorWindow obj = new EditorWindow();
1898             ErrorCode error = (ErrorCode)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
1899             if (error != ErrorCode.None)
1900             {
1901                 Log.Error(LogTag, "GetMainWindow Failed with error " + error);
1902                 throw InputMethodExceptionFactory.CreateException(error);
1903             }
1904             return obj;
1905         }
1906
1907         /// <summary>
1908         /// Sends the request to hide the IME.
1909         /// </summary>
1910         /// <privilege>
1911         /// http://tizen.org/privilege/ime
1912         /// </privilege>
1913         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1914         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1915         /// <since_tizen> 5 </since_tizen>
1916         public static void RequestHide()
1917         {
1918             ErrorCode error = ImeRequestHide();
1919             if (error != ErrorCode.None)
1920             {
1921                 Log.Error(LogTag, "RequestHide Failed with error " + error);
1922                 throw InputMethodExceptionFactory.CreateException(error);
1923             }
1924         }
1925
1926         /// <summary>
1927         /// This API requests the InputMethodEditor to initialize.
1928         /// </summary>
1929         /// <privilege>
1930         /// http://tizen.org/privilege/ime
1931         /// </privilege>
1932         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1933         /// <exception cref="InvalidOperationException">This exception can be due to operation failed.</exception>
1934         /// <since_tizen> 4 </since_tizen>
1935         [EditorBrowsable(EditorBrowsableState.Never)]
1936         public static void Create()
1937         {
1938             ErrorCode error = ImeInitialize();
1939             Log.Info(LogTag, "ImeInitialize result : " + error);
1940             if (error != ErrorCode.None)
1941             {
1942                 Log.Error(LogTag, "ImeInitialize Failed with error " + error);
1943                 throw InputMethodExceptionFactory.CreateException(error);
1944             }
1945
1946             error = ImePrepare();
1947             Log.Info(LogTag, "ImePrepare result : " + error);
1948             if (error != ErrorCode.None)
1949             {
1950                 Log.Error(LogTag, "ImePrepare Failed with error " + error);
1951                 throw InputMethodExceptionFactory.CreateException(error);
1952             }
1953         }
1954
1955         /// <summary>
1956         /// This API requests the InputMethodEditor to finalize.
1957         /// </summary>
1958         /// <privilege>
1959         /// http://tizen.org/privilege/ime
1960         /// </privilege>
1961         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1962         /// <since_tizen> 4 </since_tizen>
1963         [EditorBrowsable(EditorBrowsableState.Never)]
1964         public static void Destroy()
1965         {
1966             ErrorCode error = ImeFinalize();
1967             Log.Info(LogTag, "ImeFinalize result : " + error);
1968             if (error != ErrorCode.None)
1969             {
1970                 Log.Error(LogTag, "ImeFinalize Failed with error " + error);
1971                 throw InputMethodExceptionFactory.CreateException(error);
1972             }
1973         }
1974
1975         /// <summary>
1976         /// Sets the floating mode to on or off.
1977         /// </summary>
1978         /// <privilege>
1979         /// http://tizen.org/privilege/ime
1980         /// </privilege>
1981         /// <param name="floatingMode"><c>true</c> to set the floating mode to on and <c>false</c> to set it to off.</param>
1982         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
1983         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
1984         /// <since_tizen> 5 </since_tizen>
1985         public static void SetFloatingMode(bool floatingMode)
1986         {
1987             ErrorCode error = ImeSetFloatingMode(floatingMode);
1988             if (error != ErrorCode.None)
1989             {
1990                 Log.Error(LogTag, "SetFloatingMode Failed with error " + error);
1991                 throw InputMethodExceptionFactory.CreateException(error);
1992             }
1993         }
1994
1995         /// <summary>
1996         /// Allows the floating input panel window to move along with the mouse pointer when the mouse is pressed.
1997         /// </summary>
1998         /// <privilege>
1999         /// http://tizen.org/privilege/ime
2000         /// </privilege>
2001         /// <remarks>
2002         /// This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect.
2003         /// </remarks>
2004         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2005         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2006         /// <since_tizen> 5 </since_tizen>
2007         public static void SetFloatingDragStart()
2008         {
2009             ErrorCode error = ImeSetFloatingDragStart();
2010             if (error != ErrorCode.None)
2011             {
2012                 Log.Error(LogTag, "SetFloatingDragStart Failed with error " + error);
2013                 throw InputMethodExceptionFactory.CreateException(error);
2014             }
2015         }
2016
2017         /// <summary>
2018         /// Does not allow the movement of the floating input panel window with the mouse pointer when the mouse is pressed.
2019         /// </summary>
2020         /// <privilege>
2021         /// http://tizen.org/privilege/ime
2022         /// </privilege>
2023         /// <remarks>
2024         /// This function can be used in floating mode. If the floating mode is deactivated, calling this function has no effect.
2025         /// </remarks>
2026         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2027         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2028         /// <since_tizen> 5 </since_tizen>
2029         public static void SetFloatingDragEnd()
2030         {
2031             ErrorCode error = ImeSetFloatingDragEnd();
2032             if (error != ErrorCode.None)
2033             {
2034                 Log.Error(LogTag, "SetFloatingDragEnd Failed with error " + error);
2035                 throw InputMethodExceptionFactory.CreateException(error);
2036             }
2037         }
2038
2039         /// <summary>
2040         /// Notifies the changed language of the input panel to the the associated text input UI control.
2041         /// </summary>
2042         /// <privilege>
2043         /// http://tizen.org/privilege/ime
2044         /// </privilege>
2045         /// <remarks>
2046         /// LanguageRequestedCallback is raised after this API is called when the App requests changed language information.
2047         /// </remarks>
2048         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2049         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2050         /// <since_tizen> 6 </since_tizen>
2051         public static void SendLanguageUpdated()
2052         {
2053             ErrorCode error = ImeUpdateInputPanelEvent(ImeEventType.Language, 0);
2054             if (error != ErrorCode.None)
2055             {
2056                 Log.Error(LogTag, "SendLanguageUpdated Failed with error " + error);
2057                 throw InputMethodExceptionFactory.CreateException(error);
2058             }
2059         }
2060
2061         /// <summary>
2062         /// Sends the changed shift mode of the input panel to the the associated text input UI control.
2063         /// </summary>
2064         /// <privilege>
2065         /// http://tizen.org/privilege/ime
2066         /// </privilege>
2067         /// <param name="enable"><c>true</c> if shift button is clicked, otherwise <c>false</c>.</param>
2068         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2069         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2070         /// <since_tizen> 6 </since_tizen>
2071         public static void SendShiftModeUpdated(bool enable)
2072         {
2073             ErrorCode error = ImeUpdateInputPanelEvent(ImeEventType.ShiftMode, enable ? (uint)ImeShiftMode.On : (uint)ImeShiftMode.Off);
2074             if (error != ErrorCode.None)
2075             {
2076                 Log.Error(LogTag, "SendInputPanelEvent Failed with error " + error);
2077                 throw InputMethodExceptionFactory.CreateException(error);
2078             }
2079         }
2080
2081         /// <summary>
2082         /// Notifies the changed geometry of input panel window to the associated text input UI control.
2083         /// </summary>
2084         /// <privilege>
2085         /// http://tizen.org/privilege/ime
2086         /// </privilege>
2087         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2088         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2089         /// <since_tizen> 6 </since_tizen>
2090         public static void SendCustomGeometryUpdated()
2091         {
2092             ErrorCode error = ImeUpdateInputPanelEvent(ImeEventType.Geometry, 0);
2093             if (error != ErrorCode.None)
2094             {
2095                 Log.Error(LogTag, "SendCustomGeometryUpdated Failed with error " + error);
2096                 throw InputMethodExceptionFactory.CreateException(error);
2097             }
2098         }
2099
2100         /// <summary>
2101         /// Gets the selected text synchronously.
2102         /// </summary>
2103         /// <privilege>
2104         /// http://tizen.org/privilege/ime
2105         /// </privilege>
2106         /// <returns>The selected text.</returns>
2107         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2108         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2109         /// <since_tizen> 6 </since_tizen>
2110         public static string GetSelectedText()
2111         {
2112             IntPtr txt;
2113             ErrorCode error = ImeGetSelectedText(out txt);
2114             if (error != ErrorCode.None)
2115             {
2116                 Log.Error(LogTag, "GetSelectedText Failed with error " + error);
2117                 throw InputMethodExceptionFactory.CreateException(error);
2118             }
2119             return Marshal.PtrToStringAnsi(txt);
2120         }
2121
2122         /// <summary>
2123         /// Called to set the prediction hint string to deliver to the input panel.
2124         /// </summary>
2125         /// <since_tizen> 6 </since_tizen>
2126         public static event EventHandler<PredictionHintUpdatedEventArgs> PredictionHintUpdated
2127         {
2128             add
2129             {
2130                 if (_imePredictionHintSetDelegate == null)
2131                 {
2132                     _imePredictionHintSetDelegate = (IntPtr predictionHint, IntPtr userData) =>
2133                     {
2134                         PredictionHintUpdatedEventArgs args = new PredictionHintUpdatedEventArgs(Marshal.PtrToStringAnsi(predictionHint));
2135                         _predictionHintUpdated?.Invoke(null, args);
2136                     };
2137                     ErrorCode error = ImeEventSetPredictionHintSetCb(_imePredictionHintSetDelegate, IntPtr.Zero);
2138                     if (error != ErrorCode.None)
2139                     {
2140                         Log.Error(LogTag, "Add PredictionHintUpdated Failed with error " + error);
2141                     }
2142                 }
2143                 _predictionHintUpdated += value;
2144             }
2145             remove
2146             {
2147                 _predictionHintUpdated -= value;
2148             }
2149         }
2150
2151         /// <summary>
2152         /// Called to set the prediction hint key and value to deliver to the input panel.
2153         /// </summary>
2154         /// <since_tizen> 6 </since_tizen>
2155         public static event EventHandler<PredictionHintDataUpdatedEventArgs> PredictionHintDataUpdated
2156         {
2157             add
2158             {
2159                 if (_imePredictionHintDataSetDelegate == null)
2160                 {
2161                     _imePredictionHintDataSetDelegate = (IntPtr key, IntPtr keyValue, IntPtr userData) =>
2162                     {
2163                         PredictionHintDataUpdatedEventArgs args = new PredictionHintDataUpdatedEventArgs(Marshal.PtrToStringAnsi(key), Marshal.PtrToStringAnsi(keyValue));
2164                         _predictionHintDataUpdated?.Invoke(null, args);
2165                     };
2166
2167                     ErrorCode error = ImeEventSetPredictionHintDataSetCb(_imePredictionHintDataSetDelegate, IntPtr.Zero);
2168                     if (error != ErrorCode.None)
2169                     {
2170                         Log.Error(LogTag, "Add PredictionHintDataUpdated Failed with error " + error);
2171                     }
2172                 }
2173                 _predictionHintDataUpdated += value;
2174             }
2175             remove
2176             {
2177                 _predictionHintDataUpdated -= value;
2178             }
2179         }
2180
2181         /// <summary>
2182         /// Called when an associated text input UI control requests the text entry to set the MIME type.
2183         /// </summary>
2184         /// <since_tizen> 6 </since_tizen>
2185         public static event EventHandler<MimeTypeUpdateRequestedEventArgs> MimeTypeUpdateRequested
2186         {
2187             add
2188             {
2189                 if (_imeMimeTypeSetRequestDelegate == null)
2190                 {
2191                     _imeMimeTypeSetRequestDelegate = (IntPtr mimeType, IntPtr userData) =>
2192                     {
2193                         MimeTypeUpdateRequestedEventArgs args = new MimeTypeUpdateRequestedEventArgs(Marshal.PtrToStringAnsi(mimeType));
2194                         _mimeTypeUpdateRequested?.Invoke(null, args);
2195                     };
2196                     ErrorCode error = ImeEventSetMimeTypeSetRequestCb(_imeMimeTypeSetRequestDelegate, IntPtr.Zero);
2197                     if (error != ErrorCode.None)
2198                     {
2199                         Log.Error(LogTag, "Add MimeTypeUpdateRequested Failed with error " + error);
2200                     }
2201                 }
2202                 _mimeTypeUpdateRequested += value;
2203             }
2204             remove
2205             {
2206                 _mimeTypeUpdateRequested -= value;
2207             }
2208         }
2209
2210         /// <summary>
2211         /// Sends a private command to the associated text input UI control.
2212         /// </summary>
2213         /// <privilege>
2214         /// http://tizen.org/privilege/ime
2215         /// </privilege>
2216         /// <param name="command">The UTF-8 string to be sent.</param>
2217         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2218         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2219         /// <since_tizen> 6 </since_tizen>
2220         public static void SendPrivateCommand(string command)
2221         {
2222             ErrorCode error = ImeSendPrivateCommand(command);
2223             if (error != ErrorCode.None)
2224             {
2225                 Log.Error(LogTag, "SendPrivateCommand Failed with error " + error);
2226                 throw InputMethodExceptionFactory.CreateException(error);
2227             }
2228         }
2229
2230         /// <summary>
2231         /// Commits contents such as image to the associated text input UI control.
2232         /// </summary>
2233         /// <privilege>
2234         /// http://tizen.org/privilege/ime
2235         /// </privilege>
2236         /// <param name="content">The content URI to be sent.</param>
2237         /// <param name="description">The content description.</param>
2238         /// <param name="mimeType">The MIME type received from the MimeTypeSetRequest</param>
2239         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2240         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2241         /// <since_tizen> 6 </since_tizen>
2242         public static void CommitContent(string content, string description, string mimeType)
2243         {
2244             ErrorCode error = ImeCommitContent(content, description, mimeType);
2245             if (error != ErrorCode.None)
2246             {
2247                 Log.Error(LogTag, "CommitContent Failed with error " + error);
2248                 throw InputMethodExceptionFactory.CreateException(error);
2249             }
2250         }
2251
2252         /// <summary>
2253         /// This API updates the given native input panel window's size information.
2254         /// The native window handle of NUI Window can be got by below code.
2255         /// var handle = new Window.SafeNativeWindowHandle();
2256         /// IntPtr nativeHandle = handle.DangerousGetHandle();
2257         /// </summary>
2258         /// <privilege>
2259         /// http://tizen.org/privilege/ime
2260         /// </privilege>
2261         /// <param name="window">The native window handle.</param>
2262         /// <param name="portraitWidth">The width in the portrait mode.</param>
2263         /// <param name="portraitHeight">The height in the portrait mode.</param>
2264         /// <param name="landscapeWidth">The width in the landscape mode.</param>
2265         /// <param name="landscapeHeight">The height in the landscape mode.</param>
2266         /// <exception cref="ArgumentException">This exception can be due to an invalid parameter.</exception>
2267         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2268         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2269         /// <since_tizen> 9 </since_tizen>
2270         public static void SetSize(IntPtr window, int portraitWidth, int portraitHeight, int landscapeWidth, int landscapeHeight)
2271         {
2272             ErrorCode error = ImeSetNativeWindowSize(window, portraitWidth, portraitHeight, landscapeWidth, landscapeHeight);
2273             if (error != ErrorCode.None)
2274             {
2275                 Log.Error(LogTag, "SetSize Failed with error " + error);
2276                 throw InputMethodExceptionFactory.CreateException(error);
2277             }
2278         }
2279
2280         /// <summary>
2281         /// Sets the processKey action.
2282         /// If the key event is from the external device, DeviceInfo will have its name, class, and subclass information.
2283         /// </summary>
2284         /// <param name="processKey">
2285         /// <c>true</c> if the event was processed, otherwise the event was not processed and was forwarded to the client application.
2286         /// The first parameter is X11 key code and the second parameter is key symbol.
2287         /// The action is called when the key event is received from the external devices or the SendKey function.
2288         /// This Event processes the key event before an associated text input UI control does.
2289         /// </param>
2290         /// <since_tizen> 10 </since_tizen>
2291         public static void SetProcessKeyCallback(BoolAction<uint, KeyCode, KeyMask, InputMethodDeviceInformation> processKey)
2292         {
2293             _imeProcessKeyWithKeycodeDelegate = (uint keyCode, KeyCode keySymbol, KeyMask keyMask, IntPtr devInfo, IntPtr userData) =>
2294             {
2295                 return _processKeyWithKeycodeDelagate(keyCode, keySymbol, keyMask, new InputMethodDeviceInformation(devInfo));
2296             };
2297             ErrorCode error = ImeEventSetProcessKeyEventWithKeycodeCb(_imeProcessKeyWithKeycodeDelegate, IntPtr.Zero);
2298             if (error != ErrorCode.None)
2299             {
2300                 Log.Error(LogTag, "Add ProcessKeyWithKeycode Failed with error " + error);
2301             }
2302             _processKeyWithKeycodeDelagate = processKey;
2303         }
2304
2305         /// <summary>
2306         /// Updates the cursor position in the preedit string.
2307         /// </summary>
2308         /// <privilege>
2309         /// http://tizen.org/privilege/ime
2310         /// </privilege>
2311         /// <param name="position">The cursor position in the preedit string.</param>
2312         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2313         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2314         /// <since_tizen> 10 </since_tizen>
2315         public static void UpdatePreeditCursor(uint position)
2316         {
2317             ErrorCode error = ImeUpdatePreeditCursor(position);
2318             if (error != ErrorCode.None)
2319             {
2320                 Log.Error(LogTag, "UpdatePreeditCursor Failed with error " + error);
2321                 throw InputMethodExceptionFactory.CreateException(error);
2322             }
2323         }
2324
2325         /// <summary>
2326         /// Sets whether candidate strings will be shown or not.
2327         /// </summary>
2328         /// <privilege>
2329         /// http://tizen.org/privilege/ime
2330         /// </privilege>
2331         /// <param name="visible"><c>true</c> to show candidate strings, <c>false</c> otherwise.</param>
2332         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
2333         /// <exception cref="InvalidOperationException">The IME main loop has not started yet.</exception>
2334         /// <since_tizen> 10 </since_tizen>
2335         public static void SetCandidateVisibilityState(bool visible)
2336         {
2337             ErrorCode error = ImeSetCandidateVisibilityState(visible);
2338             if (error != ErrorCode.None)
2339             {
2340                 Log.Error(LogTag, "SetCandidateVisibilityState Failed with error " + error);
2341                 throw InputMethodExceptionFactory.CreateException(error);
2342             }
2343         }
2344
2345         /// <summary>
2346         /// Called when an associated text input UI control requests the input panel to set its input hint.
2347         /// It will only be called when the client application changes the edit field's input hint attribute after the input panel is shown.
2348         /// </summary>
2349         /// <seealso cref="InputHints"/>
2350         /// <since_tizen> 10 </since_tizen>
2351         public static event EventHandler<InputHintSetEventArgs> InputHintSet
2352         {
2353             add
2354             {
2355                 _imeInputHintSetDelegate = (InputHints hint, IntPtr userData) =>
2356                 {
2357                     InputHintSetEventArgs args = new InputHintSetEventArgs(hint);
2358                     _inputHintSet?.Invoke(null, args);
2359                 };
2360                 ErrorCode error = ImeEventSetInputHintSetCb(_imeInputHintSetDelegate, IntPtr.Zero);
2361                 if (error != ErrorCode.None)
2362                 {
2363                     Log.Error(LogTag, "Add InputHintSet Failed with error " + error);
2364                 }
2365                 else
2366                 {
2367                     _inputHintSet += value;
2368                 }
2369             }
2370             remove
2371             {
2372                 _inputHintSet -= value;
2373             }
2374         }
2375     }
2376 }