main
 1using System.Drawing;
 2using System.IO;
 3using System.Windows.Media;
 4
 5namespace solidware.financials.windows.ui.views.icons
 6{
 7    public class UIIcon
 8    {
 9        static public readonly UIIcon Null = new NullUIIcon();
10        static public readonly UIIcon Category = new UIIcon("category.png");
11        static public readonly UIIcon Comment = new UIIcon("comment.png");
12        static public readonly UIIcon Delete = new UIIcon("delete.png");
13        static public readonly UIIcon Edit = new UIIcon("edit.png");
14        static public readonly UIIcon Help = new UIIcon("help.ico");
15        static public readonly UIIcon Plus = new UIIcon("plus.png");
16        static public readonly UIIcon Refresh = new UIIcon("refresh.png");
17        static public readonly UIIcon Running = new UIIcon("running.gif");
18        static public readonly UIIcon Success = new UIIcon("success.png");
19        static public readonly UIIcon Application = new UIIcon("mokhan.ico");
20        static public readonly UIIcon Close = new UIIcon("close.png");
21        static public readonly UIIcon Info = new UIIcon("info.png");
22        static public readonly UIIcon Up = new UIIcon("up.png");
23        static public readonly UIIcon Down = new UIIcon("down.png");
24
25        UIIcon(string path)
26        {
27            this.path = path;
28        }
29
30        public virtual Stream ImageStream()
31        {
32            return IconMarker.GetImage(path);
33        }
34        
35        public virtual Icon AsIcon()
36        {
37            return new Icon(ImageStream());
38        }
39
40        public virtual ImageSource BitmapFrame()
41        {
42            return System.Windows.Media.Imaging.BitmapFrame.Create(ImageStream());
43        }
44
45        public override string ToString()
46        {
47            return string.Format("Path: {0}", path);
48        }
49
50        string path;
51
52        class NullUIIcon : UIIcon
53        {
54            public NullUIIcon() : base(string.Empty) {}
55
56            public override Stream ImageStream()
57            {
58                return null;
59            }
60
61            public override ImageSource BitmapFrame()
62            {
63                return null;
64            }
65        }
66    }
67}