protected override void OnMouseUp(MouseEventArgs arg) { try { int x = arg.X; int y = arg.Y; IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document; IFeatureLayer pfeaturelayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0]; IDataset pDS = (IDataset)pfeaturelayer.FeatureClass; TowerManager tm = new TowerManager(pDS.Workspace); // THIS IS HOW YOU CREATE A POINT IPoint pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); Tower t = tm.GetNearestTower(pPoint, 30); if (t == null) { MessageBox.Show("No towers were found within the are you clicked"); return; } MessageBox.Show("Tower id " + t.ID + Environment.NewLine + "Type: " + t.TowerType + Environment.NewLine + "NetworkBand " + t.NetworkBand); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected override void OnMouseUp(MouseEventArgs arg) { try { int x = arg.X; int y = arg.Y; IMxDocument pMxdoc = (IMxDocument)ArcMap.Application.Document; IFeatureLayer pfeaturelayer = (IFeatureLayer)pMxdoc.ActiveView.FocusMap.Layer[0]; IDataset pDS = (IDataset)pfeaturelayer.FeatureClass; IPoint pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); DeviceManager dm = new DeviceManager(pDS.Workspace); dm.AddDevice("D01", pPoint); TowerManager tm = new TowerManager(pDS.Workspace); // MessageBox.Show("we have a point"); Tower t = tm.GetNearestTower(pPoint, 10); //tm.GetTowerByID("T04"); if (t == null) { MessageBox.Show("No towers were found within the area you clicked."); return; } //IPoint pPoint = pMxdoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); MessageBox.Show("Tower id " + t.ID + Environment.NewLine + "Type " + t.TowerType + Environment.NewLine + "Networkband: " + t.NetworkBand); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }