1: public static class Shell
2: {
3: public static BitmapImage GetImage(this Application application, string file)
4: {
5: var uri = new Uri(string.Format("pack://application:,,,/{0}", file));
6: return new BitmapImage(uri);
7: }
8:
9: public static BitmapImage GetImage(this Application application, string assembly, string file)
10: {
11: var uri = new Uri(string.Format("pack://application:,,,/{0};component/{1}", assembly, file));
12: return new BitmapImage(uri);
13: }
14:
15: public static Stream GetResourceStream(this Application application, string file)
16: {
17: var uri = new Uri(string.Format("pack://application:,,,/{0}", file));
18: var sri = Application.GetResourceStream(uri);
19: if (sri != null)
20: return sri.Stream;
21:
22: return null;
23: }
24:
25: public static Stream GetResourceStream(this Application application, string assembly, string file)
26: {
27: var uri = new Uri(string.Format("pack://application:,,,/{0};component/{1}", assembly, file));
28: var sri = Application.GetResourceStream(uri);
29: if (sri != null)
30: return sri.Stream;
31:
32: return null;
33: }
34: }