/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. using System;
  4. using System.Windows.Media;
  5. using System.Windows.Media.Imaging;
  6. namespace ICSharpCode.ILSpy.Debugger.Services
  7. {
  8. static class ImageService
  9. {
  10. static BitmapImage LoadBitmap(string name)
  11. {
  12. try {
  13. BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/ILSpy.Debugger.Plugin;component/Images/" + name + ".png"));
  14. if (image == null)
  15. return null;
  16. image.Freeze();
  17. return image;
  18. }
  19. catch {
  20. // resource not found
  21. return null;
  22. }
  23. }
  24. public static readonly BitmapImage Breakpoint = LoadBitmap("Breakpoint");
  25. public static readonly BitmapImage CurrentLine = LoadBitmap("CurrentLine");
  26. public static ImageSource GetImage(string imageName)
  27. {
  28. return LoadBitmap(imageName);
  29. }
  30. }
  31. }