3 using System.Windows.Forms;
4 using DirectOutput.LedControl.Loader;
5 using System.Threading;
7 namespace LedControlFileTester
20 InitializeComponent();
26 if (CheckLedControlFile(Filename))
28 Console.WriteLine(
"LedControl file {0} seems to be ok.", Filename);
36 Console.WriteLine(
"WARNING: Found some issues in ledcontrol file: {0}", Filename);
42 private void SelectLedControlFile_Click(
object sender, EventArgs e)
45 if (OpenLedControlFile.ShowDialog() == DialogResult.OK)
47 Filename = OpenLedControlFile.FileName;
48 CheckLedControlFile(Filename);
55 private bool CheckLedControlFile(
string Filename)
60 LedControlFileName.Text = Filename;
62 ParsingResults.Rows.Clear();
64 string TempLogFile = Path.GetTempFileName();
65 DirectOutput.Log.Filename = TempLogFile;
66 DirectOutput.Log.Init();
70 DirectOutput.Log.Finish();
72 string LedControlLoadingLog = DirectOutput.General.FileReader.ReadFileToString(TempLogFile);
75 File.Delete(TempLogFile);
77 foreach (
string LogLine
in LedControlLoadingLog.Split(
new[] {
'\r',
'\n' }))
79 string[] Parts = LogLine.Split(
'\t');
82 if (Parts[1].ToLowerInvariant().Contains(
"exception") || Parts[1].ToLowerInvariant().Contains(
"warning") || Parts[1].ToLowerInvariant().Contains(
"error"))
87 int RowIndex = ParsingResults.Rows.Add();
88 ParsingResults[0, RowIndex].Value = Parts[0];
89 ParsingResults[1, RowIndex].Value = Parts[1];
97 ParsingResults.Rows.Clear();
98 MessageBox.Show(
"A error has occured when trying to load and parse the ledcontrol file: \n{0}\n\nException:\n{1}".Build(Filename, E.Message));