Insert image in tool tips

Topics: General
Feb 29, 2012 at 5:51 PM

Hey :)

Is there anyway i can put an image in tooltips ?

Feb 29, 2012 at 5:57 PM

yes, make custom tooltip, render image, enjoy ;}

Feb 29, 2012 at 8:46 PM

Thnx radioman , but can u plz put a small exemple ?

Mar 1, 2012 at 7:56 AM
namespace GMap.NET.WindowsForms.ToolTips
{
   using System.Drawing;
   using System.Drawing.Drawing2D;
   using System;
   using System.Runtime.Serialization;

#if !PocketPC
   /// <summary>
   /// GMap.NET marker
   /// </summary>
   [Serializable]
   public class GMapBaloonToolTip : GMapToolTip, ISerializable
   {
      public float Radius = 10f;

      public GMapBaloonToolTip(GMapMarker marker)
         : base(marker)
      {
         Stroke = new Pen(Color.FromArgb(140, Color.Navy));
         Stroke.Width = 3;
#if !PocketPC
         this.Stroke.LineJoin = LineJoin.Round;
         this.Stroke.StartCap = LineCap.RoundAnchor;
#endif

         Fill = Brushes.Yellow;
      }

      public override void OnRender(Graphics g)
      {
         System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
         System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
         rect.Offset(Offset.X, Offset.Y);

         using(GraphicsPath objGP = new GraphicsPath())
         {
            objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
            objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);

            objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
            objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
            objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
            objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
            objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
            objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner

            objGP.CloseFigure();

            g.FillPath(Fill, objGP);
            g.DrawPath(Stroke, objGP);
         }

#if !PocketPC
         g.DrawString(Marker.ToolTipText, Font, Foreground, rect, Format);
#else
         g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
#endif
      }

      #region ISerializable Members

      void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
      {
         info.AddValue("Radius", this.Radius);

         base.GetObjectData(info, context);
      }

      protected GMapBaloonToolTip(SerializationInfo info, StreamingContext context)
         : base(info, context)
      {
         this.Radius = Extensions.GetStruct<float>(info, "Radius", 10f);
      }

      #endregion
   }
#endif
}

Marked as answer by radioman on 12/10/2015 at 12:48 PM
Mar 1, 2012 at 1:50 PM

Done

ty so much Radioman :)

Nov 20, 2013 at 1:52 AM
how to use this code? :/
Dec 10, 2015 at 8:33 PM
I'm looking for this, how can we implement? . . another idea could be Link
Dec 10, 2015 at 8:48 PM
nothing changed, make a class myclasss : GMapToolTip {}, implement OnRender, draw anything, done
Dec 11, 2015 at 2:27 AM
hello again! thanks so much radioman this help me ;}