示例#1
0
        /// <summary>
        /// Loads the AuthUserItemsPage and changes map when user selects an item
        /// </summary>
        private async void LoadUserItems(object sender, EventArgs e)
        {
            SettingsPanel.IsVisible           = false;
            NavigationContainerGrid.IsVisible = true;
            BasemapListView.IsVisible         = false;
            await _userItemsViewModel.LoadUserItems();

            UserItemListView.IsVisible = true;
        }
示例#2
0
        /// <summary>
        /// Loads the AuthUserItemsPage and changes map when user selects an item
        /// </summary>
        private async void LoadUserItems(object sender, EventArgs e)
        {
            _userItemsViewModel = new UserItemsViewModel();
            await _userItemsViewModel.LoadUserItems();

            // Change map when user selects a new user item
            _userItemsViewModel.PropertyChanged += async(s, ea) =>
            {
                switch (ea.PropertyName)
                {
                case nameof(UserItemsViewModel.SelectedUserItem):
                {
                    // Set the viewpoint of the new map to be the same as the old map
                    // Otherwise map is being reset to the world view
                    var mapViewModel     = Resources["MapViewModel"] as MapViewModel;
                    var currentViewpoint = MapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

                    try
                    {
                        var newMap = new Map(_userItemsViewModel.SelectedUserItem)
                        {
                            InitialViewpoint = currentViewpoint
                        };

                        //Load new map
                        await newMap.LoadAsync();

                        mapViewModel.Map = newMap;
                    }
                    catch (Exception ex)
                    {
                        mapViewModel.ErrorMessage = "Unable to change maps";
                        mapViewModel.StackTrace   = ex.ToString();
                    }

                    break;
                }
                }
            };

            SettingsPanel.IsVisible = false;

            // Load the AuthUserItemsPage
            await Navigation.PushAsync(new AuthUserItemsPage { BindingContext = _userItemsViewModel });
        }