public override object CreateControl() { ParameterPanel panelFalse = new ParameterPanel(); ParameterPanel panelTrue = new ParameterPanel(); panelFalse.Init(SubParamsFalse, ParamNameWidth, (int)TotalWidth); panelTrue.Init(SubParamsTrue, ParamNameWidth, (int)TotalWidth); CheckBox cb = new CheckBox { Checked = Value }; cb.CheckedChanged += (sender, e) => ValueHasChanged(); TableLayoutPanel tlp = new TableLayoutPanel(); tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); tlp.RowStyles.Add(new RowStyle(SizeType.Absolute, paramHeight)); tlp.RowStyles.Add(new RowStyle(SizeType.AutoSize, 100)); tlp.Controls.Add(cb, 0, 0); panelFalse.Visible = !Value; panelTrue.Visible = Value; tlp.Controls.Add(panelFalse, 0, 1); tlp.Controls.Add(panelTrue, 0, 1); cb.CheckedChanged += (sender, e) => { panelFalse.Visible = !cb.Checked; panelTrue.Visible = cb.Checked; Value = cb.Checked; }; tlp.PerformLayout(); control = tlp; return(control); }
public override object CreateControl() { ParameterPanel panelFalse = new ParameterPanel(); ParameterPanel panelTrue = new ParameterPanel(); panelFalse.Init(SubParamsFalse, ParamNameWidth, (int) TotalWidth); panelTrue.Init(SubParamsTrue, ParamNameWidth, (int) TotalWidth); CheckBox cb = new CheckBox{Checked = Value}; cb.CheckedChanged += (sender, e) => ValueHasChanged(); TableLayoutPanel tlp = new TableLayoutPanel(); tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); tlp.RowStyles.Add(new RowStyle(SizeType.Absolute, paramHeight)); tlp.RowStyles.Add(new RowStyle(SizeType.AutoSize, 100)); tlp.Controls.Add(cb, 0, 0); panelFalse.Visible = !Value; panelTrue.Visible = Value; tlp.Controls.Add(panelFalse, 0, 1); tlp.Controls.Add(panelTrue, 0, 1); cb.CheckedChanged += (sender, e) =>{ panelFalse.Visible = !cb.Checked; panelTrue.Visible = cb.Checked; }; tlp.PerformLayout(); control = tlp; return control; }
public override object CreateControl() { ParameterPanel[] panels = new ParameterPanel[SubParams.Count]; for (int i = 0; i < panels.Length; i++) { panels[i] = new ParameterPanel(); panels[i].Init(SubParams[i], ParamNameWidth, (int)TotalWidth); } ComboBox cb = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; cb.SelectedIndexChanged += (sender, e) => { SetValueFromControl(); ValueHasChanged(); }; if (Values != null) { foreach (string value in Values) { cb.Items.Add(value); } if (Value >= 0 && Value < Values.Count) { cb.SelectedIndex = Value; } } TableLayoutPanel grid = new TableLayoutPanel(); grid.RowStyles.Add(new RowStyle(SizeType.Absolute, paramHeight)); grid.RowStyles.Add(new RowStyle(SizeType.AutoSize, 100)); cb.Dock = DockStyle.Fill; grid.Controls.Add(cb, 0, 0); for (int i = 0; i < panels.Length; i++) { panels[i].Visible = (i == Value); panels[i].Dock = DockStyle.Fill; grid.Controls.Add(panels[i], 0, 1); } cb.SelectedIndexChanged += (sender, e) => { for (int i = 0; i < panels.Length; i++) { panels[i].Visible = i == cb.SelectedIndex; } }; grid.Width = (int)TotalWidth; grid.Dock = DockStyle.Fill; control = grid; return(control); }
public override object CreateControl() { ParameterPanel[] panels = new ParameterPanel[SubParams.Count]; float panelHeight = 0; for (int i = 0; i < panels.Length; i++) { panels[i] = new ParameterPanel(); float h = panels[i].Init(SubParams[i], ParamNameWidth, (int)TotalWidth); panelHeight = Math.Max(panelHeight, h); } panelHeight += 7; ComboBox cb = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList }; cb.SelectedIndexChanged += (sender, e) => { SetValueFromControl(); ValueHasChanged(); }; if (Values != null) { foreach (string value in Values) { cb.Items.Add(value); } if (Value >= 0 && Value < Values.Count) { cb.SelectedIndex = Value; } } TableLayoutPanel grid = new TableLayoutPanel(); //float sfx = FormUtils.GetDpiScale(grid.CreateGraphics()); float sfx = 1; grid.RowStyles.Add(new RowStyle(SizeType.Absolute, paramHeight)); grid.RowStyles.Add(new RowStyle(SizeType.Absolute, sfx * panelHeight)); cb.Dock = DockStyle.Fill; grid.Controls.Add(cb, 0, 0); Panel placeholder = new Panel { Margin = new Padding(0), Dock = DockStyle.Fill }; grid.Controls.Add(placeholder, 0, 1); foreach (ParameterPanel t in panels) { t.Dock = DockStyle.Top; } if (Value >= 0 && panels.Length > 0) { placeholder.Controls.Add(panels[Value]); } cb.SelectedIndexChanged += (sender, e) => { placeholder.Controls.Clear(); if (cb.SelectedIndex >= 0) { placeholder.Controls.Add(panels[cb.SelectedIndex]); } }; grid.Width = (int)TotalWidth; grid.Dock = DockStyle.Top; control = grid; return(control); }