markus / SmartUpdate / FileToImageIconConverter.cs @ master
이력 | 보기 | 이력해설 | 다운로드 (1.17 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
|
6 |
namespace SmartUpdate |
7 |
{ |
8 |
#region FileToImageIconConverter |
9 |
public class FileToImageIconConverter |
10 |
{ |
11 |
private string filePath; |
12 |
private System.Windows.Media.ImageSource icon; |
13 |
|
14 |
public string FilePath { get { return filePath; } } |
15 |
|
16 |
public System.Windows.Media.ImageSource Icon |
17 |
{ |
18 |
get |
19 |
{ |
20 |
if (icon == null && System.IO.File.Exists(FilePath)) |
21 |
{ |
22 |
using (System.Drawing.Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(FilePath)) |
23 |
{ |
24 |
icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon( |
25 |
sysicon.Handle, |
26 |
System.Windows.Int32Rect.Empty, |
27 |
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); |
28 |
} |
29 |
} |
30 |
|
31 |
return icon; |
32 |
} |
33 |
} |
34 |
|
35 |
public FileToImageIconConverter(string filePath) |
36 |
{ |
37 |
this.filePath = filePath; |
38 |
} |
39 |
} |
40 |
#endregion |
41 |
} |