private void VelodyneStreamWnd_Load(object sender, EventArgs e) { MainForm form = (MainForm)this.MdiParent; VelodyneDataLine dataLine = ((VelodyneDataLine)DataStream.DataLines[0]); String pcapFile = form.Project.Folder + "\\" + DataStream.SubFolder + "\\" + dataLine.PcapLocation; String indexFile = VelodyneConverter.GetDefaultIndexFile(pcapFile); String pointFile = VelodyneConverter.GetDefaultPointFile(pcapFile); ProgressBarWnd wnd = new ProgressBarWnd(); wnd.Text = "Load data stream: " + ((VelodyneDataStream)DataStream).ShortName; wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker) { VelodyneReader.ClearProgressReport(); VelodyneReader.ProgressReport += delegate(object senderReader, ProgressReportEventArgs argsReport) { form.ReportProgress(argsReport.Precentage); logger.WriteInfo(argsReport.CurrentDataTime.ToString("yyy-MM-dd hh:mm:ss") + " " + argsReport.ReadBytes / 1000000 + " MB " + argsReport.Precentage.ToString("0.00") + "%" + Environment.NewLine); wnd.WriteLine(argsReport.CurrentDataTime.ToString("yyy-MM-dd hh:mm:ss") + " " + argsReport.ReadBytes / 1000000 + " MB " + argsReport.Precentage.ToString("0.00") + "%" + Environment.NewLine); ((BackgroundWorker)senderWorker).ReportProgress(Convert.ToInt32(argsReport.Precentage)); }; veloReader = VelodyneReader.Open(((VelodyneDataStream)DataStream).SensorType, ReturnMode.StrongestReturnOnly, indexFile, pointFile); }; wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker) { wnd.Close(); form.ReportProgress(100); // set scroll bar idxStart = veloReader.Indeces.First(); IndexData idxLast = veloReader.Indeces.Last(); trackBar.Minimum = 0; trackBar.Maximum = Convert.ToInt32((idxLast.InternalTimeStamp.Ticks - idxStart.InternalTimeStamp.Ticks) / TimeSpan.TicksPerSecond); this.Text = "Streams: "; foreach (VelodyneDataStream ds in this.VeodyneDataStreams) { this.Text += ds.ShortName + " "; } // set reader to the first index veloReader.Seek(idxStart); viewer.Render(); }; wnd.ShowDialog(); }
private void loadToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog fdb = new FolderBrowserDialog(); DialogResult result = fdb.ShowDialog(); if (result != DialogResult.OK) { return; } projectFolder = fdb.SelectedPath; MainForm form = (MainForm)this.MdiParent; ProgressBarWnd wnd = new ProgressBarWnd(); wnd.Text = "Loading project..."; wnd.ProgressBarStyle = ProgressBarStyle.Marquee; // create multiple logger List <ILogger> loggers = new List <ILogger>(); loggers.Add(ConsoleLogger); loggers.Add(wnd); MultipleLogger logger = new MultipleLogger(loggers); logger.WriteLineInfo("Start loading project: " + projectFolder); wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker) { try { Project = Project.Load(projectFolder, logger); } catch (OperationCanceledException) { logger.WriteLineInfo("Cancelled!"); eWorker.Cancel = true; } catch (Exception ex) { logger.WriteLineInfo("Error occured: " + ex.Message); eWorker.Cancel = true; } }; wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker) { if (!eWorker.Cancelled) { logger.WriteLineInfo("Project has been loaded!"); logger.WriteLineInfo("Project folder: " + this.Project.Folder); logger.WriteLineInfo("No. of data streams: " + this.Project.DataStreams.Count()); MetadataBuilder.PrintSummary(this.Project, ConsoleLogger); if (DataStreamWnd != null) { DataStreamWnd.UpdateUI(); } form?.ReportProgress(100); wnd.WriteProgress(100); wnd.Close(); } }; wnd.ShowDialog(); }