Dreamine.UI.Wpf 1.0.1
Dreamine.UI.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
IconToImageSourceConverter.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Diagnostics;
3using System.Drawing;
4using System.Globalization;
5using System.Windows;
6using System.Windows.Data;
7using System.Windows.Interop;
8using System.Windows.Media;
9using System.Windows.Media.Imaging;
10
12
21public class IconToImageSourceConverter : IValueConverter
22{
79 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
80 {
81 var icon = value as Icon;
82 if (icon == null)
83 {
84 Trace.TraceWarning("Attempted to convert {0} instead of Icon object in IconToImageSourceConverter", value);
85 return null!;
86 }
87
88 ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
89 icon.Handle,
90 Int32Rect.Empty,
91 BitmapSizeOptions.FromEmptyOptions());
92 return imageSource;
93 }
94
151 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
152 {
153 throw new NotImplementedException();
154 }
155}
object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
object Convert(object value, Type targetType, object parameter, CultureInfo culture)