/// <summary> /// Delayed processing for showing tooltips (only show them if the user hovers /// over a link for more than a specified period of time) /// </summary> /// <param name="sender">sender</param> /// <param name="e">event args</param> private void toolTipDelayTimer_Tick(object sender, EventArgs e) { try { // get the delay element from the timer ToolTipDelayTimer toolTipDelayTimer = sender as ToolTipDelayTimer; IHTMLElement delayElement = toolTipDelayTimer.DelayElement; // stop and dispose timer toolTipDelayTimer.Stop(); toolTipDelayTimer.Dispose(); // determine the link element the mouse is currently over and check to see // if the delay element is the same as the current element -- if so, show the tooltip IHTMLElement mouseOverElement = _htmlEditorControl.ElementAtPoint(Control.MousePosition); if (mouseOverElement != null && (GetLinkElement(mouseOverElement) == delayElement) && !navigatedToCurrentLinkElement && currentLinkElement != null) { // calculate the screen coordinate of the top of the current link element int elementClientY = HTMLElementHelper.GetTopRelativeToClient(mouseOverElement); Point elementScreenPt = _htmlEditorControl.ClientPointToScreenPoint(new Point(0, elementClientY)); // set location - x-based on mouse, y-based on top of element (minus height of tooltip) toolTip.Location = new Point(Control.MousePosition.X, elementScreenPt.Y - 20); // set tooltip text string href = (string)currentLinkElement.getAttribute("href", 2); // 2 means don't auto-escape href = StringHelper.Ellipsis(href, 35); toolTip.SetToolTip(String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.LinkToolTip), href)); // start timer which monitors whether the main frame is still active and // hides the tooltip if it does not _frameActiveTimer = new Timer(); _frameActiveTimer.Interval = 100; _frameActiveTimer.Tick += new EventHandler(frameActiveTimer_Tick); _frameActiveTimer.Start(); } } catch (Exception ex) { // eat exceptions that occur in here (bizzare timing bugs can occur w/ drag and // drop of images -- this is harmless and the user shouldn't be burdened with // an error message Debug.Fail("Unexpected error during tool tip delay timer: " + ex.ToString()); } }