當前位置: 首頁>>代碼示例>>C#>>正文


C# TextBox.GetRectFromCharacterIndex方法代碼示例

本文整理匯總了C#中System.Windows.Controls.TextBox.GetRectFromCharacterIndex方法的典型用法代碼示例。如果您正苦於以下問題:C# TextBox.GetRectFromCharacterIndex方法的具體用法?C# TextBox.GetRectFromCharacterIndex怎麽用?C# TextBox.GetRectFromCharacterIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Controls.TextBox的用法示例。


在下文中一共展示了TextBox.GetRectFromCharacterIndex方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PositionCaret

        private static void PositionCaret(TextBox textBox, UIElement caretElement)
        {
            var caretLocation = textBox.GetRectFromCharacterIndex(textBox.Text.Length).Location;

            if (!double.IsInfinity(caretLocation.X))
            {
                Canvas.SetLeft(caretElement, caretLocation.X);
            }

            if (!double.IsInfinity(caretLocation.Y))
            {
                Canvas.SetTop(caretElement, caretLocation.Y);
            }
        }
開發者ID:masonyang,項目名稱:OptiKey,代碼行數:14,代碼來源:TextBoxBehaviours.cs

示例2: GetCaretIndexFromPoint

		private static int GetCaretIndexFromPoint(TextBox textBox, Point point)
		{
			var index = textBox.GetCharacterIndexFromPoint(point, true);

			if (index != textBox.Text.Length - 1)
				return index;

			var caretRect = textBox.GetRectFromCharacterIndex(index);
			var caretPoint = new Point(caretRect.X, caretRect.Y);

			if (point.X > caretPoint.X)
				index += 1;

			return index;
		}
開發者ID:kknet,項目名稱:StockSharp,代碼行數:15,代碼來源:CompositeSecurityPanel.xaml.cs

示例3: AutoReplace

        private void AutoReplace(TextBox txt)
        {
            string GotLastWord = "";
            string ReplacedWord = "";
            int lastWord = txt.Text.LastIndexOf(" ");
            lastWord = lastWord + 1;
            GotLastWord = txt.Text.Substring(lastWord);

            if (Abbrev.ContainsKey(GotLastWord))
            {
                ReplacedWord = GotLastWord.Replace(GotLastWord, Abbrev[GotLastWord]);
                txt.Text = txt.Text.Replace(GotLastWord, ReplacedWord);
                txt.SelectionStart = txt.Text.Length;
                txt.GetRectFromCharacterIndex(txt.CaretIndex);
            }
        }
開發者ID:RickTek,項目名稱:AHT-Buddy,代碼行數:16,代碼來源:MainWindow.xaml.cs

示例4: GetCharacterIndexFromPoint

        // This method is to workaround the fact that textbox.GetCharacterIndexFromPoint returns the caret
        // to the left of the character... Thus you can never get the caret after the last character in the
        // expression string.
        int GetCharacterIndexFromPoint(TextBox textbox)
        {
            Point position = Mouse.GetPosition(textbox);
            int index = textbox.GetCharacterIndexFromPoint(position, false);

            if (index < 0)
            {
                // May have clicked outside the text area, get the index of nearest char
                index = textbox.GetCharacterIndexFromPoint(position, true);
                if (index < 0)
                {
                    index = 0;
                }

                // Adjust the cursor position if we clicked to the right of returned character
                Rect charRect = textbox.GetRectFromCharacterIndex(index, true);
                if (position.X > charRect.Left + charRect.Width / 2)
                {
                    index++;
                }
            }

            return index;
        }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:27,代碼來源:VisualBasicEditor.xaml.cs

示例5: OpenPopup

 private static void OpenPopup(TextBox textBox, Popup popup, int index)
 {
     popup.PlacementTarget = textBox;
     var rect = textBox.GetRectFromCharacterIndex(Math.Max(0, index));
     rect.Offset(GetPopupOffset(textBox));
     popup.PlacementRectangle = rect;
     popup.IsOpen = true;
 }
開發者ID:catwalkagogo,項目名稱:Heron,代碼行數:8,代碼來源:AutoComplete.cs

示例6: IDETabs_PreviewKeyDown

 //Handle textbox IntelliSense.
 private void IDETabs_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (sender.GetType() == typeof(TabControl))
     {
         txtboxCurrentIDECode = (TextBox)((TabItem)((TabControl)sender).SelectedItem).Content;
         if (txtboxCurrentIDECode != null)
             ViewModelIntellisense.showMethodsPopUP(txtboxCurrentIDECode.GetRectFromCharacterIndex(txtboxCurrentIDECode.CaretIndex), txtboxCurrentIDECode, popup, list, e);
     }
 }
開發者ID:syre,項目名稱:SortingIndustrialRobot,代碼行數:10,代碼來源:mainWindow.xaml.cs


注:本文中的System.Windows.Controls.TextBox.GetRectFromCharacterIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。