// Click on a graphic in the map and select it. Scroll to the web map item in the Listbox. private void GraphicsLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs e) { webmapGraphicsLayer.ClearSelection(); Graphic graphic = e.Graphic; graphic.Selected = true; ArcGISPortalItem portalitem = graphic.Attributes["PortalItem"] as ArcGISPortalItem; WebMapsListBox.SelectedItem = portalitem; WebMapsListBox.ScrollIntoView(portalitem); }
// Clear graphics layer selection private void ClearSelectButton_Click(object sender, System.Windows.RoutedEventArgs e) { try { _graphicsLayer.ClearSelection(); } catch (Exception ex) { MessageBox.Show("Selection Error: " + ex.Message, "Graphics Layer Selection Sample"); } }
// Clear graphics layer selection private void ClearSelectButton_Click(object sender, RoutedEventArgs e) { try { _graphicsLayer.ClearSelection(); SetGraphicsCountUI(); } catch (Exception ex) { var _x = new MessageDialog("Selection Error: " + ex.Message, "Graphics Layer Selection Sample").ShowAsync(); } }
public async void QueryPerson() { //if (mapOperationType != MapOperationType.QueryPerson) //{ mapOperationType = MapOperationType.QueryPerson; var mapRect = await mainMapView.Editor.RequestShapeAsync(DrawShape.Envelope) as Envelope; personsLayers.ClearSelection(); eventsLayer.ClearSelection(); var winRect = new Rect(mainMapView.LocationToScreen(new MapPoint(mapRect.XMin, mapRect.YMax, mainMapView.SpatialReference)), mainMapView.LocationToScreen(new MapPoint(mapRect.XMax, mapRect.YMin, mainMapView.SpatialReference))); var graphics = await personsLayers.HitTestAsync(mainMapView, winRect, 1000); ShowSelectFamousesByGraphic(graphics); mapOperationType = MapOperationType.None; //} //else //{ // mapOperationType = MapOperationType.None; // personsLayers.ClearSelection(); //} }
private void resultsGrid_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e) { _graphicsLayer.ClearSelection(); if (e.AddedItems != null && e.AddedItems.Count > 0) { var graphic = e.AddedItems[0] as Graphic; if (graphic != null) { graphic.IsSelected = true; } } }
public void RunApplyTextTool() { QueuedTask.Run(() => { // Take the currently selected text and update it as needed // get the first graphics layer in the map's collection of graphics layers var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType <ArcGIS.Desktop.Mapping.GraphicsLayer>().FirstOrDefault(); if (graphicsLayer == null) { return; } var selectedGraphicLayers = MapView.Active.GetSelectedLayers().OfType <GraphicsLayer>(); if (selectedGraphicLayers.Count() == 0) { //nothing selected. So clear the selected graphic layer. SelectedGraphicsLayerTOC = null; MessageBox.Show("No graphic layer selected.", "Select layer"); return; } SelectedGraphicsLayerTOC = selectedGraphicLayers.FirstOrDefault(); var selectedElements = graphicsLayer.GetSelectedElements(). OfType <GraphicElement>().Where(elem => elem.GetGraphic() is CIMTextGraphic || elem.GetGraphic() is CIMParagraphTextGraphic); if (selectedElements.Count() == 0) { //nothing selected. So clear the selected graphic layer. MessageBox.Show("No Text or Paragraph Text workflow graphics selected.", "Select graphics"); return; } // Get the editbox or the dockpane textbox value string txtBoxString = null; string queryTxtBoxString = null; if (Module1.Current.blnDockpaneOpenStatus == false) { // Use values in the edit boxes txtBoxString = Module1.Current.TextValueEditBox.Text; queryTxtBoxString = Module1.Current.QueryValueEditBox.Text; if (txtBoxString == null || txtBoxString == "") { txtBoxString = " Default Text"; } else { txtBoxString = " " + txtBoxString; } if (queryTxtBoxString != null && queryTxtBoxString != "") { txtBoxString = txtBoxString + "\r\n " + queryTxtBoxString; } } if (Module1.Current.blnDockpaneOpenStatus == true) { _dockpane = FrameworkApplication.DockPaneManager.Find("GraphicTools_TextPane") as TextPaneViewModel; txtBoxString = _dockpane.TxtBoxDoc; queryTxtBoxString = _dockpane.QueryTxtBoxDoc; if (txtBoxString == null || txtBoxString == "") { txtBoxString = " Default Text"; } else { txtBoxString = " " + txtBoxString; } if (queryTxtBoxString != null && queryTxtBoxString != "") { txtBoxString = txtBoxString + "\r\n " + queryTxtBoxString; } } foreach (var elem in selectedElements) { // Get the CIMTextGraphic of the current text graphic and update it with contents of text box if (elem.GetGraphic() is CIMTextGraphic) { var newCIMGraphic = elem.GetGraphic() as CIMTextGraphic; newCIMGraphic.Text = txtBoxString; elem.SetGraphic(newCIMGraphic); } // Get the CIMParagraphTextGraphic of the current text graphic and update it with contents of text box if (elem.GetGraphic() is CIMParagraphTextGraphic) { var newCIMGraphic = elem.GetGraphic() as CIMParagraphTextGraphic; newCIMGraphic.Text = txtBoxString; elem.SetGraphic(newCIMGraphic); } } SelectedGraphicsLayerTOC.ClearSelection(); }); }