示例#1
0
        public ComboBoxElement(ElementHostControl host, InternalTextBox textBox)
            : base(host)
        {
            m_InternalTextBox = textBox;
            m_Button          = new ComboButtonElement(host);
            m_Button.ZOrder   = 2;

            m_Button.MouseClick += delegate(object sender, MouseEventArgs e)
            {
                OnButtonClick(EventArgs.Empty);
            };
        }
        private void OnInternalTextBoxLoaded(object sender, RoutedEventArgs e)
        {
            cursorScreenPosition.X -= (double)this.GetValue(Canvas.LeftProperty);
            cursorScreenPosition.Y -= (double)this.GetValue(Canvas.TopProperty);

            int index = InternalTextBox.GetCharacterIndexFromPoint(cursorScreenPosition, true);

            if (index >= 0)
            {
                Rect   left          = InternalTextBox.GetRectFromCharacterIndex(index, false);
                Rect   right         = InternalTextBox.GetRectFromCharacterIndex(index, true);
                double x             = cursorScreenPosition.X;
                bool   closerToFront = (x - left.Left < (right.Right - x));
                if (false == closerToFront)
                {
                    index = index + 1;
                }
            }

            if (index >= 0)
            {
                InternalTextBox.CaretIndex = index;
            }
            InternalTextBox.Focusable  = true;
            InternalTextBox.Visibility = Visibility.Visible;
            if (isInNormalTextStage == false)
            {
                InternalTextBox.Foreground = new SolidColorBrush(Colors.Gray);
            }
            if (this.selectAll == true)
            {
                this.InternalTextBox.SelectAll();
            }
            if (this.Text == Configurations.ReplicationInitialString)
            {
                InternalTextBox.CaretIndex = 1;
            }
            InternalTextBox.Focus();
        }
示例#3
0
 public TextBoxElement(ElementHostControl host, InternalTextBox textBox)
     : base(host)
 {
     m_InternalTextBox = textBox;
 }