mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Added converters to resource provider
This commit is contained in:
		@@ -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();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Resource converter - converts resource identifier string into actual resource
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    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.");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Resource converter - converts resource identifier string into actual resource
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    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.");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user