PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Debugger/ILSpy.Debugger/Services/ImageService/ImageService.cs

http://github.com/icsharpcode/ILSpy
C# | 35 lines | 28 code | 4 blank | 3 comment | 2 complexity | 867a3671ebfa1a6b8621f6a79e22ebbf MD5 | raw file
 1// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 2// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 3
 4using System;
 5using System.Windows.Media;
 6using System.Windows.Media.Imaging;
 7
 8namespace ICSharpCode.ILSpy.Debugger.Services
 9{
10	static class ImageService
11	{
12		static BitmapImage LoadBitmap(string name)
13		{
14			try {
15				BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/ILSpy.Debugger.Plugin;component/Images/" + name + ".png"));
16				if (image == null)
17					return null;
18				image.Freeze();
19				return image;
20			}
21			catch {
22				// resource not found
23				return null;
24			}
25		}
26		
27		public static readonly BitmapImage Breakpoint = LoadBitmap("Breakpoint");
28		public static readonly BitmapImage CurrentLine = LoadBitmap("CurrentLine");
29		
30		public static ImageSource GetImage(string imageName)
31		{
32			return LoadBitmap(imageName);
33		}
34	}
35}