public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, ToolTip tip) { Point pt = e.GetPosition(this); if ((pt.X >= 0.0) && (pt.X <= this.Width) && (_visibleMarks.Count > 0)) { foreach (var mark in _visibleMarks) { if (Math.Abs(pt.Y - mark.Item2) < MarkHeight * 0.5) { object content = mark.Item1.ToolTipContent; if (content != null) { tip.MinWidth = tip.MinHeight = 0.0; tip.MaxWidth = tip.MaxHeight = double.PositiveInfinity; tip.Content = content; tip.IsOpen = true; return(true); } } } } return(false); }
/// <summary> /// Create an instance of the StructureMargin in the specified <see cref="IWpfTextViewHost"/>. /// </summary> /// <param name="textViewHost">The <see cref="IWpfTextViewHost"/> in which the StructureMargin will be displayed.</param> /// <param name="parentMargin">The scrollBar used to translate between buffer positions and y-coordinates.</param> /// <returns>The newly created StructureMargin.</returns> public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { IOverviewMargin containerMarginAsOverviewMargin = containerMargin as IOverviewMargin; if (containerMarginAsOverviewMargin != null) { //Create the caret margin, passing it a newly instantiated text structure navigator for the view. return(new StructureMargin(textViewHost, containerMarginAsOverviewMargin.ScrollBar, this)); } else { return(null); } }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin parentMargin) { IOverviewMargin parent = parentMargin as IOverviewMargin; if (parent != null) { return(OverviewMarkMargin.Create( textViewHost, parent.ScrollBar, this)); } else { return(null); } }
/// <summary> /// Create an instance of the CaretMargin in the specified <see cref="IWpfTextViewHost"/>. /// </summary> /// <param name="textViewHost">The <see cref="IWpfTextViewHost"/> in which the CaretMargin will be displayed.</param> /// <returns>The newly created CaretMargin.</returns> public IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) { IOverviewMargin containerMarginAsOverviewMargin = containerMargin as IOverviewMargin; if (containerMarginAsOverviewMargin != null) { //The caret margin needs to know what the constitutes a word, which means using the text structure navigator //(since the definition of a word can change based on context). //Create the caret margin, passing it a newly instantiated text structure navigator for the view. return(new CaretMargin(textViewHost, containerMarginAsOverviewMargin.ScrollBar, this)); } else { return(null); } }
public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, ToolTip tip) { if (!this.textView.IsClosed) { Point pt = e.GetPosition(this); if ((pt.X >= 0.0) && (pt.X <= MarginWidth)) { SnapshotPoint position = this.scrollBar.GetBufferPositionOfYCoordinate(pt.Y); IBlockTag deepestTag = null; var tags = this.tagger.GetTags(new SnapshotSpan(position, 0)); foreach (var tagSpan in tags) { if (tagSpan.Tag.Type != BlockType.Unknown) { if ((deepestTag == null) || (tagSpan.Tag.Level > deepestTag.Level)) { deepestTag = tagSpan.Tag; } } } if (deepestTag != null) { tip.IsOpen = true; FrameworkElement context = deepestTag.Context(this.blockColoring, this.textView.FormattedLineSource.DefaultTextProperties.Typeface, this.textView.FormattedLineSource.DefaultTextProperties.FontRenderingEmSize); //The width of the view is in zoomed coordinates so factor the zoom factor into the tip window width computation. double zoom = this.textView.ZoomLevel / 100.0; tip.MinWidth = tip.MaxWidth = Math.Floor(Math.Max(50.0, this.textView.ViewportWidth * zoom * 0.5)); tip.MinHeight = tip.MaxHeight = context.Height + 12.0; tip.Content = context; return(true); } } } return(false); }
public IOverviewTipFactory GetOverviewTipFactory(IOverviewMargin overviewMargin, IWpfTextView view) { ITextViewMargin margin = overviewMargin as ITextViewMargin; return(margin != null ? (margin.GetTextViewMargin(StructureMargin.Name) as IOverviewTipFactory) : null); }
public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, ToolTip tip) { int tipSize = base.TextViewHost.TextView.Options.GetOptionValue(DefaultOverviewMarginOptions.PreviewSizeId); if (tipSize != 0) { Point pt = e.GetPosition(this); if (_tipBuffer == null) { _tipBuffer = _provider.ProjectionFactory.CreateProjectionBuffer(null, new List <object>(0), ProjectionBufferOptions.None); _tipView = _provider.EditorFactory.CreateTextView(new VacuousTextViewModel(_tipBuffer, base.TextViewHost.TextView.TextViewModel.DataModel), base.TextViewHost.TextView.Roles, _provider.EditorOptionsFactoryService.GlobalOptions); _tipView.Options.SetOptionValue(DefaultTextViewOptions.IsViewportLeftClippedId, false); _tipView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, base.TextViewHost.TextView.Options.GetOptionValue(DefaultWpfViewOptions.AppearanceCategory)); } if (_tipBuffer.CurrentSnapshot.SpanCount == 0) { //Track the entire buffer (we use a projection buffer rather than simply the TextView's TextBuffer because -- when the preview isn't visible -- //we don't want to spend time reacting to text changes, etc.). _tipBuffer.InsertSpan(0, base.TextViewHost.TextView.TextSnapshot.CreateTrackingSpan(0, base.TextViewHost.TextView.TextSnapshot.Length, SpanTrackingMode.EdgeInclusive)); } double viewHeight = ((double)tipSize) * _tipView.LineHeight; SnapshotPoint position = _scrollBar.GetBufferPositionOfYCoordinate(pt.Y); _tipView.DisplayTextLineContainingBufferPosition(new SnapshotPoint(_tipView.TextSnapshot, position.Position), viewHeight * 0.5, ViewRelativePosition.Bottom, null, viewHeight); double left = double.MaxValue; foreach (ITextViewLine line in _tipView.TextViewLines) { //Find the first non-whitespace character on the line for (int i = line.Start.Position; (i < line.End.Position); ++i) { if (!char.IsWhiteSpace(line.Snapshot[i])) { double l = line.GetCharacterBounds(new SnapshotPoint(line.Snapshot, i)).Left; if (l < left) { left = l; } break; } } } _tipView.ViewportLeft = (left == double.MaxValue) ? 0.0 : (left * 0.75); //Compress most of the indentation (but leave a little) //The width of the view is in zoomed coordinates so factor the zoom factor into the tip window width computation. double zoom = base.TextViewHost.TextView.ZoomLevel / 100.0; _tipWindow.MinWidth = _tipWindow.MaxWidth = Math.Floor(Math.Max(50.0, base.TextViewHost.TextView.ViewportWidth * zoom * 0.5)); _tipWindow.MinHeight = _tipWindow.MaxHeight = 8.0 + viewHeight; _tipWindow.IsOpen = true; _tipWindow.Content = _tipView.VisualElement; return(true); } return(false); }
public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, System.Windows.Controls.ToolTip tip) { return(_markMarginElement.UpdateTip(margin, e, tip)); }
public IOverviewTipFactory GetOverviewTipFactory(IOverviewMargin overviewMargin, IWpfTextView view) { ITextViewMargin margin = overviewMargin as ITextViewMargin; return(margin != null ? (margin.GetTextViewMargin(PredefinedOverviewMarginNames.OverviewMark) as IOverviewTipFactory) : null); }
public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, ToolTip tip) { return this.structureMarginElement.UpdateTip(margin, e, tip); }
public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, ToolTip tip) { return(this.structureMarginElement.UpdateTip(margin, e, tip)); }
public IOverviewTipFactory GetOverviewTipFactory(IOverviewMargin overviewMargin, IWpfTextView view) { ITextViewMargin margin = overviewMargin as ITextViewMargin; return margin != null ? (margin.GetTextViewMargin(StructureMargin.Name) as IOverviewTipFactory) : null; }
public IOverviewTipFactory GetOverviewTipFactory(IOverviewMargin overviewMargin, IWpfTextView view) { ITextViewMargin margin = overviewMargin as ITextViewMargin; return margin != null ? (margin.GetTextViewMargin(PredefinedOverviewMarginNames.OverviewMark) as IOverviewTipFactory) : null; }
public bool UpdateTip(IOverviewMargin margin, MouseEventArgs e, System.Windows.Controls.ToolTip tip) { return _markMarginElement.UpdateTip(margin, e, tip); }