main
1using System;
2using System.Drawing;
3using System.IO;
4using Gorilla.Commons.Infrastructure.Reflection;
5
6namespace MoMoney.Presentation.Winforms.Resources
7{
8 public class ApplicationImage : IDisposable
9 {
10 readonly string name_of_the_image;
11 readonly Image underlying_image;
12
13 public ApplicationImage(string name_of_the_image)
14 {
15 this.name_of_the_image = name_of_the_image;
16 underlying_image = Image.FromFile(FullPathToTheFile(this));
17 }
18
19 public static implicit operator Image(ApplicationImage image_to_convert)
20 {
21 return image_to_convert.underlying_image;
22 }
23
24 public static implicit operator Bitmap(ApplicationImage image_to_convert)
25 {
26 return new Bitmap(image_to_convert);
27 }
28
29 string FullPathToTheFile(ApplicationImage image_to_convert)
30 {
31 return Path.Combine(image_to_convert.startup_directory() + @"\images", image_to_convert.name_of_the_image);
32 }
33
34 public void Dispose()
35 {
36 underlying_image.Dispose();
37 }
38 }
39}