예제 #1
0
        private async Task HandleExportComplete(ExportTileCacheJob job, TileCache cache)
        {
            // Update the view if the job is complete.
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Show the exported tiles on the preview map.
                await UpdatePreviewMap(cache);

                // Show the preview window.
                MyPreviewMapView.Visibility = Visibility.Visible;

                // Show the 'close preview' button.
                MyClosePreviewButton.Visibility = Visibility.Visible;

                // Hide the 'export tiles' button.
                MyExportButton.Visibility = Visibility.Collapsed;

                // Hide the progress bar.
                MyProgressBar.Visibility = Visibility.Collapsed;

                // Enable the 'export tiles' button.
                MyExportButton.IsEnabled = true;
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user.
                ShowStatusMessage("Job failed");

                // Hide the progress bar.
                MyProgressBar.Visibility = Visibility.Collapsed;
            }
        }
예제 #2
0
        /// <summary>
        /// Called by the ExportTileCacheJob on any status changes
        /// </summary>
        private void Job_JobChanged(object sender, EventArgs e)
        {
            // Get reference to the job
            ExportTileCacheJob job = sender as ExportTileCacheJob;

            // Update the view if the job is complete
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                RunOnUiThread(() =>
                {
                    // Store the original map viewpoint
                    _originalViewpoint = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);

                    // Show the exported tiles on the preview map
                    UpdatePreviewMap();

                    // Hide the progress bar
                    _myProgressBar.Visibility = ViewStates.Gone;

                    // Change the export button text
                    _myExportButton.Text = "Close Preview";

                    // Re-enable the button
                    _myExportButton.Enabled = true;

                    // Set the preview open flag
                    _previewOpen = true;

                    // Store the graphics overlay and then hide it
                    _overlay = _myMapView.GraphicsOverlays.FirstOrDefault();
                    _myMapView.GraphicsOverlays.Clear();
                });
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user
                ShowStatusMessage("Job failed");

                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                RunOnUiThread(() =>
                {
                    // Hide the progress bar
                    _myProgressBar.Visibility = ViewStates.Gone;

                    // Change the export button text
                    _myExportButton.Text = "Export tiles";

                    // Re-enable the export button
                    _myExportButton.Enabled = true;

                    // Set the preview open flag
                    _previewOpen = false;
                });
            }
        }
예제 #3
0
        /// <summary>
        /// Called by the ExportTileCacheJob on any status changes
        /// </summary>
        private void Job_JobChanged(object sender, EventArgs e)
        {
            // Get reference to the job
            ExportTileCacheJob job = sender as ExportTileCacheJob;

            // Update the view if the job is complete
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                Device.BeginInvokeOnMainThread(() =>
                {
                    // Show the exported tiles on the preview map
                    UpdatePreviewMap();

                    // Hide the progress bar
                    MyProgressBar.IsVisible = false;

                    // Change the export button text
                    MyExportPreviewButton.Text = "Close Preview";

                    // Re-enable the button
                    MyExportPreviewButton.IsEnabled = true;

                    // Set the preview open flag
                    _previewOpen = true;

                    // Store the overlay for later
                    _overlay = MyMapView.GraphicsOverlays.FirstOrDefault();

                    // Then hide it
                    MyMapView.GraphicsOverlays.Clear();
                });
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user
                ShowStatusMessage("Job failed");

                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                Device.BeginInvokeOnMainThread(() =>
                {
                    // Hide the progress bar
                    MyProgressBar.IsVisible = false;

                    // Change the export button text
                    MyExportPreviewButton.Text = "Export Tiles";

                    // Re-enable the export button
                    MyExportPreviewButton.IsEnabled = true;

                    // Set the preview open flag
                    _previewOpen = false;
                });
            }
        }
        private void HandleExportCompletion(ExportTileCacheJob job, TileCache cache)
        {
            // Hide the progress bar.
            _myProgressBar.StopAnimating();
            switch (job.Status)
            {
            // Update the view if the job is complete.
            case Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded:
                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread.
                InvokeOnMainThread(async() =>
                {
                    // Show the exported tiles on the preview map.
                    try
                    {
                        await UpdatePreviewMap(cache);

                        // Show the preview window.
                        _myPreviewMapView.Hidden = false;

                        // Change the export button text.
                        _myExportButton.SetTitle("Close preview", UIControlState.Normal);

                        // Re-enable the button.
                        _myExportButton.Enabled = true;

                        // Set the preview open flag.
                        _previewOpen = true;
                    }
                    catch (Exception ex)
                    {
                        ShowStatusMessage(ex.ToString());
                    }
                });
                break;

            case Esri.ArcGISRuntime.Tasks.JobStatus.Failed:
                // Notify the user.
                ShowStatusMessage("Job failed");

                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread.
                InvokeOnMainThread(() =>
                {
                    // Change the export button text.
                    _myExportButton.SetTitle("Export Tiles", UIControlState.Normal);

                    // Re-enable the export button.
                    _myExportButton.Enabled = true;

                    // Set the preview open flag.
                    _previewOpen = false;
                });
                break;
            }
        }
        /// <summary>
        /// Called by the ExportTileCacheJob on any status changes
        /// </summary>
        private void Job_JobChanged(object sender, EventArgs e)
        {
            // Get reference to the job
            ExportTileCacheJob job = sender as ExportTileCacheJob;

            // Update the view if the job is complete
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                InvokeOnMainThread(() =>
                {
                    // Show the exported tiles on the preview map
                    UpdatePreviewMap();

                    // Show the preview window
                    _myPreviewMapView.Hidden = false;

                    // Hide the progress bar
                    _myProgressBar.StopAnimating();

                    // Change the export button text
                    _myExportButton.SetTitle("Close Preview", UIControlState.Normal);

                    // Re-enable the button
                    _myExportButton.Enabled = true;

                    // Set the preview open flag
                    _previewOpen = true;
                });
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user
                ShowStatusMessage("Job failed");

                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                InvokeOnMainThread(() =>
                {
                    // Hide the progress bar
                    _myProgressBar.StopAnimating();

                    // Change the export button text
                    _myExportButton.SetTitle("Export Tiles", UIControlState.Normal);

                    // Re-enable the export button
                    _myExportButton.Enabled = true;

                    // Set the preview open flag
                    _previewOpen = false;
                });
            }
        }
        private static string getTileCacheGenerationStatusMessage(ExportTileCacheJob job)
        {
            if (job.Messages == null)
            {
                return("");
            }

            var text = string.Format("Job Status: {0}\n\nMessages:\n=====================\n", job.Status);

            foreach (GPMessage message in job.Messages)
            {
                text += string.Format("Message type: {0}\nMessage: {1}\n--------------------\n",
                                      message.MessageType, message.Description);
            }
            return(text);
        }
예제 #7
0
        private async Task HandleExportCompleted(ExportTileCacheJob job, TileCache cache)
        {
            // Update the view if the job is complete.
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Store the original map viewpoint.
                _originalViewpoint = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);

                // Show the exported tiles on the preview map.
                await UpdatePreviewMap(cache);

                // Hide the progress bar.
                _myProgressBar.Visibility = ViewStates.Gone;

                // Change the export button text.
                _myExportButton.Text = "Close Preview";

                // Re-enable the button.
                _myExportButton.Enabled = true;

                // Set the preview open flag.
                _previewOpen = true;

                // Store the graphics overlay and then hide it.
                _overlay = _myMapView.GraphicsOverlays.FirstOrDefault();
                _myMapView.GraphicsOverlays.Clear();
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user.
                ShowStatusMessage("Job failed");

                // Hide the progress bar.
                _myProgressBar.Visibility = ViewStates.Gone;

                // Change the export button text.
                _myExportButton.Text = "Export tiles";

                // Re-enable the export button.
                _myExportButton.Enabled = true;

                // Set the preview open flag.
                _previewOpen = false;
            }
        }
        /// <summary>
        /// Called by the ExportTileCacheJob on any status changes
        /// </summary>
        private async void Job_JobChanged(object sender, EventArgs e)
        {
            // Get reference to the job
            ExportTileCacheJob job = sender as ExportTileCacheJob;

            // Update the view if the job is complete
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // Show the exported tiles on the preview map
                    UpdatePreviewMap();

                    // Show the preview window
                    MyPreviewMapView.Visibility = Visibility.Visible;

                    // Show the 'close preview' button
                    MyClosePreviewButton.Visibility = Visibility.Visible;

                    // Hide the 'export tiles' button
                    MyExportButton.Visibility = Visibility.Collapsed;

                    // Hide the progress bar
                    MyProgressBar.Visibility = Visibility.Collapsed;

                    // Enable the 'export tiles' button
                    MyExportButton.IsEnabled = true;
                });
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user
                ShowStatusMessage("Job failed");

                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // Hide the progress bar
                    MyProgressBar.Visibility = Visibility.Collapsed;
                });
            }
        }
예제 #9
0
        /// <summary>
        /// Starts the export job and registers callbacks to be notified of changes to job status
        /// </summary>
        private async void StartExport()
        {
            // Update the tile cache path
            _tilePath = GetTilePath();

            // Get the parameters for the job
            ExportTileCacheParameters parameters = GetExportParameters();

            // Create the task
            ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri);

            // Create the export job
            ExportTileCacheJob job = exportTask.ExportTileCache(parameters, _tilePath);

            // Subscribe to notifications for status updates
            job.JobChanged += Job_JobChanged;

            // Start the export job
            job.Start();
        }
        private async Task HandleJobCompletion(ExportTileCacheJob job, TileCache cache)
        {
            // Update the view if the job is complete.
            if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
            {
                // Show the exported tiles on the preview map.
                await UpdatePreviewMap(cache);

                // Change the export button text.
                MyExportPreviewButton.Text = "Close Preview";

                // Re-enable the button.
                MyExportPreviewButton.IsEnabled = true;

                // Set the preview open flag.
                _previewOpen = true;

                // Store the overlay for later.
                _overlay = MyMapView.GraphicsOverlays.FirstOrDefault();

                // Then hide it.
                MyMapView.GraphicsOverlays.Clear();
            }
            else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed)
            {
                // Notify the user.
                await((Page)Parent).DisplayAlert("Error", "Job Failed", "OK");

                // Change the export button text.
                MyExportPreviewButton.Text = "Export Tiles";

                // Re-enable the export button.
                MyExportPreviewButton.IsEnabled = true;

                // Set the preview open flag.
                _previewOpen = false;
            }
        }
        private void HandleExportCompletion(ExportTileCacheJob job, TileCache cache)
        {
            // Hide the progress bar.
            _statusIndicator.StopAnimating();
            switch (job.Status)
            {
            // Update the view if the job is complete.
            case Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded:
                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread.
                InvokeOnMainThread(async() =>
                {
                    // Show the exported tiles on the preview map.
                    try
                    {
                        await UpdatePreviewMap(cache);
                    }
                    catch (Exception ex)
                    {
                        ShowStatusMessage(ex.ToString());
                    }
                });
                break;

            case Esri.ArcGISRuntime.Tasks.JobStatus.Failed:
                // Notify the user.
                ShowStatusMessage("Job failed");

                // Dispatcher is necessary due to the threading implementation;
                //     this method is called from a thread other than the UI thread.
                InvokeOnMainThread(() =>
                {
                    // Re-enable the export button.
                    _exportTilesButton.Enabled = true;
                });
                break;
            }
        }
예제 #12
0
        private async Task StartExport()
        {
            // Get the parameters for the job.
            ExportTileCacheParameters parameters = GetExportParameters();

            // Create the task.
            ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri);

            // Get the tile cache path.
            _tilePath = $"{Path.GetTempFileName()}.tpk";

            // Create the export job.
            ExportTileCacheJob job = exportTask.ExportTileCache(parameters, _tilePath);

            // Start the export job.
            job.Start();

            // Get the result.
            TileCache cache = await job.GetResultAsync();

            // Do the rest of the work.
            await HandleExportComplete(job, cache);
        }
        private async Task StartExport()
        {
            // Get the parameters for the job.
            ExportTileCacheParameters parameters = GetExportParameters();

            // Create the task.
            ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri);

            // Get the tile cache path.
            string tilePath = Path.Combine(Environment.ExpandEnvironmentVariables("%TEMP%"), Path.GetTempFileName() + ".tpk");

            // Create the export job.
            ExportTileCacheJob job = exportTask.ExportTileCache(parameters, tilePath);

            // Start the export job.
            job.Start();

            // Wait for the job to complete.
            TileCache resultTileCache = await job.GetResultAsync();

            // Do the rest of the work.
            await HandleExportCompleted(job, resultTileCache);
        }
        private async Task StartExport()
        {
            try
            {
                // Update the tile cache path.
                _tilePath = $"{Path.GetTempFileName()}.tpk";

                // Get the parameters for the job.
                ExportTileCacheParameters parameters = GetExportParameters();

                // Create the task.
                ExportTileCacheTask exportTask = await ExportTileCacheTask.CreateAsync(_serviceUri);

                // Create the export job.
                ExportTileCacheJob job = exportTask.ExportTileCache(parameters, _tilePath);

                // Show the progress bar.
                MyProgressBar.IsVisible = true;

                // Start the export job.
                job.Start();

                // Get the tile cache result.
                TileCache resultTileCache = await job.GetResultAsync();

                // Hide the progress bar.
                MyProgressBar.IsVisible = false;

                // Do the rest of the work.
                await HandleJobCompletion(job, resultTileCache);
            }
            catch (Exception ex)
            {
                await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
		private static string getTileCacheGenerationStatusMessage(ExportTileCacheJob job)
		{
			if (job.Messages == null)
				return "";

			var text = string.Format("Job Status: {0}\n\nMessages:\n=====================\n", job.Status);
			foreach (GPMessage message in job.Messages)
			{
				text += string.Format("Message type: {0}\nMessage: {1}\n--------------------\n",
					message.MessageType, message.Description);
			}
			return text;
		}