예제 #1
0
        /// <summary>
        /// Can be called from the mouse up event of the ArcMap tool.
        /// </summary>
        /// <param name="x">Clicked x coordinate.</param>
        /// <param name="y">Clicked y coordinate.</param>
        /// <returns>The picked feature candidate or null if no feature was picked.</returns>
        public ArcmapPickCandidate OnMouseUp(int x, int y)
        {
            ArcmapPickCandidate result        = null;
            IScreenDisplay      screenDisplay = ArcmapUtils.FocusMapToScreenDisplay(FocusMap);
            IPoint mapPoint        = TransformMousePositionToMapPoint(x, y, screenDisplay);
            double searchTolerance = ArcmapUtils.PixelsToDistance(_snapTolerance, screenDisplay);
            double mapScale        = GetCurrentMapScale(screenDisplay);

            List <ArcmapPickCandidate> pickCandidates = FindPickCandidates(mapPoint, _pickLayers, mapScale, searchTolerance);

            SortPickCandidates(pickCandidates);

            if (pickCandidates.Count == 1)
            {
                result = pickCandidates[0];
            }
            else if (pickCandidates.Count > 1)
            {
                System.Drawing.Point position = new System.Drawing.Point(x + popupShiftH, y + popupShiftV);
                ContextMenuStrip     menu     = BuildContextMenu(pickCandidates);
                menu.Opacity       = 0.9;
                _selectedCandidate = null;
                ContextMenuUtils.ShowContextMenu(menu, position, (IntPtr)ArcmapUtils.FocusMapToScreenDisplay(FocusMap).hWnd);
                if (_selectedCandidate != null)
                {
                    result = _selectedCandidate;
                }
            }
            return(result);
        }
예제 #2
0
        private void contextMenuItem_Select(object sender, EventArgs e)
        {
            object menuTag = ((ToolStripItem)sender).Tag;
            ArcmapPickCandidate candidate = (ArcmapPickCandidate)menuTag;

            ArcmapUtils.FlashFeature(candidate.Feature, ArcmapUtils.FocusMapToScreenDisplay(FocusMap));
        }
예제 #3
0
        /// <summary>
        /// Enumerates all workspaces in ArcMap.
        /// </summary>
        /// <param name="esriApplication">The Esri application istance.</param>
        /// <returns>Enumeration of workspaces.</returns>
        public static IEnumerable <IWorkspace> EnumerateAllWorkspaces(IApplication esriApplication)
        {
            HashSet <IWorkspace> duplicateFinder = new HashSet <IWorkspace>();

            foreach (IDataset dataset in ArcmapUtils.EnumerateAllDatasets(esriApplication))
            {
                IWorkspace workspace = dataset.Workspace;
                if ((workspace != null) && !duplicateFinder.Contains(workspace))
                {
                    duplicateFinder.Add(workspace);
                    yield return(workspace);
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ArcmapPickCandidate"/> class.
 /// </summary>
 /// <param name="identifyOby">Identified object.</param>
 /// <param name="distance">Distance from the identified object to the mouse click.</param>
 public ArcmapPickCandidate(IIdentifyObj identifyOby, double distance)
 {
     IdentifyObj          = identifyOby;
     DistanceToClickPoint = distance;
     GeometryType         = ArcmapUtils.DetectGeometryBaseType(Feature.Shape);
 }