// Fires when the identify operation has completed successfully. Updates the data shown in the // identify dialog. private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { PendingIdentifies--; if (!waitedForDoubleClick && !initiatedByTouch) { identifyTaskResults.Add(args); return; } reportResults(args); }
void doubleClickTimer_Tick(object sender, EventArgs e) { doubleClickTimer.Stop(); waitedForDoubleClick = true; // Initialize layer containing activity indicator to display on the map while results are // being retrieved. Only add the activity indicator if there are outstanding identify // operations and no results have been returned yet. if (PendingIdentifies > 0 && (identifyTaskResults == null || identifyTaskResults.Count == 0)) { if (busyLayer == null) { initializeBusyLayer(); } else { busyLayer.Graphics[0].Geometry = clickPoint; } if (!Map.Layers.Contains(busyLayer)) { Map.Layers.Add(busyLayer); } } if (identifyTaskResults != null && identifyTaskResults.Count > 0) { foreach (object item in identifyTaskResults) { IdentifyEventArgs args = item as IdentifyEventArgs; if (args != null) { reportResults(args); } else { GraphicsLayerResult result = item as GraphicsLayerResult; if (result != null) { reportResults(result); } } } } }
} // private void DrawComplete(object sender, DrawEventArgs e) /// <summary> /// Fires when the identify operation has completed successfully. /// Updates the data shown in the identify dialog. /// http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/help/Identify_task.htm /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { log("VIdentify.IdentifyTask_ExecuteCompleted"); DataItems.Clear(); var title = identifyDialog.DataDisplayTitleBottom; title.Text = "Ничего не найдено"; identifyDialog.IdentifyResultsPanel.Visibility = Visibility.Collapsed; // shrink grid and restore column.width options later var dg = identifyDialog.IdentifyDetailsDataGrid; dg.ColumnWidth = DataGridLength.SizeToCells; foreach (var col in dg.Columns) { col.Width = DataGridLength.SizeToHeader; // DataGridLength.Auto; } // fill datagrid with results if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { title.Text = string.Format("Найдено записей: {0}", args.IdentifyResults.Count); identifyDialog.IdentifyResultsPanel.Visibility = Visibility.Visible; foreach (IdentifyResult result in args.IdentifyResults) { Graphic feature = result.Feature; DataItems.Add(new DataItem() { Title = (result.Value.ToString() + " (" + result.LayerName + ")").Trim(), Data = feature.Attributes }); } // foreach result // update grid layout dg.ColumnWidth = DataGridLength.Auto; foreach (var col in dg.Columns) { col.Width = DataGridLength.Auto; } identifyDialog.UpdateLayout(); identifyDialog.IdentifyComboBox.SelectedIndex = 0; } // if has results } // private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { DataListBox.ItemsSource = null; if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { IdentifyResultsPanel.Visibility = Visibility.Visible; IdentifyBorder.Visibility = Visibility.Visible; ShowFeatures(args.IdentifyResults); } else { IdentifyListBox.Items.Clear(); IdentifyListBox.UpdateLayout(); IdentifyResultsPanel.Visibility = Visibility.Collapsed; } }
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { IdentifyDetailsDataGrid.ItemsSource = null; if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { IdentifyResultsPanel.Visibility = Visibility.Visible; ShowFeatures(args.IdentifyResults); } else { IdentifyComboBox.Items.Clear(); IdentifyComboBox.UpdateLayout(); IdentifyResultsPanel.Visibility = Visibility.Collapsed; } }
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { IdentifyDetailsDataGrid.ItemsSource = null; if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { IdentifyResultsPanel.Visibility = Visibility.Visible; NoResult.Visibility = Visibility.Collapsed; Results.Visibility = Visibility.Visible; ShowFeatures(args.IdentifyResults); } else { IdentifyComboBox.Items.Clear(); IdentifyComboBox.UpdateLayout(); Results.Visibility = Visibility.Collapsed; NoResult.Visibility = Visibility.Visible; } }
void reportResults(IdentifyEventArgs args) { if (doNotShowResults) { removeBusyIndicator(); return; } if (args.IdentifyResults != null && args.IdentifyResults.Count > 0) { Layer layer = (args.UserState as UserState).Layer; Collection <LayerInformation> layerInfos = ESRI.ArcGIS.Mapping.Core.LayerExtensions.GetLayerInfos(layer); foreach (IdentifyResult result in args.IdentifyResults) { LayerInformation layerInfo = layerInfos.FirstOrDefault(l => l.ID == result.LayerId); if (layerInfo != null) { PopupItem popupItem = PopupHelper.GetPopupItem(result.Feature, layer, layerInfo.Fields, layerInfo, result.LayerName, result.Value.ToString(), result.LayerId); if (popupItem != null) { _popupInfo.PopupItems.Add(popupItem); } } } } removeBusyIndicator(); if (_popupInfo.PopupItems.Count > 0) { if (_popupInfo.SelectedIndex < 0) { _popupInfo.SelectedIndex = 0; } PopupHelper.ShowPopup(_popupInfo, clickPoint); } }
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs e) { string mapName = (string)e.UserState; string preName = "^?^"; GeoFeatureCollection features = null; foreach (IdentifyResult result in e.IdentifyResults) { if (result.LayerName != preName) { if (features != null) { this.FeatureSets.Add(features); } AddToGraphicsLayer(result.Feature, (string)result.Value, result.DisplayFieldName, result.LayerName); features = new GeoFeatureCollection(result.DisplayFieldName, result.LayerName, mapName); features.Add(result.Feature); preName = result.LayerName; } else if (features != null) { AddToGraphicsLayer(result.Feature, (string)result.Value, result.DisplayFieldName, result.LayerName); features.Add(result.Feature); } } // Add the last layer results if (features != null) { this.FeatureSets.Add(features); } this.IsBusy = false; }
// Populate ComboBox with the results when Identify is complete. private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { IdentifyComboBox.Items.Clear(); // Check for new results. if (args.IdentifyResults.Count > 0) { // Show ComboBox and attributes DataGrid. IdentifyResultsStackPanel.Visibility = Visibility.Visible; // Add results to ComboBox. foreach (IdentifyResult result in args.IdentifyResults) { string title = string.Format("{0} ({1})", result.Value.ToString(), result.LayerName); IdentifyComboBox.Items.Add(title); } // Workaround for ComboBox bug. IdentifyComboBox.UpdateLayout(); // Store the list of Identify results. _lastIdentifyResult = args.IdentifyResults; // Initialize ComboBox and fire SelectionChanged. IdentifyComboBox.SelectedIndex = 0; } else { // Hide ComboBox and attributes DataGrid and notify the user. IdentifyResultsStackPanel.Visibility = Visibility.Collapsed; MessageBox.Show("No features found"); } }
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args) { // Remove previous results identifyComboBox.Items.Clear(); // If results are found make the grid visible if (args.IdentifyResults.Count > 0) { identifyResultsStackPanel.Visibility = Visibility.Visible; // Display value for each layer in the identify combo box foreach (IdentifyResult result in args.IdentifyResults) { string title = string.Format("{0} ({1})", result.Value.ToString(), result.LayerName); identifyComboBox.Items.Add(title); } identifyComboBox.UpdateLayout(); _lastIdentifyResult = args.IdentifyResults; identifyComboBox.SelectedIndex = 0; } else { identifyResultsStackPanel.Visibility = Visibility.Collapsed; MessageBox.Show("No features found"); } }