private void InitView() { oldSettings = new ObsData(settings); // force double buffering on to eliminate control flickering during refresh WinFormsHelper.DoubleBufferControl(panel); ReloadProperties(); }
public PropertyControl(PropertiesView view, ObsProperty property, ObsData setting) { SuspendLayout(); AutoSize = true; Margin = new Padding(0, 1, 0, 1); Size = new Size(600, 25); ResumeLayout(false); this.view = view; DoubleBuffered = true; Padding = new Padding(2); ObsPropertyType type = property.Type; bool addLabel = true; List <Control> controls = new List <Control>(); switch (type) { case ObsPropertyType.Bool: { addLabel = false; AddBool(property, setting, controls); break; } case ObsPropertyType.Int: case ObsPropertyType.Float: { AddNumeric(property, setting, controls); break; } case ObsPropertyType.Text: { AddText(property, setting, controls); break; } case ObsPropertyType.Path: { AddPath(property, setting, controls); break; } case ObsPropertyType.List: { AddList(property, setting, controls); break; } case ObsPropertyType.Color: { AddColor(property, setting, controls); break; } case ObsPropertyType.Button: { addLabel = false; AddButton(property, setting, controls); break; } case ObsPropertyType.Font: { AddFont(property, setting, controls); break; } case ObsPropertyType.EditableList: { addLabel = false; AddEditableList(property, setting, controls); break; } default: { throw new Exception(String.Format("Error, unimplemented property type {0} for property {1}", type, property.Description)); } } Label nameLabel = new Label { Text = addLabel ? property.Description : "", TextAlign = ContentAlignment.MiddleRight, MinimumSize = new Size(170, 0), AutoSize = true, Dock = DockStyle.Left }; controls.Insert(0, nameLabel); foreach (Control control in controls) { WinFormsHelper.DoubleBufferControl(control); int margin = 0; Padding oldmargin = control.Margin; oldmargin.Top = margin; oldmargin.Bottom = margin; control.Margin = oldmargin; } SuspendLayout(); Controls.AddRange(controls.ToArray()); ResumeLayout(); }