main
 1using System.Collections.Generic;
 2using System.ComponentModel;
 3using System.Windows.Forms;
 4using gorilla.commons.utility;
 5using MoMoney.Presentation.Presenters;
 6using XPExplorerBar;
 7
 8namespace momoney.presentation.presenters
 9{
10    public interface IExpandoBuilder : Builder<Expando>
11    {
12        IExpandoBuilder named(string name);
13        IExpandoBuilder with_item(IExpandoItemBuilder builder);
14    }
15
16    public class ExpandoBuilder : IExpandoBuilder
17    {
18        readonly List<IExpandoItemBuilder> builders = new List<IExpandoItemBuilder>();
19        string the_name = "";
20
21        public IExpandoBuilder named(string name)
22        {
23            the_name = name;
24            return this;
25        }
26
27        public IExpandoBuilder with_item(IExpandoItemBuilder builder)
28        {
29            builders.Add(builder);
30            return this;
31        }
32
33        public Expando build()
34        {
35            var pane = new Expando {};
36            ((ISupportInitialize) (pane)).BeginInit();
37            pane.SuspendLayout();
38
39            pane.Anchor = (AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right;
40            pane.Animate = true;
41            pane.AutoLayout = true;
42            pane.Items.AddRange(create_items());
43            pane.Name = "ux_" + the_name;
44            pane.SpecialGroup = true;
45            pane.Text = the_name;
46
47            ((ISupportInitialize) (pane)).EndInit();
48            pane.ResumeLayout(false);
49
50            return pane;
51        }
52
53        TaskItem[] create_items()
54        {
55            var items = new List<TaskItem>();
56            builders.each(x => items.Add(x.build()));
57            return items.ToArray();
58        }
59    }
60}