public static T Show <T>(string caption, T value, T resultIfCancel) { using (WinForm cd = new WinForm(WinFormStyle.Dialog)) { T result; cd.Add <Panel>(WinFormConfig.SinglePageForm); TableLayoutPanel tlpRows = cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel; TableLayoutPanel p = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells") { CellsSize = new Pair <int>(2, 1) }); p.Add(new WinFormItem("Item") { Caption = caption, DataType = typeof(T), Value = value, }); cd.Items["MainPanel"].LinkedControl.Add <TableLayoutPanel>(WinFormConfig.StdButtons()); if (cd.ShowDialog() == DialogResult.OK) { cd.Save(); result = (T)cd.GetItem("Item").Value; } else { result = resultIfCancel; } return((T)result); } }
public static Object[] Show(params WinFormItem[] items) { using (WinForm cd = new WinForm(WinFormStyle.Dialog)) { cd.Add <Panel>(WinFormConfig.SinglePageForm); TableLayoutPanel tlpRows = cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel; TableLayoutPanel p = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells") { CellsSize = new Pair <int>(2, 1) }); p.ColumnStyles[0].SizeType = SizeType.Percent; p.ColumnStyles[0].Width = 38; p.ColumnStyles[1].SizeType = SizeType.Percent; p.ColumnStyles[1].Width = 62; foreach (var item in items) { p.Add(item); } cd.Items["MainPanel"].LinkedControl.Add <TableLayoutPanel>(WinFormConfig.StdButtons()); if (cd.ShowDialog() == DialogResult.OK) { cd.Save(); return(items.Select(i => i.Value).ToArray()); } else { return(items.Select(i => i.OriginalValue).ToArray()); } } }
public DialogResult ShowDialog(DBGridParamShowType showType) { int processed = _items.Count(item => showType == DBGridParamShowType.ShowAll || item.Visible); if (processed == 0) { return(DialogResult.OK); } using (WinForm cd = new WinForm(WinFormStyle.Dialog)) { cd.Add <Panel>(WinFormConfig.SinglePageForm); TableLayoutPanel tlpRows = cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel; TableLayoutPanel p = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells") { CellsSize = new Pair <int>(2, 1) }); p.ColumnStyles[0].SizeType = SizeType.Percent; p.ColumnStyles[0].Width = 38; p.ColumnStyles[1].SizeType = SizeType.Percent; p.ColumnStyles[1].Width = 62; foreach (var item in _items) { if (showType == DBGridParamShowType.ShowAll || item.Visible) { p.Add(item); } } cd.Items["MainPanel"].LinkedControl.Add <TableLayoutPanel>(WinFormConfig.StdButtons()); cd.Size = new Size(450, (int)(450 / vbo.GoldenRatio)); cd.MinimumSize = cd.Size; cd.AcceptButton = null; if (cd.Parent != null) { cd.StartPosition = FormStartPosition.CenterParent; } else { cd.StartPosition = FormStartPosition.CenterScreen; } if (cd.ShowDialog() == DialogResult.OK) { cd.Save(); Save2Cash(); return(DialogResult.OK); } else { return(DialogResult.Cancel); } } }
public BaseViewForm(WinFormItem browser) { Width = 680; Height = (int)(Width / vbo.GoldenRatio); this.Add <Panel>(WinFormConfig.SinglePageForm); TableLayoutPanel tp = Items["FormRowsPanel"].LinkedControl as TableLayoutPanel; tp.Add(browser); browser.LinkedControl.Dock = DockStyle.Fill; var btp = GetItem("MainPanel") .LinkedControl .Add <TableLayoutPanel>(WinFormConfig.StdButtons()); btp.Height = ButtonHeight + 20; }