示例#1
0
 /// <summary>
 /// Create a measuring line between a marker and a specific point on the map
 /// </summary>
 /// <param name="p">Marker position</param>
 /// <param name="p2">Map point</param>
 /// <param name="ListPoints">List with the two points that create the line</param>
 /// <param name="marker1">Marker from which the distance is being measured</param>
 /// <param name="i">unique number that identifies each line</param>
 public MeasureLine(PointLatLng p, PointLatLng p2, List <PointLatLng> ListPoints, CustomActualGmapMarker marker1, int i)
     : base(ListPoints)
 {
     this.marker1    = marker1;
     this.p          = marker1.p;
     this.p2         = p2;
     this.ListPoints = new List <PointLatLng>();
     this.ListPoints.Add(p);
     this.ListPoints.Add(p2);
     this.num = i;
 }
示例#2
0
        /// <summary>
        /// Function to insert the label and rotate the marker drawing
        /// </summary>
        /// <param name="marker">Marker from which we want to make the shape</param>
        /// <returns>Bitmap with marker drawing, rotated, and labeled</returns>
        static public Bitmap InsertText(CustomActualGmapMarker marker)
        {
            Bitmap bmp;

            //We will take a different starting image depending on whether it is a surface vehicle, plane or undetermined
            if (marker.emitter == "car")
            {
                bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "ActualCarIco.png"));
            }
            else if (marker.emitter == "plane")
            {
                bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "PlaneActualMarker.png"));
            }
            else
            {
                bmp = (Bitmap)Image.FromFile(System.IO.Path.Combine(directory, "Markers", "ActualUndeterminedMarker.png"));
            }


            Bitmap returnBitmap = new Bitmap(60, 40);      // We create an empty Bitmap where we will be putting the images

            Graphics g = Graphics.FromImage(returnBitmap); //Create a grapichs g from bitmap

            g.SmoothingMode     = SmoothingMode.AntiAlias; //set parameters of g graphics. Interpolation and Pixel offset mode not set to highest quality to save resources
            g.InterpolationMode = InterpolationMode.High;
            g.PixelOffsetMode   = PixelOffsetMode.Default;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            if (marker.emitter == "plane" || marker.emitter == "car") //if marker is from car or plane we will rotate it. Otherwise the mareker is just a dot and it's no sense to rotate it
            {
                bmp = rotateBitmap(bmp, marker.direction);
                System.Drawing.Rectangle section = new System.Drawing.Rectangle(new System.Drawing.Point(bmp.Width / 4, bmp.Height / 4), new System.Drawing.Size(bmp.Width / 2, bmp.Height / 2));
                bmp = CropImage(bmp, section);    //After rotating image we crop it to quit unsused space
                g.DrawImage(bmp, 20, 15, 20, 20); //draw rotated image into g graphics
            }

            else
            {
                g.DrawImage(bmp, 27, 23, 6, 6); //draw dot image into g graphics
            }


            Font font       = new Font("Times New Roman", 12, System.Drawing.FontStyle.Regular, GraphicsUnit.Pixel);
            var  stringSize = g.MeasureString(marker.caption, font);
            var  localPoint = new PointF((returnBitmap.Width - stringSize.Width) / 2, 0);

            System.Drawing.Brush color = new SolidBrush(System.Drawing.Color.FromArgb(255, (byte)0, (byte)0, (byte)0)); //Set color to match radar detection color
            if (marker.DetectionMode == "SMR")
            {
                color = new SolidBrush(System.Drawing.Color.FromArgb(70, 255, 0));
            }
            if (marker.DetectionMode == "MLAT")
            {
                color = new SolidBrush(System.Drawing.Color.FromArgb(0, 151, 255));
            }
            if (marker.DetectionMode == "ADSB")
            {
                color = new SolidBrush(System.Drawing.Color.FromArgb(255, 151, 0));
            }


            g.DrawString(marker.caption, font, color, localPoint);

            g.Flush();
            bmp.Dispose();
            bmp = null;


            g.Dispose();

            return(returnBitmap);
        }