예제 #1
0
        //Finish the sketch when user double-clicks on the map
        async void map_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            client.Map map = MapWidget.Map;

            //Unregister the events
            map.MouseClick       -= map_MouseClick;
            map.MouseDoubleClick -= map_MouseDoubleClick;
            map.MouseMove        -= map_MouseMove;

            //Make a call to the REST API to get the profile line from the sketch
            ProfileService service = new ProfileService();

            Profile = await service.GetProfileLine(sketchGeometry);

            //if we fail to get the profile line, clear all graphics from the map
            if (Profile == null)
            {
                MessageBox.Show("Failed to get elevation profile");
                RemoveAllGraphicLayers();
                return;
            }

            //Update the graph with the profile info
            UpdateControls();

            CanClearGraph = true;
        }
        /// <summary>
        /// Execute is called when the user chooses the feature action from the feature actions context menu. Only called if
        /// CanExecute returned true.
        /// </summary>
        public async void Execute(ESRI.ArcGIS.OperationsDashboard.DataSource dataSource, client.Graphic feature)
        {
            //This feature action relies on a profile graph widget to create a graph based on the profile line
            //Check if the view has a ProfileGraphWidget widget to display the output graph
            ProfileGraphFromMap profileWidget = OperationsDashboard.Instance.Widgets.FirstOrDefault(w => w.GetType() == typeof(ProfileGraphFromMap)) as ProfileGraphFromMap;

            if (profileWidget == null)
            {
                MessageBox.Show("Add the Profile Graph Widget to the view to execute this feature action", "Profile Graph Widget Required");
                return;
            }

            //Send the feature to the Elevation Analysis service to get the profile line
            ProfileService service = new ProfileService();

            Profile = await service.GetProfileLine(feature.Geometry);

            if (Profile == null)
            {
                MessageBox.Show("Failed to get elevation profile");
                return;
            }

            //Send the result (Profile) to the profile graph widget and ask it to generate the graph
            profileWidget.MapWidget = MapWidget.FindMapWidget(dataSource);
            profileWidget.Profile   = Profile;
            profileWidget.UpdateControls();
        }
    /// <summary>
    /// Execute is called when the user chooses the feature action from the feature actions context menu. Only called if
    /// CanExecute returned true.
    /// </summary>
    public async void Execute(ESRI.ArcGIS.OperationsDashboard.DataSource dataSource, client.Graphic feature)
    {
      //This feature action relies on a profile graph widget to create a graph based on the profile line
      //Check if the view has a ProfileGraphWidget widget to display the output graph
      ProfileGraphFromMap profileWidget = OperationsDashboard.Instance.Widgets.FirstOrDefault(w => w.GetType() == typeof(ProfileGraphFromMap)) as ProfileGraphFromMap;
      if (profileWidget == null)
      {
        MessageBox.Show("Add the Profile Graph Widget to the view to execute this feature action", "Profile Graph Widget Required");
        return;
      }

      //Send the feature to the Elevation Analysis service to get the profile line
      ProfileService service = new ProfileService();
      Profile = await service.GetProfileLine(feature.Geometry);
      if (Profile == null)
      {
        MessageBox.Show("Failed to get elevation profile");
        return;
      }

      //Send the result (Profile) to the profile graph widget and ask it to generate the graph
      profileWidget.MapWidget = MapWidget.FindMapWidget(dataSource);
      profileWidget.Profile = Profile;
      profileWidget.UpdateControls();
    }