1 namespace RwxFramework.Ribbon
2 {
3 public partial class LayoutBuilderUI : Form
4 {
5 public IDesignerHost iDesignerHost;
6 public List<Sys_Layout> sys_Layouts;
7 public LayoutBuilderUI()
8 {
9 InitializeComponent();
10 }
11 public LayoutBuilderUI(IDesignerHost host)
12 {
13 sys_Layouts = new List<Sys_Layout>();
14 InitializeComponent();
15 iDesignerHost = host;
16 }
17 private void AddPanel(string Layout_Name, string Layout_Nick,
18 string Layout_Grid, LayoutType Layout_Type, LayoutDock Layout_Dock)
19 {
20 Sys_Layout sys_Layout = new Sys_Layout();
21 sys_Layout.Layout_Name = Layout_Name;
22 sys_Layout.Layout_Nick = Layout_Nick;
23 sys_Layout.Layout_Grid = Layout_Grid;
24 sys_Layout.Layout_Type = Layout_Type;
25 sys_Layout.Layout_Dock = Layout_Dock;
26 sys_Layout.Layout_Sort = sys_Layouts.Count;
27 sys_Layouts.Add(sys_Layout);
28 }
29 private void InitializeLayout(List<Sys_Layout> sys_Layouts, Control parentControl)
30 {
31 // MessageBox.Show((sys_Layouts.Count).ToString());
32 Control control = new Control();
33 int i = 0;
34 foreach (Sys_Layout current in sys_Layouts.OrderBy(x => x.Layout_Sort))
35 {
36 if (current.Layout_Dock != LayoutDock.fill)
37 {
38 i++;
39 SplitterControl splitterControl = (SplitterControl)
40 iDesignerHost.CreateComponent(typeof(SplitterControl));
41 splitterControl.Dock = (DockStyle)current.Layout_Dock;
42 parentControl.Controls.Add(splitterControl);
43 //MessageBox.Show(i.ToString());
44 }
45 GroupControl groupControl = null;
46 LayoutType layout_Type = current.Layout_Type;
47 if (layout_Type != LayoutType.qry)
48 {
49 groupControl = (GroupControl)this.iDesignerHost.CreateComponent(typeof(GroupControl), current.Layout_Name);
50 if (layout_Type == LayoutType.gc)
51 {
52 RwxChildGridPager rwxGrid = (RwxChildGridPager)this.iDesignerHost.CreateComponent(typeof(RwxChildGridPager), current.Layout_Grid);
53 rwxGrid.Dock = DockStyle.Fill;
54 rwxGrid.Name = current.Layout_Grid;
55 //GridControl gridControl = (GridControl)this.iDesignerHost.CreateComponent(typeof(GridControl), current.Layout_Grid);
56 //gridControl.Dock = DockStyle.Fill;
57 //gridControl.Name = current.Layout_Grid;
58 //GridView gridView = (GridView)gridControl.CreateView("GridView");
59 //gridView.OptionsView.ColumnAutoWidth = false;
60 //gridView.Name = gridControl.Name.Replace("Control", "View");
61 //gridView.OptionsView.ShowGroupPanel = false;
62 //gridView.OptionsView.ShowFooter = true;
63 //gridView.OptionsSelection.MultiSelect = true;
64 //gridControl.MainView = gridView;
65 groupControl.Controls.Add(rwxGrid);
66 }
67 }
68 else
69 {
70 groupControl = (GroupControl)this.iDesignerHost.CreateComponent(typeof(GroupControl), current.Layout_Name);
71 }
72 if (groupControl == null)
73 {
74 return;
75 }
76 groupControl.Dock = (DockStyle)current.Layout_Dock;
77 groupControl.Top = 80;
78 groupControl.Left = 80;
79 groupControl.Width = 80;
80 groupControl.Height = 80;
81 groupControl.Name = current.Layout_Name;
82 groupControl.Text = current.Layout_Nick;
83 if (((DockStyle)current.Layout_Dock).Equals(DockStyle.Fill))
84 {
85 control = groupControl;
86 }
87 parentControl.Controls.Add(groupControl);
88 }
89 control.Dock = DockStyle.Fill;
90 control.BringToFront();
91 this.sys_Layouts.Clear();
92 this.Close();
93 }
94 /// <summary>
95 /// 上下模板
96 /// </summary>
97 /// <param name="sender"></param>
98 /// <param name="e"></param>
99 private void btn_tb_Click(object sender, EventArgs e)
100 {
101 this.AddPanel("gpqry", "查询", "", LayoutType.qry, LayoutDock.top);
102 this.AddPanel("gpc", "信息", "gc", LayoutType.gc, LayoutDock.fill);
103 this.InitializeLayout(this.sys_Layouts, (Control)this.iDesignerHost.RootComponent);
104 }
105 /// <summary>
106 /// 上-左右
107 /// </summary>
108 /// <param name="sender"></param>
109 /// <param name="e"></param>
110 private void btn_tlr_Click(object sender, EventArgs e)
111 {
112 this.AddPanel("gpcl", "信息", "gcl", LayoutType.gc, LayoutDock.left);
113 this.AddPanel("gpqry", "查询", "", 0, LayoutDock.top);
114 this.AddPanel("gpcr", "信息", "gcr", LayoutType.gc, LayoutDock.fill);
115 this.InitializeLayout(this.sys_Layouts, (Control)this.iDesignerHost.RootComponent);
116 }
117 /// <summary>
118 /// 上中下
119 /// </summary>
120 /// <param name="sender"></param>
121 /// <param name="e"></param>
122 private void btn_tmb_Click(object sender, EventArgs e)
123 {
124 this.AddPanel("gpqry", "查询", "", LayoutType.qry, LayoutDock.top);
125 this.AddPanel("gpch", "信息", "gcb", LayoutType.gc, LayoutDock.buttom);
126 this.AddPanel("gpcb", "信息", "gch", LayoutType.gc, LayoutDock.fill);
127 this.InitializeLayout(this.sys_Layouts, (Control)this.iDesignerHost.RootComponent);
128 }
129 /// <summary>
130 /// 上左右上下
131 /// </summary>
132 /// <param name="sender"></param>
133 /// <param name="e"></param>
134 private void btn_tlrtb_Click(object sender, EventArgs e)
135 {
136 this.AddPanel("gpcr", "信息", "gcb", LayoutType.gc, LayoutDock.buttom);
137 this.AddPanel("gpcl", "信息", "gcl", LayoutType.gc, LayoutDock.left);
138 this.AddPanel("gpqry", "查询", "", LayoutType.qry, LayoutDock.top);
139 this.AddPanel("gpc", "信息", "gch", LayoutType.gc, LayoutDock.fill);
140 this.InitializeLayout(this.sys_Layouts, (Control)this.iDesignerHost.RootComponent);
141 }
142 /// <summary>
143 /// 上左中右
144 /// </summary>
145 /// <param name="sender"></param>
146 /// <param name="e"></param>
147 private void btn_tlcr_Click(object sender, EventArgs e)
148 {
149 this.AddPanel("gpcr", "信息", "gcr", LayoutType.gc, LayoutDock.right);
150 this.AddPanel("gpcl", "信息", "gcl", LayoutType.gc, LayoutDock.left);
151 this.AddPanel("gpqry", "查询", "", LayoutType.qry, LayoutDock.top);
152 this.AddPanel("gpc", "信息", "gc", LayoutType.gc, LayoutDock.fill);
153 this.InitializeLayout(this.sys_Layouts, (Control)this.iDesignerHost.RootComponent);
154 }
155 /// <summary>
156 /// 上中左右下
157 /// </summary>
158 /// <param name="sender"></param>
159 /// <param name="e"></param>
160 private void btn_tmlrb_Click(object sender, EventArgs e)
161 {
162 this.AddPanel("gpcr", "信息", "gcr", LayoutType.gc, LayoutDock.right);
163 this.AddPanel("gpcb", "信息", "gcb", LayoutType.gc, LayoutDock.buttom);
164 this.AddPanel("gpqry", "查询", "", LayoutType.qry, LayoutDock.top);
165 this.AddPanel("gpcl", "信息", "gcl", LayoutType.gc, LayoutDock.fill);
166 this.InitializeLayout(this.sys_Layouts, (Control)this.iDesignerHost.RootComponent);
167 }
168
169 }
170 }
171 public enum LayoutType
172 {
173 [Description("查询")]
174 qry = 0,
175 [Description("列表")]
176 gc = 1
177 }
178 public enum LayoutDock
179 {
180 top = 1,
181 buttom = 2,
182 left = 3,
183 right = 4,
184 fill = 5
185 }
186 public class Sys_Layout
187 {
188 public Guid Layout_Id { get; set; }
189 public Guid Layout_Page { get; set; }
190 public string Layout_Name { get; set; }
191 public string Layout_Nick { get; set; }
192 public int Layout_Sort { get; set; }
193 public LayoutType Layout_Type { get; set; }
194 public string Layout_Grid { get; set; }
195 public int Layout_Left { get; set; }
196 public int Layout_Top { get; set; }
197 public int Layout_Width { get; set; }
198 public int Layout_Height { get; set; }
199 public LayoutDock Layout_Dock { get; set; }
200 public string Remark { get; set; }
201 }