Example #1
0
        /// <summary>
        /// Handles the messenger request for displaying the details of a provided feature.
        /// </summary>
        private async void HandleDisplayFeatureRequest(LiteDisplayFeatureDetailsRequestMessage request)
        {
            // If there actually is a feature available and we are not running, display the feature
            if (request.RecipeHolders != null && !IsRunning)
            {
                try
                {
                    // Display the running state ('Getting Feature')
                    HandleRunningStateChange(new LiteActionRunningStateMessage(sender: this, source: this, isBusy: true, message: ApplicationResources.FeatureDetailsGettingFeature));

                    // Get the feature asynchronously, by using the FeatureRecipe of the IFeatureRecipeHolder.
                    // Note that a Feature itself implements IFeatureRecipeHolder and is capable of yielding itself via a Recipe
                    var getFeatures = new List <Task <Feature> >();
                    if (request.RecipeHolders != null && request.RecipeHolders.Count > 0)
                    {
                        foreach (var recipeHolder in request.RecipeHolders)
                        {
                            getFeatures.Add(recipeHolder.FeatureRecipe.GetFeatureAsync());
                        }

                        // Get all features, by awaiting all recipe holders.
                        var resultFeatures = await TaskFunctions.WhenAll(getFeatures);

                        var features = new List <Feature>();
                        if (resultFeatures != null)
                        {
                            foreach (var feature in resultFeatures)
                            {
                                if (feature != null)
                                {
                                    features.Add(feature);
                                }
                            }
                        }



                        // Determine the details to be presented for the current set of features
                        if (features.Count > 0 && !IsTrailFeature(features))
                        {
                            var featureDetails = FeatureDetailsProvider.DetailsFor(features);

                            // Set the feature
                            this.Feature = new EditableFeature(featureDetails, true);
                            //this.Feature = FeatureDetailsProvider.DetailsFor(features);
                        }
                    }
                }
                finally
                {
                    // Always make sure we reset the progress indicator (even in case of exceptions)
                    HandleRunningStateChange(new LiteActionRunningStateMessage(sender: this, source: this, isBusy: false));
                }
            }
        }
Example #2
0
        /// <summary>
        /// Sets up the Cancel command
        /// </summary>
        private void SetupCommands()
        {
            // Use an async lambda to carry out the command
            this.CancelCommand = new RelayCommand(async() =>
            {
                // Give some time to the current context; allowing for handling/ending the UI interaction before initiating changes (via DataBinding)
                // (or more direct: give the UI-thread time to finish the selection in the list before driving the selection itself from here.)
                await TaskFunctions.Yield();

                // Make sure we are removed from display
                SmartLinks = null;
            });
        }
        /// <summary>
        /// Select an element on the map
        /// </summary>
        private async void SelectElement(FeatureTargetGeometry element)
        {
            var map = CurrentMap;

            if (map != null)
            {
                // Allow the UI to finish its current action
                await TaskFunctions.Yield();

                // Set the map selection directly (we could have done this via the messenger as well)
                // An example of a tighter coupling, using the API of the MapViewModel directly
                map.SelectedFeatureGeometry.Set(element);
            }
        }
Example #4
0
        /// <summary>
        /// Jump to the smart link
        /// </summary>
        /// <param name="value"></param>
        private async void JumpToSmartLink(SingleSmartLink value)
        {
            // Give some time to the current context; allowing for handling/ending the UI interaction before initiating changes (via DataBinding)
            // (or more direct: give the UI-thread time to finish the selection in the list before driving the selection itself from here.)
            await TaskFunctions.Yield();

            // Make sure we are removed from display
            SmartLinks = null;

            if (value != null)
            {
                // And put the request on the databus
                HandleSingleSmartLinkActivation(_smartLinksSender, _smartLinksFeature, _smartLinksField, value);
            }
        }
Example #5
0
        /// <summary>
        /// Shows the message box with the specifiec caption
        /// </summary>
        /// <param name="messageBoxText">The main text to display</param>
        /// <param name="caption">The caption</param>
        /// <param name="button">The button (combination) to use</param>
        /// <param name="defaultResult">The default result of the message box</param>
        /// <returns>The user actived result</returns>
        public async Task <MessageBoxResult> ShowAsync(string messageBoxText, string caption, MessageBoxButton button, MessageBoxResult defaultResult)
        {
            Text             = messageBoxText;
            Caption          = caption;
            Result           = defaultResult;
            CancelVisibility = button == MessageBoxButton.OKCancel ? Visibility.Visible : Visibility.Collapsed;

            ViewVisibility = Visibility.Visible;

            while (ViewVisibility == Visibility.Visible)
            {
                await TaskFunctions.Delay(100);
            }

            return(Result);
        }
Example #6
0
 /// <summary>
 /// Adds a client-side custom layer to the map (viewModel)
 /// </summary>
 private Task AddCustomLayers(ObservableCollection <LiteMapViewModel> maps)
 {
     // For now - there are no custom layers to be set up; return a default Task.
     // The easiest way is a cached Task-Result (ie bool).
     return(TaskFunctions.FromResult(true));
 }