示例#1
0
 private UIElement CreateAdornment(string text)
 {
     var textBox = new TextBox();
     textBox.Text = text;
     textBox.BorderThickness = new Thickness(1);
     textBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
     textBox.Foreground = Brushes.Black;
     textBox.FontWeight = FontWeights.Bold;
     return textBox;
 }
        private void AddNavigateToPoint(IWpfTextViewLineCollection textViewLines, SnapshotPoint point, string key)
        {
            _navigateMap[key] = point;

            var resourceDictionary = _editorFormatMap.GetProperties(EasyMotionNavigateFormatDefinition.Name);

            var span = new SnapshotSpan(point, 1);
            var bounds = textViewLines.GetCharacterBounds(point);

            var textBox = new TextBox();
            textBox.Text = key;
            textBox.FontFamily = _classificationFormatMap.DefaultTextProperties.Typeface.FontFamily;
            textBox.Foreground = resourceDictionary.GetForegroundBrush(EasyMotionNavigateFormatDefinition.DefaultForegroundBrush);
            textBox.Background = resourceDictionary.GetBackgroundBrush(EasyMotionNavigateFormatDefinition.DefaultBackgroundBrush);
            textBox.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            Canvas.SetTop(textBox, bounds.TextTop);
            Canvas.SetLeft(textBox, bounds.Left);
            Canvas.SetZIndex(textBox, 10);

            _adornmentLayer.AddAdornment(span, _tag, textBox);
        }