private void CreateCategoryList() { // calculate seperator var seperatorXOffset = Options.SeperatorOffset; if (Options.SeperatorOffsetType == SeperatorOffsetType.Percent) { seperatorXOffset = MathHelper.RoundInt((double)Width * (double)seperatorXOffset / (double)100); } // layout categories and items int yOffset = Options.CategoryTopMargin; foreach (var categoryName in categoryNames) { var layoutPropertyCategory = new LayoutPropertyCategory(); // category title var categoryLabel = new Label() { Text = Properties.Where(x => x.CategoryName == categoryName).First().CategoryDisplayName, Font = Options.CategoryTitleFont, AutoSize = true, Tag = new ItemControlInfo() { ControlType = ControlType.CategorySeperator } }; Controls.Add(categoryLabel); layoutPropertyCategory.Label = categoryLabel; var categoryWidth = Width - Options.CategoryLeftMargin - Options.CategoryRightMargin; if (VerticalScroll.Visible) { categoryWidth -= SystemInformation.VerticalScrollBarWidth + Options.ScrollBarPadding; } categoryLabel.Location = new Point(Options.CategoryLeftMargin, yOffset + (Options.ItemHeight / 2 - categoryLabel.Height / 2)); categoryLabel.Size = new Size(categoryWidth, categoryLabel.Height); yOffset += categoryLabel.Height + (Options.ItemHeight / 2 - categoryLabel.Height / 2) + CATEGORY_TITLE_SEPERATOR_GAP; // category seperator var categorySeperator = new Panel() { Location = new Point(Options.CategoryLeftMargin, yOffset), Size = new Size(categoryWidth, 1), BackColor = Color.Black, Tag = new ItemControlInfo() { ControlType = ControlType.CategorySeperator } }; Controls.Add(categorySeperator); layoutPropertyCategory.Seperator = categorySeperator; layoutItems.Add(layoutPropertyCategory); yOffset += categorySeperator.Height + ITEM_OFFSET; // iterate for each property of category var items = properties.Where(x => x.CategoryName == categoryName && x.Browsable).ToList(); foreach (var item in items) { // layout property var layoutProperty = new LayoutProperty(); // label var itemLabel = new Label() { Text = item.DisplayName, ForeColor = Options.ItemLabelForeColor, //BackColor = Color.Red, AutoSize = true, Tag = new ItemControlInfo() { ControlType = ControlType.ItemLabel, Property = item } }; Controls.Add(itemLabel); layoutProperty.Label = itemLabel; itemLabel.Location = new Point(Options.ItemLeftMargin, yOffset + (Options.ItemHeight / 2 - itemLabel.Size.Height / 2)); itemLabel.Size = new Size(seperatorXOffset - Options.ItemLeftMargin - Options.SeperatorPadding, itemLabel.Size.Height); // edit var itemEditWidth = Width - seperatorXOffset - Options.ItemRightMargin; if (VerticalScroll.Visible) { itemEditWidth -= SystemInformation.VerticalScrollBarWidth + Options.ScrollBarPadding; } switch (item.Type) { case GenericPropertyType.String: var editorString = new PlaceholderTextBox() { Text = Convert.ToString(item.Value), Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item }, PlaceholderText = item.PlaceholderText }; editorString.TextChanged += TextBox_TextChanged; Controls.Add(editorString); layoutProperty.Control = editorString; editorString.Location = new Point(seperatorXOffset, yOffset + (Options.ItemHeight / 2 - editorString.Size.Height / 2)); editorString.Size = new Size(itemEditWidth, editorString.Size.Height); break; case GenericPropertyType.Integer: var editorInteger = new NumericUpDown() { Value = Convert.ToInt32(item.Value), Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item } }; editorInteger.ValueChanged += SpinEdit_Integer_ValueChanged; editorInteger.Minimum = Convert.ToInt32(item.MinimumValue); editorInteger.Maximum = Convert.ToInt32(item.MaximumValue); Controls.Add(editorInteger); layoutProperty.Control = editorInteger; editorInteger.Location = new Point(seperatorXOffset, yOffset + Options.ItemHeight / 2 - editorInteger.Size.Height / 2); editorInteger.Size = new Size(itemEditWidth, editorInteger.Size.Height); break; case GenericPropertyType.Decimal: var editorDecimal = new NumericUpDown() { Value = Convert.ToDecimal(item.Value), Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item } }; editorDecimal.ValueChanged += SpinEdit_Float_ValueChanged; editorDecimal.Minimum = Convert.ToDecimal(item.MinimumValue); editorDecimal.Maximum = Convert.ToDecimal(item.MaximumValue); Controls.Add(editorDecimal); layoutProperty.Control = editorDecimal; editorDecimal.Location = new Point(seperatorXOffset, yOffset + Options.ItemHeight / 2 - editorDecimal.Size.Height / 2); editorDecimal.Size = new Size(itemEditWidth, editorDecimal.Size.Height); break; case GenericPropertyType.Boolean: var editorBoolean = new CheckBox() { Checked = Convert.ToBoolean(item.Value), Text = string.Empty, Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item } }; editorBoolean.CheckedChanged += CheckEdit_CheckedChanged; Controls.Add(editorBoolean); layoutProperty.Control = editorBoolean; editorBoolean.Location = new Point(seperatorXOffset, yOffset + Options.ItemHeight / 2 - editorBoolean.Size.Height / 2); editorBoolean.Size = new Size(itemEditWidth, editorBoolean.Size.Height); break; case GenericPropertyType.Enumeration: var editorEnumeration = new ComboBox { Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item } }; editorEnumeration.DropDownStyle = ComboBoxStyle.DropDownList; var selectedIndex = -1; var index = 0; foreach (var enumItem in item.EnumItems) { editorEnumeration.Items.Add(enumItem); if (enumItem.Value.Equals(item.Value)) { selectedIndex = index; } index++; } editorEnumeration.SelectedIndex = selectedIndex; editorEnumeration.SelectedValueChanged += ComboBoxEdit_SelectedValueChanged; Controls.Add(editorEnumeration); layoutProperty.Control = editorEnumeration; editorEnumeration.Location = new Point(seperatorXOffset, yOffset + Options.ItemHeight / 2 - editorEnumeration.Size.Height / 2); editorEnumeration.Size = new Size(itemEditWidth, editorEnumeration.Size.Height); break; case GenericPropertyType.Color: var editorColor = new ColorEdit() { Color = Color.Red, Height = 21, Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item } }; editorColor.OnColorChanged += EditorColor_ColorChanged; Controls.Add(editorColor); layoutProperty.Control = editorColor; editorColor.Location = new Point(seperatorXOffset, yOffset + (Options.ItemHeight / 2 - editorColor.Size.Height / 2)); editorColor.Size = new Size(itemEditWidth, editorColor.Size.Height); break; case GenericPropertyType.Path: var editorPath = new ButtonEdit() { Text = Convert.ToString(item.Value), Height = 20, Tag = new ItemControlInfo() { ControlType = ControlType.ItemEdit, Property = item } }; editorPath.OnTextChanged += EditorPath_OnTextChanged; editorPath.OnButtonClick += EditorPath_OnButtonClick; Controls.Add(editorPath); layoutProperty.Control = editorPath; editorPath.Location = new Point(seperatorXOffset, yOffset + (Options.ItemHeight / 2 - editorPath.Size.Height / 2)); editorPath.Size = new Size(itemEditWidth, editorPath.Size.Height); break; default: break; } layoutPropertyCategory.Items.Add(layoutProperty); yOffset += Options.ItemHeight; } } }