markus / MarkusAutoUpdate / src / NetSparkle.UI.WPF / IconUtilities.cs @ d8f5045e
이력 | 보기 | 이력해설 | 다운로드 (940 Bytes)
1 | d8f5045e | taeseongkim | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Drawing; |
||
4 | using System.Text; |
||
5 | using System.Windows; |
||
6 | using System.Windows.Interop; |
||
7 | using System.Windows.Media; |
||
8 | using System.Windows.Media.Imaging; |
||
9 | |||
10 | namespace NetSparkleUpdater.UI.WPF |
||
11 | { |
||
12 | public class IconUtilities |
||
13 | { |
||
14 | /// <summary> |
||
15 | /// Convert System.Drawing.Icon to System.Windows.Media.ImageSource. |
||
16 | /// From: https://stackoverflow.com/a/6580799/3938401 |
||
17 | /// </summary> |
||
18 | /// <param name="icon"></param> |
||
19 | /// <returns></returns> |
||
20 | public static ImageSource ToImageSource(Icon icon) |
||
21 | { |
||
22 | if (icon == null) |
||
23 | { |
||
24 | return null; |
||
25 | } |
||
26 | |||
27 | ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon( |
||
28 | icon.Handle, |
||
29 | Int32Rect.Empty, |
||
30 | BitmapSizeOptions.FromEmptyOptions()); |
||
31 | |||
32 | return imageSource; |
||
33 | } |
||
34 | } |
||
35 | } |