public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (converter.CanConvertTo(targetType)) { return(converter.ConvertTo(value, targetType)); } else { return(null); } }
private Data.Image AddGetImage(string name) { // Добавить картинку в БД if (name.Length == 0) { return(null); } ImageSourceConverter imageSourceConverter = new ImageSourceConverter(); byte[] imageBin = (byte[])imageSourceConverter.ConvertTo(ImageBox.Source, typeof(byte[])); Data.Image pic = new Data.Image { ImageName = ImageNameText.Text, Bin = imageBin }; pic = Global.DB.Images.Add(pic); Global.DB.SaveChanges(); UpdateImageItems(); return(pic); }
public static byte[] ToArray(this ImageSource image) { var converter = new ImageSourceConverter(); return((byte[])converter.ConvertTo(image, typeof(byte[]))); }