public async Task <bool> TrySetCurrentThemeAsync(string theme, HttpContext httpContext) { if (!AvailableThemes.Contains(theme)) { return(false); } if (!_themeProvider.GetThemes().Contains(theme)) { _logger.ThemeNotAvailable(theme, _themeProvider.GetThemePath(ThemeProvider.ThemesBasePath, theme)); } await SetCurrentThemeAsync(theme, httpContext); return(true); }
/// <summary> /// To be called after setting _userSuppliedMap /// </summary> private async Task BuildAndApplySubsetMap() { if (_userSuppliedMap == null) { return; } // Clear existing map _subsetMap = null; // update list of available themes AvailableThemes = await ThemeResponsiveMapUtilities.ThemesFromMap(_userSuppliedMap); var systemTheme = _themeOracle.GetCurrentSystemTheme(); // Try to build map for selected theme if (SelectedTheme == "Automatic" && AvailableThemes.Contains(systemTheme)) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, systemTheme); } else if (AvailableThemes.Contains(SelectedTheme)) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, SelectedTheme); } // Fall back to fallback theme else if (AvailableThemes.Contains(FallbackTheme)) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, FallbackTheme); } // Fall back to first theme else if (AvailableThemes.Any()) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, AvailableThemes.First()); } // Fall back to input map else { _subsetMap = _userSuppliedMap; } _subsetMap.InitialViewpoint = GetCurrentViewpoint(ViewpointType.BoundingGeometry); // update map base.Map = _subsetMap; }