private void OnPreviewRightMouseDown(object sender, MouseButtonEventArgs e)
        {
            Point mouseScreenPoint = e.GetPosition(mapControl).ToMapsui();
            var   draggingFeature  = GetFeaturesAtScreenPoint(mouseScreenPoint).OfType <DraggingFeature>().FirstOrDefault();

            if (draggingFeature != null && editedObject.Vertices.Count > editedObject.MinimumVertices)
            {
                // Preventing editing end
                e.Handled = true;

                var contextMenu = new ContextMenu();
                var deleteItem  = new MenuItem {
                    Header = "Удалить вершину",
                    Icon   = BitmapResources.LoadImage("Delete.png")
                };
                deleteItem.Click += (_s, _e) => RemoveVertex(draggingFeature.Vertex);
                contextMenu.Items.Add(deleteItem);
                contextMenu.IsOpen = true;
            }
        }
        private ContextMenu CreateMapObjectContextMenu(IMapObject iMapObject)
        {
            var contextMenu = new ContextMenu();

            contextMenu.Items.Add(CreateModifyItem());
            contextMenu.Items.Add(CreateRemoveItem());
            if (iMapObject is MapObject mapObj && !(iMapObject is BoundingAreaPolygon))
            {
                contextMenu.Items.Add(CreateConvertItem(mapObj));
            }
            return(contextMenu);

            ///////// BUTTONS CREATION LOCAL FUNCS
            MenuItem CreateModifyItem()
            {
                var item = new MenuItem
                {
                    Header = "Редактировать",
                    Icon   = BitmapResources.LoadImage("EditPolygon.png")
                };

                item.Click += (s, e) =>
                {
                    UnhighlightAllMapObjects();
                    EndAllTools();
                    StartMapObjectEditing(iMapObject);
                };
                return(item);
            }

            MenuItem CreateRemoveItem()
            {
                var item = new MenuItem
                {
                    Header = "Удалить",
                    Icon   = BitmapResources.LoadImage("Delete.png")
                };

                item.Click += (s, e) =>
                {
                    if (iMapObject is MapObject mapObject)
                    {
                        if (iMapObject == boundingAreaTool.BoundingArea)
                        {
                            boundingAreaTool.Remove();
                            RefreshButtons();
                        }
                        else
                        {
                            mapObjectLayer.TryRemove(mapObject);
                        }
                    }
                    else if (iMapObject is AttractorObject attractor)
                    {
                        attractorLayer.TryRemove(attractor);
                        RefreshButtons();
                    }
                    RefreshLayers();
                };
                return(item);
            }

            MenuItem CreateConvertItem(MapObject mapObject)
            {
                var parent = new MenuItem
                {
                    Header = "Преобразовать в..."
                };
                var convertOptions = AreaTypes.All
                                     .Where(x => x.GeometryType == mapObject.AreaType.GeometryType);

                foreach (var areaType in convertOptions)
                {
                    var item = new MenuItem
                    {
                        Header = areaType.DisplayedName
                    };
                    item.Click += (s, e) =>
                    {
                        mapObject.AreaType = areaType;
                        RefreshLayers();
                    };
                    parent.Items.Add(item);
                }
                return(parent);
            }

            ///////// END BUTTONS CREATION LOCAL FUNCS
        }