Exemple #1
0
        private static void IMEControl_GetCompExtEvent(refRECT rect)
        {
            ITextBox textBox_ = Game1.keyboardDispatcher.Subscriber as ITextBox;
            TextBox  textBox  = Game1.keyboardDispatcher.Subscriber as TextBox;

            if (textBox == null)
            {
                return;
            }

            Vector2 vector2 = textBox.Font.MeasureString(comp.text);

            if (textBox_ != null)
            {
                Acp  acp     = textBox_.GetSelection();
                RECT CompExt = textBox_.GetTextExt(new Acp(0, acp.Start));
                rect.left = CompExt.right;
                rect.top  = CompExt.top;
            }
            else if (textBox != null)//without ITextBox interface
            {
                int strLen  = textBox is ChatTextBox ? (int)(textBox as ChatTextBox).currentWidth : (int)textBox.Font.MeasureString(textBox.Text).X;
                int xOffset = textBox.X + strLen + (textBox is ChatTextBox ? 12 : 16);
                //if without textbox, we can only insert at end
                rect.left = xOffset;
                rect.top  = textBox.Y + (textBox is ChatTextBox ? 12 : 8);
            }
            rect.right  = rect.left + (int)vector2.X;
            rect.bottom = rect.top + 32;
        }
Exemple #2
0
        private void M_compositionHandler_eventGetTextExt(refRECT rect)
        {
            Font f    = new Font("Microsoft YaHei", 20F, System.Drawing.FontStyle.Regular, GraphicsUnit.Pixel);
            Size sif  = TextRenderer.MeasureText(storedStr, f, new Size(0, 0), TextFormatFlags.NoPadding);
            Size sif2 = TextRenderer.MeasureText(compStr, f, new Size(0, 0), TextFormatFlags.NoPadding);

            //Map rect
            rect.left = label_DisplayStr.Location.X + sif.Width;
            rect.top  = label_DisplayStr.Location.Y;
            //should use Font height, because some IME draw CompStr themselves, when CompStr is Empty
            //so the candidate window wont cover the text
            rect.bottom = rect.top + f.Height;
            rect.right  = rect.left + sif2.Width;
        }