/// <summary> /// Initializes a new instance of the <see cref="SettingsViewModel"/> class. /// </summary> public SettingsViewModel(ConfigurationViewModel configurationViewModel, IIconCaching iconCaching, ILogger <SettingsViewModel> logger) : base(new object()) { _configuration = configurationViewModel; _configuration.PropertyChanged += Configuration_PropertyChanged; _iconCaching = iconCaching; _logger = logger; }
private static async void IconChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { var control = (ImageLabel)dependencyObject; if (control == null) { return; } // fix IconPathState by removing empty space and special characters string iconPath = control.IconPath; Match format = Regex.Match(iconPath, @"format=svg"); Match state = Regex.Match(iconPath, @"state=(.+?)&"); if (state != null) { if (!string.IsNullOrEmpty(state.Value)) { string newstate = Regex.Replace(state.Groups[1].Value, "[^0-9a-zA-Z.&]", string.Empty); iconPath = control.IconPath.Replace(state.Groups[1].Value, newstate, StringComparison.InvariantCulture); } } IIconCaching iconCaching = (IIconCaching)DIService.Instance.Services.GetService(typeof(IIconCaching)); iconPath = await iconCaching.ResolveIconPath(iconPath, format.Success? "svg" : "png"); if (format.Success) { control.Icon.Source = new SvgImageSource(new Uri(iconPath)); } else { control.Icon.Source = new BitmapImage(new Uri(iconPath)); } }