public override void Dispose() { if (ColorPicker != null) { ColorPicker.Dispose(); } Loaded -= ColorPickerDemo_Loaded; }
static void Main(string[] args) { WindowCreateInfo windowCI = new WindowCreateInfo() { X = 100, Y = 100, WindowWidth = 960, WindowHeight = 540, WindowTitle = "SimpleGui Example" }; Sdl2Window window = VeldridStartup.CreateWindow(ref windowCI); _graphicsDevice = VeldridStartup.CreateGraphicsDevice(window); gui = new Gui(window, _graphicsDevice); control = new Control() { Size = new Vector2(500, 500), Position = new Vector2(5, 5), ColorType = ControlColorType.Form, IsHoverable = false, IsClickable = false }; control.Initialize(); control.SetCenterScreen(); gui.SceneGraph.Root.AddChild(control); text = new Text("Text") { Position = new Vector2(5, 5), Size = new Vector2(100, 34), }; text.Initialize(); control.AddChild(text); button = new Button("Button") { Size = new Vector2(100, 34), Position = new Vector2(5, 40), }; button.Initialize(); control.AddChild(button); button.MouseUp = () => { text.Content = "Hello"; text.Recreate(); colorPicker = new ColorPicker() { }; colorPicker.Initialize(); colorPicker.SetCenterScreen(); gui.SceneGraph.Root.AddChild(colorPicker); colorPicker.Closed = () => { gui.SceneGraph.Root.RemoveChild(colorPicker); colorPicker.Dispose(); }; }; textBox = new TextBox() { Size = new Vector2(160, 34), Position = new Vector2(5, 80), Text = "TextBox" }; textBox.Initialize(); control.AddChild(textBox); checkbox = new Checkbox() { Size = new Vector2(120, 24), Position = new Vector2(5, 120), Text = "Checkbox" }; checkbox.Initialize(); control.AddChild(checkbox); image = new Image("gui/Test.png") { Size = new Vector2(150, 150), Position = new Vector2(5, 160), }; image.Initialize(); control.AddChild(image); listBox = new ListBox() { Size = new Vector2(120, 120), Position = new Vector2(180, 5), }; listBox.Initialize(); listBox.AddItem("ListBoxItem 1"); listBox.AddItem("ListBoxItem 2"); listBox.AddItem("ListBoxItem 3"); control.AddChild(listBox); CreateResources(); while (window.Exists) { var snap = window.PumpEvents(); if (window.Exists) { gui.Update(snap); Draw(); Thread.Sleep(1); } } DisposeResources(); }