protected override object Convert(object value, Type targetType, object parameter)
{
Image image = null;
if (!(value is LogEvent))
{
return image;
}
var logEvent = (LogEvent)value;
switch (logEvent)
{
case LogEvent.Debug:
if (_debugImage == null)
{
_debugImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Debug.png", AssemblyName), UriKind.RelativeOrAbsolute));
}
image = new Image { Source = _debugImage };
break;
case LogEvent.Error:
if (_errorImage == null)
{
_errorImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Error.png", AssemblyName), UriKind.RelativeOrAbsolute));
}
image = new Image {Source = _errorImage};
break;
case LogEvent.Info:
if (_infoImage == null)
{
_infoImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Info.png", AssemblyName), UriKind.RelativeOrAbsolute));
}
image = new Image { Source = _infoImage };
break;
case LogEvent.Warning:
if (_warningImage == null)
{
_warningImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Warning.png", AssemblyName), UriKind.RelativeOrAbsolute));
}
image = new Image {Source = _warningImage};
break;
}
if (image != null)
{
//// Or hardcoded on 16 x 16?
//Binding b = new Binding("Width");
//b.Source = image.Source;
//image.SetBinding(Image.MaxWidthProperty, b);
image.MaxWidth = 16;
//b = new Binding("Height");
//b.Source = image.Source;
//image.SetBinding(Image.MaxHeightProperty, b);
image.MaxHeight = 16;
}
return image;
}
}