private bool AnimatePlane()
        {
            // Skip doing anything if animation is paused
            if (!_animationTimer)
            {
                return(true);
            }

            // Get the next position; % prevents going out of bounds even if the keyframe value is
            //     changed unexpectedly (e.g. due to user interaction with the progress slider).
            MissionFrame currentFrame = _missionData[_keyframe % _frameCount];

            // Update the UI
            double missionProgress = _keyframe / (double)_frameCount;

            // This is needed because the event could be running on a non-UI thread
            Device.BeginInvokeOnMainThread(() =>
            {
                // Update the progress slider; temporarily remove event subscription to avoid feedback loop
                MissionProgressBar.ValueChanged -= MissionProgressOnSeek;
                MissionProgressBar.Value         = missionProgress * 100;
                MissionProgressBar.ValueChanged += MissionProgressOnSeek;

                // Update stats display
                AltitudeLabel.Text = currentFrame.Elevation.ToString("F");
                HeadingLabel.Text  = currentFrame.Heading.ToString("F");
                PitchLabel.Text    = currentFrame.Pitch.ToString("F");
                RollLabel.Text     = currentFrame.Roll.ToString("F");
            });

            // Update plane's position
            _plane3D.Geometry = currentFrame.ToMapPoint();
            _plane3D.Attributes["HEADING"] = currentFrame.Heading;
            _plane3D.Attributes["PITCH"]   = currentFrame.Pitch;
            _plane3D.Attributes["ROLL"]    = currentFrame.Roll;

            // Update the inset map; plane symbol position
            _plane2D.Geometry = currentFrame.ToMapPoint();
            // Update inset's viewpoint and heading
            Viewpoint vp = new Viewpoint(currentFrame.ToMapPoint(), InsetMapView.MapScale,
                                         360 + (float)currentFrame.Heading);

            InsetMapView.SetViewpoint(vp);

            // Update the keyframe. This advances the animation
            _keyframe++;

            // Restart the animation if it has finished
            if (_keyframe >= _frameCount)
            {
                _keyframe = 0;
            }

            // Keep the animation event going
            return(true);
        }
        private void AnimatePlane(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            // Get the next position; % prevents going out of bounds even if the keyframe value is
            //     changed unexpectedly (e.g. due to user interaction with the progress slider).
            MissionFrame currentFrame = _missionData[_keyframe % _frameCount];

            // Update the UI
            double missionProgress = _keyframe / (double)_frameCount;

            // This is needed because the event could be running on a non-UI thread
            RunOnUiThread(() =>
            {
                // Update the progress slider; temporarily remove event subscription to prevent feedback loop
                _missionProgressBar.ProgressChanged -= MissionProgressOnSeek;
                _missionProgressBar.Progress         = (int)(missionProgress * 100);
                _missionProgressBar.ProgressChanged += MissionProgressOnSeek;

                // Update stats display
                _altitudeTextView.Text = currentFrame.Elevation.ToString("F");
                _headingTextView.Text  = currentFrame.Heading.ToString("F");
                _pitchTextView.Text    = currentFrame.Pitch.ToString("F");
                _rollTextView.Text     = currentFrame.Roll.ToString("F");
            });

            // Update plane's position
            _plane3D.Geometry = currentFrame.ToMapPoint();
            _plane3D.Attributes["HEADING"] = currentFrame.Heading;
            _plane3D.Attributes["PITCH"]   = currentFrame.Pitch;
            _plane3D.Attributes["ROLL"]    = currentFrame.Roll;

            // Update the inset map; plane symbol position
            _plane2D.Geometry = currentFrame.ToMapPoint();
            // Update inset's viewpoint and heading
            Viewpoint vp = new Viewpoint(currentFrame.ToMapPoint(), _insetMapView.MapScale,
                                         360 + (float)currentFrame.Heading);

            _insetMapView.SetViewpoint(vp);

            // Update the keyframe. This advances the animation
            _keyframe++;

            // Restart the animation if it has finished
            if (_keyframe >= _frameCount)
            {
                _keyframe = 0;
            }
        }
        private async void AnimatePlane(object sender, object elapsedEventArgs)
        {
            // Get the next position; % prevents going out of bounds even if the keyframe value is
            //     changed unexpectedly (e.g. due to user interaction with the progress slider).
            MissionFrame currentFrame = _missionData[_keyframe % _frameCount];

            // Update the UI
            double missionProgress = _keyframe / (double)_frameCount;

            // This is needed because the event could be running on a non-UI thread
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                // Update the progress slider
                MissionProgressBar.Value = missionProgress;

                // Update stats display
                AltitudeTextBlock.Text = $"{currentFrame.Elevation:F}m";
                HeadingTextBlock.Text  = $"{currentFrame.Heading:F}\u00B0";
                PitchTextBlock.Text    = $"{currentFrame.Pitch:F}\u00B0";
                RollTextBlock.Text     = $"{currentFrame.Roll:F}\u00B0";
            });

            // Update plane's position
            _plane3D.Geometry = currentFrame.ToMapPoint();
            _plane3D.Attributes["HEADING"] = currentFrame.Heading;
            _plane3D.Attributes["PITCH"]   = currentFrame.Pitch;
            _plane3D.Attributes["ROLL"]    = currentFrame.Roll;

            // Update the inset map; plane symbol position
            _plane2D.Geometry = currentFrame.ToMapPoint();
            // Update inset's viewpoint and heading
            Viewpoint vp = new Viewpoint(currentFrame.ToMapPoint(), InsetMapView.MapScale,
                                         360 + (float)currentFrame.Heading);

            InsetMapView.SetViewpoint(vp);

            // Update the keyframe. This advances the animation
            _keyframe++;

            // Restart the animation if it has finished
            if (_keyframe >= _frameCount)
            {
                _keyframe = 0;
            }
        }
        private void AnimatePlane(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            // Get the next position; % prevents going out of bounds even if the keyframe value is
            //     changed unexpectedly (e.g. due to user interaction with the progress slider).
            MissionFrame currentFrame = _missionData[_keyframe % _frameCount];

            // Update the UI
            double missionProgress = _keyframe / (double)_frameCount;

            // This is needed because the event could be running on a non-UI thread
            Dispatcher.BeginInvoke(new Action(() =>
            {
                // Update the progress slider
                MissionProgressBar.Value = missionProgress;

                // Update stats display
                AltitudeLabel.Text = currentFrame.Elevation.ToString("F") + "m";
                HeadingLabel.Text  = currentFrame.Heading.ToString("F") + "бу";
                PitchLabel.Text    = currentFrame.Pitch.ToString("F") + "бу";
                RollLabel.Text     = currentFrame.Roll.ToString("F") + "бу";
            }));

            // Update plane's position
            _plane3D.Geometry = currentFrame.ToMapPoint();
            _plane3D.Attributes["HEADING"] = currentFrame.Heading;
            _plane3D.Attributes["PITCH"]   = currentFrame.Pitch;
            _plane3D.Attributes["ROLL"]    = currentFrame.Roll;

            // Update the inset map; plane symbol position
            _plane2D.Geometry = currentFrame.ToMapPoint();
            // Update inset's viewpoint and heading
            Viewpoint vp = new Viewpoint(currentFrame.ToMapPoint(), InsetMapView.MapScale,
                                         360 + (float)currentFrame.Heading);

            InsetMapView.SetViewpoint(vp);

            // Update the keyframe. This advances the animation
            _keyframe++;

            // Restart the animation if it has finished
            if (_keyframe >= _frameCount)
            {
                _keyframe = 0;
            }
        }
Exemple #5
0
        private void AnimatePlane()
        {
            // Get the next position; % prevents going out of bounds even if the keyframe value is
            //     changed unexpectedly (e.g. due to user interaction with the progress slider).
            MissionFrame currentFrame = _missionData[_keyframe];

            // Update the UI
            double missionProgress = _keyframe / (double)_frameCount;

            // This is needed because the event could be running on a non-UI thread
            InvokeOnMainThread(() =>
            {
                // Update stats display
                _altitudeLabel.Text = currentFrame.Elevation.ToString("F");
                _headingLabel.Text  = currentFrame.Heading.ToString("F");
                _pitchLabel.Text    = currentFrame.Pitch.ToString("F");
                _rollLabel.Text     = currentFrame.Roll.ToString("F");
                _progressLabel.Text = $"{(missionProgress * 100):F}%";
            });

            // Update plane's position
            _plane3D.Geometry = currentFrame.ToMapPoint();
            _plane3D.Attributes["HEADING"] = currentFrame.Heading;
            _plane3D.Attributes["PITCH"]   = currentFrame.Pitch;
            _plane3D.Attributes["ROLL"]    = currentFrame.Roll;

            // Update the inset map; plane symbol position
            _plane2D.Geometry = currentFrame.ToMapPoint();
            // Update inset's viewpoint and heading
            Viewpoint vp = new Viewpoint(currentFrame.ToMapPoint(), _insetMapView.MapScale,
                                         360 + (float)currentFrame.Heading);

            _insetMapView.SetViewpoint(vp);

            // Update the keyframe. This advances the animation
            _keyframe++;

            // Restart the animation if it has finished
            if (_keyframe >= _frameCount)
            {
                _keyframe = 0;
            }
        }