private void FilePropertyChanged(string file) { MBTileSource ts; if (file != null) { ts = new MBTileSource(file); if (ts.Metadata.ContainsKey("name")) { SourceName = ts.Metadata["name"]; } if (ts.Metadata.ContainsKey("description")) { Description = ts.Metadata["description"]; } if (ts.Metadata.ContainsKey("minzoom")) { int minZoom; if (int.TryParse(ts.Metadata["minzoom"], out minZoom)) { MinZoomLevel = minZoom; } } if (ts.Metadata.ContainsKey("maxzoom")) { int maxZoom; if (int.TryParse(ts.Metadata["maxzoom"], out maxZoom)) { MaxZoomLevel = maxZoom; } } TileSource = ts; } else if ((ts = TileSource as MBTileSource) != null) { ClearValue(TileSourceProperty); if (ts.Metadata.ContainsKey("name")) { ClearValue(SourceNameProperty); } if (ts.Metadata.ContainsKey("description")) { ClearValue(DescriptionProperty); } if (ts.Metadata.ContainsKey("minzoom")) { ClearValue(MinZoomLevelProperty); } if (ts.Metadata.ContainsKey("maxzoom")) { ClearValue(MaxZoomLevelProperty); } } }
private async Task FilePropertyChanged(string file) { var mbTileSource = TileSource as MBTileSource; if (mbTileSource != null) { if (file == null) { ClearValue(TileSourceProperty); if (mbTileSource.Name != null) { ClearValue(SourceNameProperty); } if (mbTileSource.Description != null) { ClearValue(DescriptionProperty); } if (mbTileSource.MinZoom.HasValue) { ClearValue(MinZoomLevelProperty); } if (mbTileSource.MaxZoom.HasValue) { ClearValue(MaxZoomLevelProperty); } } mbTileSource.Dispose(); } if (file != null) { mbTileSource = new MBTileSource(file); await mbTileSource.Initialize(); if (mbTileSource.Name != null) { SourceName = mbTileSource.Name; } if (mbTileSource.Description != null) { Description = mbTileSource.Description; } if (mbTileSource.MinZoom.HasValue) { MinZoomLevel = mbTileSource.MinZoom.Value; } if (mbTileSource.MaxZoom.HasValue) { MaxZoomLevel = mbTileSource.MaxZoom.Value; } TileSource = mbTileSource; } }