2013-11-27 40 views
4
using System.Drawing; 
    using System.Drawing.Drawing2D; 

    namespace WindowsFormsApplication1 
    {  
     [Serializable] 
     public class GMapBaloonTool: GMapToolTip, ISerializable 
     { 
      public float Radius = 10f; 
      public GMapBaloonTool(GMapMarker marker) 
       : base(marker) 
      { 
       Stroke = new Pen(Color.FromArgb(140, Color.Navy)); 
       Stroke.Width = 3; 
       this.Stroke.LineJoin = LineJoin.Round; 
       this.Stroke.StartCap = LineCap.RoundAnchor;  
       Fill = Brushes.Pink; 
      } 

上面的代码,使工具提示更改其颜色。
enter image description here我可以在system.drawing中添加一个控件,例如一个按钮吗?

我使用gMaps.net在winforms C#中创建自定义谷歌地图。我正在努力添加一个marker + onClick事件,该事件将显示来自DVR的视频馈送。
唯一的问题是,内置GMapsToolTip只显示字符串,虽然我有一个作为相机控制的activeX。
我需要的是在工具提示中显示相机(activeX)。
在greatmaps论坛上看到this。创作者说我可以制作自定义工具提示。
所以我问的是,是否有可能使用此system.drawing命名空间创建/添加控件?
如果可能,请告诉我如何..
如果不是,如果你知道任何其他方式,让我们知道它。

  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); 
       } 

       g.DrawString(Marker.ToolTipText, Font, Foreground, rect, Format);  
     g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);  
      } 

      #region ISerializable Members  
      void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) 
      { 
       info.AddValue("Radius", this.Radius);  
       base.GetObjectData(info, context); 
      } 

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

该代码使得在圆形气球,所以我不知道如何添加我的控制,看起来像这样.. (从HTML做,但我需要它的WinForms)

enter image description here

希望有人能帮助我。 哦,如果你只会将我重定向到伟大地图的讨论网站,请不要。我从那里了解不多,所以我在这里问。

+0

中自定义的WinForms工具提示可以通过自定义'ToolStripControlHost'来实现,你应该尝试搜索就可以了,做一些演示您当前的外线项目在应用于您的项目之前先看到它在行动。那里有很多样品。关键是您必须知道如何以及何时在地图上的某个位置显示工具提示。 –

回答

1

您可以尝试在相机控件上使用DrawToBitmap方法。我所期待的三种情况之一发生:

  • 你得到一个黑色的矩形
  • 你在你叫DrawToBitmap
  • 你得到一个实况视频(感谢此刻让相机的一帧覆盖视频播放功能)

你最好的选择是数字2和3,因为它们可以用来提供你想要的功能。如果您获得编号1,控件渲染不使用Winforms的通常渲染逻辑,因此您必须解决它。

实际上,您可能需要更直接地访问相机渲染输出,因为每秒创建25个位图可能有点太多了,无法使用。你会到达那里:)

0

已经得到这个工作。使用的形式的实例,以创建一个信息窗口 This是链接..

相关问题