ownChat: Neues TimeStamp-Objekt wird unterstützt und der Chat funktioniert wieder.
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
using System.IO;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace BeWo.Scheduler.Converter
|
|
{
|
|
public class BitmapToBitmapSourceConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
//return null;
|
|
if (!(value is Bitmap source) || targetType != typeof(ImageSource))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var stream = new MemoryStream();
|
|
source.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
|
|
stream.Position = 0;
|
|
|
|
var result = new BitmapImage();
|
|
result.BeginInit();
|
|
result.StreamSource = stream;
|
|
result.EndInit();
|
|
//stream.Close();
|
|
return result;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
} |