protected virtual async Task AsyncToolTipRequestDefaultImpl(ToolTipRequestEventArgs arg) { var adapter = _adapter; if (null != adapter) { var info = await adapter.GetToolTipAsync(arg.Position); if (null != info) { arg.SetToolTip(info.Create()); } } }
private async void OnMouseHover(object sender, MouseEventArgs e) { TextViewPosition?position; try { position = TextArea.TextView.GetPositionFloor(e.GetPosition(TextArea.TextView) + TextArea.TextView.ScrollOffset); } catch (ArgumentOutOfRangeException) { // TODO: check why this happens e.Handled = true; return; } var args = new ToolTipRequestEventArgs { InDocument = position.HasValue }; if (!position.HasValue || position.Value.Location.IsEmpty) { return; } args.LogicalPosition = position.Value.Location; args.Position = Document.GetOffset(position.Value.Line, position.Value.Column); RaiseEvent(args); if (args.ContentToShow == null) { if (AsyncToolTipRequest != null) { await AsyncToolTipRequest.Invoke(args).ConfigureAwait(true); } } if (args.ContentToShow == null) { return; } if (_toolTip == null) { _toolTip = new ToolTip { MaxWidth = 400 }; _toolTip.Closed += ToolTipClosed; ToolTipService.SetInitialShowDelay(_toolTip, 0); } _toolTip.PlacementTarget = this; // required for property inheritance var stringContent = args.ContentToShow as string; if (stringContent != null) { _toolTip.Content = new TextBlock { Text = stringContent, TextWrapping = TextWrapping.Wrap }; } else { _toolTip.Content = args.ContentToShow; } e.Handled = true; _toolTip.IsOpen = true; }