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
LedWizAutoConfigurator.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using DirectOutput.Cab.Toys.LWEquivalent;
6 using DirectOutput.Cab.Toys;
7 
8 namespace DirectOutput.Cab.Out.LW
9 {
14  {
15  #region IAutoConfigOutputController Member
16 
21  public void AutoConfig(Cabinet Cabinet)
22  {
23 
24 
25  List<int> Preconfigured = new List<int>(Cabinet.OutputControllers.Where(OC => OC is LedWiz).Select(LW => ((LedWiz)LW).Number));
26  List<int> Numbers = LedWiz.GetLedwizNumbers();
27  foreach (int N in Numbers)
28  {
29  if (!Preconfigured.Contains(N))
30  {
31  LedWiz LW = new LedWiz(N);
32  if (!Cabinet.OutputControllers.Contains(LW.Name))
33  {
34 
35  Cabinet.OutputControllers.Add(LW);
36  Log.Write("Detected and added LedWiz Nr. {0} with name {1}".Build(LW.Number, LW.Name));
37 
38 
39  if (!Cabinet.Toys.Any(T => T is LedWizEquivalent && ((LedWizEquivalent)T).LedWizNumber == LW.Number))
40  {
42  LWE.LedWizNumber = LW.Number;
43  LWE.Name = "{0} Equivalent".Build(LW.Name);
44 
45  for (int i = 1; i < 33; i++)
46  {
47  LedWizEquivalentOutput LWEO = new LedWizEquivalentOutput() { OutputName = "{0}\\{0}.{1:00}".Build(LW.Name, i), LedWizEquivalentOutputNumber = i };
48  LWE.Outputs.Add(LWEO);
49  }
50 
51  if (!Cabinet.Toys.Contains(LWE.Name))
52  {
53  Cabinet.Toys.Add(LWE);
54  Log.Write("Added LedwizEquivalent Nr. {0} with name {1} for Ledwiz Nr. {2}".Build(LWE.LedWizNumber,LWE.Name,LW.Number));
55  }
56 
57  }
58  }
59  }
60  }
61 
62 
63 
64 
65 
66  }
67 
68  #endregion
69  }
70 }