Example #1
0
 internal void OnShowToolTip()
 {
     if (ShowToolTip != null && !owner.Capture)
     {
         Control             c     = GetFocus();
         Point               local = c.PointToClient(Cursor.Position);
         IntelliTipEventArgs args  = new IntelliTipEventArgs();
         args.Type     = this.type;
         args.Focus    = c;
         args.Location = local;
         ShowToolTip(this, args);
         string toolTip = args.ToolTip;
         if (!string.IsNullOrEmpty(toolTip))
         {
             this.tip.ShowAlways = true;
             this.tip.Active     = true;
             Point p = args.Location;
             if (p.X == local.X && p.Y == local.Y)
             {
                 p.Y += 10;
                 p.Y += 10;
             }
             this.tipTime = Environment.TickCount;
             showing      = c;
             this.tip.Show(WordWrap(toolTip), (IWin32Window)c, p);
             return;
         }
     }
     this.tip.Hide(owner);
     this.type = TipRequestType.Default;
 }
 void OnShowToolTip(object sender, IntelliTipEventArgs args)
 {
     if (_list != null)
     {
         int i = this._listBox.SelectedIndex;
         if (args.Type == TipRequestType.Hover)
         {
             Point pt = args.Location;
             for (int j = 0, n = this._listBox.Items.Count; j < n; j++)
             {
                 Rectangle r = this._listBox.GetItemRectangle(j);
                 if (r.Contains(pt))
                 {
                     i = j;
                     break;
                 }
             }
         }
         if (i >= 0 && i < _list.Count)
         {
             string t = _list.GetTooltip(i);
             if (!string.IsNullOrEmpty(t))
             {
                 Rectangle r = this._listBox.GetItemRectangle(i);
                 Point     p = new Point(r.Right, r.Top);
                 p = this._listBox.PointToScreen(p);
                 Screen screen = Screen.FromPoint(p);
                 using (Graphics g = this.CreateGraphics())
                 {
                     SizeF s = g.MeasureString(t, SystemFonts.MenuFont);
                     if (p.X + s.Width > screen.Bounds.Right)
                     {
                         p.X = screen.Bounds.Right - (int)s.Width;
                         if (p.X < 0)
                         {
                             p.X = 0;
                         }
                         p.Y += this._listBox.ItemHeight;
                     }
                 }
                 args.Location = args.Focus.PointToClient(p);
                 args.ToolTip  = t;
             }
         }
     }
 }
 void OnShowToolTip(object sender, IntelliTipEventArgs args)
 {
     if (list != null) {
         int i = this.listBox.SelectedIndex;
         if (args.Type == TipRequestType.Hover) {
             Point pt = args.Location;
             for (int j = 0, n = this.listBox.Items.Count; j < n; j++) {
                 Rectangle r = this.listBox.GetItemRectangle(j);
                 if (r.Contains(pt)) {
                     i = j;
                     break;
                 }
             }
         }
         if (i >= 0 && i < list.Count) {
             string t = list.GetTooltip(i);
             if (!string.IsNullOrEmpty(t)) {
                 Rectangle r = this.listBox.GetItemRectangle(i);
                 Point p = new Point(r.Right, r.Top);
                 p = this.listBox.PointToScreen(p);
                 Screen screen = Screen.FromPoint(p);
                 using (Graphics g = this.CreateGraphics()) {
                     SizeF s = g.MeasureString(t, SystemFonts.MenuFont);
                     if (p.X + s.Width > screen.Bounds.Right) {
                         p.X = screen.Bounds.Right - (int)s.Width;
                         if (p.X < 0) p.X = 0;
                         p.Y += this.listBox.ItemHeight;
                     }
                 }
                 args.Location = args.Focus.PointToClient(p);
                 args.ToolTip = t;
             }
         }
     }
 }
Example #4
0
        internal void OnShowToolTip()
        {
            this.type = TipRequestType.Default;
            lastHover = new Rectangle(Cursor.Position, Size.Empty);
            lastHover.Inflate(10, 10);
            resetpending = true;

            if (ShowToolTip != null && !owner.Capture) {
                Control c = GetFocus();
                Point local = c.PointToClient(Cursor.Position);
                IntelliTipEventArgs args = new IntelliTipEventArgs();
                args.Type = this.type;
                args.Focus = c;
                args.Location = local;
                ShowToolTip(this, args);
                string toolTip = args.ToolTip;
                if (!string.IsNullOrEmpty(toolTip)) {
                    this.tip.ShowAlways = true;
                    this.tip.Active = true;
                    Point p = args.Location;
                    if (p.X == local.X && p.Y == local.Y) {
                        p.Y += 10;
                        p.Y += 10;
                    }
                    this.tipTime = Environment.TickCount;
                    showing = c;
                    this.tip.Show(WordWrap(toolTip), (IWin32Window)c, p);
                    return;
                }
            }
            this.tip.Hide(owner);
        }