/// <summary> /// Creates a specified control based on the SBMatAttrb in the Material File /// </summary> /// <param name="property"></param> /// <param name="Object"></param> /// <returns></returns> private Control CreateControl(PropertyInfo property, object Object) { if (property.PropertyType == typeof(SBMatAttrib <Vector4>)) { SBMatAttrib <Vector4> matinfo = (SBMatAttrib <Vector4>)property.GetValue(Object); GenericBindingVector4Editor editor = new GenericBindingVector4Editor(matinfo.Name, matinfo.IsColor); editor.Dock = DockStyle.Top; editor.Bind(matinfo, "Value"); toolTips.SetToolTip(editor.Controls[0], matinfo.Description); vectorSection.Contents.Add(editor); } if (property.PropertyType == typeof(SBMatAttrib <bool>)) { SBMatAttrib <bool> matinfo = (SBMatAttrib <bool>)property.GetValue(Object); GenericBindingCheckBox editor = new GenericBindingCheckBox(matinfo.Name); editor.Dock = DockStyle.Top; editor.Bind(matinfo, "Value"); toolTips.SetToolTip(editor, matinfo.Description); boolSection.Contents.Add(editor); } if (property.PropertyType == typeof(SBMatAttrib <float>)) { SBMatAttrib <float> matinfo = (SBMatAttrib <float>)property.GetValue(Object); GenericBindingTextBox <float> editor = new GenericBindingTextBox <float>(); editor.Bind(matinfo, "Value"); SBHBox hungrybox = new SBHBox(); hungrybox.AddControl(new Label() { Text = matinfo.Name }); hungrybox.AddControl(editor); hungrybox.Dock = DockStyle.Top; toolTips.SetToolTip(hungrybox, matinfo.Description); floatSection.Contents.Add(hungrybox); } return(null); }
public GenericMaterialEditor() : base() { Text = "Material Editor"; Size = new Size(300, 600); menu = new SBMenuBar(); { var file = new SBToolStripMenuItem("Material"); { var delete = new SBToolStripMenuItem("Delete Selected"); delete.Click += DeleteMaterial; file.DropDownItems.Add(delete); var import = new SBToolStripMenuItem("Import Material"); import.Click += ImportMaterial; file.DropDownItems.Add(import); var export = new SBToolStripMenuItem("Export Material"); export.Click += ExportMaterial; file.DropDownItems.Add(export); } menu.Items.Add(file); } //_viewport = new GLControl(); //_viewport.Size = new Size(400, 400); //_viewport.Dock = DockStyle.Top; MinimumSize = new Size(240, 240); ApplicationSettings.SkinControl(this); //Controls.Add(_viewport); viewport = new GLViewport(); viewport.OnRenderFrame += Render; viewport.Dock = DockStyle.Top; viewport.MinimumSize = new Size(240, 240); materialList = new SBListView(); materialList.Dock = DockStyle.Top; materialList.MinimumSize = new Size(240, 180); materialList.MultiSelect = false; materialList.View = View.LargeIcon; materialList.HideSelection = false; materialList.SelectedIndexChanged += SelectedMaterialChanged; toolTips = new ToolTip(); TopMost = true; mainPanel = new Panel(); mainPanel.AutoSize = true; mainPanel.AutoScroll = true; mainPanel.Dock = DockStyle.Fill; vectorSection = new SBPopoutPanel(PopoutSide.Bottom, "Vectors", "Vectors"); vectorSection.Dock = DockStyle.Top; floatSection = new SBPopoutPanel(PopoutSide.Bottom, "Floats", "Floats"); floatSection.Dock = DockStyle.Top; boolSection = new SBPopoutPanel(PopoutSide.Bottom, "Bools", "Bools"); boolSection.Dock = DockStyle.Top; mainPanel.Controls.Add(vectorSection); mainPanel.Controls.Add(floatSection); mainPanel.Controls.Add(boolSection); typeLabel = new Label(); typeLabel.Dock = DockStyle.Top; materialLabel = new GenericBindingTextBox <string>(); materialLabel.Dock = DockStyle.Top; materialName = new GenericBindingTextBox <string>(); materialName.Dock = DockStyle.Top; Controls.Add(mainPanel); //Controls.Add(viewport); Controls.Add(materialName); Controls.Add(materialLabel); Controls.Add(materialList); Controls.Add(typeLabel); Controls.Add(menu); ResizeEnd += onResize; FormClosing += Editor_FormClosing; }