Esempio n. 1
0
        private void Map1_MapClick(object sender, MapClickMapViewEventArgs e)
        {
            // Here we loop through all of the PrinterLayers to find the one the user right mouse clicked on.
            // Then we show the right click menu to give the user some options
            if (e.MouseButton == MapMouseButton.Right)
            {
                ((MenuItem)Map1.ContextMenu.Items[0]).IsEnabled = false;
                ((MenuItem)Map1.ContextMenu.Items[1]).IsEnabled = false;

                PrinterInteractiveOverlay printerOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];
                for (int i = printerOverlay.PrinterLayers.Count - 1; i >= 0; i--)
                {
                    if (printerOverlay.PrinterLayers[i].GetType() != typeof(PagePrinterLayer))
                    {
                        RectangleShape boundingBox = printerOverlay.PrinterLayers[i].GetPosition();
                        if (boundingBox.Contains(e.WorldLocation))
                        {
                            ((MenuItem)Map1.ContextMenu.Items[0]).Tag       = printerOverlay.PrinterLayers[i];
                            ((MenuItem)Map1.ContextMenu.Items[0]).IsEnabled = true;

                            ((MenuItem)Map1.ContextMenu.Items[1]).Tag       = printerOverlay.PrinterLayers[i];
                            ((MenuItem)Map1.ContextMenu.Items[1]).IsEnabled = true;

                            break;
                        }
                    }
                }
            }
        }
 private static void CloseSplittedRing(Vertex vertex, RectangleShape closeArea, RingShape ring)
 {
     for (int i = 0; i < ring.Vertices.Count; i++)
     {
         var currentVertex = ring.Vertices[i];
         if (closeArea.Contains(new PointShape(currentVertex)))
         {
             ring.Vertices[i] = new Vertex(vertex.X, vertex.Y);
         }
     }
 }
Esempio n. 3
0
        void timer_Tick(object sender, EventArgs e)
        {
            //Gets the GPS info from the textfile.
            DataTable carData = GetCarData();

            double               angle;
            LayerOverlay         vehicleOverlay = (LayerOverlay)winformsMap1.Overlays["VehicleOverlay"];
            InMemoryFeatureLayer carLayer       = vehicleOverlay.Layers["CarLayer"] as InMemoryFeatureLayer;

            PointShape pointShape = carLayer.InternalFeatures[0].GetShape() as PointShape;

            // Get the Row of Data we are working with.
            DataRow carDataRow = carData.Rows[0];

            double Lat  = Convert.ToDouble(carDataRow["LAT"]);
            double Long = Convert.ToDouble(carDataRow["LONG"]);

            if (previousLong == 0)
            {
                previousLong = Long;
                previousLat  = Lat;
            }

            double Xdiff = previousLong - Long;
            double Ydiff = previousLat - Lat;

            //Gets the angle based on the current GPS position and the previous one to get the direction of the vehicle.
            angle = GetAngleFromTwoVertices(new Vertex(previousLong, previousLat), new Vertex(Long, Lat));

            carLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.RotationAngle = 90 - (float)angle;

            pointShape.X  = Long;
            pointShape.Y  = Lat;
            pointShape.Id = "Car";

            carLayer.Open();
            carLayer.EditTools.BeginTransaction();
            carLayer.EditTools.Update(pointShape);
            carLayer.EditTools.CommitTransaction();
            carLayer.Close();

            previousLong = Long;
            previousLat  = Lat;

            //Function to center the map to a point (the moving moving vehicle feature)if it goes outside the tolerance.
            RectangleShape toleranceRectangleShape = new RectangleShape(winformsMap1.CurrentExtent.UpperLeftPoint, winformsMap1.CurrentExtent.LowerRightPoint);

            toleranceRectangleShape.ScaleDown(60);
            if (toleranceRectangleShape.Contains(new PointShape(Long, Lat)) == false)
            {
                winformsMap1.CenterAt(new PointShape(Long, Lat));

                //Resets the RectangleShape of the tolerance layer (for displaying only)
                LayerOverlay         toleranceOverlay = (LayerOverlay)winformsMap1.Overlays["ToleranceOverlay"];
                InMemoryFeatureLayer toleranceLayer   = toleranceOverlay.Layers["ToleranceLayer"] as InMemoryFeatureLayer;

                RectangleShape newToleranceRectangleShape = new RectangleShape(winformsMap1.CurrentExtent.UpperLeftPoint, winformsMap1.CurrentExtent.LowerRightPoint);
                newToleranceRectangleShape.ScaleDown(60);
                newToleranceRectangleShape.Id = "Tolerance";

                toleranceLayer.Open();
                toleranceLayer.EditTools.BeginTransaction();
                toleranceLayer.EditTools.Update(newToleranceRectangleShape);
                toleranceLayer.EditTools.CommitTransaction();
                toleranceLayer.Close();

                winformsMap1.Refresh();
            }
            else
            {
                winformsMap1.Refresh(vehicleOverlay);
            }
        }