ArcGISWindowsPhoneSDK.AttributeQuery.QueryTask_ExecuteCompleted C# (CSharp) Метод

QueryTask_ExecuteCompleted() приватный Метод

private QueryTask_ExecuteCompleted ( object sender, ESRI args ) : void
sender object
args ESRI
Результат void
        private void QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
        {
            FeatureSet featureSet = args.FeatureSet;

            // If initial query to populate states list box
            if ((args.UserState as string) == "initial")
            {
                // Just show on initial load
                QueryListBox.Items.Add("Select...");

                foreach (Graphic graphic in args.FeatureSet.Features)
                {
                    QueryListBox.Items.Add(graphic.Attributes["STATE_NAME"].ToString());
                }

                QueryListBox.SelectedIndex = 0;
                return;
            }

            // Remove the first entry if "Select..."
            if (QueryListBox.Items[0].ToString().Contains("Select..."))
                QueryListBox.Items.RemoveAt(0);

            // If an item has been selected
            GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
            graphicsLayer.ClearGraphics();

            if (featureSet != null && featureSet.Features.Count > 0)
            {
                // Show selected feature attributes in DataGrid
                Graphic selectedFeature = featureSet.Features[0];

                ResultsListBox.Items.Clear();
                //QueryDetailsDataGrid.ItemsSource = selectedFeature.Attributes;
                foreach (KeyValuePair<string, object> pair in selectedFeature.Attributes)
                {
                    TextBlock tb1 = new TextBlock()
                    {
                        FontSize = 30,
                        FontWeight = FontWeights.Bold,
                        Text = string.Format("{0}: ", pair.Key)
                    };
                    TextBlock tb2 = new TextBlock()
                    {
                        FontSize = 30,
                        Text = string.Format(" {0}", pair.Value)
                    };
                    StackPanel sp = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Vertical };
                    sp.Children.Add(tb1);
                    sp.Children.Add(tb2);
                    ListBoxItem item = new ListBoxItem();
                    item.Content = sp;
                    ResultsListBox.Items.Add(item);
                }

                // Highlight selected feature
                selectedFeature.Symbol = DefaultFillSymbol;
                graphicsLayer.Graphics.Add(selectedFeature);

                // Zoom to selected feature (define expand percentage)
                ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent;

                double expandPercentage = 30;

                double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100);
                double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100);

                ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope(
                selectedFeatureExtent.XMin - (widthExpand / 2),
                selectedFeatureExtent.YMin - (heightExpand / 2),
                selectedFeatureExtent.XMax + (widthExpand / 2),
                selectedFeatureExtent.YMax + (heightExpand / 2));

                MyMap.ZoomTo(displayExtent);

                // If DataGrid not visible (initial load), show it
                if (ResultsListBox.Visibility == Visibility.Collapsed)
                {
                    ResultsListBox.Visibility = Visibility.Visible;
                    QueryGrid.Height = Double.NaN;
                    QueryGrid.UpdateLayout();
                }
            }
            else
            {
                //QueryDetailsDataGrid.ItemsSource = null;
                ResultsListBox.Visibility = Visibility.Collapsed;
                QueryGrid.Height = Double.NaN;
                QueryGrid.UpdateLayout();
            }
        }