public static void RefreshGraph(PlotterDisplayEx pdeGraph) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. try { if (pdeGraph.InvokeRequired) { RefreshGraphCallBack d = new RefreshGraphCallBack(RefreshGraph); pdeGraph.BeginInvoke(d, new object[] { pdeGraph }); } else { if (pdeGraph.DataSources == null || pdeGraph.DataSources.Count == 0) { return; } var data = pdeGraph.DataSources[pdeGraph.DataSources.Count - 1]; if ((data.Length - pdeGraph.starting_idx) >= (int)pdeGraph.endX) { float dx = pdeGraph.endX - pdeGraph.startX; pdeGraph.SetStartingIdx((int)(data.Length - dx - (Math.Abs(pdeGraph.MoveMouse) > 0 ? pdeGraph.MoveMouse - 1 : 0))); } pdeGraph.UpdateUI(); } } catch (Exception ex) { Console.WriteLine("RefreshGraph: " + ex.Message); } }
public static void GraphInit(PlotterDisplayEx pdeGraph, string graphName = "") { if (pdeGraph == null) { return; } pdeGraph.DoubleBuffering = true; pdeGraph.PanelLayout = PlotterGraphPaneEx.LayoutMode.NORMAL; pdeGraph.Smoothing = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; pdeGraph.BackgroundColorTop = Color.FromArgb(0, 15, 33); pdeGraph.BackgroundColorBot = Color.FromArgb(0, 15, 33); pdeGraph.SolidGridColor = Color.FromArgb(0, 128, 0); pdeGraph.DashedGridColor = Color.FromArgb(0, 128, 0); pdeGraph.StartingIndexOff = 0; pdeGraph.DataSources.Clear(); pdeGraph.DataSources.Add(GraphData.CreateDefault(graphName).Data); pdeGraph.SetPlayPanelInvisible(); pdeGraph.SetDisplayRangeX(0, 60); pdeGraph.SetGridDistanceX(10); pdeGraph.SetStartingIdx(0); foreach (var control in pdeGraph.Controls) { if (control is VScrollBar vsBar && vsBar != null) { SetGridDistanceY(pdeGraph, vsBar.Value); break; } } foreach (var control in pdeGraph.Controls) { if (control is HScrollBar hBar && hBar != null) { SetGridDistanceX(pdeGraph, hBar.Value); break; } } RefreshGraph(pdeGraph); }