15 public static class DirectOutputHandler
22 public static string GetVersion()
24 return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
41 public static void UpdateTableElement(
string TableElementTypeChar,
int Number,
int Value)
46 C = TableElementTypeChar[0];
51 throw new Exception(
"Could not extract the first char of the TableElementTypeChar parameter", E);
55 Pinball.ReceiveData(C, Number, Value);
61 throw new Exception(
"You must call Init before passing data to the DirectOutput framework");
65 throw new Exception(
"A exception occured when passing in data (TableElementTypeChar: {0}, Number: {1}, Value: {2})".Build(C, Number, Value), E);
82 public static void UpdateNamedTableElement(
string TableElementName,
int Value)
86 Pinball.ReceiveData(TableElementName, Value);
92 throw new Exception(
"You must call Init before passing data to the DirectOutput framework");
96 throw new Exception(
"A exception occured when passing in data (TableElementName: {0}, Value: {1})".Build(TableElementName, Value), E);
109 public static void Finish()
128 public static void Init(
string HostingApplicationName,
string TableFilename,
string RomName)
134 string HostAppFilename = HostingApplicationName.Replace(
".",
"");
136 foreach (
char C
in Path.GetInvalidFileNameChars())
138 HostAppFilename = HostAppFilename.Replace(C.ToString(),
"");
141 foreach (
char C
in Path.GetInvalidPathChars())
143 HostAppFilename = HostAppFilename.Replace(C.ToString(),
"");
147 HostAppFilename =
"GlobalConfig_{0}".Build(HostAppFilename);
150 FileInfo F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config",
"GlobalConfig_{0}.xml".Build(HostAppFilename)));
154 FileInfo LnkFile =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config",
"GlobalConfig_{0}.lnk".Build(HostAppFilename)));
157 string ConfigDirPath = ResolveShortcut(LnkFile);
158 if (Directory.Exists(ConfigDirPath))
160 F =
new FileInfo(Path.Combine(ConfigDirPath,
"GlobalConfig_{0}.xml".Build(HostAppFilename)));
167 F =
new FileInfo(
"GlobalConfig_{0}.xml".Build(HostAppFilename));
171 F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"GlobalConfig_{0}.xml".Build(HostAppFilename)));
175 F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config",
"GlobalConfig_{0}.xml".Build(HostAppFilename)));
176 if (!F.Directory.Exists)
179 F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"GlobalConfig_{0}.xml".Build(HostAppFilename)));
188 Pinball.
Setup((F.Exists ? F.FullName :
""), TableFilename, RomName);
193 throw new Exception(
"Object has already been initialized. You must call Finish() before initializing again.");
202 public static void ShowFrontend()
212 System.
Windows.
Forms.MessageBox.Show(
"Could not show DirectOutput frontend.\n The following exception occured:\n{0}".Build(E.Message),
"DirectOutput");
218 throw new Exception(
"Init has to be called before the frontend is opend.");
225 private static string ResolveShortcut(FileInfo ShortcutFile)
227 string TargetPath =
"";
230 Type WScriptShell = Type.GetTypeFromProgID(
"WScript.Shell");
231 object Shell = Activator.CreateInstance(WScriptShell);
232 object Shortcut = WScriptShell.InvokeMember(
"CreateShortcut", BindingFlags.InvokeMethod, null, Shell,
new object[] { ShortcutFile.FullName });
233 TargetPath = (string)Shortcut.GetType().InvokeMember(
"TargetPath", BindingFlags.GetProperty, null, Shortcut, null);
244 if (Directory.Exists(TargetPath))
248 else if (File.Exists(TargetPath))
273 public static bool IsInitialized
277 return Pinball != null;
282 private static Pinball _Pinball;
290 public static Pinball Pinball
292 get {
return _Pinball; }
293 private set { _Pinball = value; }
void Setup(string GlobalConfigFilename="", string TableFilename="", string RomName="")
Configures the Pinball object. Loads the global config, table config and cabinet config ...
Pinball is the main object of the DirectOutput framework. It holds all objects required to process P...
static void Open(Pinball Pinball, Form Owner=null)