public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var bmp = value as Bitmap; if (bmp == null) { var defaultBmp = parameter as Bitmap; if (defaultBmp != null) { return(BitmapSourceConverter.ConvertFromImage(defaultBmp)); } } return(bmp == null ? null : BitmapSourceConverter.ConvertFromImage(bmp)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is NotificationIcon)) { return(null); } var icon = (NotificationIcon)value; Bitmap bmp = null; switch (icon) { case NotificationIcon.None: break; case NotificationIcon.Checked: bmp = Properties.Resources.Checked; break; case NotificationIcon.Cancel: bmp = Properties.Resources.Cancel; break; case NotificationIcon.Error: bmp = Properties.Resources.Error; break; case NotificationIcon.Hazzard: bmp = Properties.Resources.Hazzard; break; case NotificationIcon.Important: bmp = Properties.Resources.Important; break; case NotificationIcon.NoEntry: bmp = Properties.Resources.NoEntry; break; case NotificationIcon.Poison: bmp = Properties.Resources.Poison; break; case NotificationIcon.Stop: bmp = Properties.Resources.Stop; break; case NotificationIcon.Unavailable: bmp = Properties.Resources.Unavailable; break; case NotificationIcon.Info: bmp = Properties.Resources.Info; break; case NotificationIcon.Question: bmp = Properties.Resources.Question; break; case NotificationIcon.Warning: bmp = Properties.Resources.Warning; break; default: break; } return(bmp == null ? null : BitmapSourceConverter.ConvertFromImage(bmp)); }