/// <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 SBTextureList() { Text = "Texture List"; Dock = DockStyle.Fill; ApplicationSettings.SkinControl(this); TextureList = new ListBox(); TextureList.Dock = DockStyle.Top; TextureList.SelectedIndexChanged += (sender, args) => { if (TextureList.SelectedIndex != -1) { PropertyGrid.SelectedObject = TextureList.Items[TextureList.SelectedIndex]; } }; PropertyGrid = new PropertyGrid(); PropertyGrid.Dock = DockStyle.Top; PropertyGrid.Size = new Size(200, 500); PropertyGrid.SelectedObjectsChanged += (sender, agrs) => { if (PropertyGrid.SelectedObject is SBSurface surface && surface.Arrays.Count > 0) { MipLevel.Maximum = surface.Arrays[0].Mipmaps.Count - 1; } }; DisplayBox = new GroupBox(); DisplayBox.Text = "Texture Options"; DisplayBox.Dock = DockStyle.Top; DisplayBox.Size = new Size(400, 140); ApplicationSettings.SkinControl(DisplayBox); MipLevel = new TrackBar(); MipLevel.Maximum = 20; MipLevel.Dock = DockStyle.Top; DisplayBox.Controls.Add(MipLevel); DisplayBox.Controls.Add(new Label() { Text = "Mip Level", Dock = DockStyle.Top }); SBHBox hungryBox = new SBHBox(); hungryBox.Dock = DockStyle.Top; DisplayBox.Controls.Add(hungryBox); SBHBox buttons = new SBHBox(); buttons.Dock = DockStyle.Top; DisplayBox.Controls.Add(buttons); Export = new SBButton("Export Texture"); Export.Click += (sender, args) => { string fileName; string supported = string.Join(";*", Extension()); if (Tools.FileTools.TrySaveFile(out fileName, "Supported Formats|*" + supported)) { Save(fileName); } }; buttons.AddControl(Export); Replace = new SBButton("Replace"); Replace.Click += (sender, args) => { string fileName; string supported = string.Join(";*", Extension()); if (Tools.FileTools.TryOpenFile(out fileName, "Supported Formats|*" + supported)) { var sur = OpenFile(fileName); if (sur != null) { if (PropertyGrid.SelectedObject is SBSurface surface) { surface.Arrays = sur.Arrays; surface.Width = sur.Width; surface.Height = sur.Height; surface.PixelFormat = sur.PixelFormat; surface.InternalFormat = sur.InternalFormat; surface.Depth = sur.Depth; surface.TextureTarget = sur.TextureTarget; surface.RefreshRendering(); PropertyGrid.SelectedObject = surface; } } } }; buttons.AddControl(Replace); Import = new SBButton("Import"); Import.Click += (sender, args) => { string[] fileNames; string supported = string.Join(";*", Extension()); if (Tools.FileTools.TryOpenFiles(out fileNames, "Supported Formats|*" + supported)) { foreach (var fileName in fileNames) { var surface = OpenFile(fileName); if (surface != null) { if (TextureBank != null) { TextureBank.Add(surface); } TextureList.Items.Add(surface); } } } }; buttons.AddControl(Import); R = new SBButton("R"); R.BackColor = Color.Red; R.Width = 32; R.Click += (sender, args) => { if (R.BackColor == Color.Gray) { R.BackColor = Color.Red; } else { R.BackColor = Color.Gray; } }; hungryBox.AddControl(R); G = new SBButton("G"); G.BackColor = Color.Green; G.Width = 32; G.Click += (sender, args) => { if (G.BackColor == Color.Gray) { G.BackColor = Color.Green; } else { G.BackColor = Color.Gray; } }; hungryBox.AddControl(G); B = new SBButton("B"); B.BackColor = Color.Blue; B.Width = 32; B.Click += (sender, args) => { if (B.BackColor == Color.Gray) { B.BackColor = Color.Blue; } else { B.BackColor = Color.Gray; } }; hungryBox.AddControl(B); A = new SBButton("A"); A.BackColor = Color.Black; A.Width = 32; A.Click += (sender, args) => { if (A.BackColor == Color.Gray) { A.BackColor = Color.Black; } else { A.BackColor = Color.Gray; } }; hungryBox.AddControl(A); Controls.Add(new Splitter() { Dock = DockStyle.Top, Height = 10 }); Controls.Add(PropertyGrid); Controls.Add(new Splitter() { Dock = DockStyle.Top, Height = 10 }); Controls.Add(DisplayBox); Controls.Add(new Splitter() { Dock = DockStyle.Top, Height = 10 }); Controls.Add(TextureList); }