static Window CreatePackageWindow(InfoItem infoItem) { var window = new TooltipInformationWindow(); window.ShowArrow = true; window.RepositionWindow(); var cts = new CancellationTokenSource(); window.Closed += delegate { cts.Cancel(); }; var packages = infoItem.Packages; TooltipInformation ti; bool done = CreatePackageTooltipInfo((string)infoItem.ResolveResult.Reference, packages, out ti); if (!done) { packages.ContinueWith(t => { if (!done) { done = CreatePackageTooltipInfo((string)infoItem.ResolveResult.Reference, packages, out ti); if (ti != null) { window.Clear(); window.AddOverload(ti); } } }, cts.Token, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } window.AddOverload(ti); return(window); }
async void ShowTooltip() { var currentSelectedItem = selectedItem; if (currentSelectedItem == null || currentSelectedItem.DataSource == null) { HideTooltip(); return; } var i = currentSelectedItem.Item; if (i < 0 || i >= currentSelectedItem.DataSource.Count) { return; } if (tooltipSrc != null) { tooltipSrc.Cancel(); } tooltipSrc = new CancellationTokenSource(); var token = tooltipSrc.Token; try { currentTooltip = await currentSelectedItem.DataSource [i].GetTooltipInformation(token); } catch (OperationCanceledException) { HideTooltip(); return; } catch (Exception e) { LoggingService.LogError("Error while creating search popup window tooltip", e); HideTooltip(); return; } if (currentTooltip == null || string.IsNullOrEmpty(currentTooltip.SignatureMarkup) || token.IsCancellationRequested) { HideTooltip(); return; } declarationviewwindow.Hide(); declarationviewwindow.Clear(); declarationviewwindow.AddOverload(currentTooltip); declarationviewwindow.CurrentOverload = 0; declarationviewwindow.ShowArrow = true; var rect = SelectedItemRectangle; declarationviewwindow.ShowPopup(this, new Rectangle(0, (int)rect.Y - 5, Bounds.Width, (int)rect.Height), PopupPosition.Right); }
void ShowTooltip() { HideTooltip(); var currentSelectedItem = selectedItem; if (currentSelectedItem == null || currentSelectedItem.DataSource == null) { return; } var i = currentSelectedItem.Item; if (i < 0 || i >= currentSelectedItem.DataSource.ItemCount) { return; } if (tooltipSrc != null) { tooltipSrc.Cancel(); } tooltipSrc = new CancellationTokenSource(); var token = tooltipSrc.Token; ThreadPool.QueueUserWorkItem(delegate { TooltipInformation tooltip; try { tooltip = currentSelectedItem.DataSource.GetTooltip(i); } catch (Exception e) { LoggingService.LogError("Error while creating search popup window tooltip", e); return; } if (tooltip == null || string.IsNullOrEmpty(tooltip.SignatureMarkup) || token.IsCancellationRequested) { return; } Application.Invoke(delegate { if (token.IsCancellationRequested) { return; } declarationviewwindow.Clear(); declarationviewwindow.AddOverload(tooltip); declarationviewwindow.CurrentOverload = 0; declarationViewTimer = GLib.Timeout.Add(250, DelayedTooltipShow); }); }); }