private void OnLoad(object sender, EventArgs e) { MakeCurrent(); MouseUp += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } }; // workaround for correct context switching (mouseclicks might change the gui directly) KeyDown += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } }; KeyPress += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } }; glGui = new GLGui(this); var verticalSplitter = glGui.Add(new GLSplitLayout(glGui) { Size = ClientSize, SplitterPosition = 0.85f, Orientation = GLSplitterOrientation.Vertical, Anchor = GLAnchorStyles.All }); TreeContainer = verticalSplitter.Add(new PBTTreeContainer(glGui)); var sidebarFlow = verticalSplitter.Add(new GLFlowLayout(glGui) { FlowDirection = GLFlowDirection.TopDown }); var sidebarSkin = sidebarFlow.Skin; sidebarSkin.BackgroundColor = glGui.Skin.FormActive.BackgroundColor; sidebarFlow.Skin = sidebarSkin; reload = sidebarFlow.Add(new GLButton(glGui) { Text = "Reload", Enabled = false }); reload.Click += (s, ev) => ShowPBT(currentPBTName); save = sidebarFlow.Add(new GLButton(glGui) { Text = "Save", Enabled = false }); save.Click += (s, ev) => SavePBT(); create = sidebarFlow.Add(new GLButton(glGui) { Text = "New" }); create.Click += (s, ev) => CreatePBT(); var fileListTitle = sidebarFlow.Add(new GLLabel(glGui) { Text = "Load:", AutoSize = true }); var horizontalSplitter = sidebarFlow.Add(new GLSplitLayout(glGui) { Orientation = GLSplitterOrientation.Horizontal, SplitterPosition = 0.8f, Size = new Size(sidebarFlow.InnerWidth, sidebarFlow.InnerHeight - fileListTitle.Outer.Bottom), Anchor = GLAnchorStyles.All }); var fileListScrollable = horizontalSplitter.Add(new GLScrollableControl(glGui)); fileList = fileListScrollable.Add(new GLFlowLayout(glGui) { FlowDirection = GLFlowDirection.TopDown, AutoSize = true }); UpdatePBTFileList(); Overview = horizontalSplitter.Add(new PBTOverviewControl(glGui, TreeContainer)); Resize += (s, ev) => { MakeCurrent(); GL.Viewport(ClientSize); }; Paint += OnRender; //Application.Idle += (s, ev) => Invalidate(); Timer t = new Timer(); t.Interval = 16; t.Tick += (s, ev) => Invalidate(); t.Start(); }
private void OnLoad(object sender, EventArgs e) { VSync = false; // vsync is nice, but you can't really measure performance while it's on glgui = new GLGui(this); var mainAreaControl = glgui.Add(new GLGroupLayout(glgui) { Size = new Size(ClientSize.Width, ClientSize.Height - 200), Anchor = GLAnchorStyles.All }); // change background color: var mainSkin = mainAreaControl.Skin; mainSkin.BackgroundColor = glgui.Skin.FormActive.BackgroundColor; mainSkin.BorderColor = glgui.Skin.FormActive.BorderColor; mainAreaControl.Skin = mainSkin; var consoleScrollControl = glgui.Add(new GLScrollableControl(glgui) { Outer = new Rectangle(0, ClientSize.Height - 200, ClientSize.Width, 200), Anchor = GLAnchorStyles.Left | GLAnchorStyles.Right | GLAnchorStyles.Bottom }); console = consoleScrollControl.Add(new GLLabel(glgui) { AutoSize = true, Multiline = true }); fpsLabel = mainAreaControl.Add(new GLLabel(glgui) { Location = new Point(10, 10), AutoSize = true }); // change font and background color: var skin = fpsLabel.SkinEnabled; skin.Font = new GLFont(new Font("Arial", 12.0f)); skin.BackgroundColor = glgui.Skin.TextBoxActive.BackgroundColor; fpsLabel.SkinEnabled = skin; var helloWorldForm = mainAreaControl.Add(new GLForm(glgui) { Title = "Hello World", Outer = new Rectangle(50, 100, 200, 150), AutoSize = false }); helloWorldForm.Add(new GLForm(glgui) { Title = "Hello Form", Outer = new Rectangle(100, 32, 100, 100), AutoSize = false }) .MouseMove += (s, w) => Console.WriteLine(w.Position.ToString()); var flow = helloWorldForm.Add(new GLFlowLayout(glgui) { FlowDirection = GLFlowDirection.BottomUp, Location = new Point(10, 10), Size = helloWorldForm.InnerSize, AutoSize = true }); for (int i = 0; i < 5; i++) { flow.Add(new GLButton(glgui) { Text = "Button" + i, Size = new Size(150, 0) }) .Click += (s, w) => Console.WriteLine(s + " pressed."); } flow.Add(new GLButton(glgui) { Text = "Hide Cursor", Size = new Size(150, 0) }) .Click += (s, w) => glgui.Cursor = GLCursor.None; var loremIpsumForm = mainAreaControl.Add(new GLForm(glgui) { Title = "Lorem Ipsum", Location = new Point(600, 100), Size = new Size(300, 200) }); loremIpsumForm.Add(new GLTextBox(glgui) { Text = "Lorem ipsum dolor sit amet,\nconsetetur sadipscing elitr,\nsed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,\nsed diam voluptua.\n\nAt vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", Multiline = true, WordWrap = true, Outer = new Rectangle(4, 4, loremIpsumForm.Inner.Width - 8, loremIpsumForm.Inner.Height - 8), Anchor = GLAnchorStyles.All }).Changed += (s, w) => Console.WriteLine(s + " text length: " + ((GLTextBox)s).Text.Length); var fixedSizeForm = mainAreaControl.Add(new GLForm(glgui) { Title = "Fixed size Form", Location = new Point(64, 300), Size = new Size(100, 200), AutoSize = true }); var fooBarFlow = fixedSizeForm.Add(new GLFlowLayout(glgui) { FlowDirection = GLFlowDirection.TopDown, AutoSize = true }); fooBarFlow.Add(new GLCheckBox(glgui) { Text = "CheckBox A", AutoSize = true }) .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked); fooBarFlow.Add(new GLCheckBox(glgui) { Text = "CheckBox B", AutoSize = true }) .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked); fooBarFlow.Add(new GLCheckBox(glgui) { Text = "Totally different CheckBox", AutoSize = true }) .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked); fooBarFlow.Add(new GLCheckBox(glgui) { Text = "Go away!", AutoSize = true }) .Changed += (s, w) => Console.WriteLine(s + ": " + ((GLCheckBox)s).Checked); for (int i = 0; i < 3; i++) { var viewportForm = mainAreaControl.Add(new GLForm(glgui) { Title = "Cube", Location = new Point(300 + i * 16, 64 + i * 16), Size = new Size(200, 200) }); viewportForm.Add(new GLViewport(glgui) { Size = viewportForm.InnerSize, Anchor = GLAnchorStyles.All }) .RenderViewport += OnRenderViewport; } stopwatch = new Stopwatch(); Resize += (s, ev) => GL.Viewport(ClientSize); Paint += OnRender; stopwatch.Start(); Application.Idle += (s, ev) => Invalidate(); }
private void OnLoad(object sender, EventArgs e) { MakeCurrent(); MouseUp += (s, ev) => { try { MakeCurrent(); } catch (GraphicsContextException) { } }; // workaround for correct context switching (mouseclicks might change the gui directly) glGui = new GLGui(this); if (monospaceFont == null) { monospaceFont = new GLFont(new Font("Lucida Console", 6.5f)); monospaceFont.Options.Monospacing = GLFontMonospacing.Yes; } var verticalSplitter = glGui.Add(new GLSplitLayout(glGui) { Size = ClientSize, SplitterPosition = 0.7f, Orientation = GLSplitterOrientation.Vertical, Anchor = GLAnchorStyles.All }); TreeContainer = verticalSplitter.Add(new PBTTreeContainer(glGui)); TreeContainer.Add(new PBTTaskTreeControl <DataType>(glGui, Root.Root, true)); var sidebar = verticalSplitter.Add(new GLFlowLayout(glGui) { FlowDirection = GLFlowDirection.TopDown }); var sidebarSkin = sidebar.Skin; sidebarSkin.BackgroundColor = System.Drawing.Color.FromArgb(48, 48, 48); sidebar.Skin = sidebarSkin; var extended = sidebar.Add(new GLCheckBox(glGui) { Text = "extended view", Checked = true, AutoSize = true }); extended.Changed += (s, ev) => { MakeCurrent(); TreeContainer.Clear(); TreeContainer.Add(new PBTTaskTreeControl <DataType>(glGui, Root.Root, extended.Checked)); }; var filter = sidebar.Add(new GLButton(glGui) { Text = "Impulse Filter", AutoSize = true }); var horizontalSplitter = sidebar.Add(new GLSplitLayout(glGui) { Size = new Size(sidebar.InnerWidth, sidebar.InnerHeight - extended.Outer.Bottom), SplitterPosition = 0.5f, Orientation = GLSplitterOrientation.Horizontal, Anchor = GLAnchorStyles.All }); dataControl = horizontalSplitter.Add(new GLDataControl(glGui)); dataControl.SetData(Root.Context.Data); var horizontalSplitter2 = horizontalSplitter.Add(new GLSplitLayout(glGui) { Orientation = GLSplitterOrientation.Horizontal, SplitterPosition = 0.5f }); var impulseLogScroll = horizontalSplitter2.Add(new GLScrollableControl(glGui)); impulseLog = impulseLogScroll.Add(new GLLabel(glGui) { Multiline = true, AutoSize = true }); var impulseLogSkin = impulseLog.SkinEnabled; impulseLogSkin.Font = monospaceFont; impulseLog.SkinEnabled = impulseLogSkin; impulseLogger = new PBTImpulseLogger <DataType, ImpulseType>(new LabelWriter(impulseLog), Root.Context); HandleDestroyed += (s, ev) => impulseLogger.Dispose(); filter.Click += (s, ev) => glGui.Add(new PBTImpulseFilterForm <DataType, ImpulseType>(glGui, impulseLogger)); Overview = horizontalSplitter2.Add(new PBTOverviewControl <DataType>(glGui, TreeContainer)); Resize += (s, ev) => { MakeCurrent(); GL.Viewport(ClientSize); }; Paint += OnRender; //Application.Idle += (s, ev) => Invalidate(); Timer t = new Timer(); t.Interval = 16; t.Tick += (s, ev) => Invalidate(); t.Start(); }