WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
LedControlConfigList.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using System.Linq;
3 using DirectOutput.Cab;
4 using DirectOutput.Cab.Toys;
6 using DirectOutput.Table;
8 using System.IO;
9 namespace DirectOutput.LedControl.Loader
10 {
11 
15  public class LedControlConfigList : List<LedControlConfig>
16  {
22  public Dictionary<int, TableConfig> GetTableConfigDictonary(string RomName)
23  {
24  Dictionary<int, TableConfig> D = new Dictionary<int, TableConfig>();
25 
26  bool FoundMatch = false;
27  foreach (LedControlConfig LCC in this)
28  {
29 
30  foreach (TableConfig TC in LCC.TableConfigurations)
31  {
32  if (RomName.ToUpper() == TC.ShortRomName.ToUpper())
33  {
34  D.Add(LCC.LedWizNumber, TC);
35  FoundMatch = true;
36  break;
37  }
38  }
39  }
40 
41  if (FoundMatch) return D;
42 
43  foreach (LedControlConfig LCC in this)
44  {
45 
46  foreach (TableConfig TC in LCC.TableConfigurations)
47  {
48  if (RomName.ToUpper().StartsWith("{0}_".Build(TC.ShortRomName.ToUpper())))
49  {
50  D.Add(LCC.LedWizNumber, TC);
51  FoundMatch = true;
52  break;
53  }
54  }
55  }
56 
57  if (FoundMatch) return D;
58 
59  foreach (LedControlConfig LCC in this)
60  {
61 
62  foreach (TableConfig TC in LCC.TableConfigurations)
63  {
64  if (RomName.StartsWith(TC.ShortRomName))
65  {
66  D.Add(LCC.LedWizNumber, TC);
67 
68  break;
69  }
70  }
71  }
72  return D;
73  }
74 
75 
83  public bool ContainsConfig(string RomName)
84  {
85  return GetTableConfigDictonary(RomName).Count > 0;
86 
87  }
88 
89 
95  public void LoadLedControlFiles(IList<string> LedControlFilenames, bool ThrowExceptions = false)
96  {
97  for (int i = 0; i < LedControlFilenames.Count; i++)
98  {
99  LoadLedControlFile(LedControlFilenames[i], i + 1, ThrowExceptions);
100  }
101  }
102 
108  public void LoadLedControlFiles(Dictionary<int, FileInfo> LedControlIniFiles, bool ThrowExceptions = false)
109  {
110  foreach (KeyValuePair<int,FileInfo> F in LedControlIniFiles)
111  {
112  LoadLedControlFile(F.Value.FullName, F.Key, ThrowExceptions);
113  }
114  }
115 
116 
123  public void LoadLedControlFile(string LedControlFilename, int LedWizNumber, bool ThrowExceptions = false)
124  {
125  Log.Write("Loading LedControl file {0}".Build(LedControlFilename));
126 
127  LedControlConfig LCC = new LedControlConfig(LedControlFilename, LedWizNumber, ThrowExceptions);
128  Add(LCC);
129  }
130 
134  public LedControlConfigList() { }
135 
141  public LedControlConfigList(IList<string> LedControlFilenames, bool ThrowExceptions = false)
142  : this()
143  {
144  LoadLedControlFiles(LedControlFilenames, ThrowExceptions);
145  }
146 
147 
148 
149  }
150 }
A table config from a ini file.
Definition: TableConfig.cs:9
The namespace DirectOutput.Cab.Toys contains all toy related classes.
TableConfigList TableConfigurations
Gets or sets the list of table configurations in the ledcontrol.ini.
bool ContainsConfig(string RomName)
Determines whether a config for the spcified RomName exists in the configs.
void LoadLedControlFiles(IList< string > LedControlFilenames, bool ThrowExceptions=false)
Loads a list of ledcontrol.ini files.
int LedWizNumber
Gets or sets the number of the LedWiz resp. LedWizEquivalent to which the settings in this config wil...
static void Write(string Message)
Writes the specified message to the logfile.
Definition: Log.cs:99
void LoadLedControlFiles(Dictionary< int, FileInfo > LedControlIniFiles, bool ThrowExceptions=false)
Loads a list of ledcontrol.ini files.
A simple logger used to record important events and exceptions.
Definition: Log.cs:14
string ShortRomName
Gets or sets the short name of the rom.
Definition: TableConfig.cs:18
Dictionary< int, TableConfig > GetTableConfigDictonary(string RomName)
Gets a dictionary of table configs for a specific romname from the loaded ini file data...
void LoadLedControlFile(string LedControlFilename, int LedWizNumber, bool ThrowExceptions=false)
Loads a single ledcontrol.ini file.
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
Definition: Cab.cs:16
Ledcontrol configuration read from a ledcontrol.ini file.
List of LedControlConfig objects loaded from LedControl.ini files.
The Table namespace contains all table specific classes like the Table class itself, TableElement and effect assigment classes.
Definition: Table.cs:14
LedControlConfigList(IList< string > LedControlFilenames, bool ThrowExceptions=false)
Initializes a new instance of the LedControlConfigList class.
LedControlConfigList()
Initializes a new instance of the LedControlConfigList class.