private void RemoveActiveThemeDictionary() { if (_activeThemeDictionary != null) { ResourcesSource.Verbose("Removing previously active theme dictionary."); Application.Current.Resources.MergedDictionaries.Remove(_activeThemeDictionary); } else { ResourcesSource.Verbose("Didn't find an active theme dictionary. Nothing to remove."); } }
/// <summary> /// Changes the application's currently active theme. /// </summary> /// <param name="themeName"> /// The name of the new theme to be applied. /// Pass null to indicate that no theme is supposed to be used. /// </param> public void ChangeTheme(string themeName) { VerifyAccess(); if (CurrentTheme != themeName) { ResourcesSource.TraceInformation("Changing application theme to {0}."); CurrentTheme = themeName; var themeEventArgs = new ThemeChangedEventArgs(themeName); RaiseThemeChanged(themeEventArgs); } }
public void GetMasteringTools_ReturnsAllElements() { // Arrange var data = _fixture.Create <Resource[]>(); IJsonReader reader = Substitute.For <IJsonReader>(); reader.ReadAll <Resource>(Arg.Any <string>()).Returns(data); // Act var source = new ResourcesSource(reader); // Assert Assert.Equal(data, source.GetResources()); }
private IEnumerator Mining(ResourcesSource source, Action onTakeResource, Action endCallback = null) { while (source != null) { if (source.TryRequestResource() == false) { break; } onTakeResource.Invoke(); yield return(new WaitForSeconds(_punchDelay)); } endCallback?.Invoke(); }
private void SetActiveThemeDictionary(ResourceDictionary dictionary) { if (dictionary != null) { ResourcesSource.Verbose("Adding active theme dictionary."); _activeThemeDictionary = dictionary; // I would love to not add this to the global app's resources, but // it breaks the resource lookup otherwise. // So far, this seems to be the only working solution. Application.Current.Resources.MergedDictionaries.Add(_activeThemeDictionary); } else { ResourcesSource.Verbose("Didn't find an active dictionary to load."); } }
public void StartMining(ResourcesSource source, Action onTakeResource, Action endCallback = null) { StartCoroutine(Mining(source, onTakeResource, endCallback)); }