internal bool MouseMove(GraphicView activeView, System.Windows.Forms.MouseEventArgs e)
{
bool needPaint = false;
Item newHover = pickItem(e);
if (hoverItem != newHover)
{
if (!showingTooltip)
{
if (newHover != null)
timer.Change(TooltipDelay, System.Threading.Timeout.Infinite);
else
timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
}
else
{
if (newHover == null)
timer.Change(TooltipDelay, System.Threading.Timeout.Infinite);
else
timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
}
}
if (hoverItem != null || hoverItem != newHover)
needPaint = true;
hoverItem = newHover;
Model.Model model = Model.Model.Instance;
View.Renderer.RenderOptions options = activeView.ModelRenderer.RenderOptions;
// Get position in the item's local coordinate system
if (hoverItem is Joint)
hoverPos = getHoverPos((Joint)hoverItem, model, options);
else if (hoverItem is LineElement)
{
LineElement line = hoverItem as LineElement;
if (options.ShowDeformed)
hoverPos = getHoverPos(line, activeView, e.Location, model, options);
else
{
Snap.LineMagnet lm = new Canguro.Controller.Snap.LineMagnet(line);
lm.Snap(activeView, e.Location);
hoverPos = lm.SnapPositionInt;
hoverXPos = (hoverPos - line.I.Position).Length() / line.LengthInt;
}
}
// Get text to draw
tooltipText = itemTextBuilder.GetItemText(hoverItem, hoverPos, hoverXPos);
// Get Size of text
if (!string.IsNullOrEmpty(tooltipText))
{
tooltipRectangle = hoverPainter.MeasureText(tooltipText);
#if DEBUG
if (tooltipRectangle.Width == 0 || tooltipRectangle.Height == 0)
throw new Exception("Measure String returned 0");
#endif
tooltipRectangle.Location += deltaRect;
tooltipRectangle.X += e.X;
tooltipRectangle.Y += e.Y;
tooltipRectangle.Width += 8;
tooltipRectangle.Height += 4;
Viewport vp = activeView.Viewport;
if (tooltipRectangle.Right > (vp.X + vp.Width))
tooltipRectangle.X -= (tooltipRectangle.Width + 2 * deltaRect.Width);
rectHelper.MouseMove(activeView, tooltipRectangle.Location, tooltipRectangle.Location + tooltipRectangle.Size);
}
else if (!showingTooltip)
timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
return showingTooltip || needPaint;
}