void ShowStaticGraph() { var line = new Line(1.0f, new GLColor(1.0, 0.0, 1.0, 0.0), new[] { new GLPoint(0, 0), new GLPoint(1, 1), new GLPoint(2, 2), new GLPoint(3, 3), new GLPoint(4, 4), new GLPoint(5, 4), new GLPoint(6, 3), new GLPoint(7, 2), new GLPoint(8, 1), }); _graph.Lines.Add(line); _graph.Display(new GLRect(0, 0, 10, 10), true); _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) }; _timer.Tick += delegate { var c = line.Color; line.Color = new GLColor(c.A, Adjust(c.R), Adjust(c.G), Adjust(c.B)); _graph.Draw(); }; _timer.Start(); }
public void Create() { if (graphBitmap != null) { graphBitmap.Dispose(); } if (hoverBitmap != null) { hoverBitmap.Dispose(); } if (Width > 0 && Height > 0) { graphBitmap = new Bitmap(Width, Height); hoverBitmap = new Bitmap(Width, Height); Graphics g = Graphics.FromImage(graphBitmap); g.Clear(BackColor); graph.Draw(g, new RectangleF(0, 0, Width, Height)); g.Dispose(); } else { graphBitmap = null; hoverBitmap = null; } }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(1.0 / 30.0); _timer.Tick += delegate { _graph.Draw(); }; _graph = new LineGraph(); _graph.TextEnabled = true; _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowDynamicGraph(); _timer.Start(); }; }
void ShowDynamicGraph() { _graph.TextEnabled = true; var line1 = new Line(1.0f, Colors.Red.ToGLColor(), new GLPoint[] { }); var line2 = new Line(1.0f, Colors.Green.ToGLColor(), new GLPoint[] { }); var line3 = new Line(1.0f, Colors.Blue.ToGLColor(), new GLPoint[] { }); _graph.Lines.Add(line1); _graph.Lines.Add(line2); _graph.Lines.Add(line3); _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.001) }; var i = 0; var rect = new GLRect(0, 0, 500, 100); var rand = new Random(); _timer.Tick += delegate { line1.AddPoint(new GLPoint(i, (rand.Next() % 10) + 5)); line2.AddPoint(new GLPoint(i, (rand.Next() % 10) + 15)); line3.AddPoint(new GLPoint(i, (rand.Next() % 10) + 25)); i++; if (i >= (rect.Width + rect.X)) { line1.RemovePoint(0); line2.RemovePoint(0); line3.RemovePoint(0); var d = (i - (rect.Width + rect.X)); rect = new GLRect(rect.X + d, rect.Y, rect.Width, rect.Height); _graph.Display(rect, false); } _graph.Draw(); }; _timer.Start(); _graph.Display(rect, true); }
public void ShowResultsMenu() { Debug.Log("Showing results."); // for each result with n values m_resultsHelpMenu.SetActive(false); m_resultsMenu.values = new List <float>(); List <float> newVals = new List <float>(); int maxCount = 0; for (int a = 0; a < m_playerResults.Count; a++) { if (m_playerResults[a].GetCount() > maxCount) { maxCount = m_playerResults[a].GetCount(); } } Debug.Log("Max count is " + maxCount); for (int i = 0; i < maxCount; i++) { newVals.Add(-1); for (int a = 0; a < m_playerResults.Count; a++) { PlayerData thisData = m_playerResults[a]; if (thisData.GetCount() > i) { newVals[i] = 0; float toFloat; if (thisData.m_results[i] == true) { toFloat = 1f; } else { toFloat = 0f; } newVals[i] += toFloat; } } } List <float> finalVals = new List <float>(); for (int i = 0; i < maxCount; i++) { if (newVals[i] != -1) { finalVals.Add(newVals[i]); } } for (int i = 0; i < finalVals.Count; i++) { finalVals[i] /= finalVals.Count; m_resultsMenu.values.Add(finalVals[i]); } m_mainMenu.SetActive(false); m_resultsMenu.gameObject.SetActive(true); m_resultsMenu.Draw(m_camera); /* * for (int a = 0; a < m_playerResults.Count;a++) * { * float total = 0; * PlayerData thisData = m_playerResults[a]; * * for (int i=0;i<thisData.GetCount();i++) * { * if (thisData.m_results[i] == true) * { * total += 1; * } * } * total /= thisData.GetCount(); * m_resultsMenu.values.Add(total); * }*/ }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } _graph = new LineGraph(); _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowStaticGraph(); }; _graph.Control.MouseClick += (s, args) => { if (args.Button == MouseButtons.Right) { var origin = _graph.Window.ScreenToView(new GLPoint(args.Location.X, args.Location.Y)); var size = new GLSize(10, 1); var group1 = new MenuItem("Group 1"); group1.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.HotPink.ToGLColor())); _graph.Draw(); }; var group2 = new MenuItem("Group 2"); group2.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Blue.ToGLColor())); _graph.Draw(); }; var nox = new MenuItem("No Explosive"); nox.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Aqua.ToGLColor())); _graph.Draw(); }; var ofb = new MenuItem("Out Of Bounds"); ofb.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Yellow.ToGLColor())); _graph.Draw(); }; var dnt = new MenuItem("DNT"); dnt.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Orange.ToGLColor())); _graph.Draw(); }; var explosive = new MenuItem("Explosive"); explosive.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Maroon.ToGLColor())); _graph.Draw(); }; var peroxide = new MenuItem("Peroxide"); peroxide.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Green.ToGLColor())); _graph.Draw(); }; var menu = new ContextMenu { MenuItems = { group1, group2, nox, ofb, dnt, explosive, peroxide } }; menu.Show(_graph.Control, args.Location); } }; }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) return; _graph = new LineGraph(); _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowStaticGraph(); }; _graph.Control.MouseClick += (s, args) => { if (args.Button == MouseButtons.Right) { var origin = _graph.Window.ScreenToView(new GLPoint(args.Location.X, args.Location.Y)); var size = new GLSize(10, 1); var group1 = new MenuItem("Group 1"); group1.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.HotPink.ToGLColor())); _graph.Draw(); }; var group2 = new MenuItem("Group 2"); group2.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Blue.ToGLColor())); _graph.Draw(); }; var nox = new MenuItem("No Explosive"); nox.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Aqua.ToGLColor())); _graph.Draw(); }; var ofb = new MenuItem("Out Of Bounds"); ofb.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Yellow.ToGLColor())); _graph.Draw(); }; var dnt = new MenuItem("DNT"); dnt.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Orange.ToGLColor())); _graph.Draw(); }; var explosive = new MenuItem("Explosive"); explosive.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Maroon.ToGLColor())); _graph.Draw(); }; var peroxide = new MenuItem("Peroxide"); peroxide.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Green.ToGLColor())); _graph.Draw(); }; var menu = new ContextMenu { MenuItems = { group1, group2, nox, ofb, dnt, explosive, peroxide } }; menu.Show(_graph.Control, args.Location); } }; }
void ShowStaticGraph() { var textures = new Form1.PersistentTextures(); _graph.Display(new GLRect(0, -20, 1000, 50), true); var random = new Random(); _clearTimer = new DispatcherTimer(); _clearTimer.Interval = TimeSpan.FromMilliseconds(100); _clearTimer.Tick += delegate { var count = _graph.Lines.Count; if (count > 0) { for (var i = 0; i < count / 2; i++) { _graph.Lines.RemoveAt(0); } } count = _graph.Markers.Count; if (count > 0) { for (var i = 0; i < count / 2; i++) { _graph.Markers.RemoveAt(0); } } _graph.Draw(); }; _clearTimer.Start(); _drawTimer = new DispatcherTimer(); _drawTimer.Interval = TimeSpan.FromMilliseconds(10); _drawTimer.Tick += delegate { var data = new List <GLPoint>(); for (var i = 0; i < 1000; i++) { data.Add(new GLPoint(i, random.NextDouble() * 30 - 15)); } _graph.Lines.Add(new Line(1.0f, System.Drawing.Color.Black.ToGLColor(), data.ToArray())); _graph.Draw(); }; _drawTimer.Start(); _rectangleDrawer = new DispatcherTimer(); _rectangleDrawer.Interval = TimeSpan.FromMilliseconds(10); _rectangleDrawer.Tick += delegate { for (var i = 0; i < 10; i++) { _graph.Markers.Add(new Rectangle(new GLColor(1, 0.5, 0.5, 0.5), true, new GLPoint(random.NextDouble() * 1000, random.NextDouble() * 30 - 15), new GLSize(random.NextDouble() * 10, 1))); } }; _rectangleDrawer.Start(); _markerDrawer = new DispatcherTimer(); _markerDrawer.Interval = TimeSpan.FromMilliseconds(10); _markerDrawer.Tick += delegate { for (var i = 0; i < 10; i++) { _graph.Markers.Add( new Form1.SatisfiedMarker( new GLPoint(random.NextDouble() * 1000, random.NextDouble() * 30 - 15), textures.RedOrb)); } }; _markerDrawer.Start(); }