public PBTDescriptionForm(GLGui gui, GLLabel descriptionLabel, Data.Task task) : base(gui) { this.task = task; this.descriptionLabel = descriptionLabel; Title = task.TaskType.Name + " Description"; SizeMin = Size = new Size(200, 100); var descriptionBackup = task.Description; var text = Add(new GLTextBox(gui) { Text = task.Description ?? "", Location = new Point(4, 4), AutoSize = false, Multiline = true, WordWrap = true, Size = new Size(InnerWidth - 8, InnerHeight - 27), Anchor = GLAnchorStyles.All }); text.Changed += (s, e) => descriptionLabel.Text = task.Description = text.Text; var ok = Add(new GLButton(gui) { Text = "OK", Location = new Point(4, InnerHeight - 18), Anchor = GLAnchorStyles.Bottom | GLAnchorStyles.Left }); ok.Click += (s, e) => { if (text.Text == "") { task.Description = null; } Parent.Remove(this); }; var abort = Add(new GLButton(gui) { Text = "Abort", Location = new Point(InnerWidth - 79, InnerHeight - 19), Anchor = GLAnchorStyles.Bottom | GLAnchorStyles.Right }); abort.Click += (s, e) => { descriptionLabel.Text = (task.Description = descriptionBackup) ?? ""; Parent.Remove(this); }; }
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 Start(GLWinFormControl glwfc) { this.glwfc = glwfc; matrixcalc = new GLMatrixCalc(); matrixcalc.PerspectiveNearZDistance = 1f; matrixcalc.PerspectiveFarZDistance = worldsize * 2; matrixcalc.InPerspectiveMode = true; matrixcalc.ResizeViewPort(this, glwfc.Size); items.Add(new GLMatrixCalcUniformBlock(), "MCUB"); // create a matrix uniform block displaycontrol = new GLControlDisplay(items, glwfc, matrixcalc); // hook form to the window - its the master, it takes its size from mc.ScreenCoordMax displaycontrol.Focusable = true; // we want to be able to focus and receive key presses. displaycontrol.Name = "displaycontrol"; displaycontrol.Font = new Font("Arial", 12); gl3dcontroller = new Controller3Dd(); gl3dcontroller.PaintObjects = ControllerDraw; gl3dcontroller.ZoomDistance = 20e6 * 1000 * mscaling; // zoom 1 is X km gl3dcontroller.PosCamera.ZoomMin = 0.001f; gl3dcontroller.PosCamera.ZoomMax = 300f; gl3dcontroller.PosCamera.ZoomScaling = 1.08f; gl3dcontroller.Start(matrixcalc, displaycontrol, new Vector3d(0, 0, 0), new Vector3d(135f, 0, 0f), 0.025F, registermouseui: false, registerkeyui: true); gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) => { double eyedistr = Math.Pow(eyedist, 1.0); float v = (float)Math.Max(eyedistr / 1200, 0); //System.Diagnostics.Debug.WriteLine("Speed " + eyedistr + " "+ v); return((float)ms * v); }; for (int i = 1; i <= 10; i++) { int v = i * i; double f = (gl3dcontroller.PosCamera.ZoomMax - gl3dcontroller.PosCamera.ZoomMin) * v / 100.0 + gl3dcontroller.PosCamera.ZoomMin; System.Diagnostics.Debug.WriteLine($"{i} {v} {f}"); } displaycontrol.Paint += (o, ts) => // subscribing after Controller start means we paint over the scene { // MCUB set up by Controller3DDraw which did the work first // System.Diagnostics.Debug.WriteLine("Controls Draw"); displaycontrol.Render(glwfc.RenderState, ts); }; displaycontrol.MouseClick += MouseClickOnMap; // grab mouse UI displaycontrol.MouseUp += MouseUpOnMap; displaycontrol.MouseDown += MouseDownOnMap; displaycontrol.MouseMove += MouseMoveOnMap; displaycontrol.MouseWheel += MouseWheelOnMap; double startspeed = 60 * 60 * 6; // in sec GLImage minus = new GLImage("timeplus1y", new Rectangle(0, 0, 32, 32), Properties.Resources.GoBackward); minus.MouseClick += (e1, m1) => { currentjd -= 365; }; displaycontrol.Add(minus); GLImage back = new GLImage("timeback", new Rectangle(40, 0, 32, 32), Properties.Resources.Backwards); back.MouseClick += (e1, m1) => { if (jdscaling > 0) { jdscaling /= 2; } else if (jdscaling < 0) { jdscaling *= 2; } else { jdscaling = -startspeed; } }; displaycontrol.Add(back); GLImage pause = new GLImage("timepause", new Rectangle(80, 0, 32, 32), Properties.Resources.Pause); pause.MouseClick += (e1, m1) => { jdscaling = 0; }; displaycontrol.Add(pause); GLImage fwd = new GLImage("timefwd", new Rectangle(120, 0, 32, 32), Properties.Resources.Forward); fwd.MouseClick += (e1, m1) => { if (jdscaling < 0) { jdscaling /= 2; } else if (jdscaling > 0) { jdscaling *= 2; } else { jdscaling = startspeed; } }; displaycontrol.Add(fwd); GLImage plus = new GLImage("timeplus1y", new Rectangle(160, 0, 32, 32), Properties.Resources.GoForward); plus.MouseClick += (e1, m1) => { currentjd += 365; }; displaycontrol.Add(plus); GLImage sysleft = new GLImage("sysleft", new Rectangle(200, 0, 32, 32), Properties.Resources.GoBackward); sysleft.MouseClick += (e1, m1) => { DisplayNode(-1); }; displaycontrol.Add(sysleft); mastersystem = new GLLabel("sysname", new Rectangle(230, 6, 70, 20), "All", Color.DarkOrange); mastersystem.TextAlign = ContentAlignment.MiddleCenter; displaycontrol.Add(mastersystem); GLImage sysright = new GLImage("sysright", new Rectangle(300, 0, 32, 32), Properties.Resources.GoForward); sysright.MouseClick += (e1, m1) => { DisplayNode(1); }; displaycontrol.Add(sysright); timedisplay = new GLLabel("state", new Rectangle(340, 6, 800, 20), "Label", Color.DarkOrange); displaycontrol.Add(timedisplay); datalabel = new GLLabel("datalabel", new Rectangle(0, 40, 400, 100), "", Color.DarkOrange); datalabel.TextAlign = ContentAlignment.TopLeft; displaycontrol.Add(datalabel); status = new GLLabel("Status", new Rectangle(0, 0, 2000, 24), "x"); status.Dock = DockingType.BottomLeft; status.ForeColor = Color.Orange; status.BackColor = Color.FromArgb(50, 50, 50, 50); displaycontrol.Add(status); rightclickmenubody = new GLContextMenu("RightClickMenuBody", new GLMenuItem("RCMInfo", "Information") { MouseClick = (s, e) => { } }, new GLMenuItem("RCMZoomIn", "Track") { MouseClick = (s, e) => { track = (int)rightclickmenubody.Tag; } }, new GLMenuItem("RCMZoomIn", "Track Central Body") { MouseClick = (s, e) => { int body = (int)rightclickmenubody.Tag; if (bodyinfo[body].parentindex >= 0) { track = bodyinfo[body].parentindex; } } }, new GLMenuItem("RCMZoomIn", "Zoom In") { }, new GLMenuItem("RCMUntrack", "Untrack") { MouseClick = (s1, e1) => { track = -1; } } ); rightclickmenubody.Opening += (ms, tag) => { ms["RCMUntrack"].Enabled = track != -1; }; rightclickmenuscreen = new GLContextMenu("RightClickMenuBody", new GLMenuItem("RCMSysDisplay", "System Display") { MouseClick = (s, e) => { } }, new GLMenuItem("RCMUntrack", "Untrack") { MouseClick = (s1, e1) => { track = -1; } } ); rightclickmenuscreen.Opening += (ms, tag) => { ms["RCMUntrack"].Enabled = track != -1; }; if (true) { var shader = new GLColorShaderWorld(); items.Add(shader); GLRenderState lines = GLRenderState.Lines(1); lines.DepthTest = false; int gridsize = (int)(worldsize * mscaling); int gridoffset = (int)(gridlines * mscaling); int nolines = gridsize / gridoffset * 2 + 1; Color gridcolour = Color.FromArgb(80, 80, 80, 80); rObjects.Add(shader, GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines, GLShapeObjectFactory.CreateLines(new Vector3(-gridsize, -0, -gridsize), new Vector3(-gridsize, -0, gridsize), new Vector3(gridoffset, 0, 0), nolines), new Color4[] { gridcolour }) ); rObjects.Add(shader, GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines, GLShapeObjectFactory.CreateLines(new Vector3(-gridsize, -0, -gridsize), new Vector3(gridsize, -0, -gridsize), new Vector3(0, 0, gridoffset), nolines), new Color4[] { gridcolour })); Size bmpsize = new Size(128, 30); var maps = new GLBitmaps("bitmap1", rObjects, bmpsize, 3, OpenTK.Graphics.OpenGL4.SizedInternalFormat.Rgba8, false, false); using (StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap) { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }) { float hsize = 40e6f * 1000 * mscaling; // million km -> m -> scaling float vsize = hsize * bmpsize.Height / bmpsize.Width; Font f = new Font("MS sans serif", 12f); long pos = -nolines / 2 * (gridlines / 1000); for (int i = -nolines / 2; i < nolines / 2; i++) { if (i != 0) { double v = Math.Abs(pos * 1000); long p = Math.Abs(pos); maps.Add(i, (p).ToString("N0"), f, Color.White, Color.Transparent, new Vector3(i * gridoffset + hsize / 2, 0, vsize / 2), new Vector3(hsize, 0, 0), new Vector3(0, 0, 0), fmt); maps.Add(i, (v / oneAU_m).ToString("N1") + "AU", f, Color.White, Color.Transparent, new Vector3(i * gridoffset + hsize / 2, 0, -vsize / 2), new Vector3(hsize, 0, 0), new Vector3(0, 0, 0), fmt); maps.Add(i, (p).ToString("N0"), f, Color.White, Color.Transparent, new Vector3(hsize / 2, 0, i * gridoffset + vsize / 2), new Vector3(hsize, 0, 0), new Vector3(0, 0, 0), fmt); maps.Add(i, (v / oneAU_m).ToString("N1") + "AU", f, Color.White, Color.Transparent, new Vector3(hsize / 2, 0, i * gridoffset - vsize / 2), new Vector3(hsize, 0, 0), new Vector3(0, 0, 0), fmt); } pos += 50000000; } } } var orbitlinesvertshader = new GLPLVertexShaderModelWorldUniform(new Color[] { Color.FromArgb(128, 128, 0, 0), Color.FromArgb(128, 128, 128, 0) }); orbitlineshader = new GLShaderPipeline(orbitlinesvertshader, new GLPLFragmentShaderVSColor()); bodyplaneshader = new GLShaderPipeline(orbitlinesvertshader, new GLPLFragmentShaderVSColor()); // model pos in, with uniform world pos, vectors out, with vs_colour selected by worldpos.w // set up ARB IDs for all images we are going to use.. var tbs = items.NewBindlessTextureHandleBlock(arbblock); var texs = items.NewTexture2D(null, Properties.Resources.golden, SizedInternalFormat.Rgba8); var texp = items.NewTexture2D(null, Properties.Resources.moonmap1k, SizedInternalFormat.Rgba8); var texb = items.NewTexture2D(null, Properties.Resources.dotted, SizedInternalFormat.Rgba8); var texs2 = items.NewTexture2D(null, Properties.Resources.wooden, SizedInternalFormat.Rgba8); tbs.WriteHandles(new IGLTexture[] { texs, texp, texb, texs2 }); // using 0 tex coord, 4 image id and arb text binding var bodyfragshader = new GLPLFragmentShaderBindlessTexture(arbblock, discardiftransparent: true, useprimidover2: false); // takes 0:Vector4 model, 1: vec2 text, 4:matrix, out is 0:tex, 1: modelpos, 2: instance, 4 = matrix[3][3] var bodyvertshader = new GLPLVertexShaderModelMatrixTexture(1000000 * 1000 * mscaling, useeyedistance: false); bodyshader = new GLShaderPipeline(bodyvertshader, bodyfragshader); items.Add(bodyshader); // hold shape var sphereshape = GLSphereObjectFactory.CreateTexturedSphereFromTriangles(3, 1.0f); spherebuffer = items.NewBuffer(); // fill buffer with model co-ords spherebuffer.AllocateFill(sphereshape.Item1); spheretexcobuffer = items.NewBuffer(); // fill buffer with tex coords spheretexcobuffer.AllocateFill(sphereshape.Item2); bodymatrixbuffer = items.NewBuffer(); // this holds the matrix to set position and size GLStorageBlock findbufferresults = items.NewStorageBlock(findblock); var geofind = new GLPLGeoShaderFindTriangles(findbufferresults, 16); // pass thru normal vert/tcs/tes then to geoshader for results findshader = items.NewShaderPipeline(null, bodyvertshader, null, null, geofind, null, null, null); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Closed += ShaderTest_Closed; matrixcalc = new GLMatrixCalc(); matrixcalc.PerspectiveNearZDistance = 1f; matrixcalc.PerspectiveFarZDistance = worldsize * 2; matrixcalc.InPerspectiveMode = true; matrixcalc.ResizeViewPort(this, glwfc.Size); displaycontrol = new GLControlDisplay(items, glwfc, matrixcalc); // hook form to the window - its the master, it takes its size fro mc.ScreenCoordMax displaycontrol.Focusable = true; // we want to be able to focus and receive key presses. displaycontrol.Name = "displaycontrol"; displaycontrol.Paint += (o, ts) => // subscribing after start means we paint over the scene, letting transparency work { // MCUB set up by Controller3DDraw which did the work first displaycontrol.Render(glwfc.RenderState, ts); }; double startspeed = 60 * 60 * 6; // in sec GLImage minus = new GLImage("plus", new Rectangle(0, 0, 32, 32), Properties.Resources.GoBackward); minus.MouseClick += (e1, m1) => { currentjd -= 365; }; displaycontrol.Add(minus); GLImage back = new GLImage("back", new Rectangle(40, 0, 32, 32), Properties.Resources.Backwards); back.MouseClick += (e1, m1) => { if (jdscaling > 0) { jdscaling /= 2; } else if (jdscaling < 0) { jdscaling *= 2; } else { jdscaling = -startspeed; } }; displaycontrol.Add(back); GLImage pause = new GLImage("back", new Rectangle(80, 0, 32, 32), Properties.Resources.Pause); pause.MouseClick += (e1, m1) => { jdscaling = 0; }; displaycontrol.Add(pause); GLImage fwd = new GLImage("fwd", new Rectangle(120, 0, 32, 32), Properties.Resources.Forward); fwd.MouseClick += (e1, m1) => { if (jdscaling < 0) { jdscaling /= 2; } else if (jdscaling > 0) { jdscaling *= 2; } else { jdscaling = startspeed; } }; displaycontrol.Add(fwd); GLImage plus = new GLImage("plus", new Rectangle(160, 0, 32, 32), Properties.Resources.GoForward); plus.MouseClick += (e1, m1) => { currentjd += 365; }; displaycontrol.Add(plus); status = new GLLabel("state", new Rectangle(200, 0, 400, 20), "Label", Color.DarkOrange); displaycontrol.Add(status); datalabel = new GLLabel("datalabel", new Rectangle(0, 40, 400, 100), "", Color.DarkOrange); datalabel.TextAlign = ContentAlignment.TopLeft; displaycontrol.Add(datalabel); gl3dcontroller = new Controller3D(); gl3dcontroller.PaintObjects = ControllerDraw; gl3dcontroller.ZoomDistance = 3000F; gl3dcontroller.Start(matrixcalc, displaycontrol, new Vector3(0, 0, 0), new Vector3(135f, 0, 0f), 0.025F); gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) => { return((float)ms * 100.0f); }; items.Add(new GLColorShaderWorld(), "COSW"); items.Add(new GLTexturedShaderObjectCommonTranslation(), "TEXOCT"); items.Add(new GLTexture2D(Properties.Resources.golden, SizedInternalFormat.Rgba8), "golden"); items.Add(new GLTexture2D(Properties.Resources.moonmap1k, SizedInternalFormat.Rgba8), "moon"); #region coloured lines int gridsize = (int)(worldsize * mscaling); int markers = gridsize / 20; { GLRenderState lines = GLRenderState.Lines(1); Color gridcolour = Color.FromArgb(255, 60, 60, 60); rObjects.Add(items.Shader("COSW"), GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines, GLShapeObjectFactory.CreateLines(new Vector3(-gridsize, -0, -gridsize), new Vector3(-gridsize, -0, gridsize), new Vector3(markers, 0, 0), gridsize / markers * 2 + 1), new Color4[] { gridcolour }) ); rObjects.Add(items.Shader("COSW"), GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, lines, GLShapeObjectFactory.CreateLines(new Vector3(-gridsize, -0, -gridsize), new Vector3(gridsize, -0, -gridsize), new Vector3(0, 0, markers), gridsize / markers * 2 + 1), new Color4[] { gridcolour })); } rObjects.Add(new GLOperationClearDepthBuffer()); { GLRenderState rt = GLRenderState.Tri(); float sunscaled = sunradiusm * mscaling * sunscaleup; rObjects.Add(items.Shader("TEXOCT"), "sun", GLRenderableItem.CreateVector4Vector2(items, PrimitiveType.Triangles, rt, GLSphereObjectFactory.CreateTexturedSphereFromTriangles(3, sunscaled), new GLRenderDataTranslationRotationTexture(items.Tex("golden"), new Vector3(0, 0, 0)) )); } #endregion { // debug check DateTime t = new DateTime(2000, 1, 1, 12, 0, 0); double jd = t.ToJulianDate(); DateTime t2 = jd.JulianToDateTime(); System.Diagnostics.Debug.WriteLine($"Date time {t} JD {jd} back to {t2}"); } items.Add(new GLMatrixCalcUniformBlock(), "MCUB"); // create a matrix uniform block currentjd = KeplerOrbitElements.J2000; jdscaling = 0; bodies = new KeplerOrbitElements[4]; bodypositions = new GLRenderDataTranslationRotationTexture[4]; // earth bodies[0] = new KeplerOrbitElements(true, semimajoraxiskm: 0.38709893 * AU, // https://nssdc.gsfc.nasa.gov/planetary/factsheet/mercuryfact.html eccentricity: 0.20563069, inclination: 7.00487, longitudeofascendingnode: 48.33167, longitudeofperihelion: 77.45645, meanlongitude: 252.25084, currentjd); bodies[1] = new KeplerOrbitElements(true, semimajoraxiskm: 0.72333199 * AU, // https://nssdc.gsfc.nasa.gov/planetary/factsheet/venusfact.html eccentricity: 0.00677323, inclination: 3.39471, longitudeofascendingnode: 76.68069, longitudeofperihelion: 131.53298, meanlongitude: 181.97973, currentjd); bodies[2] = new KeplerOrbitElements(true, semimajoraxiskm: 1.49596E+08, // https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html eccentricity: 0.0167086, inclination: 0.00005, longitudeofascendingnode: -11.26064, longitudeofperihelion: 102.94719, meanlongitude: 100.46435, currentjd); bodies[3] = new KeplerOrbitElements(true, semimajoraxiskm: 1.52366231 * AU, // https://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html eccentricity: 0.09341233, inclination: 1.85061, longitudeofascendingnode: 49.57854, longitudeofperihelion: 336.04084, meanlongitude: 355.45332, currentjd); float planetsize = earthradiusm * mscaling * planetscaleup; for (int i = 0; i < bodies.Length; i++) { bodies[i].CentralMass = Msol; System.Diagnostics.Debug.WriteLine($"{i} {bodies[i].OrbitalPeriodS/60/60/24} {bodies[i].CalculateMass(bodies[i].OrbitalPeriodS)}"); bodypositions[i] = new GLRenderDataTranslationRotationTexture(items.Tex("moon"), new Vector3(0, 0, 0)); GLRenderState rt = GLRenderState.Tri(); rObjects.Add(items.Shader("TEXOCT"), "Body" + i, GLRenderableItem.CreateVector4Vector2(items, PrimitiveType.Triangles, rt, GLSphereObjectFactory.CreateTexturedSphereFromTriangles(3, planetsize), bodypositions[i])); Vector4[] orbit = bodies[i].Orbit(currentjd, 1, mscaling); GLRenderState lines = GLRenderState.Lines(1); rObjects.Add(items.Shader("COSW"), GLRenderableItem.CreateVector4Color4(items, PrimitiveType.LineStrip, lines, orbit, new Color4[] { Color.FromArgb(255, 128, 0, 0) })); } systemtimer.Interval = 25; systemtimer.Tick += new EventHandler(SystemTick); systemtimer.Start(); }
public MapMenu(Map g) { map = g; GLBaseControl.Themer = Theme; // names of MS* are on screen items hidden during main menu presentation GLImage menuimage = new GLImage("MSMainMenu", new Rectangle(10, 10, iconsize, iconsize), Properties.Resources.hamburgermenu); menuimage.ToolTipText = "Open configuration menu"; map.displaycontrol.Add(menuimage); menuimage.MouseClick = (o, e1) => { ShowMenu(); }; GLImage tpback = new GLImage("MSTPBack", new Rectangle(50, 10, iconsize, iconsize), Properties.Resources.GoBackward); tpback.ToolTipText = "Go back one system"; map.displaycontrol.Add(tpback); tpback.MouseClick = (o, e1) => { g.GoToTravelSystem(-1); }; GLImage tphome = new GLImage("MSTPHome", new Rectangle(90, 10, iconsize, iconsize), Properties.Resources.GoToHomeSystem); tphome.ToolTipText = "Go to current home system"; map.displaycontrol.Add(tphome); tphome.MouseClick = (o, e1) => { g.GoToTravelSystem(0); }; GLImage tpforward = new GLImage("MSTPForward", new Rectangle(130, 10, iconsize, iconsize), Properties.Resources.GoForward); tpforward.ToolTipText = "Go forward one system"; map.displaycontrol.Add(tpforward); tpforward.MouseClick = (o, e1) => { g.GoToTravelSystem(1); }; GLTextBoxAutoComplete tptextbox = new GLTextBoxAutoComplete(EntryTextName, new Rectangle(170, 10, 300, iconsize), ""); tptextbox.TextAlign = ContentAlignment.MiddleLeft; tptextbox.BackColor = Color.FromArgb(96, 50, 50, 50); tptextbox.BorderColor = Color.Gray; tptextbox.BorderWidth = 1; map.displaycontrol.Add(tptextbox); GLToolTip maintooltip = new GLToolTip("MTT", Color.FromArgb(180, 50, 50, 50)); maintooltip.ForeColor = Color.Orange; map.displaycontrol.Add(maintooltip); status = new GLLabel("Status", new Rectangle(10, 500, 600, 24), "x"); status.Dock = DockingType.BottomLeft; status.ForeColor = Color.Orange; status.BackColor = Color.FromArgb(50, 50, 50, 50); map.displaycontrol.Add(status); // detect mouse press with menu open and close it map.displaycontrol.GlobalMouseDown += (ctrl, e) => { // if map open, and no ctrl hit or ctrl is not a child of galmenu if (map.displaycontrol["Galmenu"] != null && (ctrl == null || !map.displaycontrol["Galmenu"].IsThisOrChildOf(ctrl))) { ((GLForm)map.displaycontrol["Galmenu"]).Close(); } }; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Closed += ShaderTest_Closed; items.Add(new GLMatrixCalcUniformBlock(), "MCUB"); // create a matrix uniform block int front = -20000, back = front + 90000, left = -45000, right = left + 90000, vsize = 2000; Vector4[] displaylines = new Vector4[] { new Vector4(left, -vsize, front, 1), new Vector4(left, +vsize, front, 1), new Vector4(left, +vsize, front, 1), new Vector4(right, +vsize, front, 1), new Vector4(right, +vsize, front, 1), new Vector4(right, -vsize, front, 1), new Vector4(right, -vsize, front, 1), new Vector4(left, -vsize, front, 1), new Vector4(left, -vsize, back, 1), new Vector4(left, +vsize, back, 1), new Vector4(left, +vsize, back, 1), new Vector4(right, +vsize, back, 1), new Vector4(right, +vsize, back, 1), new Vector4(right, -vsize, back, 1), new Vector4(right, -vsize, back, 1), new Vector4(left, -vsize, back, 1), new Vector4(left, -vsize, front, 1), new Vector4(left, -vsize, back, 1), new Vector4(left, +vsize, front, 1), new Vector4(left, +vsize, back, 1), new Vector4(right, -vsize, front, 1), new Vector4(right, -vsize, back, 1), new Vector4(right, +vsize, front, 1), new Vector4(right, +vsize, back, 1), }; GLRenderState rl = GLRenderState.Lines(1); { items.Add(new GLFixedShader(System.Drawing.Color.Yellow), "LINEYELLOW"); rObjects.Add(items.Shader("LINEYELLOW"), GLRenderableItem.CreateVector4(items, PrimitiveType.Lines, rl, displaylines)); } float h = 0; if (h != -1) { items.Add(new GLColorShaderWorld(), "COS-1L"); int dist = 1000; Color cr = Color.FromArgb(100, Color.White); rObjects.Add(items.Shader("COS-1L"), // horizontal GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl, GLShapeObjectFactory.CreateLines(new Vector3(left, h, front), new Vector3(left, h, back), new Vector3(dist, 0, 0), (back - front) / dist + 1), new Color4[] { cr }) ); rObjects.Add(items.Shader("COS-1L"), GLRenderableItem.CreateVector4Color4(items, PrimitiveType.Lines, rl, GLShapeObjectFactory.CreateLines(new Vector3(left, h, front), new Vector3(right, h, front), new Vector3(0, 0, dist), (right - left) / dist + 1), new Color4[] { cr }) ); } GLMatrixCalc mc = new GLMatrixCalc(); mc.PerspectiveNearZDistance = 1f; mc.PerspectiveFarZDistance = 500000f; mc.ResizeViewPort(this, glwfc.Size); // must establish size before starting displaycontrol = new GLControlDisplay(items, glwfc, mc); // hook form to the window - its the master, it takes its size fro mc.ScreenCoordMax displaycontrol.Focusable = true; // we want to be able to focus and receive key presses. displaycontrol.Name = "displaycontrol"; displaycontrol.Font = new Font("Times", 8); GLForm pform; if (true) { pform = new GLForm("Form1", "GL Form demonstration", new Rectangle(0, 0, 1000, 800)); //pform.BackColor = Color.FromArgb(200, Color.Red); //pform.Opacity = 0.7f; // pform.BackColorGradientDir = 90; // pform.BackColorGradientAlt = Color.FromArgb(200, Color.Yellow); //pform.ScaleWindow = new SizeF(0.75f, 0.75f); //pform.AlternatePos = new RectangleF(100, 100, 500, 400); //pform.AlternatePos = new RectangleF(100, 100, 1200, 1000); // pform.ScaleWindow = new SizeF(0.0f, 0.0f); // pform.Animators.Add(new AnimateScale(100, 1000, true, new SizeF(1, 1),removeafterend:true)); // pform.Animators.Add(new AnimateTranslate(glwfc.ElapsedTimems + 100, glwfc.ElapsedTimems + 1000, false, new Point(100, 100), removeafterend: true)); // pform.Animators.Add(new AnimateOpacity(glwfc.ElapsedTimems + 100, glwfc.ElapsedTimems + 2000, false, 1.0f,0.0f, removeafterend: true)); int taborder = 0; if (true) { GLLabel lab1 = new GLLabel("Lab1", new Rectangle(400, 0, 0, 0), "From Check"); pform.Add(lab1); GLButton b1 = new GLButton("B1", new Rectangle(5, 10, 80, 30), "Configuration Dialog"); b1.Margin = new MarginType(2); b1.AutoSize = true; b1.TabOrder = taborder++; b1.Padding = new PaddingType(5); b1.Click += (c, ev) => { ConfDialog(); }; b1.ToolTipText = "Button 1 tip\r\nLine 2 of it"; pform.Add(b1); GLButton b2 = new GLButton("B2", new Rectangle(5, 50, 0, 0), "Msg1"); b2.Image = Properties.Resources.ImportSphere; b2.TabOrder = taborder++; b2.ImageAlign = ContentAlignment.MiddleLeft; b2.TextAlign = ContentAlignment.MiddleRight; b2.Click += (c, ev) => { MsgDialog1(); }; b2.ToolTipText = "Button 2 tip\r\nLine 2 of it"; pform.Add(b2); GLButton b3 = new GLButton("B3", new Rectangle(100, 10, 80, 30), "Font"); b3.Margin = new MarginType(2); b3.TabOrder = taborder++; b3.Padding = new PaddingType(5); b3.ToolTipText = "Button 3 tip\r\nLine 2 of it"; b3.Click += (c, ev) => { displaycontrol.Font = new Font("Times", 12); }; pform.Add(b3); GLButton b4 = new GLButton("B4", new Rectangle(100, 50, 80, 30), "Msg2"); b4.TabOrder = taborder++; b4.Padding = new PaddingType(2); b4.ToolTipText = "Button 4 tip\r\nLine 2 of it"; b4.Click += (c, ev) => { MsgDialog2(); }; pform.Add(b4); GLButton b5 = new GLButton("B5", new Rectangle(200, 10, 80, 30), "Conf2"); b5.TabOrder = taborder++; b5.Padding = new PaddingType(2); b5.ToolTipText = "Button 5 tip\r\nLine 2 of it"; b5.Click += (c, ev) => { ConfDialog2(); }; pform.Add(b5); GLButton b6 = new GLButton("B3", new Rectangle(200, 50, 80, 30), "Disabled"); b6.TabOrder = taborder++; b6.ToolTipText = "Button 6 tip\r\nLine 2 of it"; b6.Enabled = false; pform.Add(b6); } if (true) { GLComboBox cb1 = new GLComboBox("CB", new Rectangle(0, 100, 0, 0), new List <string>() { "one", "two", "three" }); cb1.Margin = new MarginType(16, 8, 16, 8); cb1.TabOrder = taborder++; cb1.ToolTipText = "Combo Box"; pform.Add(cb1); GLComboBox cbstars = new GLComboBox("GalaxyStarsNumber", new Rectangle(100, 100, 100, 32)); cbstars.ToolTipText = "Control how many stars are shown when zoomes in"; cbstars.Items = new List <string>() { "Ultra", "High", "Medium", "Low" }; cbstars.TabOrder = taborder++; var list = new List <int>() { 1000000, 500000, 250000, 100000 }; int itemno = 1; cbstars.SelectedIndex = itemno >= 0 ? itemno : 1; // high default pform.Add(cbstars); } if (true) { GLCheckBox chk1 = new GLCheckBox("Checkbox1", new Rectangle(0, 150, 0, 0), "Normal"); chk1.Margin = new MarginType(16, 0, 0, 0); chk1.TabOrder = taborder++; pform.Add(chk1); GLCheckBox chk2 = new GLCheckBox("Checkbox2", new Rectangle(100, 150, 0, 0), "Radio"); chk2.Appearance = GLCheckBox.CheckBoxAppearance.Radio; chk2.TabOrder = taborder++; chk2.Checked = true; pform.Add(chk2); GLCheckBox chk3 = new GLCheckBox("Checkbox3", new Rectangle(200, 150, 0, 0), "Button"); chk3.Appearance = GLCheckBox.CheckBoxAppearance.Button; chk3.TabOrder = taborder++; chk3.BackColor = Color.FromArgb(200, 200, 200); pform.Add(chk3); GLCheckBox chk4 = new GLCheckBox("Checkbox4", new Rectangle(300, 150, 0, 0), ""); chk4.TabOrder = taborder++; pform.Add(chk4); GLCheckBox chk5 = new GLCheckBox("Checkbox5", new Rectangle(350, 150, 0, 0), "R1"); chk5.Appearance = GLCheckBox.CheckBoxAppearance.Radio; chk5.GroupRadioButton = true; chk5.TabOrder = taborder++; pform.Add(chk5); GLCheckBox chk6 = new GLCheckBox("Checkbox6", new Rectangle(400, 150, 0, 0), "R2"); chk6.Appearance = GLCheckBox.CheckBoxAppearance.Radio; chk6.GroupRadioButton = true; chk6.TabOrder = taborder++; pform.Add(chk6); GLCheckBox chk7 = new GLCheckBox("Checkbox7", new Rectangle(0, 175, 0, 0), "Disabled"); chk7.TabOrder = taborder++; chk7.Enabled = false; pform.Add(chk7); GLCheckBox chk8 = new GLCheckBox("Checkbox8", new Rectangle(100, 175, 0, 0), "Disabled"); chk8.Appearance = GLCheckBox.CheckBoxAppearance.Radio; chk8.TabOrder = taborder++; chk8.Enabled = false; pform.Add(chk8); GLCheckBox chk9 = new GLCheckBox("Checkbox9", new Rectangle(200, 175, 0, 0), "CDisabled"); chk9.TabOrder = taborder++; chk9.Enabled = false; chk9.Checked = true; pform.Add(chk9); GLCheckBox chk10 = new GLCheckBox("Checkbox10", new Rectangle(300, 175, 0, 0), "CDisabled"); chk10.Appearance = GLCheckBox.CheckBoxAppearance.Radio; chk10.TabOrder = taborder++; chk10.Enabled = false; chk10.Checked = true; pform.Add(chk10); } if (true) { GLDateTimePicker dtp = new GLDateTimePicker("DTP", new Rectangle(0, 210, 500, 30), DateTime.Now); dtp.Culture = System.Globalization.CultureInfo.GetCultureInfo("de-AT"); dtp.Format = GLDateTimePicker.DateTimePickerFormat.Long; //dtp.CustomFormat = "'start' dddd 'hello there' MMMM' and here 'yyyy"; dtp.Font = new Font("Ms Sans Serif", 11); dtp.ShowCheckBox = true; dtp.ShowCalendar = true; dtp.ShowUpDown = true; dtp.AutoSize = true; //dtp.Culture = CultureInfo.GetCultureInfo("es"); dtp.TabOrder = taborder++; pform.Add(dtp); } if (true) { List <string> i1 = new List <string>() { "one two three four five six seven eight", "two", "three", "four", "five", "six", "seven is very long too to check", "eight", "nine", "ten", "eleven", "twelve" }; GLListBox lb1 = new GLListBox("LB1", new Rectangle(0, 260, 260, 100), i1); lb1.Font = new Font("Microsoft Sans Serif", 12f); lb1.TabOrder = taborder++; lb1.ShowFocusBox = true; lb1.ScrollBarTheme.SliderColor = Color.AliceBlue; lb1.ScrollBarTheme.ThumbButtonColor = Color.Blue; //lb1.FitToItemsHeight = false; pform.Add(lb1); lb1.SelectedIndexChanged += (s, si) => { System.Diagnostics.Debug.WriteLine("Selected index " + si); }; } if (true) { GLUpDownControl upc1 = new GLUpDownControl("UPC1", new Rectangle(0, 600, 26, 46)); upc1.TabOrder = taborder++; pform.Add(upc1); upc1.Clicked += (s, upe) => System.Diagnostics.Debug.WriteLine("Up down control {0} {1}", s.Name, upe); } if (true) { GLCalendar cal = new GLCalendar("Cal", new Rectangle(500, 10, 300, 200)); cal.TabOrder = taborder++; //cal.Culture = CultureInfo.GetCultureInfo("es"); cal.AutoSize = true; cal.Font = new Font("Arial", 10); pform.Add(cal); } if (true) { GLNumberBoxFloat glf = new GLNumberBoxFloat("FLOAT", new Rectangle(500, 250, 100, 25), 23.4f); glf.BackColor = Color.AliceBlue; glf.TabOrder = taborder++; glf.Font = new Font("Ms Sans Serif", 12); glf.Minimum = -1000; glf.Maximum = 1000; glf.ValueChanged += (a) => { System.Diagnostics.Debug.WriteLine("GLF value changed"); }; glf.ValidityChanged += (a, b) => { System.Diagnostics.Debug.WriteLine($"GLF validity changed {b}"); }; pform.Add(glf); GLButton glfbut = new GLButton("FLOATBUT", new Rectangle(610, 250, 40, 15), "Value"); glfbut.Click += (e1, b1) => { glf.Value = 20.22f; }; pform.Add(glfbut); GLTextBoxAutoComplete gla = new GLTextBoxAutoComplete("ACTB", new Rectangle(500, 300, 100, 25)); gla.TabOrder = taborder++; gla.Font = new Font("Ms Sans Serif", 12); gla.PerformAutoCompleteInThread += (s, a, set) => { var r = new List <string>() { "one", "two", "three" }; foreach (var x in r) { if (x.StartsWith(s) || s.IsEmpty()) { set.Add(x); } } }; gla.SelectedEntry += (s) => { System.Diagnostics.Debug.WriteLine($"Autocomplete selected {s.Text}"); }; pform.Add(gla); } if (true) { GLButton b1 = new GLButton("BD1", new Rectangle(5, 10, 80, 30), "Bottom 1"); b1.TabOrder = taborder++; b1.Dock = DockingType.Bottom; displaycontrol.Add(b1); GLButton b2 = new GLButton("BD2", new Rectangle(5, 10, 80, 30), "Bottom 2"); b2.TabOrder = taborder++; b2.Dock = DockingType.Bottom; displaycontrol.Add(b2); } displaycontrol.Add(pform); } if (true) { GLForm pform2 = new GLForm("Form2", "Form 2 GL Control demonstration", new Rectangle(1100, 0, 400, 400)); pform2.BackColor = Color.FromArgb(200, Color.Red); pform2.Font = new Font("Ms sans serif", 10); pform2.BackColorGradientDir = 90; pform2.BackColorGradientAlt = Color.FromArgb(200, Color.Blue); displaycontrol.Add(pform2); GLButton b1 = new GLButton("*********** F2B1", new Rectangle(5, 10, 80, 30), "F2B1"); pform2.Add(b1); } if (true) { GLToolTip tip = new GLToolTip("ToolTip"); displaycontrol.Add(tip); } displaycontrol.GlobalMouseDown += (ctrl, ex) => { if (ctrl == null || !pform.IsThisOrChildOf(ctrl)) { // System.Diagnostics.Debug.WriteLine("Not on form"); } else { // System.Diagnostics.Debug.WriteLine("Click on form"); } }; gl3dcontroller = new Controller3D(); gl3dcontroller.ZoomDistance = 5000F; gl3dcontroller.YHoldMovement = true; gl3dcontroller.PaintObjects = Controller3dDraw; gl3dcontroller.KeyboardTravelSpeed = (ms, eyedist) => { return((float)ms * 10.0f); }; gl3dcontroller.MatrixCalc.InPerspectiveMode = true; if (displaycontrol != null) { gl3dcontroller.Start(mc, displaycontrol, new Vector3(0, 0, 10000), new Vector3(140.75f, 0, 0), 0.5F); // HOOK the 3dcontroller to the form so it gets Form events displaycontrol.Paint += (o, ts) => // subscribing after start means we paint over the scene, letting transparency work { displaycontrol.Render(glwfc.RenderState, ts); // we use the same matrix calc as done in controller 3d draw }; } else { gl3dcontroller.Start(glwfc, new Vector3(0, 0, 10000), new Vector3(140.75f, 0, 0), 0.5F); // HOOK the 3dcontroller to the form so it gets Form events } systemtimer.Start(); }
private void AddContent() { // ###above### addAbove = AddTaskAddButton(this, task => InsertAbove(task), false); // title title = Add(new GLLabel(Gui) { AutoSize = true, Text = Task.TaskType.Name }); minInnerWidth = title.Width; var titleSkin = title.SkinEnabled; titleSkin.TextAlign = GLFontAlignment.Centre; titleSkin.Color = Color.FromArgb(255, 255, 255); title.SkinEnabled = titleSkin; title.AutoSize = false; // description description = Add(new GLLabel(Gui) { Text = Task.Description ?? "", AutoSize = true, Multiline = true, WordWrap = true, SizeMin = new Size(0, 0) }); var descriptionSkin = description.SkinEnabled; descriptionSkin.Color = Color.FromArgb(255, 192, 96); description.SkinEnabled = descriptionSkin; // ###parameters### parameterTitles = new GLLabel[Task.TaskType.Parameters.Count]; parameterValues = new GLControl[Task.TaskType.Parameters.Count]; for (int i = 0; i < Task.TaskType.Parameters.Count; i++) { int localIndex = i; var parameter = Task.TaskType.Parameters[i]; parameterTitles[i] = Add(new GLLabel(Gui) { Text = parameter.ShortType + " " + parameter.Name + ":", AutoSize = true }); minInnerWidth = Math.Max(minInnerWidth, parameterTitles[i].Width); if (parameter.IsEnum) { var parameterValue = Add(new GLButton(Gui) { AutoSize = true, Text = Task.ParameterValues[i] ?? "", }); parameterValue.Click += (s, e) => { var t = Editor.TreeContainer.InnerSize; var p = Editor.TreeContainer.ScrollPosition; Editor.TreeContainer.Add(new PBTEnumForm(Gui, this, localIndex, parameterValue) { Location = new Point(p.X + t.Width / 2 - 200, p.Y + t.Height / 2 - 150) }); }; parameterValues[i] = parameterValue; } else { var parameterValue = Add(new GLTextBox(Gui) { AutoSize = true, Text = Task.ParameterValues[i] ?? "", Multiline = true, WordWrap = false, }); parameterValue.SkinActive = codeBoxActive; parameterValue.SkinDisabled = codeBoxDisabled; parameterValue.SkinEnabled = codeBoxEnabled; parameterValue.SkinHover = codeBoxHover; parameterValue.Changed += (s, e) => Task.ParameterValues[localIndex] = parameterValue.Text; parameterValues[i] = parameterValue; } } for (int i = 0; i < Task.TaskType.Parameters.Count; i++) { parameterValues[i].SizeMin = new Size(minInnerWidth, 14); } if (Task.TaskType.Name == "Reference") { var loadTask = Add(new GLButton(Gui) { Text = "Load" }); loadTask.Click += (s, e) => Editor.ShowPBT(Task.ParameterValues[0]); } // ###below### addBelowFlow = Add(new GLFlowLayout(Gui) { FlowDirection = GLFlowDirection.LeftToRight, AutoSize = true }); var addButtonsFlowSkin = addBelowFlow.Skin; addButtonsFlowSkin.Padding = new GLPadding(0); addBelowFlow.Skin = addButtonsFlowSkin; switch (Task.TaskType.Category.Name) { case "LeafTasks": break; case "Decorators": if (Task.Subtasks.Count == 0) { addBelow.Add(AddTaskAddButton(addBelowFlow, task => InsertBelow(0, task))); } break; case "ParentTasks": for (int i = 0; i <= Task.Subtasks.Count; i++) { int li = i; addBelow.Add(AddTaskAddButton(addBelowFlow, task => InsertBelow(li, task))); } break; default: MessageBox.Show("Unknown Task Category: " + Task.TaskType.Category.Name, "Error during Task loading", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
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(); }
public MapMenu(Map g, Map.Parts parts) { map = g; // names of MS* are on screen items hidden during main menu presentation int leftmargin = 4; int vpos = 4; int hpad = 8; int hpos = leftmargin; GLImage menuimage = new GLImage("MSMainMenu", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.hamburgermenu")); menuimage.ToolTipText = "Open configuration menu"; map.displaycontrol.Add(menuimage); menuimage.MouseClick = (o, e1) => { ShowMenu(parts); }; hpos += menuimage.Width + hpad; if ((parts & Map.Parts.TravelPath) != 0) { GLImage tpback = new GLImage("MSTPBack", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GoBackward")); tpback.ToolTipText = "Go back one system"; map.displaycontrol.Add(tpback); tpback.MouseClick = (o, e1) => { g.GoToTravelSystem(-1); }; hpos += iconsize + hpad; GLImage tphome = new GLImage("MSTPHome", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GoToHomeSystem")); tphome.ToolTipText = "Go to current system"; map.displaycontrol.Add(tphome); tphome.MouseClick = (o, e1) => { g.GoToCurrentSystem(); }; hpos += iconsize + hpad; GLImage tpforward = new GLImage("MSTPForward", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GoForward")); tpforward.ToolTipText = "Go forward one system"; map.displaycontrol.Add(tpforward); tpforward.MouseClick = (o, e1) => { g.GoToTravelSystem(1); }; hpos += iconsize + hpad; } if ((parts & Map.Parts.GalaxyResetPos) != 0) { GLImage tpgalview = new GLImage("MSTPGalaxy", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy")); tpgalview.ToolTipText = "View Galaxy"; map.displaycontrol.Add(tpgalview); tpgalview.MouseClick = (o, e1) => { g.ViewGalaxy(); }; hpos += iconsize + hpad; } if ((parts & Map.Parts.Bookmarks) != 0) { GLCheckBox butbkmks = new GLCheckBox("MSTPBookmarks", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowBookmarks"), null); butbkmks.ToolTipText = "Show bookmark list"; butbkmks.CheckOnClick = true; butbkmks.CheckChanged += (e1) => { g.ToggleBookmarkList(butbkmks.Checked); }; map.displaycontrol.Add(butbkmks); hpos += butbkmks.Width + hpad; } if ((parts & Map.Parts.SearchBox) != 0) { EntryTextBox = new GLTextBoxAutoComplete("MSTPEntryText", new Rectangle(hpos, vpos, 300, iconsize), ""); EntryTextBox.TextAlign = ContentAlignment.MiddleLeft; EntryTextBox.BackColor = Color.FromArgb(96, 50, 50, 50); EntryTextBox.BorderColor = Color.Gray; EntryTextBox.BorderWidth = 1; map.displaycontrol.Add(EntryTextBox); hpos += EntryTextBox.Width + hpad; } if ((parts & Map.Parts.PrepopulateEDSMLocalArea) != 0) { GLImage butpopstars = new GLImage("MSPopulate", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowMoreStars")); butpopstars.ToolTipText = "Load star box at current look location"; butpopstars.MouseClick = (o, e1) => { g.AddMoreStarsAtLookat(); }; map.displaycontrol.Add(butpopstars); hpos += butpopstars.Width + hpad; } DBStatus = new GLImage("MSDB", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.db")); DBStatus.Dock = DockingType.BottomRight; DBStatus.ToolTipText = "Reading from DB"; DBStatus.Visible = false; map.displaycontrol.Add(DBStatus); status = new GLLabel("Status", new Rectangle(leftmargin, 500, 600, 24), "x"); status.Dock = DockingType.BottomLeft; status.ForeColor = Color.Orange; status.BackColor = Color.FromArgb(50, 50, 50, 50); map.displaycontrol.Add(status); GLToolTip maintooltip = new GLToolTip("MTT", Color.FromArgb(180, 50, 50, 50)); maintooltip.ForeColor = Color.Orange; map.displaycontrol.Add(maintooltip); // detect mouse press with menu open and close it map.displaycontrol.GlobalMouseDown += (ctrl, e) => { // if map open, and no ctrl hit or ctrl is not a child of galmenu if (map.displaycontrol["Galmenu"] != null && (ctrl == null || !map.displaycontrol["Galmenu"].IsThisOrChildOf(ctrl))) { ((GLForm)map.displaycontrol["Galmenu"]).Close(); } }; }
// on menu button.. public void ShowMenu(Map.Parts parts) { //map.displaycontrol.ApplyToControlOfName("InfoBoxForm*", (c) => { ((GLForm)c).Close(); }); // close any info box forms (don't want to I think) map.displaycontrol.ApplyToControlOfName("MS*", (c) => { c.Visible = false; }); // hide the visiblity of the on screen controls int leftmargin = 4; int vpos = 10; int hpad = 8; int ypad = 10; GLForm pform = new GLForm("Galmenu", "Configure Map", new Rectangle(10, 10, 500, 600)); pform.FormClosed = (frm) => { map.displaycontrol.ApplyToControlOfName("MS*", (c) => { c.Visible = true; }); }; pform.Resizeable = pform.Moveable = false; // provide opening animation pform.ScaleWindow = new SizeF(0.0f, 0.0f); pform.Animators.Add(new GLControlAnimateScale(10, 400, true, new SizeF(1, 1))); pform.Font = new Font("Arial", 10f); // and closing animation pform.FormClosing += (f, e) => { var nb = ((GLNumberBoxLong)pform["GalaxyStarsGB"]?["LYDist"]);; if (nb != null) { map.LocalAreaSize = (int)nb.Value; } e.Handled = true; // stop close var ani = new GLControlAnimateScale(10, 400, true, new SizeF(0, 0)); // add a close animation ani.FinishAction += (a, c, t) => { pform.ForceClose(); }; // when its complete, force close pform.Animators.Add(ani); }; { // top buttons int hpos = 0; if ((parts & Map.Parts.PerspectiveChange) != 0) { GLPanel p3d2d = new GLPanel("3d2d", new Rectangle(leftmargin, vpos, 80, iconsize), Color.Transparent); GLCheckBox but3d = new GLCheckBox("3d", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.3d"), null); but3d.Checked = map.gl3dcontroller.MatrixCalc.InPerspectiveMode; but3d.ToolTipText = "3D View"; but3d.GroupRadioButton = true; but3d.MouseClick += (e1, e2) => { map.gl3dcontroller.ChangePerspectiveMode(true); }; p3d2d.Add(but3d); hpos += but3d.Width + hpad; GLCheckBox but2d = new GLCheckBox("2d", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.2d"), null); but2d.Checked = !map.gl3dcontroller.MatrixCalc.InPerspectiveMode; but2d.ToolTipText = "2D View"; but2d.GroupRadioButton = true; but2d.MouseClick += (e1, e2) => { map.gl3dcontroller.ChangePerspectiveMode(false); }; p3d2d.Add(but2d); hpos += but2d.Width + hpad; pform.Add(p3d2d); } if ((parts & Map.Parts.YHoldButton) != 0) { GLCheckBox butelite = new GLCheckBox("Elite", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.EliteMovement"), null); butelite.ToolTipText = "Select elite movement (on Y plain)"; butelite.Checked = map.gl3dcontroller.YHoldMovement; butelite.CheckChanged += (e1) => { map.gl3dcontroller.YHoldMovement = butelite.Checked; }; pform.Add(butelite); hpos += butelite.Width + hpad; } if ((parts & Map.Parts.Galaxy) != 0) { GLCheckBox butgal = new GLCheckBox("Galaxy", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null); butgal.ToolTipText = "Show galaxy image"; butgal.Checked = map.GalaxyDisplay; butgal.CheckChanged += (e1) => { map.GalaxyDisplay = butgal.Checked; }; pform.Add(butgal); hpos += butgal.Width + hpad; } if ((parts & Map.Parts.Grid) != 0) { GLCheckBox butgrid = new GLCheckBox("GridLines", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.Grid"), null); butgrid.ToolTipText = "Show grid"; butgrid.Checked = map.Grid; butgrid.CheckChanged += (e1) => { map.Grid = butgrid.Checked; }; pform.Add(butgrid); hpos += butgrid.Width + hpad; } if ((parts & Map.Parts.StarDots) != 0) { GLCheckBox butsd = new GLCheckBox("StarDots", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.StarDots"), null); butsd.ToolTipText = "Show star field"; butsd.Checked = map.StarDotsSpritesDisplay; butsd.CheckChanged += (e1) => { map.StarDotsSpritesDisplay = butsd.Checked; }; pform.Add(butsd); hpos += butsd.Width + hpad; } if ((parts & Map.Parts.NavRoute) != 0) { GLCheckBox butnr = new GLCheckBox("NavRoute", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.NavRoute"), null); butnr.ToolTipText = "Show nav route"; butnr.Checked = map.NavRouteDisplay; butnr.CheckChanged += (e1) => { map.NavRouteDisplay = butnr.Checked; }; pform.Add(butnr); hpos += butnr.Width + hpad; } if ((parts & Map.Parts.Bookmarks) != 0) { GLCheckBox butbkmks = new GLCheckBox("Bookmarks", new Rectangle(hpos, vpos, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowBookmarks"), null); butbkmks.ToolTipText = "Show bookmarks"; butbkmks.Checked = map.ShowBookmarks; butbkmks.CheckChanged += (e1) => { map.ShowBookmarks = butbkmks.Checked; }; pform.Add(butbkmks); hpos += butbkmks.Width + hpad; } vpos += iconsize + ypad; } if ((parts & Map.Parts.EDSMStars) != 0) { GLGroupBox tpgb = new GLGroupBox("GalaxyStarsGB", "Galaxy Stars", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, iconsize * 2)); tpgb.BackColor = Color.Transparent; tpgb.ForeColor = Color.Orange; pform.Add(tpgb); int hpos = leftmargin; GLCheckBox butgalstars = new GLCheckBox("GalaxyStars", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GalaxyStars"), null); butgalstars.ToolTipText = "Show stars when zoomed in"; butgalstars.Checked = (map.GalaxyStars & 1) != 0; butgalstars.CheckChanged += (e1) => { map.GalaxyStars ^= 1; }; tpgb.Add(butgalstars); hpos += butgalstars.Width + hpad; GLCheckBox butgalstarstext = new GLCheckBox("GalaxyStarsText", new Rectangle(hpos, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GalaxyStarsText"), null); butgalstarstext.ToolTipText = "Show names of stars when zoomed in"; butgalstarstext.Checked = (map.GalaxyStars & 2) != 0; butgalstarstext.CheckChanged += (e1) => { map.GalaxyStars ^= 2; }; tpgb.Add(butgalstarstext); hpos += butgalstarstext.Width + hpad; if ((parts & Map.Parts.PrepopulateEDSMLocalArea) != 0) { GLNumberBoxLong nblong = new GLNumberBoxLong("LYDist", new Rectangle(hpos, 0, 50, iconsize), map.LocalAreaSize); nblong.Minimum = 1; nblong.Maximum = 500; nblong.ToolTipText = "Set distance in ly of the box around the current star to show"; tpgb.Add(nblong); hpos += nblong.Width + hpad; GLLabel lylab = new GLLabel("LYLab", new Rectangle(hpos, 0, 30, iconsize), "Ly"); lylab.ForeColor = Color.DarkOrange; tpgb.Add(lylab); hpos += lylab.Width + hpad; } if ((parts & Map.Parts.LimitSelector) != 0) { GLComboBox cbstars = new GLComboBox("GalaxyStarsNumber", new Rectangle(hpos, 0, 150, iconsize)); cbstars.ToolTipText = "Control how many stars are shown when zoomes in"; cbstars.Items = new List <string>() { "Stars-Ultra", "Stars-High", "Stars-Medium", "Stars-Low" }; var list = new List <int>() { 750000, 500000, 250000, 100000 }; int itemno = list.IndexOf(map.GalaxyStarsMaxObjects); // may be -1 if (itemno < 0) { itemno = 2; map.GalaxyStarsMaxObjects = list[itemno]; } cbstars.SelectedIndex = itemno; // high default cbstars.SelectedIndexChanged += (e1) => { map.GalaxyStarsMaxObjects = list[cbstars.SelectedIndex]; }; tpgb.Add(cbstars); } vpos += tpgb.Height + ypad; } if ((parts & Map.Parts.TravelPath) != 0) { GLGroupBox tpgb = new GLGroupBox("TravelPathGB", "Travel Path", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, iconsize * 3)); tpgb.BackColor = Color.Transparent; tpgb.ForeColor = Color.Orange; pform.Add(tpgb); GLCheckBox buttp = new GLCheckBox("TravelPathTape", new Rectangle(leftmargin, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.TravelPath"), null); buttp.ToolTipText = "Show travel path"; buttp.Checked = map.TravelPathTapeDisplay; buttp.CheckChanged += (e1) => { map.TravelPathTapeDisplay = buttp.Checked; }; tpgb.Add(buttp); GLDateTimePicker dtps = new GLDateTimePicker("TPStart", new Rectangle(50, 0, 350, 30), System.DateTime.Now); dtps.SuspendLayout(); dtps.AutoSize = true; dtps.ShowCheckBox = dtps.ShowCalendar = true; dtps.Value = map.TravelPathStartDate; dtps.Checked = map.TravelPathStartDateEnable; dtps.ValueChanged += (e1) => { map.TravelPathStartDate = dtps.Value; map.TravelPathRefresh(); }; dtps.CheckChanged += (e1) => { map.TravelPathStartDateEnable = dtps.Checked; map.TravelPathRefresh(); }; dtps.ShowUpDown = true; dtps.ResumeLayout(); tpgb.Add(dtps); GLCheckBox buttptext = new GLCheckBox("TravelPathText", new Rectangle(leftmargin, 34, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.GalaxyStarsText"), null); buttptext.ToolTipText = "Show names of stars when zoomed in"; buttptext.Checked = map.TravelPathTextDisplay; buttptext.CheckChanged += (e1) => { map.TravelPathTextDisplay = !map.TravelPathTextDisplay; }; tpgb.Add(buttptext); GLDateTimePicker dtpe = new GLDateTimePicker("TPEnd", new Rectangle(50, 34, 350, 30), System.DateTime.Now); dtpe.SuspendLayout(); dtpe.AutoSize = true; dtpe.ShowCheckBox = dtps.ShowCalendar = true; dtpe.Value = map.TravelPathEndDate; dtpe.Checked = map.TravelPathEndDateEnable; dtpe.ValueChanged += (e1) => { map.TravelPathEndDate = dtpe.Value; map.TravelPathRefresh(); }; dtpe.CheckChanged += (e1) => { map.TravelPathEndDateEnable = dtpe.Checked; map.TravelPathRefresh(); }; dtpe.ShowUpDown = true; dtpe.ResumeLayout(); tpgb.Add(dtpe); vpos += tpgb.Height + ypad; } if ((parts & Map.Parts.GalObjects) != 0) { GLGroupBox galgb = new GLGroupBox("GalGB", "Galaxy Objects", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50)); galgb.ClientHeight = (iconsize + 4) * 2; galgb.BackColor = Color.Transparent; galgb.ForeColor = Color.Orange; pform.Add(galgb); GLFlowLayoutPanel galfp = new GLFlowLayoutPanel("GALFP", DockingType.Fill, 0); galfp.FlowPadding = new PaddingType(2, 2, 2, 2); galfp.BackColor = Color.Transparent; galgb.Add(galfp); vpos += galgb.Height + ypad; IReadOnlyDictionary <GalMapType.VisibleObjectsType, Image> icons = new BaseUtils.Icons.IconGroup <GalMapType.VisibleObjectsType>("GalMap"); for (int i = GalMapType.VisibleTypes.Length - 1; i >= 0; i--) { var gt = GalMapType.VisibleTypes[i]; bool en = map.GetGalObjectTypeEnable(gt.TypeName); GLCheckBox butg = new GLCheckBox("GMSEL" + i, new Rectangle(0, 0, iconsize, iconsize), icons[gt.VisibleType.Value], null); butg.ToolTipText = "Enable/Disable " + gt.Description; butg.Checked = en; butg.CheckChanged += (e1) => { map.SetGalObjectTypeEnable(gt.TypeName, butg.Checked); }; galfp.Add(butg); } GLCheckBox butgonoff = new GLCheckBox("GMONOFF", new Rectangle(0, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null); butgonoff.ToolTipText = "Enable/Disable Display"; butgonoff.Checked = map.GalObjectDisplay; butgonoff.CheckChanged += (e1) => { map.GalObjectDisplay = !map.GalObjectDisplay; }; galfp.Add(butgonoff); } if ((parts & Map.Parts.Regions) != 0) { // EDSM regions GLGroupBox edsmregionsgb = new GLGroupBox("EDSMR", "EDSM Regions", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50)); edsmregionsgb.ClientHeight = iconsize + 8; edsmregionsgb.BackColor = Color.Transparent; edsmregionsgb.ForeColor = Color.Orange; pform.Add(edsmregionsgb); vpos += edsmregionsgb.Height + ypad; GLCheckBox butedre = new GLCheckBox("EDSMRE", new Rectangle(leftmargin, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null); butedre.ToolTipText = "Enable EDSM Regions"; butedre.Checked = map.EDSMRegionsEnable; butedre.UserCanOnlyCheck = true; edsmregionsgb.Add(butedre); GLCheckBox buted2 = new GLCheckBox("EDSMR2", new Rectangle(50, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionOutlines"), null); buted2.Checked = map.EDSMRegionsOutlineEnable; buted2.Enabled = map.EDSMRegionsEnable; buted2.ToolTipText = "Enable Region Outlines"; buted2.CheckChanged += (e1) => { map.EDSMRegionsOutlineEnable = !map.EDSMRegionsOutlineEnable; }; edsmregionsgb.Add(buted2); GLCheckBox buted3 = new GLCheckBox("EDSMR3", new Rectangle(100, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionShading"), null); buted3.Checked = map.EDSMRegionsShadingEnable; buted3.Enabled = map.EDSMRegionsEnable; buted3.ToolTipText = "Enable Region Shading"; buted3.CheckChanged += (e1) => { map.EDSMRegionsShadingEnable = !map.EDSMRegionsShadingEnable; }; edsmregionsgb.Add(buted3); GLCheckBox buted4 = new GLCheckBox("EDSMR4", new Rectangle(150, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionNames"), null); buted4.Checked = map.EDSMRegionsTextEnable; buted4.Enabled = map.EDSMRegionsEnable; buted4.ToolTipText = "Enable Region Naming"; buted4.CheckChanged += (e1) => { map.EDSMRegionsTextEnable = !map.EDSMRegionsTextEnable; }; edsmregionsgb.Add(buted4); // elite regions GLGroupBox eliteregionsgb = new GLGroupBox("ELITER", "Elite Regions", new Rectangle(leftmargin, vpos, pform.ClientWidth - leftmargin * 2, 50)); eliteregionsgb.ClientHeight = iconsize + 8; eliteregionsgb.BackColor = Color.Transparent; eliteregionsgb.ForeColor = Color.Orange; pform.Add(eliteregionsgb); vpos += eliteregionsgb.Height + ypad; GLCheckBox butelre = new GLCheckBox("ELITERE", new Rectangle(leftmargin, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.ShowGalaxy"), null); butelre.ToolTipText = "Enable Elite Regions"; butelre.Checked = map.EliteRegionsEnable; butelre.UserCanOnlyCheck = true; eliteregionsgb.Add(butelre); GLCheckBox butel2 = new GLCheckBox("ELITER2", new Rectangle(50, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionOutlines"), null); butel2.Checked = map.EliteRegionsOutlineEnable; butel2.Enabled = map.EliteRegionsEnable; butel2.ToolTipText = "Enable Region Outlines"; butel2.CheckChanged += (e1) => { map.EliteRegionsOutlineEnable = !map.EliteRegionsOutlineEnable; }; eliteregionsgb.Add(butel2); GLCheckBox butel3 = new GLCheckBox("ELITER3", new Rectangle(100, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionShading"), null); butel3.Checked = map.EliteRegionsShadingEnable; butel3.Enabled = map.EliteRegionsEnable; butel3.ToolTipText = "Enable Region Shading"; butel3.CheckChanged += (e1) => { map.EliteRegionsShadingEnable = !map.EliteRegionsShadingEnable; }; eliteregionsgb.Add(butel3); GLCheckBox butel4 = new GLCheckBox("ELITER4", new Rectangle(150, 0, iconsize, iconsize), BaseUtils.Icons.IconSet.GetBitmap("GalMap.RegionNames"), null); butel4.Checked = map.EliteRegionsTextEnable; butel4.Enabled = map.EliteRegionsEnable; butel4.ToolTipText = "Enable Region Naming"; butel4.CheckChanged += (e1) => { map.EliteRegionsTextEnable = !map.EliteRegionsTextEnable; }; eliteregionsgb.Add(butel4); butedre.CheckChanged += (e) => { if (e.Name == "EDSMRE") { butelre.CheckedNoChangeEvent = !butedre.Checked; } else { butedre.CheckedNoChangeEvent = !butelre.Checked; } map.EDSMRegionsEnable = butedre.Checked; map.EliteRegionsEnable = butelre.Checked; buted2.Enabled = buted3.Enabled = buted4.Enabled = butedre.Checked; butel2.Enabled = butel3.Enabled = butel4.Enabled = butelre.Checked; }; butelre.CheckChanged += butedre.CheckChanged; } pform.ClientHeight = vpos; map.displaycontrol.Add(pform); }
public LabelWriter(GLLabel label) { this.label = label; }
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(); }
public PBTTaskBrowserForm(GLGui gui, PBTEditorControl editor, Action <Data.Task> callback, bool leafTasksSelectable, bool allowAborting = true) : base(gui) { this.callback = callback; Title = "Task Browser"; SizeMin = Size = new Size(400, 450); var splitter = Add(new GLSplitLayout(gui) { Size = new Size(InnerWidth, InnerHeight - 23), Anchor = GLAnchorStyles.All, SplitterPosition = 0.6f, Orientation = GLSplitterOrientation.Horizontal }); var taskScrollable = splitter.Add(new GLScrollableControl(gui)); var horizontalFlow = taskScrollable.Add(new GLFlowLayout(gui) { FlowDirection = GLFlowDirection.LeftToRight, AutoSize = true, Anchor = GLAnchorStyles.All }); var categories = editor.TaskTypes.TaskTypeCategories.ToDictionary(c => c.Name); var parentTasksFlow = horizontalFlow.Add(new GLFlowLayout(gui) { FlowDirection = GLFlowDirection.TopDown, AutoSize = true }); parentTasksFlow.Add(new GLLabel(gui) { Text = "ParentTasks", AutoSize = true }); foreach (var taskType in categories["ParentTasks"].TaskTypes) { var ltt = taskType; parentTasksFlow.Add(new GLLinkLabel(gui) { Text = ltt.Name, AutoSize = true }).Click += (s, e) => Select(ltt); } var decoratorsFlow = horizontalFlow.Add(new GLFlowLayout(gui) { FlowDirection = GLFlowDirection.TopDown, AutoSize = true }); decoratorsFlow.Add(new GLLabel(gui) { Text = "Decorators", AutoSize = true }); foreach (var taskType in categories["Decorators"].TaskTypes) { var ltt = taskType; decoratorsFlow.Add(new GLLinkLabel(gui) { Text = ltt.Name, AutoSize = true }).Click += (s, e) => Select(ltt); } if (leafTasksSelectable) { var leafTasksFlow = horizontalFlow.Add(new GLFlowLayout(gui) { FlowDirection = GLFlowDirection.TopDown, AutoSize = true }); leafTasksFlow.Add(new GLLabel(gui) { Text = "LeafTasks", AutoSize = true }); foreach (var taskType in categories["LeafTasks"].TaskTypes) { var ltt = taskType; leafTasksFlow.Add(new GLLinkLabel(gui) { Text = ltt.Name, AutoSize = true }).Click += (s, e) => Select(ltt); } } var summaryScrollable = splitter.Add(new GLScrollableControl(gui)); summary = summaryScrollable.Add(new GLLabel(gui) { Text = "", AutoSize = true, Multiline = true, WordWrap = true, SizeMax = new Size(summaryScrollable.InnerWidth - summaryScrollable.Vertical.Width, int.MaxValue) }); ok = Add(new GLButton(gui) { Text = "OK", Enabled = false, Location = new Point(4, InnerHeight - 18), Anchor = GLAnchorStyles.Bottom | GLAnchorStyles.Left }); ok.Click += (s, ev) => callback(selection.Create()); if (editor.Clipboard != null && (leafTasksSelectable || editor.Clipboard.TaskType.Category.Name != "LeafTasks")) { var paste = Add(new GLButton(gui) { Text = "Paste", Location = new Point(ok.Outer.Right + 4, InnerHeight - 18), Anchor = GLAnchorStyles.Bottom | GLAnchorStyles.Left }); paste.Click += (s, e) => callback(editor.Clipboard.DeepCopy()); } if (allowAborting) { var abort = Add(new GLButton(gui) { Text = "Abort", Location = new Point(InnerWidth - 79, InnerHeight - 19), Anchor = GLAnchorStyles.Bottom | GLAnchorStyles.Right }); abort.Click += (s, e) => Parent.Remove(this); } }