Exemplo n.º 1
0
        /// <summary>
        /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data.</param>
        /// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization.</param>
        /// <exception cref="T:System.Security.SecurityException">
        /// The caller does not have the required permission.
        /// </exception>
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("Id", this.Id);
            info.AddValue("IsVisible", this.IsVisibile);

            GMapMarker[] markerArray = new GMapMarker[this.Markers.Count];
            this.Markers.CopyTo(markerArray, 0);
            info.AddValue("Markers", markerArray);

            GMapRoute[] routeArray = new GMapRoute[this.Routes.Count];
            this.Routes.CopyTo(routeArray, 0);
            info.AddValue("Routes", routeArray);

            GMapPolygon[] polygonArray = new GMapPolygon[this.Polygons.Count];
            this.Polygons.CopyTo(polygonArray, 0);
            info.AddValue("Polygons", polygonArray);
        }
Exemplo n.º 2
0
        void RegeneratePolygon()
        {
            List<PointLatLng> polygonPoints = new List<PointLatLng>();

            foreach (GMapMarker m in gmap.Markers)
            {
                if (m is GMapMarkerRect)
                {
                    m.Tag = polygonPoints.Count;
                    polygonPoints.Add(m.Position);
                }
            }

            if (polygon == null)
            {
                polygon = new GMapPolygon(polygonPoints  /*, "polygon test" */);
                polygon.IsHitTestVisible = true;
                polygons.Polygons.Add(polygon);
            }
            else
            {
                polygon.Points.Clear();
                polygon.Points.AddRange(polygonPoints);

                if (polygons.Polygons.Count == 0)
                {
                    polygons.Polygons.Add(polygon);
                }
                else
                {
                    gmap.UpdatePolygonLocalPosition(polygon);
                }
            }
        }