示例#1
0
        public void ShowFeatures(List <IdentifyResult> results)
        {
            _dataItems = new List <DataItem>();

            if (results != null && results.Count > 0)
            {
                IdentifyComboBox.Items.Clear();
                foreach (IdentifyResult result in results)
                {
                    Graphic feature = result.Feature;
                    string  title   = result.Value.ToString() + " (" + result.LayerName + ")";
                    _dataItems.Add(new DataItem()
                    {
                        Title = title,
                        Data  = feature.Attributes
                    });
                    IdentifyComboBox.Items.Add(title);
                }

                // Workaround for bug with ComboBox
                IdentifyComboBox.UpdateLayout();

                IdentifyComboBox.SelectedIndex = 0;
            }
        }
        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;
            }
        }
        public void ShowFeatures(List <IdentifyResult> results)
        {
            _dataItems = new List <DataItem>();

            if (results != null && results.Count > 0)
            {
                int layerId       = 0;
                int activeLayerId = 0;
                IdentifyComboBox.Items.Clear();
                _layersIdentified.Clear();
                foreach (IdentifyResult result in results)
                {
                    Graphic feature = result.Feature;
                    string  title   = result.Value.ToString() + " (" + result.LayerName + ")";

                    feature.Attributes.Remove("Shape");
                    feature.Attributes.Remove("OBJECTID");

                    _dataItems.Add(new DataItem()
                    {
                        Title = title,
                        Data  = feature.Attributes
                    });
                    IdentifyComboBox.Items.Add(title);

                    if (_activeIdentifyLayer == result.LayerName)
                    {
                        activeLayerId = layerId;
                    }
                    layerId++;
                    _layersIdentified.Add(result.LayerName);
                }

                // Workaround for bug with ComboBox
                IdentifyComboBox.UpdateLayout();

                IdentifyComboBox.SelectedIndex = activeLayerId;
            }

            Visibility = System.Windows.Visibility.Visible;
        }