private void GeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs args)
 {
     GPParameter gpParameter = args.Results.OutParameters[0];
     if (gpParameter is GPFeatureRecordSetLayer)
     {
         GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
         ProfileImage.Source = new BitmapImage(new Uri(gpLayer.FeatureSet.Features[0].Attributes["profileURL"].ToString(), UriKind.Absolute));
         ProfileView.Visibility = Visibility.Visible;
     }
 }
 private void GeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
 {
     foreach (GPParameter gpParameter in e.Results.OutParameters)
     {
         if (gpParameter is GPFeatureRecordSetLayer)
         {
             GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
             foreach (Graphic graphic in gpLayer.FeatureSet.Features)
             {
                 graphic.Symbol = LayoutRoot.Resources["PathLineSymbol"] as Symbol;
                 _graphicsLayer.Graphics.Add(graphic);
             }
         }
     }
 }
 private void GPService_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
 {
     this.IsBusy = false;
     this.ToggleWidgetContent(1);
     txtExtractionStatus.Visibility = Visibility.Collapsed;
     foreach (GPParameter gpParam in e.Results.OutParameters)
     {
         if (gpParam is GPDataFile)
         {
             string dataUrl = (gpParam as GPDataFile).Url;
             lnkExtractionOutput.NavigateUri = new Uri(dataUrl, UriKind.Absolute);
             break;
         }
     }
 }
 private void GeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
 {
     foreach (GPParameter gpParameter in e.Results.OutParameters)
     {
         if (gpParameter is GPFeatureRecordSetLayer)
         {
             GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
             foreach (Graphic graphic in gpLayer.FeatureSet.Features)
             {
               graphic.Symbol = LayoutRoot.Resources["PathLineSymbol"] as Symbol;
               _graphicsLayer.Graphics.Add(graphic);
             }
         }
     }
 }
Beispiel #5
0
        private void findNearestWSGPTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
        {
            try
            {
                foreach (GPParameter gpParameter in e.Results.OutParameters)
                {
                    if (gpParameter is GPFeatureRecordSetLayer)
                    {
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        foreach (client.Graphic graphic in gpLayer.FeatureSet.Features)
                        {
                            double distance = Convert.ToDouble(graphic.Attributes["NEAR_DIST"]) * 69.09;
                            _weatherStationDistanceInfo = "Distance to weather station: " + distance.ToString("0.000") + " miles";

                            //get the wind direction from the nearest weather station...
                            int fid = Convert.ToInt32(graphic.Attributes["NEAR_FID"]);

                            if (_windDirectionLayer != null)
                            {
                                QueryTask windDirectionQueryTask = new QueryTask(_windDirectionLayer.Url);
                                windDirectionQueryTask.ExecuteCompleted += WindDirectionQueryTask_ExecuteCompleted;
                                windDirectionQueryTask.Failed           += QueryTask_Failed;

                                ESRI.ArcGIS.Client.Tasks.Query windDirectionQuery = new ESRI.ArcGIS.Client.Tasks.Query();
                                windDirectionQuery.OutFields.AddRange(new string[] { "*" });
                                windDirectionQuery.Where = "OBJECTID =" + fid;

                                windDirectionQueryTask.ExecuteAsync(windDirectionQuery);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                MessageBox.Show("Error finding the nearest weather station!", "Error");
                return;
            }
        }
Beispiel #6
0
        // End Buttons
        #endregion


        #region ERG Chemical GP Tool Logic

        //Execute task is completed
        void ERGGeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
        {
            foreach (GPParameter gpParameter in e.Results.OutParameters)
            {
                if (gpParameter is GPFeatureRecordSetLayer)
                {
                    if (gpParameter.Name == "output_areas")
                    {
                        _ergZoneGraphicsLayer.Graphics.Clear();
                        ESRI.ArcGIS.Client.Geometry.Polygon sharedPolygon = null;

                        //add the erg zone polygons on the map
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        foreach (client.Graphic graphic in gpLayer.FeatureSet.Features)
                        {
                            string zone = graphic.Attributes["ERGZone"].ToString();
                            switch (zone)
                            {
                            case "Initial Isolation Zone":
                                graphic.Symbol = _mydictionary["sfsZone2"] as client.Symbols.SimpleFillSymbol;
                                break;

                            case "Protective Action Zone":
                                graphic.Symbol = _mydictionary["sfsZone1"] as client.Symbols.SimpleFillSymbol;
                                break;

                            case "Combined Zone":
                                graphic.Symbol = _mydictionary["sfsZone3"] as client.Symbols.SimpleFillSymbol;
                                sharedPolygon  = (ESRI.ArcGIS.Client.Geometry.Polygon)graphic.Geometry;
                                break;
                            }
                            _ergZoneGraphicsLayer.Graphics.Add(graphic);
                        }
                        //zoom to the result
                        if (chkZoomToMap.IsChecked == true)
                        {
                            _mapWidget.Map.Extent = sharedPolygon.Extent.Expand(1.2);
                        }
                    }
                    else
                    {
                        //add the erg zone polygons on the map
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        foreach (client.Graphic graphic in gpLayer.FeatureSet.Features)
                        {
                            string lineType = graphic.Attributes["LineType"].ToString();
                            switch (lineType)
                            {
                            case "Arc":
                                graphic.Symbol = _mydictionary["ArcLineSymbol"] as client.Symbols.SimpleLineSymbol;
                                break;

                            case "Radial":
                                graphic.Symbol = _mydictionary["RadialSymbol"] as client.Symbols.SimpleLineSymbol;
                                break;
                            }
                            _ergZoneGraphicsLayer.Graphics.Add(graphic);
                        }
                    }
                }
            }
        }
Beispiel #7
0
 private void GeoProcessingTaskExport2PDF_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
 {
     GPParameter gpParameter = e.Results.OutParameters[0];
     PdfEventArgs pdfEvent = new PdfEventArgs() { pdfFile = gpParameter.ToString() };
     pdfHandler(this, pdfEvent);
 }
        private void findNearestWSGPTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
        {
            try
            {
                foreach (GPParameter gpParameter in e.Results.OutParameters)
                {
                    if (gpParameter is GPFeatureRecordSetLayer)
                    {
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        foreach (client.Graphic graphic in gpLayer.FeatureSet.Features)
                        {
                            double distance = Convert.ToDouble(graphic.Attributes["NEAR_DIST"]) * 69.09;
                            _weatherStationDistanceInfo = "Distance to weather station: " + distance.ToString("0.000") + " miles";

                            //get the wind direction from the nearest weather station... 
                            int fid = Convert.ToInt32(graphic.Attributes["NEAR_FID"]);

                            if (_windDirectionLayer != null)
                            {
                                QueryTask windDirectionQueryTask = new QueryTask(_windDirectionLayer.Url);
                                windDirectionQueryTask.ExecuteCompleted += WindDirectionQueryTask_ExecuteCompleted;
                                windDirectionQueryTask.Failed += QueryTask_Failed;

                                ESRI.ArcGIS.Client.Tasks.Query windDirectionQuery = new ESRI.ArcGIS.Client.Tasks.Query();
                                windDirectionQuery.OutFields.AddRange(new string[] { "*" });
                                windDirectionQuery.Where = "OBJECTID =" + fid;

                                windDirectionQueryTask.ExecuteAsync(windDirectionQuery);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                MessageBox.Show("Error finding the nearest weather station!", "Error");
                return;
            }
        }
        // End Buttons
        #endregion


        #region ERG Chemical GP Tool Logic

        //Execute task is completed 
        void ERGGeoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
        {
            foreach (GPParameter gpParameter in e.Results.OutParameters)
            {
                if (gpParameter is GPFeatureRecordSetLayer)
                {
                    if (gpParameter.Name == "output_areas")
                    {
                        _ergZoneGraphicsLayer.Graphics.Clear();
                        ESRI.ArcGIS.Client.Geometry.Polygon sharedPolygon = null;

                        //add the erg zone polygons on the map
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        foreach (client.Graphic graphic in gpLayer.FeatureSet.Features)
                        {
                            string zone = graphic.Attributes["ERGZone"].ToString();
                            switch (zone)
                            {
                                case "Initial Isolation Zone":
                                    graphic.Symbol = _mydictionary["sfsZone2"] as client.Symbols.SimpleFillSymbol;
                                    break;
                                case "Protective Action Zone":
                                    graphic.Symbol = _mydictionary["sfsZone1"] as client.Symbols.SimpleFillSymbol;
                                    break;
                                case "Combined Zone":
                                    graphic.Symbol = _mydictionary["sfsZone3"] as client.Symbols.SimpleFillSymbol;
                                    sharedPolygon = (ESRI.ArcGIS.Client.Geometry.Polygon)graphic.Geometry;
                                    break;
                            }
                            _ergZoneGraphicsLayer.Graphics.Add(graphic);
                        }
                        //zoom to the result
                        if (chkZoomToMap.IsChecked == true)
                            _mapWidget.Map.Extent = sharedPolygon.Extent.Expand(1.2);
                    }
                    else 
                    {
                        //add the erg zone polygons on the map
                        GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer;
                        foreach (client.Graphic graphic in gpLayer.FeatureSet.Features)
                        {
                            string lineType = graphic.Attributes["LineType"].ToString();
                            switch (lineType)
                            {
                                case "Arc":
                                    graphic.Symbol = _mydictionary["ArcLineSymbol"] as client.Symbols.SimpleLineSymbol;
                                    break;
                                case "Radial":
                                    graphic.Symbol = _mydictionary["RadialSymbol"] as client.Symbols.SimpleLineSymbol;
                                    break;
                            }
                            _ergZoneGraphicsLayer.Graphics.Add(graphic);
                        }
                    }

                }
            }
        }
        void geoprocessorTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e)
        {


            if (e.Results == null || e.Results.OutParameters.Count == 0 || (e.Results.OutParameters[0] as GPFeatureRecordSetLayer).FeatureSet.Features.Count == 0)
            {
                MessageBox.Show("Fail to get elevation data. Draw another line");
                return;
            }

            ESRI.ArcGIS.Client.Geometry.Polyline elevationLine =
                (e.Results.OutParameters[0] as GPFeatureRecordSetLayer).FeatureSet.Features[0].Geometry
                as ESRI.ArcGIS.Client.Geometry.Polyline;

            foreach (MapPoint p in elevationLine.Paths[0])
            {
                p.M = Math.Round(((p.M / 1000) * .621371192237), 4);
                p.Z = Math.Round((p.Z * 3.28083989501), 2);
            }

            MapPoint lastPoint = elevationLine.Paths[0][elevationLine.Paths[0].Count - 1];

            _elevationProfileDialog.ProfileDistance = lastPoint.M;
            _elevationProfileDialog.ProfileData = elevationLine.Paths[0];


            var top = ((FrameworkElement)Application.Current.RootVisual).ActualHeight - 400;
            if (MapApplication.Current.IsEditMode)
                top -= 20;
            MapApplication.Current.ShowWindow("", _elevationProfileDialog, false, (s, a) => ClearLayers(), null, WindowType.Floating, top);
        }