Esempio n. 1
0
        private void UpdateCompositionWindow()
        {
            string compositionString = ImeHelper.GetImmCompositionString(this.imeContext, 8);

            this.textBoxControl.Select(this.startCaretIndex, this.previousCompString.Length);
            this.textBoxControl.Insert(compositionString);
            this.previousCompString = compositionString;
            this.textBoxControl.Select(this.startCaretIndex, this.previousCompString.Length);
            TextPosition positionFromOffset = this.textBoxControl.Navigator.GetPositionFromOffset(this.startCaretIndex);
            TextPosition textPosition       = this.textBoxControl.Navigator.GetPositionFromOffset(this.startCaretIndex + 1);

            if ((object)textPosition == null)
            {
                textPosition = positionFromOffset;
            }
            TextPosition position  = textPosition;
            PointF       location1 = this.textBoxControl.ViewElement.GetLocation(positionFromOffset);
            PointF       location2 = this.textBoxControl.ViewElement.GetLocation(position);

            if ((double)location2.Y > (double)location1.Y)
            {
                location1.X = position.Line.Location.X;
                location1.Y = location2.Y;
            }
            int num = this.textBoxControl.ViewElement.Lines.Count > 0 ? (int)this.textBoxControl.ViewElement.Lines[0].Location.Y - this.textBoxControl.ViewElement.ControlBoundingRectangle.Y : 0;

            this.startCaretLocation = new Point((int)((double)location1.X + (double)this.textBoxControl.ViewElement.ScrollOffset.Width), (int)((double)location1.Y + (double)this.textBoxControl.ViewElement.ScrollOffset.Height) - num);
            this.UpdateCompositionWindowLocation(this.startCaretLocation);
        }
Esempio n. 2
0
        private IntPtr WndProc(
            IntPtr hWnd,
            int msg,
            IntPtr wParam,
            IntPtr lParam,
            ref bool handled,
            ref bool defWndProc)
        {
            switch (msg)
            {
            case 269:
                this.StartComposition();
                break;

            case 270:
                this.EndComposition();
                break;

            case 271:
                if (this.IsKorean())
                {
                    if ((int)lParam == 2048)
                    {
                        handled = !this.imeActive;
                        this.shouldRepositionCaret = true;
                        this.textBoxControl.OnIMECompositionResult(ImeHelper.GetImmCompositionString(this.imeContext, 2048));
                        break;
                    }
                    if (this.shouldRepositionCaret)
                    {
                        this.shouldRepositionCaret = false;
                        this.startCaretIndex       = this.textBoxControl.CaretIndex;
                        this.previousCompString    = string.Empty;
                        this.startCaretLocation    = new Point(this.textBoxControl.Caret.ControlBoundingRectangle.Left, this.textBoxControl.ViewElement.ControlBoundingRectangle.Top);
                        this.UpdateCompositionWindowLocation(this.startCaretLocation);
                    }
                }
                this.UpdateCompositionWindow();
                break;
            }
            return(IntPtr.Zero);
        }