2 using System.ComponentModel.Composition;
4 using System.Reflection;
5 using DirectPluginInterface;
7 using System.Windows.Forms;
12 namespace DirectPlugin
18 [Export(typeof(IDirectPlugin))]
22 #region IPlugin Members
35 Version V = typeof(
Pinball).Assembly.GetName().Version;
36 DateTime BuildDate =
new DateTime(2000, 1, 1).AddDays(V.Build).AddSeconds(V.Revision * 2);
37 return "DirectOutput (V: {0} as of {1})".Build(V.ToString(), BuildDate.ToString(
"yyyy.MM.dd HH:mm"));
50 public void DataReceive(
char TableElementTypeChar,
int Number,
int Value)
79 public void PluginInit(
string HostingApplicationName,
string TableFilename,
string GameName)
81 string HostAppFilename = HostingApplicationName.Replace(
".",
"");
82 foreach (
char C
in Path.GetInvalidFileNameChars() )
84 HostAppFilename=HostAppFilename.Replace(
""+C,
"");
86 foreach (
char C
in Path.GetInvalidPathChars())
88 HostAppFilename = HostAppFilename.Replace(
"" + C,
"");
90 HostAppFilename =
"GlobalConfig_{0}".Build(HostAppFilename);
93 FileInfo F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config", HostAppFilename+
".xml"));
97 FileInfo LnkFile =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config", HostAppFilename +
".lnk"));
100 string ConfigDirPath = ResolveShortcut(LnkFile);
101 if (Directory.Exists(ConfigDirPath))
103 F =
new FileInfo(Path.Combine(ConfigDirPath, HostAppFilename+
".xml"));
115 private string ResolveShortcut(FileInfo ShortcutFile)
117 string TargetPath =
"";
120 Type WScriptShell = Type.GetTypeFromProgID(
"WScript.Shell");
121 object Shell = Activator.CreateInstance(WScriptShell);
122 object Shortcut = WScriptShell.InvokeMember(
"CreateShortcut", BindingFlags.InvokeMethod, null, Shell,
new object[] { ShortcutFile.FullName });
123 TargetPath = (string)Shortcut.GetType().InvokeMember(
"TargetPath", BindingFlags.GetProperty, null, Shortcut, null);
134 if (Directory.Exists(TargetPath))
138 else if (File.Exists(TargetPath))
156 #region IDirectPluginFrontend Member
158 public void PluginShowFrontend(Form Owner = null)
162 DirectOutput.Frontend.MainMenu.Open(
Pinball);
168 System.Windows.Forms.MessageBox.Show(
"Could not show DirectOutput frontend.\n The following exception occured:\n{0}".Build(E.Message),
"DirectOutput");
188 get {
return _Pinball; }
189 set { _Pinball = value; }