2013-11-27 42 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是鏈接..

相關問題