public void Draw() { if (bold) { // Sprite.DrawBoldText(pos.X + left, pos.Y, textData, textFont); } else { GLFont.DrawText(pos.X + left, pos.Y, textData, fontId, fontColor); } }
private void GLView_Load(object sender, EventArgs e) { glControl.InitializeContexts(); if (DesignMode) return; MakeCurrent(); Ilut.ilutInit(); font = GLFont.LoadFont("Times", 10.0f, System.Drawing.FontStyle.Regular); }
public Button(Rectangle rectangle, string text, OnClick onClick) { base.zOrder = 0; this.text = text; this.areaRectangle = rectangle; base.onClick = onClick; texNormalS = "normal.jpg"; texPressedS = "pressed.jpg"; textHoverS = "hover.jpg"; texCurrent = texNormal; textWidth = GLFont.GlSize("verdana", 18, text); textPosition = new Vector2(areaRectangle.X + (areaRectangle.Width - textWidth) / 2, areaRectangle.Y + ((areaRectangle.Height - 15) / 2) + 14); this.fontId = GLFont.GetFontId("verdana", 18); }
public PBTTaskControl(GLGui gui, PBT.Task <DataType> task, bool extended) : base(gui) { Task = task; Render += OnRender; AutoSize = true; FlowDirection = GLFlowDirection.TopDown; skin = Skin; skin.Border = new GLPadding(1); skin.BorderColor = Color.FromArgb(32, 32, 32); skin.BackgroundColor = Color.FromArgb(48, 48, 48); Skin = skin; if (monospaceFont == null) { monospaceFont = new GLFont(new Font("Lucida Console", 6.5f)); monospaceFont.Options.Monospacing = GLFontMonospacing.Yes; } // title title = Add(new GLLabel(Gui) { AutoSize = true, Text = Task.GetType().Name.TrimEnd('1', '2', '`') }); var titleSkin = title.SkinEnabled; titleSkin.TextAlign = GLFontAlignment.Centre; titleSkin.Color = Color.FromArgb(255, 255, 255); title.SkinEnabled = titleSkin; title.AutoSize = false; if (extended) { // content (quick and dirty) string contentString = ""; var fields = task.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic); foreach (var f in fields) { var v = f.GetValue(task); if (v == null) { continue; } var ft = f.FieldType.Name.TrimEnd('1', '2', '`') + " " + f.Name + ":\n "; if (v is string && f.Name == "impulse") { contentString += ft + v.ToString() + "\n\n"; } else if (v is Expression || v.GetType().Name.Contains("Expression")) // i'm lazy right now :/ { var codeField = v.GetType().GetField("code", BindingFlags.Instance | BindingFlags.NonPublic); if (codeField == null) { // must be ResultExpression contentString += ft + v.ToString() + "\n\n"; } else { var code = codeField.GetValue(v); if (code != null) { contentString += ft + code.ToString().Replace("\n", "\n ") + "\n\n"; } else { contentString += ft + "null\n\n"; } } } } contentString = contentString.TrimEnd('\n', '\t'); if (contentString.Length > 0) { var content = Add(new GLLabel(Gui) { AutoSize = true, Text = contentString, Multiline = true, WordWrap = false }); var contentSkin = content.SkinEnabled; contentSkin.Font = monospaceFont; content.SkinEnabled = contentSkin; } } }
public void Draw() { Sprite.DrawSprite(areaRectangle, texCurrent); GLFont.DrawText(textPosition.X, textPosition.Y, text, fontId, fontColor); }
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(); }