private void timer1_Tick(object sender, EventArgs e)
{
if (IsSerialPortClosed()) return;
if (uploadlabel.Visible)
{
while ((BytesToRead() > 0) && (uploadprogress.Value < uploadprogress.Maximum))
{
UpdateProgressBar();
}
if (uploadprogress.Value < uploadprogress.Maximum) return;
if (!uploadprogress.Visible) return; //There was an error uploading the spc. Abort and output.
Application.DoEvents();
ReadLine();
ReadLine();
HideProgressBar();
}
else
{
var str = string.Empty;
while (BytesToRead() > 0)
{
var line = ReadLine();
if (line.StartsWith("----START OF SPC TAGS----"))
{
while (!line.StartsWith("----END OF SPC TAGS----") && (line != string.Empty))
{
var prevLine = line;
line = ReadLine();
if (line.StartsWith("----END OF SPC TAGS----") || (line == string.Empty)) break;
if (!line.Contains(':'))
{
textOutput.AppendText(prevLine + Environment.NewLine);
textOutput.AppendText(line + Environment.NewLine);
line = string.Empty;
continue;
}
switch (line.Split(':')[0])
{
case "OST Disc/Track #":
OSTDiscTrackLabel.Text =
line.Split(new[] {"OST Disc/Track #: "}, StringSplitOptions.None)[1];
continue;
case "SPC File name":
textOutput.AppendText("File " +
line.Split(new[] {"SPC File name: "},
StringSplitOptions.None)
[1] +
" Now playing from SD" + Environment.NewLine);
continue;
case "Song Name":
GameTitleLabel.Text =
line.Split(new[] {"Song Name: "}, StringSplitOptions.None)[1];
continue;
case "Game":
SongTitleLabel.Text = line.Split(new[] {"Game: "}, StringSplitOptions.None)[1];
continue;
case "Artists":
SongArtistLabel.Text =
line.Split(new[] {"Artists: "}, StringSplitOptions.None)[1];
continue;
case "Dumper":
DumperLabel.Text = line.Split(new[] {"Dumper: "}, StringSplitOptions.None)[1];
continue;
case "Comments":
CommentsLabel.Text =
line.Split(new[] {"Comments: "}, StringSplitOptions.None)[1];
line = ReadLine();
while (!line.StartsWith("----End of Comments----"))
{
CommentsLabel.Text += Environment.NewLine + line;
line = ReadLine();
}
continue;
case "Original Soundtrack Title":
OSTTitleLabel.Text =
line.Split(new[] {"Original Soundtrack Title: "}, StringSplitOptions.None)[1
];
continue;
case "Publisher name":
PublisherLabel.Text =
line.Split(new[] {"Publisher name: "}, StringSplitOptions.None)[1];
continue;
case "Copyright Year":
CopyrightYearLabel.Text =
line.Split(new[] {"Copyright Year: "}, StringSplitOptions.None)[1];
continue;
case "Play Time":
PlayTimeLabel.Text =
line.Split(new[] {"Play Time: "}, StringSplitOptions.None)[1];
continue;
case "Fadeout Time":
FadeoutTimeLabel.Text =
line.Split(new[] {"Fadeout Time: "}, StringSplitOptions.None)[1];
continue;
default:
textOutput.AppendText(prevLine + Environment.NewLine);
textOutput.AppendText(line + Environment.NewLine);
line = string.Empty;
break;
}
}
continue;
}
if (line.Contains("]|") && line.StartsWith("["))
{
var key = line.Split('[')[1].Split(']')[0];
var text = line.Split('|')[1];
var nodes = DirectoryView.Nodes.Find(key, false);
foreach (var node in nodes.Where(node => node.Text == text))
{
DirectoryView.SelectedNode = node;
break;
}
continue;
}
if (!line.Contains("APU Reset Complete"))
str += line + Environment.NewLine;
else
{
InitProgressBar(63,2,17);
ClearTags();
break;
}
}
textOutput.AppendText(str);
Application.DoEvents();
}
}