internal ProxyPlugin(string pluginFile, TrainBase train) { externalCrashed = false; PluginTitle = System.IO.Path.GetFileName(pluginFile); //Load the plugin via the proxy callback var handle = Process.GetCurrentProcess().MainWindowHandle; try { var hostProcess = new Process(); hostProcess.StartInfo.FileName = @"Win32PluginProxy.exe"; hostProcess.Start(); HostInterface.Win32PluginHostReady.WaitOne(); pipeProxy = new DuplexChannelFactory <IAtsPluginProxy>(new InstanceContext(this), new NetNamedPipeBinding(), new EndpointAddress(HostInterface.Win32PluginHostEndpointAddress)).CreateChannel(); pipeProxy.SetPluginFile(pluginFile, Process.GetCurrentProcess().Id); SetForegroundWindow(handle.ToInt32()); } catch { //That didn't work externalCrashed = true; } PluginValid = true; PluginMessage = null; Train = train; Panel = new int[256]; SupportsAI = AISupport.None; switch (PluginTitle.ToLowerInvariant()) { case "ukdt.dll": SupportsAI = AISupport.Program; AI = new UKDtAI(this); break; case "ukspt.dll": SupportsAI = AISupport.Program; AI = new UKSptAI(this); break; case "ukmut.dll": SupportsAI = AISupport.Program; AI = new UKMUtAI(this); break; case "hei_ats.dll": SupportsAI = AISupport.Program; AI = new HeiAtsAI(this); break; } LastTime = 0.0; LastReverser = -2; LastPowerNotch = -1; LastBrakeNotch = -1; LastAspects = new int[] { }; LastSection = -1; LastException = null; Sound = new int[256]; LastSound = new int[256]; }
// --- constructors --- internal Win32Plugin(string pluginFile, TrainBase train) { base.PluginTitle = System.IO.Path.GetFileName(pluginFile); base.PluginValid = true; base.PluginMessage = null; base.Train = train; base.Panel = new int[256]; base.SupportsAI = AISupport.None; switch (PluginTitle.ToLowerInvariant()) { case "ukdt.dll": SupportsAI = AISupport.Program; AI = new UKDtAI(this); break; case "ukspt.dll": SupportsAI = AISupport.Program; AI = new UKSptAI(this); break; case "ukmut.dll": SupportsAI = AISupport.Program; AI = new UKMUtAI(this); break; case "hei_ats.dll": SupportsAI = AISupport.Program; AI = new HeiAtsAI(this); break; } base.LastTime = 0.0; base.LastReverser = -2; base.LastPowerNotch = -1; base.LastBrakeNotch = -1; base.LastAspects = new int[] { }; base.LastSection = -1; base.LastException = null; this.PluginFile = pluginFile; this.Sound = new int[256]; this.LastSound = new int[256]; this.PanelHandle = new GCHandle(); this.SoundHandle = new GCHandle(); }