Beispiel #1
0
        private async void AddSketch(object sender, EventArgs e)
        {
            // Enable the editing buttons.
            _doneButton.Enabled = _undoButton.Enabled = _redoButton.Enabled = true;

            // Prevent the user from adding pipes concurrently.
            _addButton.Enabled = false;

            // Get the geometry of the user drawn line.
            Geometry geometry = await _sketchEditor.StartAsync(SketchCreationMode.Polyline);

            _addButton.Enabled = true;

            // Verify that the user has drawn a polyline.
            if (!(geometry is Polyline))
            {
                return;
            }

            // Get the first point of the pipe.
            MapPoint firstPoint = ((Polyline)geometry).Parts[0].StartPoint;

            try
            {
                // Get the users selected elevation offset.
                double elevationOffset = _elevationSlider.Value;

                // Get the elevation of the geometry from the first point of the pipe.
                double elevation = await _elevationSurface.GetElevationAsync(firstPoint);

                // Create a polyline for the pipe at the selected altitude.
                Polyline elevatedLine = GeometryEngine.SetZ(geometry, elevation + elevationOffset) as Polyline;

                // Create a graphic for the pipe.
                Graphic linegraphic = new Graphic(elevatedLine);
                _pipesOverlay.Graphics.Add(linegraphic);

                // Display a message with the pipes offset from the surface.
                if (elevationOffset < 0)
                {
                    _helpLabel.Text = string.Format("Pipe added {0:0.0}m below surface", elevationOffset * -1);
                }
                else if (elevationOffset == 0)
                {
                    _helpLabel.Text = "Pipe added at ground level";
                }
                else
                {
                    _helpLabel.Text = string.Format("Pipe added {0:0.0}m above the surface", elevationOffset);
                }

                // Enable the view button once a pipe has been added to the graphics overlay.
                _viewButton.Enabled = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Beispiel #2
0
 private void ZValueChanged(object sender, Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
 {
     foreach (GraphicsOverlay overlay in MySceneView.GraphicsOverlays)
     {
         foreach (Graphic graphic in overlay.Graphics)
         {
             graphic.Geometry = GeometryEngine.SetZ(graphic.Geometry, e.NewValue);
         }
     }
 }
Beispiel #3
0
 private void ZValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <double> e)
 {
     foreach (GraphicsOverlay overlay in MySceneView.GraphicsOverlays)
     {
         foreach (Graphic graphic in overlay.Graphics)
         {
             graphic.Geometry = GeometryEngine.SetZ(graphic.Geometry, e.NewValue);
         }
     }
 }
Beispiel #4
0
 private void ZValueChanged(object sender, SeekBar.ProgressChangedEventArgs e)
 {
     foreach (GraphicsOverlay overlay in _mySceneView.GraphicsOverlays)
     {
         foreach (Graphic graphic in overlay.Graphics)
         {
             graphic.Geometry = GeometryEngine.SetZ(graphic.Geometry, _zSlider.Progress);
         }
     }
     _zLabel.Text = $"{_zSlider.Progress} meters";
 }
Beispiel #5
0
        private void ZSlider_ValueChanged(object sender, ValueChangedEventArgs e)
        {
            // Ensure that the SceneView has loaded.
            if (MySceneView == null)
            {
                return;
            }

            foreach (GraphicsOverlay overlay in MySceneView.GraphicsOverlays)
            {
                foreach (Graphic graphic in overlay.Graphics)
                {
                    graphic.Geometry = GeometryEngine.SetZ(graphic.Geometry, e.NewValue);
                }
            }

            // Update Z value in the UI.
            ValueLabel.Text = $"Z Value: {(int)e.NewValue} meters";
        }