WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
LedControlFileTestWizard.cs
Go to the documentation of this file.
1 using System;
2 using System.IO;
3 using System.Windows.Forms;
5 using System.Threading;
6 
8 {
13  public partial class LedControlFileTestWizard : Form
14  {
19  {
20  InitializeComponent();
21  }
22 
23 
24  public LedControlFileTestWizard(string Filename):this()
25  {
26  if (CheckLedControlFile(Filename))
27  {
28  Console.WriteLine("LedControl file {0} seems to be ok.", Filename);
29  this.Refresh();
30 
31  Thread.Sleep(1500);
32  this.Close();
33  }
34  else
35  {
36  Console.WriteLine("WARNING: Found some issues in ledcontrol file: {0}", Filename);
37  }
38  }
39 
40 
41 
42  private void SelectLedControlFile_Click(object sender, EventArgs e)
43  {
44  string Filename = "";
45  if (OpenLedControlFile.ShowDialog() == DialogResult.OK)
46  {
47  Filename = OpenLedControlFile.FileName;
48  CheckLedControlFile(Filename);
49 
50 
51 
52  }
53  }
54 
55  private bool CheckLedControlFile(string Filename)
56  {
57  try
58  {
59  bool OK = true;
60  LedControlFileName.Text = Filename;
61 
62  ParsingResults.Rows.Clear();
63 
64  string TempLogFile = Path.GetTempFileName();
65  DirectOutput.Log.Filename = TempLogFile;
67 
68  LedControlConfig L = new LedControlConfig(Filename, 1);
69 
71 
72  string LedControlLoadingLog = DirectOutput.General.FileReader.ReadFileToString(TempLogFile);
73 
74 
75  File.Delete(TempLogFile);
76 
77  foreach (string LogLine in LedControlLoadingLog.Split(new[] { '\r', '\n' }))
78  {
79  string[] Parts = LogLine.Split('\t');
80  if (Parts.Length > 1)
81  {
82  if (Parts[1].ToLowerInvariant().Contains("exception") || Parts[1].ToLowerInvariant().Contains("warning") || Parts[1].ToLowerInvariant().Contains("error"))
83  {
84  OK = false;
85  }
86 
87  int RowIndex = ParsingResults.Rows.Add();
88  ParsingResults[0, RowIndex].Value = Parts[0];
89  ParsingResults[1, RowIndex].Value = Parts[1];
90  }
91  }
92  return OK;
93 
94  }
95  catch (Exception E)
96  {
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));
99  return false;
100  }
101  }
102 
103 
104  }
105 }
Static class to read files.
Definition: FileReader.cs:9
static void Finish()
Finishes the logger. Closes the log file.
Definition: Log.cs:78
LedControlFileTestWizard()
Initializes a new instance of the LedControlFileTestWizard class.
static void Init()
Initializes the log using the file defnied in the Filename property.
Definition: Log.cs:40
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
Namespace for the LedControlFileTester application.
The DirectOutput.LedControl namespace contains the classes to read and understand the classical LedCo...
Definition: ColorConfig.cs:6
Ledcontrol configuration read from a ledcontrol.ini file.
static string Filename
Gets or sets the filename for the log.
Definition: Log.cs:31
This is the main form of the LedControlFileTester application. It contains all functionality of the...
The namespace DirectOutput.General contains classes for general use.