diff --git a/RainmeterStudio/Business/ResourceProvider.cs b/RainmeterStudio/Business/ResourceProvider.cs index 37d39d5d..526f0414 100644 --- a/RainmeterStudio/Business/ResourceProvider.cs +++ b/RainmeterStudio/Business/ResourceProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Reflection; using System.Resources; +using System.Windows.Data; using System.Windows.Media; using RainmeterStudio.Core.Utils; @@ -127,4 +128,52 @@ namespace RainmeterStudio.Business _cacheStrings.Clear(); } } + + /// + /// Resource converter - converts resource identifier string into actual resource + /// + public class StringResourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + string identifier = value as string; + object resource = null; + + if (identifier != null) + { + resource = ResourceProvider.GetString(identifier); + } + + return resource; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException("Operation not supported."); + } + } + + /// + /// Resource converter - converts resource identifier string into actual resource + /// + public class ImageResourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + string identifier = value as string; + object resource = null; + + if (identifier != null) + { + resource = ResourceProvider.GetImage(identifier); + } + + return resource; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException("Operation not supported."); + } + } }