Esempio n. 1
0
 /// <summary>
 /// Creates a new polygon map shape.
 /// </summary>
 /// <param name="metadata">The map metadata.</param>
 /// <param name="bounds">The shape bounds.</param>
 public MapShapePolygon(MapMetadata metadata, MapRectangle bounds)
     : base(MapShapeType.Polygon, metadata)
 {
     this.bounds = bounds;
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a map with the specified bounds.
 /// </summary>
 /// <param name="bounds">The map bounds.</param>
 public Map(MapRectangle bounds)
 {
     this.bounds = bounds;
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a new polygon map shape.
 /// </summary>
 /// <param name="bounds">The shape bounds.</param>
 public MapShapePolygon(MapRectangle bounds)
     : base(MapShapeType.Polygon)
 {
     this.bounds = bounds;
 }
Esempio n. 4
0
 /// <summary>
 /// Draws the item on the specified graphics object within the specified map bounds and scale.
 /// </summary>
 /// <param name="graphics">The graphics</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="brush">The brush.</param>
 /// <param name="pen">The pen.</param>
 internal override void Draw(Graphics graphics, MapRectangle bounds, MapScale scale, Brush brush, Pen pen)
 {
     // Create a new graphics path.
     using (GraphicsPath path = new GraphicsPath())
     {
         // Compute the marker center.
         PointF center = new PointF(
             (float)((this.Location.X - bounds.Left) * scale.Width),
             (float)((bounds.Top - this.Location.Y) * scale.Height)
             );
         // Add a circle to the path.
         path.AddEllipse((float)(center.X - this.Size.Width / 2.0), (float)(center.Y - this.Size.Height / 2.0), this.Size.Width, this.Size.Height);
         // Fill the path.
         if (null != brush) graphics.FillPath(brush, path);
         // Draw the path.
         if (null != pen) graphics.DrawPath(pen, path);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Updates the map item geometric characteristics to the specified map bounds and scale.
 /// </summary>
 /// <param name="bounds">The map bounds.</param>
 /// <param name="scale">The map scale.</param>
 internal override void Update(MapRectangle bounds, MapScale scale)
 {
     // If the object has been disposed throw an exception.
     if (this.disposed) throw new ObjectDisposedException("marker");
     // Compute the marker center.
     PointF center = new PointF(
         (float)((this.Location.X - bounds.Left) * scale.Width),
         (float)((bounds.Top - this.Location.Y) * scale.Height)
         );
     // Lock the current path.
     lock (this.sync)
     {
         // Reset the graphics path.
         this.path.Reset();
         // Add a circle to the path.
         this.path.AddEllipse((float)(center.X - this.Size.Width / 2.0), (float)(center.Y - this.Size.Height / 2.0), this.Size.Width, this.Size.Height);
         // Set the region bounds.
         this.bounds = this.path.GetBounds().Ceiling();
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Updates the map item geometric characteristics to the specified map bounds and scale.
 /// </summary>
 /// <param name="bounds">The map bounds.</param>
 /// <param name="scale">The map scale.</param>
 internal override void Update(MapRectangle bounds, MapScale scale)
 {
     // If the object has been disposed throw an exception.
     if (this.disposed) throw new ObjectDisposedException("region");
     lock (this.sync)
     {
         // Reset the graphics path.
         this.path.Reset();
         // For all shape parts.
         for (int indexPart = 0; indexPart < shape.Parts.Count; indexPart++)
         {
             // Update the list of points for each part polygon.
             for (int indexPoint = 0; indexPoint < shape.Parts[indexPart].Points.Count; indexPoint++)
             {
                 this.points[indexPart][indexPoint].X = (float)((shape.Parts[indexPart].Points[indexPoint].X - bounds.Left) * scale.Width);
                 this.points[indexPart][indexPoint].Y = (float)((bounds.Top - shape.Parts[indexPart].Points[indexPoint].Y) * scale.Height);
             }
             // Add the polygon to the graphics path.
             this.path.AddPolygon(this.points[indexPart]);
         }
         // Set the region bounds.
         this.bounds = this.path.GetBounds().Ceiling();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Draws the item on the specified graphics object within the specified map bounds and scale.
 /// </summary>
 /// <param name="graphics">The graphics.</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="scale">The scale.</param>
 internal override void Draw(Graphics graphics, MapRectangle bounds, MapScale scale)
 {
     // Create the brush.
     using (SolidBrush brush = new SolidBrush(this.BackgroundColor))
     {
         // Create the pen.
         using (Pen pen = new Pen(this.BorderColor))
         {
             this.Draw(graphics, bounds, scale, brush, pen);
         }
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Draws the item on the specified graphics object within the specified map bounds and scale.
 /// </summary>
 /// <param name="graphics">The graphics</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="brush">The brush.</param>
 /// <param name="pen">The pen.</param>
 internal override void Draw(Graphics graphics, MapRectangle bounds, MapScale scale, Brush brush, Pen pen)
 {
     // Create a new graphics path.
     using (GraphicsPath path = new GraphicsPath())
     {
         // For all shape parts.
         for (int indexPart = 0; indexPart < shape.Parts.Count; indexPart++)
         {
             // Update the list of points for each part polygon.
             for (int indexPoint = 0; indexPoint < shape.Parts[indexPart].Points.Count; indexPoint++)
             {
                 this.points[indexPart][indexPoint].X = (float)((shape.Parts[indexPart].Points[indexPoint].X - bounds.Left) * scale.Width);
                 this.points[indexPart][indexPoint].Y = (float)((bounds.Top - shape.Parts[indexPart].Points[indexPoint].Y) * scale.Height);
             }
             // Add the polygon to the graphics path.
             path.AddPolygon(this.points[indexPart]);
         }
         // Fill the path.
         if (null != brush) graphics.FillPath(brush, path);
         // Draw the path.
         if (null != pen) graphics.DrawPath(pen, path);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Draws the item on the specified graphics object within the specified map bounds and scale.
 /// </summary>
 /// <param name="graphics">The graphics.</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="scale">The scale.</param>
 internal abstract void Draw(Graphics graphics, MapRectangle bounds, MapScale scale);
Esempio n. 10
0
 /// <summary>
 /// Updates the map item geometric characteristics to the specified map bounds and scale.
 /// </summary>
 /// <param name="bounds">The map bounds.</param>
 /// <param name="scale">The map scale.</param>
 internal abstract void Update(MapRectangle bounds, MapScale scale);
Esempio n. 11
0
 /// <summary>
 /// Draws the item on the specified graphics object within the specified map bounds and scale.
 /// </summary>
 /// <param name="graphics">The graphics</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="scale">The scale.</param>
 /// <param name="brush">The brush.</param>
 /// <param name="pen">The pen.</param>
 internal abstract void Draw(Graphics graphics, MapRectangle bounds, MapScale scale, Brush brush, Pen pen);
Esempio n. 12
0
 /// <summary>
 /// An event handler called when the map bounds have changed.
 /// </summary>
 /// <param name="mapBounds">The map bounds.</param>
 private void OnMapBoundsChanged(MapRectangle mapBounds)
 {
     // Compute the map size to use the default values in case the width and height are zero.
     this.mapSize = new MapSize(
         mapBounds.Width != 0 ? mapBounds.Width : MapControl.mapBoundsDefault.Width,
         mapBounds.Height != 0 ? mapBounds.Height : MapControl.mapBoundsDefault.Height
         );
     // Compute the map bounds.
     this.mapBounds = new MapRectangle(
         new MapPoint(mapBounds.Left, mapBounds.Top),
         this.mapSize
         );
     // Recompute the map scale and bitmap size.
     this.OnMapSizeChanged();
     // Refresh the current map.
     this.OnRefreshMap();
 }