1
2
3
4
5
6 using System;
7 using System.Windows.API;
8
9 namespace System.Windows
10 {
11 public enum StandardBitmapId : int
12 {
13 OBM_BTNCORNERS = 32758,
14 OBM_BTSIZE = 32761,
15 OBM_CHECK = 32760,
16 OBM_CHECKBOXES = 32759,
17 OBM_CLOSE = 32754,
18 OBM_COMBO = 32738,
19 OBM_DNARROW = 32752,
20 OBM_DNARROWD = 32742,
21 OBM_DNARROWI = 32736,
22 OBM_LFARROW = 32750,
23 OBM_LFARROWD = 32740,
24 OBM_LFARROWI = 32734,
25 OBM_MNARROW = 32739,
26 OBM_REDUCE = 32749,
27 OBM_REDUCED = 32746,
28 OBM_RESTORE = 32747,
29 OBM_RESTORED = 32744,
30 OBM_RGARROW = 32751,
31 OBM_RGARROWD = 32741,
32 OBM_RGARROWI = 32735,
33 OBM_SIZE = 32766,
34 OBM_UPARROW = 32753,
35 OBM_UPARROWD = 32743,
36 OBM_UPARROWI = 32737,
37 OBM_ZOOM = 32748,
38 OBM_ZOOMD = 32745
39 }
40
41 public class WinBitmap : Resource
42 {
43 public nothrow WinBitmap() : bitmapHandle(null), standard(false)
44 {
45 }
46 public nothrow WinBitmap(void* bitmapHandle_) : bitmapHandle(bitmapHandle_), standard(false)
47 {
48 }
49 public nothrow WinBitmap(void* bitmapHandle_, bool standard_) : bitmapHandle(bitmapHandle_), standard(standard_)
50 {
51 }
52 public nothrow WinBitmap(WinBitmap&& that) : bitmapHandle(that.bitmapHandle), standard(that.standard)
53 {
54 that.bitmapHandle = null;
55 that.standard = false;
56 }
57 public ~WinBitmap()
58 {
59 if (bitmapHandle != null && !standard)
60 {
61 WinDestroyBitmap(bitmapHandle);
62 }
63 }
64 public default nothrow void operator=(WinBitmap&&);
65 suppress WinBitmap(const WinBitmap&);
66 suppress void operator=(const WinBitmap&);
67 public nothrow void* Handle() const
68 {
69 return bitmapHandle;
70 }
71 public nothrow bool IsStandard() const
72 {
73 return standard;
74 }
75 public nothrow void SetStandard()
76 {
77 standard = true;
78 }
79 private void* bitmapHandle;
80 private bool standard;
81 }
82
83 public WinBitmap LoadStandardBitmap(StandardBitmapId bitmapId)
84 {
85 void* bitmapHandle = WinLoadStandardBitmap(cast<int>(bitmapId));
86 if (bitmapHandle == null)
87 {
88 throw WindowsAPIException(WinGetLastError());
89 }
90 return WinBitmap(bitmapHandle, true);
91 }
92
93 public WinBitmap LoadBitmap(const string& bitmapName)
94 {
95 return WinBitmap(LoadBitmap(bitmapName.Chars()));
96 }
97 }