Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I add a control in system.drawing, e.g a button perhaps?

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

the above code, makes the tooltip change its color.
enter image description here

I am using gMaps.net to create custom google map inside winforms C#. I am working unto adding a marker + onClick event that will display video feeds from the DVR.
Only problem is that, the built in GMapsToolTip only displays strings although I have an activeX that act as a control for the camera.
What I need is to display the camera(activeX) inside the tooltip.
Saw this on a forum in greatmaps. Creator said I can make custom tooltips.
so what I am asking is, is it possible to create/add controls using this system.drawing namespace?
if possible, please do tell me how..
if not, if you know any other way, let know it.

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

this code makes the balloon on a rounded shape, so I don't know how to add my control to look something like this.. (made from html, but I need it on winforms)

enter image description here

hoping for someone who can help me. and oh, if you will only redirect me back to the discussion site of greatmaps, please don't. I can't understand much from there, so I asked in here.

like image 609
AdorableVB Avatar asked Nov 11 '22 17:11

AdorableVB


1 Answers

You can try using the DrawToBitmap method on your camera control. I'd expect one of three things to happen:

  • You get a black rectangle
  • You get one frame of the camera at the moment you called DrawToBitmap
  • You get a live video feed (thanks to overlay video playback features)

Your best options are number 2 and 3, because they can be used to provide the functionality you want. If you get number 1, the control rendering doesn't use the usual render logic of Winforms, so you'll have to work around it.

In practice, you'll probably want a more direct access to the camera rendering output, because creating 25 bitmaps per second might be a little too much work to be useful. You'll get there :)

like image 56
Luaan Avatar answered Nov 15 '22 11:11

Luaan