public void SetCursorPosition(double d) { //TODO move view to see position when not in view chart.ChartAreas[0].CursorX.SetCursorPosition(d); SetCursorLineRed(); ProbeView.SetProbe(GetEntryAt(d)); MoveViewToCursor(); }
public void LoadLog(DSLOGFileEntry logInfo) { if (logInfo == null) { return; } WaitForLoadingPlotting(); LoadingLog = true; LogInfo = logInfo; string dslogFile = $"{logInfo.FilePath}\\{logInfo.Name}.dslog"; chart.Invoke((Action)(() => { StopStreaming(); LogStreamer = null; InitChart(); LogEntries = null; ClearInfoLabel(); ProbeView.SetProbe(null); })); if (File.Exists(dslogFile)) { DSLOGReader reader = null; LastEntry = 0; if (logInfo.Live) { LogStreamer = new DSLOGStreamer(dslogFile); reader = LogStreamer; LogStreamer.Stream(); } else { reader = new DSLOGReader(dslogFile); try { reader.Read(); } catch (Exception ex) { MessageBox.Show("Log Corrupted!"); LoadingLog = false; return; } } if (reader.Version != 4) { LoadingLog = false; return; } chart.Invoke((Action)(() => { ChartArea area = chart.ChartAreas[0]; StartTime = reader.StartTime; EndTime = reader.Entries.Last().Time; LogEntries = reader.Entries; area.AxisX.Minimum = StartTime.ToOADate(); area.AxisX.Maximum = EndTime.ToOADate(); area.CursorX.IntervalOffset = reader.StartTime.Millisecond % 20; labelFileInfo.Text = $"{logInfo.Name}.dslog"; if (logInfo.IsFMSMatch) { labelFileInfo.Text = labelFileInfo.Text + $" ({logInfo.EventName} {logInfo.MatchType.ToString()} {logInfo.FMSMatchNum})"; labelFileInfo.BackColor = logInfo.GetMatchTypeColor(); //buttonAnalysis.Enabled = true; SetUpMatchTime(); } else { CanUseMatchTime = false; ChangeUseMatchTime(false); } })); PlotLog(); PointCount = LogEntries.Count; chart.Invoke((Action)(() => { SetEnergy(); chart.ChartAreas[0].AxisX.ScaleView.ZoomReset(); chart.ChartAreas[0].AxisY2.ScaleView.ZoomReset(); this.chart.ChartAreas[0].CursorY.IsUserSelectionEnabled = false; })); LoadingLog = false; labelFileInfo.Invoke((Action)(() => { if (logInfo.Live) { labelFileInfo.BackColor = Color.Lime; BackColor = Color.Lime; timerStream.Start(); } })); SetAutoScrollColor(); } else { LoadingLog = false; MessageBox.Show("Log Corrupted!"); } }