/// <summary>
        /// Creates a new view model object based on the given layer object
        /// </summary>
        /// <param name="parentViewModel">parent view model</param>
        /// <param name="layer">layer object</param>
        public LayerListEntryViewModel(LayerListViewModel parentViewModel, Layer layer)
        {
            this.parentViewModel = parentViewModel;
            this.layer           = layer;

            this.TypeImageSource       = SvgImageCache.GetImageSource(layer, "#000000");
            this.VisibilityImageSource = SvgImageCache.GetLayerVisibilityImageSource(layer, "#000000");

            this.SetupBindings();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets up bindings for this view model
        /// </summary>
        private void SetupBindings()
        {
            this.TypeImageSource       = SvgImageCache.GetImageSource(this.Layer);
            this.VisibilityImageSource = SvgImageCache.GetLayerVisibilityImageSource(this.Layer);

            this.ItemTappedCommand       = new AsyncCommand(this.OnTappedLayerItemAsync);
            this.VisibilityTappedCommand = new AsyncCommand(this.OnTappedLayerVisibilityAsync);
            this.ZoomToLayerCommand      = new AsyncCommand(this.OnZoomToLayerAsync, this.OnCanExecuteZoomToLayer);
            this.ExportLayerCommand      = new AsyncCommand(this.OnExportLayerAsync, this.OnCanExecuteExportLayer);
            this.DeleteLayerCommand      = new AsyncCommand(this.OnDeleteLayerAsync, this.OnCanExecuteDeleteLayer);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the user tapped on the layer visibility icon
        /// </summary>
        /// <returns>task to wait on</returns>
        private async Task OnTappedLayerVisibilityAsync()
        {
            this.Layer.IsVisible = !this.Layer.IsVisible;

            IDataService dataService      = DependencyService.Get <IDataService>();
            var          layerDataService = dataService.GetLayerDataService();
            await layerDataService.Update(this.Layer);

            App.MapView.SetLayerVisibility(this.Layer);

            this.VisibilityImageSource = SvgImageCache.GetLayerVisibilityImageSource(this.Layer);
            this.OnPropertyChanged(nameof(this.VisibilityImageSource));
        }