Exemple #1
0
        //In the MouseDoubleClick event, we allow adding a new draggable icon by left double clicking on the map and
        //removing an icon by right double clicking.
        private void winformsMap1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            winformsMap1.EditOverlay.EditShapesLayer.Open();
            PointShape clickedPointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, e.X, e.Y, winformsMap1.Width, winformsMap1.Height);

            //For removing the icon clicked on.
            if (e.Button == MouseButtons.Right)
            {
                Collection <Feature> clickedFeatures = winformsMap1.EditOverlay.EditShapesLayer.QueryTools.GetFeaturesNearestTo(clickedPointShape, GeographyUnit.DecimalDegree, 1,
                                                                                                                                ReturningColumnsType.AllColumns);
                winformsMap1.EditOverlay.EditShapesLayer.Close();

                if (clickedFeatures.Count > 0)
                {
                    //Gets the dimension of the icon and checks if the clicked point is inside it.
                    ValueStyle valueStyle = (ValueStyle)winformsMap1.EditOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[0];
                    //we loop thru the different ValueItem to get the appropriate icon according to the "Type".
                    GeoImage geoImage = null;
                    string   text     = clickedFeatures[0].ColumnValues["Type"].Trim();
                    foreach (ValueItem valueItem in valueStyle.ValueItems)
                    {
                        if (text == valueItem.Value)
                        {
                            geoImage = (GeoImage)valueStyle.ValueItems[0].DefaultPointStyle.Image;
                            break;
                        }
                    }
                    //We check to see if we clicked inside the icon itself.
                    ScreenPointF screenPointF = ExtentHelper.ToScreenCoordinate(winformsMap1.CurrentExtent, clickedFeatures[0], winformsMap1.Width, winformsMap1.Height);
                    RectangleF   rectangleF   = new RectangleF(screenPointF.X - (geoImage.GetWidth() / 2), screenPointF.Y - (geoImage.GetHeight() / 2),
                                                               geoImage.GetWidth(), geoImage.GetHeight());
                    bool IsInside = rectangleF.Contains(new PointF(e.X, e.Y));

                    //If inside, removes the feature from the EditShapesLayer of the EditOverlay.
                    if (IsInside == true)
                    {
                        winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Remove(clickedFeatures[0]);
                        winformsMap1.Refresh(winformsMap1.EditOverlay);
                    }
                }
            }
            //Adding a new icon.
            else if (e.Button == MouseButtons.Left)
            {
                Feature carFeature = new Feature(clickedPointShape);
                carFeature.ColumnValues["Type"] = "Unknown";
                //We use DateTime.Now.Ticks to be sure to use a unique key each time we add a new feature.
                winformsMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(DateTime.Now.Ticks.ToString(), carFeature);
                //We call CalculateAllControlPoints to update the control points with the new feature to be able to drag the newly added feature.
                winformsMap1.EditOverlay.CalculateAllControlPoints();
                winformsMap1.Refresh(winformsMap1.EditOverlay);
            }
        }
Exemple #2
0
 protected override void DrawScreenImageWithoutScalingCore(GeoImage image, float centerXInScreen, float centerYInScreen, DrawingLevel drawingLevel, float xOffset, float yOffset, float rotateAngle)
 {
     DrawScreenImageCore(image, centerXInScreen, centerYInScreen, image.GetWidth(), image.GetHeight(), drawingLevel, xOffset, yOffset, rotateAngle);
 }