private bool LoadFiles(List<string> files)
{
// KFreon: Select files to load if required
List<string> Files = new List<string>();
if (files == null)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
ofd.Title = "Select file/s to load";
ofd.Filter = "All Supported|*.dds;*.tpf;*.MEtpf;*.mod;*.jpg;*.jpeg;*.png;*.bmp|DDS Images|*.dds|Texmod TPF's|*.tpf|Texplorer TPF's|*.MEtpf|Images|*.jpg;*.jpeg;*.png;*.bmp;*.dds|Standard Images|*.jpg;*.jpeg;*.png;*.bmp";
ofd.Multiselect = true;
System.Windows.Forms.DialogResult res = System.Windows.Forms.DialogResult.Abort;
this.Invoke(new Action(() => res = ofd.ShowDialog()));
if (res == System.Windows.Forms.DialogResult.OK)
Files.AddRange(ofd.FileNames.ToList());
else
return false;
}
}
else
Files = files;
// KFreon: Change GUI
this.Invoke(new Action(() =>
{
OverallProg.ChangeProgressBar(0, Files.Count);
OverallStatusLabel.Text = "Loading file" + ((Files.Count == 1) ? "" : "s") + "...";
}));
foreach (string file in Files)
{
switch (Path.GetExtension(file).ToLowerInvariant())
{
case ".tpf":
case ".metpf":
LoadTPF(file);
break;
case ".dds":
case ".png":
case ".jpg":
case ".jpeg":
case ".bmp":
LoadExternal(file, false);
break;
case ".log":
case ".txt":
case ".def":
LoadExternal(file, true);
break;
case ".mod":
LoadMOD(file);
break;
default:
DebugOutput.PrintLn("File: " + file + " is unsupported.");
break;
}
// Heff: Cancellation check
if (cts.IsCancellationRequested)
return false;
OverallProg.IncrementBar();
}
this.Invoke(new Action(() =>
{
OverallProgressBar.Value = OverallProgressBar.Maximum;
OverallStatusLabel.Text = "File" + ((Files.Count > 1) ? "s" : "") + " loaded! Ready.";
RedrawTreeView();
}));
GC.Collect();
return true;
}