private void HandleGenerationCompleted(GenerateGeodatabaseJob job)
        {
            // Hide the progress bar.
            _progressBar.RemoveFromSuperview();

            switch (job.Status)
            {
            // If the job completed successfully, add the geodatabase data to the map.
            case JobStatus.Succeeded:
                // Clear out the existing layers.
                _myMapView.Map.OperationalLayers.Clear();

                // Loop through all feature tables in the geodatabase and add a new layer to the map.
                foreach (GeodatabaseFeatureTable table in _resultGdb.GeodatabaseFeatureTables)
                {
                    // Create a new feature layer for the table.
                    FeatureLayer layer = new FeatureLayer(table);

                    // Add the new layer to the map.
                    _myMapView.Map.OperationalLayers.Add(layer);
                }

                // Enable editing features.
                _readyForEdits = EditState.Ready;

                // Update the help label.
                _helpLabel.Text = "2. Tap a point feature to select.";
                break;

            // See if the job failed.
            case JobStatus.Failed:
                // Create a message to show the user.
                string message = "Generate geodatabase job failed";

                // Show an error message (if there is one).
                if (job.Error != null)
                {
                    message += ": " + job.Error.Message;
                }
                else
                {
                    // If no error, show messages from the job.
                    message = job.Messages.Aggregate(message, (current, m) => current + "\n" + m.Message);
                }

                // Show the message.
                ShowStatusMessage(message);
                break;
            }
        }
Exemple #2
0
        private async Task HandleGenerationStatusChange(GenerateGeodatabaseJob job, Geodatabase resultGdb)
        {
            switch (job.Status)
            {
            // If the job completed successfully, add the geodatabase data to the map.
            case JobStatus.Succeeded:
                // Clear out the existing layers.
                _myMapView.Map.OperationalLayers.Clear();

                // Loop through all feature tables in the geodatabase and add a new layer to the map.
                foreach (GeodatabaseFeatureTable table in resultGdb.GeodatabaseFeatureTables)
                {
                    // Create a new feature layer for the table.
                    FeatureLayer layer = new FeatureLayer(table);

                    // Add the new layer to the map.
                    _myMapView.Map.OperationalLayers.Add(layer);
                }

                // Best practice is to unregister the geodatabase.
                await _gdbSyncTask.UnregisterGeodatabaseAsync(resultGdb);

                // Tell the user that the geodatabase was unregistered.
                ShowStatusMessage("Since no edits will be made, the local geodatabase has been unregistered per best practice.");

                // Re-enable the generate button.
                _generateButton.Enabled = true;
                break;

            // See if the job failed.
            case JobStatus.Failed:
                // Create a message to show the user.
                string message = "Generate geodatabase job failed";

                // Show an error message (if there is one).
                if (job.Error != null)
                {
                    message += ": " + job.Error.Message;
                }
                else
                {
                    // If no error, show messages from the job.
                    IEnumerable <string> m = from msg in job.Messages select msg.Message;
                    message += ": " + string.Join("\n", m);
                }

                ShowStatusMessage(message);

                // Re-enable the generate button.
                _generateButton.Enabled = true;
                break;
            }

            // Hide the progress bar.
            _progressBar.RemoveFromSuperview();
        }
Exemple #3
0
        private void UpdateUI()
        {
            if (BookshelfBook.Status == Book.BookStatus.DOWNLOADED || BookshelfBook.Status == Book.BookStatus.ISUPDATE)
            {
                if (downloadSpinner != null)
                {
                    downloadSpinner.StopAnimating();
                    downloadSpinner.RemoveFromSuperview();
                    downloadSpinner.Dispose();
                    downloadSpinner = null;
                }

                if (downloadLabel != null)
                {
                    downloadLabel.RemoveFromSuperview();
                    downloadLabel.Dispose();
                    downloadLabel = null;
                }

                if (progressView != null)
                {
                    progressView.RemoveFromSuperview();
                    progressView.Dispose();
                    progressView = null;
                }

                // bookInfoView
                if (bookInfoView == null)
                {
                    UpdateBookInfo();
                }

                if (BookshelfBook.Status == Book.BookStatus.DOWNLOADED)
                {
                    // descriptionLabel
                    if (descriptionLabel == null)
                    {
                        descriptionLabel       = eBriefingAppearance.GenerateLabel(14, eBriefingAppearance.Gray2);
                        descriptionLabel.Frame = new CGRect(10, titleLabel.Frame.Bottom + 4, 260, 42);
                        descriptionLabel.Lines = 2;
                        descriptionLabel.Text  = BookshelfBook.Description;
                        descriptionLabel.Alpha = 0f;
                        this.AddSubview(descriptionLabel);
                    }
                }
                else
                {
                    // updateButton
                    if (updateButton == null)
                    {
                        updateButton      = UIButton.FromType(UIButtonType.Custom);
                        updateButton.Font = eBriefingAppearance.ThemeBoldFont(14);
                        updateButton.SetTitleColor(eBriefingAppearance.Color("37b878"), UIControlState.Normal);
                        updateButton.SetTitleColor(UIColor.White, UIControlState.Highlighted);
                        updateButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_unfilled.png").CreateResizableImage(new UIEdgeInsets(0, 14f, 0, 14f)), UIControlState.Normal);
                        updateButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_filled.png").CreateResizableImage(new UIEdgeInsets(0, 14f, 0, 14f)), UIControlState.Highlighted);
                        updateButton.Frame = new CGRect(this.Center.X - 65, bookInfoView.Frame.Top - 28, 130, updateButton.CurrentBackgroundImage.Size.Height);
                        updateButton.SetTitle("UPDATE", UIControlState.Normal);
                        updateButton.TouchUpInside += HandleUpdateButtonTouchUpInside;
                        this.AddSubview(updateButton);
                    }
                }

                ShowHideInfo(1f);
            }
            else
            {
                // downloadSpinner
                if (downloadSpinner == null)
                {
                    downloadSpinner       = eBriefingAppearance.GenerateBounceSpinner();
                    downloadSpinner.Frame = new CGRect(10, (this.Frame.Bottom - 50), downloadSpinner.Frame.Width, downloadSpinner.Frame.Height);
                    this.AddSubview(downloadSpinner);
                }

                // downloadLabel
                if (downloadLabel == null)
                {
                    downloadLabel       = eBriefingAppearance.GenerateLabel(17);
                    downloadLabel.Frame = new CGRect(downloadSpinner.Frame.Right + 8, downloadSpinner.Frame.Y + 2, this.Frame.Width - (downloadSpinner.Frame.Right + 8) - 10, 21);
                    this.AddSubview(downloadLabel);

                    UpdateDownloadLabel();
                }

                // progressView
                if (progressView == null)
                {
                    progressView                   = new UIProgressView(UIProgressViewStyle.Default);
                    progressView.Frame             = new CGRect(downloadLabel.Frame.X, downloadLabel.Frame.Bottom + 8, downloadLabel.Frame.Width, progressView.Frame.Height);
                    progressView.ProgressTintColor = eBriefingAppearance.BlueColor;
                    progressView.Progress          = BookshelfBook.DownloadProgress;
                    this.AddSubview(progressView);
                }
            }
        }