Пример #1
0
 private void commitText(string text)
 {
     OnNewImeComposition?.Invoke(text);
     OnNewImeResult?.Invoke(text);
 }
Пример #2
0
 private void imeResult()
 {
     //todo: implement
     OnNewImeResult?.Invoke(string.Empty);
 }
Пример #3
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case WM_CONTEXTMENU:
                return;

            case WM_IME_STARTCOMPOSITION:
                imeActive = true;

                OnImeActivity?.Invoke(true);
                return;

            case WM_IME_ENDCOMPOSITION:
                imeActive = false;
                //ImeDeactivateTime = OsuGame.Time;

                OnImeActivity?.Invoke(false);
                return;

            case WM_IME_COMPOSITION:
                string str = string.Empty;

                if (((int)m.LParam & GCS_RESULTSTR) > 0)
                {
                    str = getIMEString(GCS_RESULTSTR);
                    OnNewImeResult?.Invoke(str);
                }

                if (((int)m.LParam & GCS_COMPSTR) > 0)
                {
                    str = getIMEString(GCS_COMPSTR);
                    OnNewImeComposition?.Invoke(str);
                }

                if (string.IsNullOrEmpty(str))
                {
                    OnNewImeComposition?.Invoke(str);
                }
                return;

            case WM_IME_SETCONTEXT:
                m.Result = DefWindowProc(Handle, m.Msg, m.WParam, new IntPtr(~0xC000000F));
                return;

            case WM_IME_NOTIFY:

                switch ((int)m.WParam.ToInt32())
                {
                case IMN_PRIVATE:
                    return;

                case IMN_OPENCANDIDATE:
                case IMN_CHANGECANDIDATE:
                    //CandidateList candidate;
                    //IntPtr ptr;
                    //IntPtr hIMC = ImmGetContext(this.Handle);
                    //uint size = ImmGetCandidateList(hIMC, 0, IntPtr.Zero, 0);
                    //Candidates.Clear();
                    //if (size > 0)
                    //{
                    //    ptr = Marshal.AllocHGlobal((int)size);
                    //    size = ImmGetCandidateList(hIMC, 0, ptr, size);
                    //    candidate = (CandidateList)Marshal.PtrToStructure(ptr, typeof(CandidateList));
                    //    if (candidate.dwCount > 1)
                    //    {
                    //        for (int i = (int)candidate.dwPageStart; i < candidate.dwCount; i++)
                    //        {
                    //            //Notice:only support up to 10 candidates now.
                    //            if (i - candidate.dwPageStart > candidate.dwPageSize - 1)
                    //                break;
                    //            int stringOffset = Marshal.ReadInt32(ptr, 24 + 4 * i);
                    //            IntPtr addr = (IntPtr)(ptr.ToInt32() + stringOffset);
                    //            string caStr = Marshal.PtrToStringUni(addr);
                    //            Candidates.Add(caStr);
                    //        }
                    //    }
                    //    Marshal.FreeHGlobal(ptr);
                    //}
                    //ImmReleaseContext(this.Handle, hIMC);
                    return;

                case IMN_CLOSECANDIDATE:
                    Candidates.Clear();
                    return;
                }
                break;
            }

            base.WndProc(ref m);
        }