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

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