Esempio n. 1
0
 void Ime_ImeReconvert(object sender, ImeReconvertStringEventArgs e)
 {
     if (this.RectSelection)
     {
         return;
     }
     if (this.Controller.SelectionLength == 0)
     {
         TextPoint tp = this.LayoutLines.GetTextPointFromIndex(this.Controller.SelectionStart);
         e.TargetString = this.LayoutLines[tp.row];
         e.AutoAdjust   = true;
     }
     else
     {
         e.TargetString = this.SelectedText;
         if (e.TargetString.Length > 40)
         {
             e.TargetString.Remove(40);
         }
     }
     e.CaretPostion = this.View.CaretLocation;
 }
Esempio n. 2
0
        unsafe private IntPtr HandleIMR_ReconvertString(IntPtr lParam)
        {
            ImeReconvertStringEventArgs e = new ImeReconvertStringEventArgs();

            this.ImeReconvert(this, e);
            RECONVERTSTRING *reconv    = (RECONVERTSTRING *)lParam.ToPointer();
            char *           paragraph = (char *)((byte *)reconv + sizeof(RECONVERTSTRING));
            int reconvlen = sizeof(RECONVERTSTRING) + e.TargetString.Length * sizeof(char);

            if (reconv != null)
            {
                reconv->dwSize            = (uint)sizeof(RECONVERTSTRING);
                reconv->dwVersion         = 0;
                reconv->dwStrLen          = (uint)e.TargetString.Length;
                reconv->dwStrOffset       = (uint)sizeof(RECONVERTSTRING);
                reconv->dwTargetStrLen    = 0;
                reconv->dwTargetStrOffset = 0;
                for (int i = 0; i < e.TargetString.Length; i++)
                {
                    paragraph[i] = e.TargetString[i];
                }
                if (e.AutoAdjust)
                {
                    IntPtr ime = ImmGetContext(this.Handle);
                    ImmSetCompositionStringW(ime, SCS_QUERYRECONVERTSTRING, reconv, (uint)reconvlen, (void *)IntPtr.Zero, 0);
                    ImmReleaseContext(this.Handle, ime);
                    this.ImeQueryReconvert(this, new ImeQueryRecovertStringEventArgs((int)reconv->dwTargetStrOffset, (int)reconv->dwTargetStrLen));
                }
                else
                {
                    reconv->dwCompStrLen    = (uint)e.TargetString.Length;
                    reconv->dwCompStrOffset = 0;
                }

                this.Location = e.CaretPostion;
            }
            return(new IntPtr(reconvlen));
        }