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:
parent
56e7bf000e
commit
20fea8776a
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
|
using System.Windows.Data;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using RainmeterStudio.Core.Utils;
|
using RainmeterStudio.Core.Utils;
|
||||||
|
|
||||||
@ -127,4 +128,52 @@ namespace RainmeterStudio.Business
|
|||||||
_cacheStrings.Clear();
|
_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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user