Browse Source

Minor code reformat.

pull/63/merge
Matt Ward 13 years ago
parent
commit
31e96db276
  1. 9
      src/Main/Base/Project/Src/Services/FileIconService.cs
  2. 28
      src/Main/Base/Project/Src/Services/IconService.cs

9
src/Main/Base/Project/Src/Services/FileIconService.cs

@ -9,7 +9,7 @@ using System.Drawing;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop
{ {
/// <summary> /// <summary>
/// This Class contains a ResourceManager, which handles bitmap resources /// This Class handles bitmap resources
/// for the application which were loaded from the filesystem. /// for the application which were loaded from the filesystem.
/// </summary> /// </summary>
public static class FileIconService public static class FileIconService
@ -29,7 +29,7 @@ namespace ICSharpCode.SharpDevelop
} }
/// <summary> /// <summary>
/// Returns a bitmap from the file system. Paceholders like ${SharpDevelopBinPath} /// Returns a bitmap from the file system. Placeholders like ${SharpDevelopBinPath}
/// and AddinPath (e. g. ${AddInPath:ICSharpCode.FiletypeRegisterer}) are resolved /// and AddinPath (e. g. ${AddInPath:ICSharpCode.FiletypeRegisterer}) are resolved
/// through the StringParser. /// through the StringParser.
/// The bitmaps are reused, you must not dispose the Bitmap! /// The bitmaps are reused, you must not dispose the Bitmap!
@ -46,11 +46,12 @@ namespace ICSharpCode.SharpDevelop
public static Bitmap GetBitmap(string name) public static Bitmap GetBitmap(string name)
{ {
Bitmap bmp = null; Bitmap bmp = null;
if (name.ToUpper().StartsWith("FILE:")) { if (name.ToUpper().StartsWith("FILE:")) {
lock (bitmapCache) { lock (bitmapCache) {
if (bitmapCache.TryGetValue(name, out bmp)) if (bitmapCache.TryGetValue(name, out bmp))
return bmp; return bmp;
bmp = (Bitmap)Image.FromFile(StringParser.Parse(name.Substring(5,name.Length-5))); string fileName = StringParser.Parse(name.Substring(5, name.Length - 5));
bmp = (Bitmap)Image.FromFile(fileName);
bitmapCache[name] = bmp; bitmapCache[name] = bmp;
} }
} }

28
src/Main/Base/Project/Src/Services/IconService.cs

@ -61,20 +61,20 @@ namespace ICSharpCode.SharpDevelop
public static Bitmap GetBitmap(string name) public static Bitmap GetBitmap(string name)
{ {
Bitmap bmp = null; Bitmap bmp = null;
try { try {
bmp = FileIconService.GetBitmap(name); bmp = FileIconService.GetBitmap(name);
if (bmp == null) { if (bmp == null) {
bmp = WinFormsResourceService.GetBitmap(name); bmp = WinFormsResourceService.GetBitmap(name);
} }
} catch (ResourceNotFoundException ex) { } catch (ResourceNotFoundException ex) {
LoggingService.Warn(ex); LoggingService.Warn(ex);
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
LoggingService.Warn(ex); LoggingService.Warn(ex);
} }
if (bmp != null) { if (bmp != null) {
return bmp; return bmp;
} }
return WinFormsResourceService.GetBitmap("Icons.16x16.MiscFiles"); return WinFormsResourceService.GetBitmap("Icons.16x16.MiscFiles");
} }
public static Icon GetIcon(string name) public static Icon GetIcon(string name)

Loading…
Cancel
Save