private void AddContextMenu() { ContextMenu = new GLContextMenu(Gui); ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Edit Description" }).Click += (s, e) => { var c = ContextMenu.Location; var p = Editor.TreeContainer.ScrollPosition; Editor.TreeContainer.Add(new PBTDescriptionForm(Gui, description, Task) { Location = new Point(p.X + c.X, p.Y + c.Y) }); }; ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Copy" }) .Click += (s, e) => Editor.Clipboard = new Data.Task(Task.TaskType, Task.Description, Task.ParameterValues.ToArray()); ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Cut" }) .Click += (s, e) => { Editor.Clipboard = new Data.Task(Task.TaskType, Task.Description, Task.ParameterValues.ToArray()); Delete(false); }; ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Delete" }) .Click += (s, e) => Delete(false); ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Copy Subtree" }) .Click += (s, e) => Editor.Clipboard = Task.DeepCopy(); ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Cut Subtree" }) .Click += (s, e) => { Editor.Clipboard = Task.DeepCopy(); Delete(true); }; ContextMenu.Add(new GLContextMenuEntry(Gui) { Text = "Delete Subtree" }) .Click += (s, e) => Delete(true); }
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; if (true) { bool testform1 = true; 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"; if (testform1) { GLForm pform = new GLForm("Form1", "GL Menu demonstration", new Rectangle(10, 10, 600, 200)); displaycontrol.Add(pform); if (true) { GLMenuStrip menubar = new GLMenuStrip("Menubar", new Rectangle(0, 0, 500, 24)); menubar.AutoOpenDelay = 1000; menubar.Font = new Font("Euro Caps", 12); menubar.Dock = DockingType.Top; menubar.SubMenuBorderWidth = 1; GLMenuItem l1 = new GLMenuItem("MI-0A", "MenuA"); menubar.Add(l1); GLMenuItem l1a = new GLMenuItem("A-1", "MenuA-1"); GLMenuItem l1b = new GLMenuItem("A-2", "MenuA-2"); l1b.CheckOnClick = true; l1b.Checked = true; GLMenuItem l1c = new GLMenuItem("A-3", "MenuA-3") { Image = Properties.Resources.GoToHomeSystem }; l1c.CheckOnClick = true; l1.SubMenuItems = new List <GLBaseControl>() { l1a, l1b, l1c }; GLMenuItem l1a1 = new GLMenuItem("A-1-1", "MenuA-1-1"); GLMenuItem l1a2 = new GLMenuItem("A-1-2", "MenuA-1-2"); GLMenuItem l1a21 = new GLMenuItem("A-1-2-1", "MenuA-1-2-1"); GLMenuItem l1a22 = new GLMenuItem("A-1-2-2", "MenuA-1-2-2"); l1a2.SubMenuItems = new List <GLBaseControl>() { l1a21, l1a22 }; GLCheckBox l1a3 = new GLCheckBox("A-1-3", new Rectangle(0, 0, 0, 0), "CheckBox A-1-3"); l1a3.CheckOnClick = true; l1a3.CheckChanged += (bc) => { menubar.CloseMenus(); }; // need to associate check changed with closing menus - optional GLComboBox l1a4 = new GLComboBox("A-1-4", new Rectangle(0, 0, 0, 0), new List <string>() { "one", "two", "three" }); l1a4.SelectedIndexChanged += (c) => { menubar.CloseMenus(); }; l1a4.DisableChangeKeys = true; l1a.SubMenuItems = new List <GLBaseControl>() { l1a1, l1a2, l1a3, l1a4 }; GLMenuItem l2 = new GLMenuItem("MI-0B", "MenuB"); menubar.Add(l2); GLMenuItem l2a = new GLMenuItem("B-1", "MenuB-1"); l2a.Click += (s) => { System.Diagnostics.Debug.WriteLine("Clicked Menu " + s.Name); }; GLMenuItem l2b = new GLMenuItem("B-2", "MenuB-2"); l2.SubMenuItems = new List <GLBaseControl>() { l2a, l2b }; GLMenuItem l3 = new GLMenuItem("MI-0C", "MenuC"); menubar.Add(l3); pform.Add(menubar); } } if (true) { GLContextMenu ctx1, ctx2; ctx1 = new GLContextMenu("CM1"); GLMenuItem cm1 = new GLMenuItem("CM1A", "Menu-1"); cm1.CheckOnClick = true; GLMenuItem cm2 = new GLMenuItem("CM1B", "Menu-2"); cm2.CheckOnClick = true; GLMenuItem cm3 = new GLMenuItem("CM1C", "Menu-3"); GLMenuItem l1a1 = new GLMenuItem("CM1C-1", "Menu-1-1"); l1a1.CheckOnClick = true; GLMenuItem l1a2 = new GLMenuItem("CM1C-2", "MenuA-1-2"); GLCheckBox l1a3 = new GLCheckBox("CM1C-3", new Rectangle(0, 0, 0, 0), "CheckBox A-1-3"); l1a3.CheckOnClick = true; cm3.SubMenuItems = new List <GLBaseControl>() { l1a1, l1a2, l1a3 }; int count = 0; ctx1.Opening += (c1, c2) => { bool on = count++ % 2 == 0; System.Diagnostics.Debug.WriteLine($"Set cm2 state {on}"); cm2.Visible = on; }; ctx1.Add(cm1); ctx1.Add(cm2); ctx1.Add(cm3); Color tc = Color.Orange; ctx2 = new GLContextMenu("CM1", new GLMenuItem[] { new GLMenuItem("CM1A", "MenuR1") { CheckOnClick = true, ForeColor = tc }, new GLMenuItem("CM1B", "MenuR2") { CheckOnClick = true, Enabled = false, ForeColor = tc }, new GLMenuItem("CM1C", "MenuR3") { CheckOnClick = true }, new GLMenuItem("CM1C", "MenuR4") { CheckOnClick = true }, new GLMenuItem("CM1C", "MenuR5") { }, }); ctx2.Font = new Font("Euro caps", 18f); displaycontrol.MouseClick += (s, ev) => { if (ev.Button == GLMouseEventArgs.MouseButtons.Left) { System.Diagnostics.Debug.WriteLine($"*********************** OPEN"); ctx1.Show(displaycontrol, ev.ScreenCoord); } else if (ev.Button == GLMouseEventArgs.MouseButtons.Right) { ctx2.Show(displaycontrol, ev.ScreenCoord); } }; } } 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.Interval = 25; systemtimer.Tick += new EventHandler(SystemTick); systemtimer.Start(); }
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"; pform = new GLForm("Form1", "GL Control demonstration", new Rectangle(10, 10, 700, 800)); displaycontrol.Add(pform); if (true) { dgv = new GLDataGridView("DGV-1", new Rectangle(10, 10, 600, 500)); dgv.Dock = DockingType.Fill; dgv.DefaultAltRowCellStyle.BackColor = Color.FromArgb(255, 240, 240, 240); dgv.DefaultAltRowCellStyle.ForeColor = Color.DarkBlue; dgv.SelectRowOnRightClick = true; // dgv.ColumnFillMode = GLDataGridView.ColFillMode.FillWidth; var col0 = dgv.CreateColumn(); var col1 = dgv.CreateColumn(); var col2 = dgv.CreateColumn(); var col3 = dgv.CreateColumn(); col0.Width = 20; col0.MinimumWidth = 30; col0.Text = "Col0"; col1.Width = 150; col1.Text = "Col1"; col1.MinimumWidth = 50; col2.Width = 150; col2.Text = "Col2"; col3.Width = 150; col3.Text = "Col3"; dgv.AddColumn(col0); dgv.AddColumn(col1); dgv.AddColumn(col2); dgv.AddColumn(col3); pform.BackColor = Color.FromArgb(128, 128, 128, 128); pform.ForeColor = Color.DarkOrange; dgv.DefaultCellStyle.Padding = new PaddingType(5); dgv.BackColor = Color.FromArgb(128, 60, 60, 0); dgv.DefaultColumnHeaderStyle.ForeColor = dgv.DefaultRowHeaderStyle.ForeColor = dgv.DefaultCellStyle.ForeColor = dgv.DefaultAltRowCellStyle.ForeColor = Color.DarkOrange; dgv.UpperLeftBackColor = dgv.DefaultColumnHeaderStyle.BackColor = dgv.DefaultRowHeaderStyle.BackColor = Color.FromArgb(192, 64, 64, 64); dgv.DefaultCellStyle.BackColor = Color.FromArgb(200, 40, 40, 40); dgv.DefaultAltRowCellStyle.BackColor = Color.FromArgb(200, 50, 50, 50); dgv.ScrollBarTheme.BackColor = Color.Transparent; dgv.ScrollBarTheme.SliderColor = Color.FromArgb(0, 64, 64, 64); dgv.ScrollBarTheme.ThumbButtonColor = Color.DarkOrange; dgv.ScrollBarTheme.MouseOverButtonColor = Color.Orange; dgv.ScrollBarTheme.MousePressedButtonColor = Color.FromArgb(255, 255, 192, 0); dgv.ScrollBarTheme.ArrowButtonColor = Color.Transparent; dgv.ScrollBarTheme.ArrowColor = Color.DarkOrange; col2.SortCompare = GLDataGridViewSorts.SortCompareNumeric; for (int i = 0; i < 200; i++) { var row = dgv.CreateRow(); if (i < 2 || i > 5) { row.AutoSize = true; } string prefix = char.ConvertFromUtf32(i + 65); var imgcell = new GLDataGridViewCellImage(Properties.Resources.GoBackward); imgcell.Style.ContentAlignment = ContentAlignment.MiddleLeft; imgcell.Size = new Size(16, 16); row.AddCell(imgcell); row.AddCell(new GLDataGridViewCellText($"{prefix} R{i,2}C1 long bit of text for it to wrap again and again and again")); var but = new GLButton("EmbBut" + i, new Rectangle(0, 0, 30, 15), "But" + i); row.AddCell(new GLDataGridViewCellText($"{i}")); dgv.AddRow(row); } var butcel = new GLDataGridViewCellButton(new Rectangle(0, 0, 80, 24), "Buttext"); butcel.MouseClick += (e2, e3) => { System.Diagnostics.Debug.WriteLine("Click on grid button"); }; butcel.Style.Padding = new PaddingType(3); butcel.Style.ContentAlignment = ContentAlignment.MiddleLeft; dgv.Rows[0].AddCell(butcel); dgv.Rows[1].Height = 40; // dgv.Rows[1].Cells[0].Selected = true; { GLContextMenu cm = new GLContextMenu("CMContent"); GLMenuItem cm1 = new GLMenuItem("CM1A", "Menu-1"); GLMenuItem cm2 = new GLMenuItem("CM1B", "Menu-2"); cm2.CheckOnClick = true; GLMenuItem cm3 = new GLMenuItem("CM1C", "Menu-3"); cm.Add(cm1); cm.Add(cm2); cm.Add(cm3); cm.Opening += (e1, tag) => { GLDataGridView.RowColPos g = (GLDataGridView.RowColPos)tag; System.Diagnostics.Debug.WriteLine($"Open menu content at {g.Row} {g.Column} {g.Location}"); }; dgv.ContextMenuGrid = cm; } { GLContextMenu cm = new GLContextMenu("CMColheader"); GLMenuItem cm1 = new GLMenuItem("CM1A", "Colheader1"); GLMenuItem cm2 = new GLMenuItem("CM1B", "ColHeader2"); cm.Add(cm1); cm.Add(cm2); cm.Opening += (e1, tag) => { GLDataGridView.RowColPos g = (GLDataGridView.RowColPos)tag; System.Diagnostics.Debug.WriteLine($"Open menu col header at {g.Row} {g.Column} {g.Location}"); }; dgv.ContextMenuColumnHeaders = cm; } { GLContextMenu cm = new GLContextMenu("CMRowheader"); GLMenuItem cm1 = new GLMenuItem("CM1A", "RowHeader-1"); cm1.Click = (ctrlb) => { GLMessageBox msg = new GLMessageBox("Confirm", displaycontrol, new Point(int.MinValue, 0), "Ag", "Warning", GLMessageBox.MessageBoxButtons.OKCancel); }; GLMenuItem cm2 = new GLMenuItem("CM1B", "RowHeader-2"); cm.Add(cm1); cm.Add(cm2); cm.Opening += (e1, tag) => { GLDataGridView.RowColPos g = (GLDataGridView.RowColPos)tag; System.Diagnostics.Debug.WriteLine($"Open menu row header at {g.Row} {g.Column} {g.Location}"); }; dgv.ContextMenuRowHeaders = cm; } dgv.MouseClickOnGrid += (r, c, e1) => { System.Diagnostics.Debug.WriteLine($"Mouse click on grid {r} {c}"); }; dgv.SelectedRow += (rw, state) => { System.Diagnostics.Debug.WriteLine($"Row Selected {rw.Index} {state}"); var rowset = dgv.GetSelectedRows(); foreach (var r in rowset) { System.Diagnostics.Debug.WriteLine($".. Row {r.Index} selected"); } }; dgv.SelectedCell += (cell, state) => { System.Diagnostics.Debug.WriteLine($"Cell Selected {cell.RowParent.Index} {cell.Index} "); var cellset = dgv.GetSelectedCells(); foreach (var c in cellset) { System.Diagnostics.Debug.WriteLine($".. Cell {c.RowParent.Index} {c.Index} "); } }; dgv.SelectionCleared += () => { System.Diagnostics.Debug.WriteLine($"Selection cleared"); }; pform.Add(dgv); } { GLToolTip tip = new GLToolTip("ToolTip"); displaycontrol.Add(tip); } 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 { //System.Diagnostics.Debug.WriteLine(ts + " Render"); 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.Interval = 25; systemtimer.Tick += new EventHandler(SystemTick); systemtimer.Start(); }