public override void DoMenuItem(esriE2MenuType menuType, object menuArgs, int menuItemId) { // Perform the actual work of the context menu. // First, get the result information (not applicable to the Options menu). ResultInfo resInfo = menuArgs as ResultInfo; // Choose the item action to run. switch (menuItemId) { case (361): // Send To menu item. 361 is arbitrary, could be any number { SendLocationToDialog(resInfo.ChosenResult); break; } } }
public override MenuDef GetMenu(esriE2MenuType menuType, object menuArgs) { if (menuType == esriE2MenuType.ResultContextMenu) { // GetMenu for a ResultContextMenu is only called on the TaskUI which created the result // in the first place, and can be used to add any additional context menu items to the // standard menu. if (_mainMenu == null) { // For the main context menu, support one simple item. _mainMenu = new MenuDef(); } return this._mainMenu; } else if (menuType == esriE2MenuType.ResultSendToMenu) { // GetMenu for a ResultSentToMenu is called for any result, regardless of which TaskUI // first created the result. Here, the TaskUI should decide if it supports working with // the menuArgs passed in. // For the send to menu, support all PlaceResults with Point geometries. // Checking the category means we do not present the context menu for failed executions, // only for results where we successfully set the Category property. ResultInfo resInfo = menuArgs as ResultInfo; PlaceResult chosenRes = resInfo.ChosenResult as PlaceResult; if ((chosenRes != null) && (chosenRes.Geometry is Point)) { if (this._sendToMenu == null) { // Create the menu if required. _sendToMenu = new MenuDef(); _sendToMenu.AddItem("StreetViewer", "StreetViewer", false, false, 361); //361 is arbitrary could be any number } return this._sendToMenu; } } // For all other cases, do not provide a menu. return null; }