public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (converter.CanConvertTo(targetType))
     {
         return(converter.ConvertTo(value, targetType));
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public static byte[] ToArray(this ImageSource image)
        {
            var converter = new ImageSourceConverter();

            return((byte[])converter.ConvertTo(image, typeof(byte[])));
        }