DirectOuput Framework R2
DirectOutput framework R2 for virtual pinball cabinets
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
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;
5 using DirectOutput.GlobalConfiguration;
6 using DirectOutput.Table;
7 using DirectOutput.Cab.Toys.LWEquivalent;
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 }