main
 1using System;
 2using System.Drawing;
 3using System.Windows.Forms;
 4using gorilla.commons.utility;
 5using MoMoney.Presentation.Winforms.Resources;
 6using XPExplorerBar;
 7
 8namespace MoMoney.Presentation.Presenters
 9{
10    public interface IExpandoItemBuilder : Builder<TaskItem>
11    {
12        IExpandoItemBuilder named(string name);
13        IExpandoItemBuilder represented_by_image(ApplicationImage image);
14        IExpandoItemBuilder represented_by_icon(HybridIcon image);
15        IExpandoItemBuilder when_clicked_execute(Action action);
16    }
17
18    public class ExpandoItemBuilder : IExpandoItemBuilder
19    {
20        string the_name = "";
21        Image the_image;
22        Action the_action = () => {};
23
24        public IExpandoItemBuilder named(string name)
25        {
26            the_name = name;
27            return this;
28        }
29
30        public IExpandoItemBuilder represented_by_image(ApplicationImage image)
31        {
32            the_image = image;
33            return this;
34        }
35
36        public IExpandoItemBuilder represented_by_icon(HybridIcon icon)
37        {
38            the_image = icon;
39            return this;
40        }
41
42        public IExpandoItemBuilder when_clicked_execute(Action action)
43        {
44            the_action = action;
45            return this;
46        }
47
48        public TaskItem build()
49        {
50            var item = new TaskItem
51                       {
52                           Anchor = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right),
53                           BackColor = Color.Transparent,
54                           Image = the_image,
55                           Name = "ux" + the_name,
56                           Text = the_name,
57                           UseVisualStyleBackColor = false,
58                           ShowFocusCues = true,
59                       };
60            item.Click += (sender, e) => the_action();
61            return item;
62        }
63    }
64}