-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormSampleCatalog.cs
More file actions
105 lines (97 loc) · 4.72 KB
/
FormSampleCatalog.cs
File metadata and controls
105 lines (97 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;
namespace VariScan
{
public partial class FormSampleCatalog : Form
{
public struct TargetShoot
{
public string Target;
public string Date;
public string Set;
}
public static List<TargetShoot> SessionList { get; set; }
//public static List<string> SessionSets { get; set; }
public FormSampleCatalog()
{
InitializeComponent();
//make this form topmost, if selected in calling form
Configuration cfg = new Configuration();
if (Convert.ToBoolean(cfg.AnalysisFormOnTop.ToString()))
this.TopMost = true;
//Dimension the target/date array
List<string> targetList = VariScanFileManager.GetTargetNameList();
List<string> dateList = VariScanFileManager.GetAllImageDates();
//If no targets, return
if (targetList.Count == 0)
return;
//Create the row and column headers by target and date
imageBankGridView.RowCount = targetList.Count;
for (int i = 0; i < targetList.Count; i++)
imageBankGridView.Rows[i].HeaderCell.Value = targetList[i];
imageBankGridView.ColumnCount = dateList.Count;
for (int i = 0; i < dateList.Count; i++)
imageBankGridView.Columns[i].HeaderCell.Value = dateList[i];
//Fill in Filters and image count for each cell, if any
for (int iRow = 0; iRow < imageBankGridView.RowCount; iRow++)
for (int iCol = 0; iCol < imageBankGridView.ColumnCount; iCol++)
{
//Get the list of image paths for this cell
string cellTgt = imageBankGridView.Rows[iRow].HeaderCell.Value.ToString();
DateTime cellDate = Convert.ToDateTime(imageBankGridView.Columns[iCol].HeaderCell.Value.ToString());
List<string> imagePaths = VariScanFileManager.GetTargetSessionPaths(cellTgt, cellDate);
//Check to see if there are some images, if so get a list of filters, then a count of images per filter
if (imagePaths.Count > 0)
{
List<string> filterList = new List<string>();
foreach (string path in imagePaths)
{
(string tName, string iDate, string iFilter, string iSeq, string iSet) = VariScanFileManager.ParseImageFileName(Path.GetFileNameWithoutExtension(path));
//SessionSets.Add(iSet);
filterList.Add(iFilter);
}
filterList = filterList.Distinct().ToList();
//SessionSets = SessionSets.Distinct().ToList();
foreach (string filter in filterList)
imageBankGridView.Rows[iRow].Cells[iCol].Value += "F" + filter +
"(" +
VariScanFileManager.GetTargetSessionPaths(cellTgt, cellDate, filter).Count().ToString() +
") ";
}
}
SessionList = new List<TargetShoot>();
return;
}
private void Select_Click(object sender, EventArgs e)
{
Configuration cfg = new Configuration();
//Assemble selection of cells
DataGridViewSelectedCellCollection selectedCells = imageBankGridView.SelectedCells;
//Clear session list
SessionList.Clear();
//Add selected list of target dates to session list
foreach (DataGridViewCell s in selectedCells)
{
if (s.Value != null)
{
string t = s.OwningRow.HeaderCell.Value.ToString();
string d = s.OwningColumn.HeaderCell.Value.ToString();
//Add session sets
List<string> imagePaths = VariScanFileManager.GetTargetSessionPaths(t, Convert.ToDateTime(d));
foreach (string f in imagePaths)
{
//get session set and add to session list
(string tName, string iDate, string iFilter, string iSeq, string iSet) = VariScanFileManager.ParseImageFileName(Path.GetFileNameWithoutExtension(f));
SessionList.Add(new TargetShoot { Target = t, Date = d, Set = iSet });
}
}
SessionList = SessionList.Distinct().ToList();
}
this.Close();
return;
}
}
}