private void BuildList(string MapName = "", string Prefix = "", DateTime? StartDate = null, DateTime? EndDate = null)
{
// Remove old junk from the list
SnapshotView.Items.Clear();
SnapshotView.SuspendLayout();
// Define what we are filtering
bool filterMap = !String.IsNullOrWhiteSpace(MapName);
bool filterPrefix = !String.IsNullOrWhiteSpace(Prefix);
bool filterDate = (EndDate != null && StartDate != null);
try
{
// Add each found snapshot to the snapshot view
string path = (ViewSelect.SelectedIndex == 0) ? Paths.SnapshotTempPath : Paths.SnapshotProcPath;
foreach (SnapshotFile file in GetSnapshotFileInfos(path).OrderByDescending(o => o.ProcessedDate))
{
// Filtering of Mapname
if (filterMap && !MapName.Equals(file.MapName, StringComparison.InvariantCultureIgnoreCase))
continue;
// Filtering of Server Prefix
if (filterPrefix && !Prefix.Equals(file.ServerPrefix, StringComparison.InvariantCultureIgnoreCase))
continue;
// Filtering of Dates
if (filterDate && (file.ProcessedDate >= EndDate || file.ProcessedDate <= StartDate))
continue;
// Add item
ListViewItem Row = new ListViewItem();
Row.Tag = file;
Row.SubItems.Add(file.MapName);
Row.SubItems.Add(file.ServerPrefix);
Row.SubItems.Add(file.ProcessedDate.ToString());
SnapshotView.Items.Add(Row);
}
// If we have no items, disable a few things...
if (SnapshotView.Items.Count == 0)
{
ImportBtn.Enabled = false;
SnapshotView.CheckBoxes = false;
ListViewItem Row = new ListViewItem();
Row.Tag = String.Empty;
Row.SubItems.Add(String.Format("There are no {0}processed snapshots!", (ViewSelect.SelectedIndex == 0) ? "un" : ""));
Row.SubItems.Add("");
Row.SubItems.Add("");
SnapshotView.Items.Add(Row);
}
else
SnapshotView.CheckBoxes = true;
}
catch
{
}
SnapshotView.ResumeLayout();
SnapshotView.Update();
}