private void ResizeTable(Table table, int columns, IList<Widget> list) { RemoveContainerEntries(table); double rows = (double)list.Count / (double)columns; double remainder = rows - (int)rows; if(remainder != 0.0) { rows++; } if(rows > 0 && columns > 0) { table.Resize((uint)rows, (uint)columns); } }
private void LoadControlTable(Table table, bool advanced) { while(table.Children.Length > 0) { table.Remove(table.Children[0]); } table.Resize(1, 1); table.RowSpacing = 5; table.ColumnSpacing = 12; uint y = 0; foreach(PipelineVariable variable in profile.Pipeline) { if(advanced != variable.Advanced) { continue; } Label label = new Label(); label.Show(); label.Markup = String.Format("<b>{0}:</b>", GLib.Markup.EscapeText(variable.Name)); label.Xalign = 0.0f; try { Widget control = BuildControl(variable); if(control == null) { throw new ApplicationException("Control could not be created"); } variable_widgets.Add(variable.Id, control); if(variable.ControlType != PipelineVariableControlType.Check) { variable_widgets.Add(".label." + variable.Id, label); } control.Show(); table.Resize(y + 1, 2); if(variable.ControlType != PipelineVariableControlType.Check) { table.Attach(label, 0, 1, y, y + 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0); } table.Attach(control, 1, 2, y, y + 1, control is ComboBox ? AttachOptions.Fill : AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, (uint)(variable.ControlType == PipelineVariableControlType.Check ? 2 : 0)); y++; } catch { } } foreach(Widget widget in variable_widgets.Values) { if(widget is PipelineVariableComboBox) { OnComboChanged(widget, EventArgs.Empty); } else if(widget is CheckButton) { (widget as CheckButton).Toggle(); } } table.Visible = y > 0; }
private void AddTabAndSlidersFor(Type t) { Table table = new Table(1,1,false); notebook.AppendPage(table, new Label(t.Name)); uint fieldCount = 0; foreach (var field in t.GetFields()) { if (field.FieldType == typeof(float) && field.IsPublic && field.IsStatic) { HScale hscale = new HScale(0, 1, 0.01); hscale.Digits = 2; foreach (var attribute in field.GetCustomAttributes(false)) { if (attribute is RangeAttribute) { var range = (RangeAttribute)attribute; hscale.Adjustment.Upper = range.m_max; hscale.Adjustment.Lower = range.m_min; hscale.Digits = range.m_places; break; } } hscale.Value = (float)field.GetValue(null); var localField = field; hscale.ValueChanged += (obj, args) => { localField.SetValue(null, (float)hscale.Value); }; table.Resize(fieldCount+1, 2); Label label = new Label(field.Name); table.Attach(label , 0, 1, fieldCount, fieldCount+1); table.Attach(hscale, 1, 2, fieldCount, fieldCount+1); table.Homogeneous = false; table.ShowAll(); fieldCount++; } } }