Beispiel #1
0
        /// <summary>
        /// Handle when IMESample is created
        /// </summary>
        protected override void OnCreate()
        {
            base.OnCreate();
            InputMethodEditor.Create();
            // Set the necessary callback functions
            RegisterCallback();

            Window.Instance.KeyEvent += OnKeyEvent;
            Window.Instance.Resized  += OnResized;
        }
Beispiel #2
0
        protected override void OnPreCreate()
        {
            Application.ClearCurrent();

            /*
             * Since the IMEWindow class acquires window handle from InputMethod module and
             * the handle is created internally when calling InputMethodEditor.Create() function,
             * this needs to be called BEFORE creating new IMEWindow instance.
             */
            InputMethodEditor.Create();
            MainWindow = InputMethodEditor.GetMainWindow();
            MainWindow.IndicatorMode = IndicatorMode.Hide;
        }
Beispiel #3
0
 /// <summary>
 /// The main entrance of the application
 /// </summary>
 /// <param name="args"> The string arguments. </param>
 static void Main(string[] args)
 {
     try
     {
         // start inputmethod
         InputMethodEditor.Run(Create, Terminate, Show, Hide);
         var app = new IMESample("", WindowMode.Opaque, WindowType.Ime);
         app.Run(args);
     }
     catch (Exception e)
     {
         Log.Info("IMESample", "Inputmethod Run error : Caught Exception " + e.ToString());
     }
 }
 /// <summary>
 /// The main entrance of the application.
 /// </summary>
 /// <param name="args"> The string arguments. </param>
 static void Main(string[] args)
 {
     try
     {
         // Set the necessary callback functions
         RegisterCallback();
         // start inputmethod
         InputMethodEditor.Run(Create, Terminate, Show, Hide);
         app = new Program();
         global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
         app.Run(args);
     }
     catch (Exception e)
     {
         Log.Info("IMESample", "Inputmethod Run error : Caught Exception " + e.ToString());
     }
 }
 /// <summary>
 /// The main entrance of the application.
 /// </summary>
 /// <param name="args"> The string arguments. </param>
 static void Main(string[] args)
 {
     try
     {
         // Set the necessary callback functions
         RegisterCallback();
         // start inputmethod
         InputMethodEditor.Run(Create, Terminate, Show, Hide);
         app = new Program();
         // If there is no code below, the IME's window will be circular.
         Xamarin.Forms.Platform.Tizen.Forms.SetFlags("LightweightPlatform_Experimental");
         global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);
         app.Run(args);
     }
     catch (Exception e)
     {
         Log.Info("IMESample", "Inputmethod Run error : Caught Exception " + e.ToString());
     }
 }
Beispiel #6
0
 protected override void OnTerminate()
 {
     InputMethodEditor.Destroy();
     base.OnTerminate();
 }
        /// <summary>
        /// Default class constructor.
        /// </summary>
        public MainPageViewModel()
        {
            MainLabel = new string[KeyLen];

            Array.Copy(LowerCase, MainLabel, MainLabel.Length);

            ShiftStatus       = IMEShiftStates.ShiftOff;
            LayoutType        = IMEKeyboardLayoutType.LayoutEnglish;
            LayoutString      = "?123";
            ShiftImage        = "sample_ime_shift_off.png";
            SymText           = "";
            ShiftImageOpacity = 1;
            ShiftBgImageColor = "Gray";

            this.Backspace = new Command(() =>
            {
                // Send a backspace key event.
                InputMethodEditor.SendKeyEvent(KeyCode.BackSpace, KeyMask.Pressed);
                InputMethodEditor.SendKeyEvent(KeyCode.BackSpace, KeyMask.Released);
            });
            this.PressButton = new Command((value) =>
            {
                string input = value.ToString();
                // Sending input text data.
                InputMethodEditor.CommitString(input);
                if (LayoutType == IMEKeyboardLayoutType.LayoutEnglish && ShiftStatus == IMEShiftStates.ShiftOn)
                {
                    Array.Copy(LowerCase, MainLabel, MainLabel.Length);
                    ShiftStatus = IMEShiftStates.ShiftOff;
                    ShiftImage  = "sample_ime_shift_off.png";
                    UpdateDisplay();
                }
            });
            this.ReturnButton = new Command(() =>
            {
                // Send a return key event.
                InputMethodEditor.SendKeyEvent(KeyCode.Return, KeyMask.Pressed);
                InputMethodEditor.SendKeyEvent(KeyCode.Return, KeyMask.Released);
            });
            this.ShiftButton = new Command(() =>
            {
                if (LayoutType == IMEKeyboardLayoutType.LayoutEnglish)
                {
                    SymText           = "";
                    ShiftImageOpacity = 1;
                    if (ShiftStatus == IMEShiftStates.ShiftOff)
                    {
                        Array.Copy(UpperCase, MainLabel, MainLabel.Length);
                        ShiftStatus       = IMEShiftStates.ShiftOn;
                        ShiftImage        = "sample_ime_shift_on.png";
                        ShiftBgImageColor = "Gray";
                        UpdateDisplay();
                    }
                    else if (ShiftStatus == IMEShiftStates.ShiftOn)
                    {
                        Array.Copy(UpperCase, MainLabel, MainLabel.Length);
                        ShiftStatus       = IMEShiftStates.ShiftLock;
                        ShiftImage        = "sample_ime_shift_loc.png";
                        ShiftBgImageColor = "DeepSkyBlue";
                        UpdateDisplay();
                    }
                    else if (ShiftStatus == IMEShiftStates.ShiftLock)
                    {
                        Array.Copy(LowerCase, MainLabel, MainLabel.Length);
                        ShiftStatus       = IMEShiftStates.ShiftOff;
                        ShiftImage        = "sample_ime_shift_off.png";
                        ShiftBgImageColor = "Gray";
                        UpdateDisplay();
                    }
                }
                else if (LayoutType == IMEKeyboardLayoutType.LayoutSym2)
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutSym1;
                    Array.Copy(Symbol1, MainLabel, MainLabel.Length);
                    SymText           = "1/2";
                    ShiftImageOpacity = 0;
                    ShiftBgImageColor = "Gray";
                    UpdateDisplay();
                }
                else
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutSym2;
                    Array.Copy(Symbol2, MainLabel, MainLabel.Length);
                    SymText           = "2/2";
                    ShiftImageOpacity = 0;
                    ShiftBgImageColor = "Gray";
                    UpdateDisplay();
                }
            });
            this.LayoutButton = new Command(() =>
            {
                if (LayoutType == IMEKeyboardLayoutType.LayoutEnglish)
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutSym1;
                    Array.Copy(Symbol1, MainLabel, MainLabel.Length);
                    LayoutString      = "abc";
                    SymText           = "1/2";
                    ShiftImageOpacity = 0;
                    ShiftBgImageColor = "Gray";
                    UpdateDisplay();
                }
                else if (LayoutType == IMEKeyboardLayoutType.LayoutSym1 || LayoutType == IMEKeyboardLayoutType.LayoutSym2)
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutEnglish;
                    Array.Copy(LowerCase, MainLabel, MainLabel.Length);
                    LayoutString      = "?123";
                    SymText           = "";
                    ShiftBgImageColor = "Gray";
                    ShiftImage        = "sample_ime_shift_off.png";
                    ShiftImageOpacity = 1;
                    UpdateDisplay();
                }
            });
        }
Beispiel #8
0
        /// <summary>
        /// Sets IME window position and size
        /// </summary>
        private static void SetScreenSize()
        {
            IntPtr nativeHandle = new Window.SafeNativeWindowHandle().DangerousGetHandle();

            InputMethodEditor.SetSize(nativeHandle, 720, 442, 1280, 380);
        }
        /// <summary>
        /// Default class constructor
        /// </summary>
        public MainViewModel()
        {
            MainLabel = new string[KeyLen];
            Array.Copy(LowerCase, MainLabel, MainLabel.Length);
            ShiftStatus    = IMEShiftStates.ShiftOff;
            ShiftImage     = ImageURL + "shift_off.png";
            BackSpaceImage = ImageURL + "back_space_normal.png";
            SpaceImage     = ImageURL + "space_normal.png";
            ReturnImage    = ImageURL + "enter_normal.png";
            LayoutString   = "?123";
            SymText        = "";

            /// <summary>
            /// Process text button event
            /// </summary>
            this.PressButton = new Command((value) =>
            {
                string text = value.ToString();
                Log.Info("IMESample", "PressButton: Text : " + text);
                InputMethodEditor.CommitString(text);
                if (LayoutType == IMEKeyboardLayoutType.LayoutEnglish && ShiftStatus == IMEShiftStates.ShiftOn)
                {
                    Array.Copy(LowerCase, MainLabel, MainLabel.Length);
                    ShiftStatus = IMEShiftStates.ShiftOff;
                    ShiftImage  = ImageURL + "shift_off.png";
                    UpdateDisplay();
                }
            });

            /// <summary>
            /// Process shift button event
            /// </summary>
            this.ShiftButton = new Command(() =>
            {
                Log.Info("IMESample", "ShiftButton Clicked.");
                if (LayoutType == IMEKeyboardLayoutType.LayoutEnglish)
                {
                    SymText = "";
                    switch (ShiftStatus)
                    {
                    case IMEShiftStates.ShiftOff:
                        Array.Copy(UpperCase, MainLabel, MainLabel.Length);
                        ShiftStatus = IMEShiftStates.ShiftOn;
                        ShiftImage  = ImageURL + "shift_on.png";
                        break;

                    case IMEShiftStates.ShiftOn:
                        Array.Copy(UpperCase, MainLabel, MainLabel.Length);
                        ShiftStatus = IMEShiftStates.ShiftLock;
                        ShiftImage  = ImageURL + "shift_loc.png";
                        break;

                    case IMEShiftStates.ShiftLock:
                        Array.Copy(LowerCase, MainLabel, MainLabel.Length);
                        ShiftStatus = IMEShiftStates.ShiftOff;
                        ShiftImage  = ImageURL + "shift_off.png";
                        break;
                    }
                }
                else if (LayoutType == IMEKeyboardLayoutType.LayoutSym1)
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutSym2;
                    Array.Copy(Symbol2, MainLabel, MainLabel.Length);
                    SymText = "2/2";
                }
                else
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutSym1;
                    Array.Copy(Symbol1, MainLabel, MainLabel.Length);
                    SymText = "1/2";
                }

                UpdateDisplay();
            });

            /// <summary>
            /// Process backspace button event
            /// </summary>
            this.BackSpaceButton = new Command(() =>
            {
                Log.Info("IMESample", "BackSpaceButton Clicked.");
                InputMethodEditor.SendKeyEvent(KeyCode.BackSpace, KeyMask.Pressed);
                InputMethodEditor.SendKeyEvent(KeyCode.BackSpace, KeyMask.Released);
            });

            /// <summary>
            /// Process layout button event
            /// </summary>
            this.LayoutButton = new Command(() =>
            {
                Log.Info("IMESample", "LayoutButton Clicked.");
                if (LayoutType == IMEKeyboardLayoutType.LayoutEnglish)
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutSym1;
                    Array.Copy(Symbol1, MainLabel, MainLabel.Length);
                    LayoutString = "abc";
                    SymText      = "1/2";
                    ShiftImage   = "";
                }
                else
                {
                    LayoutType = IMEKeyboardLayoutType.LayoutEnglish;
                    Array.Copy(LowerCase, MainLabel, MainLabel.Length);
                    LayoutString = "?123";
                    SymText      = "";
                    ShiftImage   = ImageURL + "shift_off.png";
                }

                UpdateDisplay();
            });

            /// <summary>
            /// Process return button event
            /// </summary>
            this.ReturnButton = new Command(() =>
            {
                Log.Info("IMESample", "ReturnButton Clicked.");
                InputMethodEditor.SendKeyEvent(KeyCode.Return, KeyMask.Pressed);
                InputMethodEditor.SendKeyEvent(KeyCode.Return, KeyMask.Released);
            });
        }