2 using System.ComponentModel.Composition;
4 using System.Reflection;
5 using B2SServerPluginInterface;
11 namespace B2SServerPlugin
17 [Export(typeof(IDirectPlugin))]
18 public class Plugin : IDirectPlugin, IDirectPluginFrontend
21 #region IDirectPluginFrontend Member
32 DirectOutput.Frontend.MainMenu.Open(
Pinball);
38 System.Windows.Forms.MessageBox.Show(
"Could not show DirectOutput frontend.\n The following exception occured:\n{0}".Build(E.Message),
"DirectOutput");
45 #region IDirectPlugin Members
58 Version V = typeof(
Pinball).Assembly.GetName().Version;
59 DateTime BuildDate =
new DateTime(2000, 1, 1).AddDays(V.Build).AddSeconds(V.Revision * 2);
60 return "DirectOutput (V: {0} as of {1})".Build(V.ToString(), BuildDate.ToString(
"yyyy.MM.dd HH:mm"));
73 public void DataReceive(
char TableElementTypeChar,
int Number,
int Value)
97 public void PluginInit(
string TableFilename,
string RomName)
101 FileInfo F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config",
"GlobalConfig_B2SServer.xml"));
105 FileInfo LnkFile =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config",
"GlobalConfig_B2SServer.lnk"));
108 string ConfigDirPath = ResolveShortcut(LnkFile);
109 if (Directory.Exists(ConfigDirPath))
111 F =
new FileInfo(Path.Combine(ConfigDirPath,
"GlobalConfig_B2SServer.xml"));
118 F =
new FileInfo(
"GlobalConfig_B2SServer.xml");
122 F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"GlobalConfig_B2SServer.xml"));
126 F =
new FileInfo(Path.Combine(
new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName,
"config",
"GlobalConfig_B2SServer.xml"));
141 private string ResolveShortcut(FileInfo ShortcutFile)
143 string TargetPath =
"";
146 Type WScriptShell = Type.GetTypeFromProgID(
"WScript.Shell");
147 object Shell = Activator.CreateInstance(WScriptShell);
148 object Shortcut = WScriptShell.InvokeMember(
"CreateShortcut", BindingFlags.InvokeMethod, null, Shell,
new object[] { ShortcutFile.FullName });
149 TargetPath = (string)Shortcut.GetType().InvokeMember(
"TargetPath", BindingFlags.GetProperty, null, Shortcut, null);
160 if (Directory.Exists(TargetPath))
164 else if (File.Exists(TargetPath))
196 get {
return _Pinball; }
197 set { _Pinball = value; }