private void sampleLiDARToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (TimeLineWnd == null)
            {
                MessageBox.Show("Frame is not selected! Open the TimeLine window and select a frame.", "Frame is not selected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text = "Export LiDAR frames...";
            loggers.Add(wnd);

            MultipleLogger logger = new MultipleLogger(loggers);

            wnd.WriteLine("Export LiDAR frames..");
            toolStripProgressBar.Visible = true;

            DateTime startTime = TimeLineWnd.CurrentTime;

            startTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, startTime.Hour, startTime.Minute, startTime.Second);

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    for (int k = 0; k < 100; k++)
                    {
                        wnd.CancelTokenSource.Token.ThrowIfCancellationRequested();
                        DateTime currentTime = startTime.AddSeconds(k);
                        wnd.WriteLine("Time: " + currentTime.ToString("yyyy-MM-hh HH:mm:ss.fff"));
                        this.SampleLiDAR(currentTime, LiDARTransformType.None);
                    }
                }
                catch (OperationCanceledException)
                {
                    logger.WriteLineWarning("User cancelled!");
                    return;
                }
                catch (Exception ex)
                {
                    logger.WriteLineError("Error occured: " + ex.Message);
                }

                logger.WriteLineInfo("done.");
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                toolStripProgressBar.Visible = false;
            };

            wnd.ShowDialog();
        }
        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 extractFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);

            if (!Directory.Exists(Project.Folder + "\\" + Project.MetadataFolder))
            {
                Directory.CreateDirectory(Project.Folder + "\\" + Project.MetadataFolder);
            }
            var fileLogger = FileLogger.Create(Project.Folder + "\\" + Project.MetadataFolder + "\\metadata.txt", Project.Folder + "\\" + Project.MetadataFolder + "\\warnings.txt");

            loggers.Add(fileLogger);

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text             = "Loading project...";
            wnd.ProgressBarStyle = ProgressBarStyle.Blocks;
            loggers.Add(wnd);

            MultipleLogger logger = new MultipleLogger(loggers);

            wnd.WriteLine("Start loading project: " + projectFolder);
            toolStripProgressBar.Visible = true;

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    MetadataBuilder.Create(Project, new MultipleLogger(loggers), wnd.CancelTokenSource.Token);
                }
                catch (OperationCanceledException)
                {
                }
                catch (Exception ex)
                {
                    logger.WriteLineError("Error occured: " + ex.Message);
                }
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                toolStripProgressBar.Visible = false;
                fileLogger.Flush();
                fileLogger.Dispose();
            };

            wnd.ShowDialog();
        }
        private void updateFileTimesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <ILogger> loggers = new List <ILogger>();

            loggers.Add(ConsoleLogger);

            MainForm       form = (MainForm)this.MdiParent;
            ProgressBarWnd wnd  = new ProgressBarWnd();

            wnd.Text = "Updating file times...";
            loggers.Add(wnd);

            MultipleLogger logger = new MultipleLogger(loggers);

            wnd.WriteLine("Start updating file times: " + projectFolder);
            toolStripProgressBar.Visible = true;

            wnd.Worker.DoWork += delegate(object senderWorker, DoWorkEventArgs eWorker)
            {
                try
                {
                    int k = 0;
                    foreach (DataStream stream in Project.DataStreams)
                    {
                        wnd.CancelTokenSource.Token.ThrowIfCancellationRequested();

                        logger.WriteProgress((++k / (double)Project.DataStreams.Count()) * 100.0);
                        if (stream is ImageDataStream)
                        {
                            logger.WriteLineInfo("Image data stream: " + stream.ShortName);
                            ImageDataStream imageDataStream = stream as ImageDataStream;
                            imageDataStream.UpdateFileTimes();
                        }

                        if (stream is VideoDataStream)
                        {
                            logger.WriteLineInfo("Image data stream: " + stream.ShortName);
                            VideoDataStream videoDataStream = stream as VideoDataStream;
                            videoDataStream.UpdateFileTimes();
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                    logger.WriteLineWarning("User cancelled!");
                    return;
                }
                catch (Exception ex)
                {
                    logger.WriteLineError("Error occured: " + ex.Message);
                }

                logger.WriteLineInfo("done.");
            };

            wnd.Worker.RunWorkerCompleted += delegate(object senderWorker, RunWorkerCompletedEventArgs eWorker)
            {
                toolStripProgressBar.Visible = false;
            };

            wnd.ShowDialog();
        }