private void UpdateDataGridFromFilesystem(string pathFolder) { DataTable table = new DataTable(); table.Columns.Add("name", typeof(string)); table.Columns.Add("version", typeof(string)); table.Columns.Add("type", typeof(string)); table.Columns.Add("frames", typeof(int)); table.Columns.Add("laserName", typeof(string)); table.Columns.Add("laserPower", typeof(double)); table.Columns.Add("duration (sec)", typeof(double)); table.Columns.Add("framerate (fps)", typeof(double)); foreach (string dataFolder in System.IO.Directory.GetDirectories(pathFolder)) { var pv = new PrairieViewer.PrairieFolder(dataFolder); double frameTimeLast = pv.info.FrameTimes[pv.info.FrameTimes.Length - 1]; double framesPerSec = pv.info.FrameTimes.Length / frameTimeLast; DataRow row = table.NewRow(); int column = 0; row.SetField(column++, pv.FolderName); row.SetField(column++, pv.info.Version); row.SetField(column++, pv.info.SequenceType); row.SetField(column++, pv.info.FrameTimes.Length); row.SetField(column++, pv.info.LaserName); row.SetField(column++, Math.Round(pv.info.LaserPower, 2)); row.SetField(column++, Math.Round(frameTimeLast, 2)); row.SetField(column++, Math.Round(framesPerSec, 2)); table.Rows.Add(row); } dataGridView1.DataSource = table; dataGridView1.AutoResizeColumns(); }
static void Main(string[] args) { string pathHere = System.IO.Path.GetFullPath("./"); string pathDemoData = System.IO.Path.GetFullPath("../../../../../data/stripped"); if (!System.IO.Directory.Exists(pathDemoData)) { throw new Exception($"demo data path cannot be found: {pathDemoData}"); } else { System.Console.WriteLine($"Using demo data path: {pathDemoData}"); } string[] dataFolders = System.IO.Directory.GetDirectories(pathDemoData); foreach (string dataFolder in dataFolders) { var fldr = new PrairieViewer.PrairieFolder(dataFolder); } Console.WriteLine("\npress ENTER to exit..."); Console.ReadLine(); }
// when a given folder is selected, the GUI will be updated private void FolderSelected(string folderName) { string pathSelected = System.IO.Path.Combine(PathOutputFolder, folderName); // read Prairie XML var pf = new PrairieViewer.PrairieFolder(pathSelected); tbPvInfo.Text = pf.info?.GetInfo().Replace("\n", "\r\n"); // read experiment XML exp = new PrairieViewer.Experiment(pathSelected); UpdateGuiFromExperiment(); SaveNeeded(false); // load reference images panel1.Controls.Clear(); int refImageCount = 0; string refImageFolder = System.IO.Path.Combine(pathSelected, "References"); if (System.IO.Directory.Exists(refImageFolder)) { string[] refImagePaths = System.IO.Directory.GetFiles(refImageFolder, "*.tif"); int nextYPos = 10; int fixedImageWidth = 330; foreach (string refImagePath in refImagePaths) { string imageFileName = System.IO.Path.GetFileName(refImagePath); if (imageFileName.Contains("16bit")) { continue; } else { refImageCount += 1; } // add the label Label lbl = new Label(); lbl.Location = new Point(10, nextYPos); lbl.Text = imageFileName; lbl.AutoSize = true; lbl.Font = new Font("Arial", 8); panel1.Controls.Add(lbl); nextYPos += 20; // add the image Bitmap bmp = new Bitmap(refImagePath); double heightToWidthRatio = (double)bmp.Height / (double)bmp.Width; PictureBox pb = new PictureBox(); pb.BackgroundImage = bmp; pb.BackgroundImageLayout = ImageLayout.Zoom; pb.Size = new Size(fixedImageWidth, (int)(fixedImageWidth * heightToWidthRatio)); pb.Location = new Point(10, nextYPos); panel1.Controls.Add(pb); nextYPos += pb.Height + 30; } } gbRefImages.Text = $"Reference Images ({refImageCount})"; lblStatus.Text = $"Loaded information about {pf.FolderName}"; }