commit b5e98da66b1c130b26bd7ce2fed66a805f032536 Author: BlubbFish Date: Thu Jun 18 16:44:44 2015 +0000 Init diff --git a/RailWorks_Joystick_API.sln b/RailWorks_Joystick_API.sln new file mode 100644 index 0000000..ee3f93a --- /dev/null +++ b/RailWorks_Joystick_API.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RailWorks_Joystick_API", "RailWorks_Joystick_API\RailWorks_Joystick_API.csproj", "{5420C2F8-42A0-4A9C-9DFF-5AC66FF19B49}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5420C2F8-42A0-4A9C-9DFF-5AC66FF19B49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5420C2F8-42A0-4A9C-9DFF-5AC66FF19B49}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5420C2F8-42A0-4A9C-9DFF-5AC66FF19B49}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5420C2F8-42A0-4A9C-9DFF-5AC66FF19B49}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RailWorks_Joystick_API/Globals.cs b/RailWorks_Joystick_API/Globals.cs new file mode 100644 index 0000000..ea4536e --- /dev/null +++ b/RailWorks_Joystick_API/Globals.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + class Globals { + + public static Joystick JoyDevices; + + public static List DeviceNames; + + public static InputHandler IHandler; + + public static TextBox DevStatus; + + public static int DevStatusID = -1; + + public static frmManageControls ControlManager = new frmManageControls(); + + public static frmControls ControlsWindow = new frmControls(); + + public static frmSpeedo SpeedoWindow = new frmSpeedo(); + + public delegate void UpdateDeviceDebugDelegate(int DeviceID); + + public static float Clamp(float Value, float MinValue, float MaxValue) { + return Math.Max(MinValue, Math.Min(MaxValue, Value)); + } + + public static int Clamp(int Value, int MinValue, int MaxValue) { + return Math.Max(MinValue, Math.Min(MaxValue, Value)); + } + + public static void AxisChanged(string DeviceName, int DeviceID, string AxisName, int NewValue, int Delta) { + IHandler.UpdateAxis(DeviceID, AxisName, NewValue, Delta); + UpdateDeviceDebugDelegate Del = (zahl) => UpdateDeviceDebug(DeviceID); + DevStatus.Invoke(Del, DeviceID); + } + + public static void ButtonChanged(string DeviceName, int DeviceID, string ButtonName, int NewValue, int Delta) { + IHandler.UpdateButton(DeviceID, ButtonName, NewValue, Delta); + UpdateDeviceDebugDelegate Del = (zahl) => UpdateDeviceDebug(DeviceID); + DevStatus.Invoke(Del, DeviceID); + } + + public static void UpdateDeviceDebug(int DeviceID) { + if((DevStatusID == -1)) { + DevStatus.Text = IHandler.Devices[DeviceID].ToString(); + } else if((DevStatusID == DeviceID)) { + DevStatus.Text = IHandler.Devices[DeviceID].ToString(); + } + } + + public static string IntToStr(int Int) { + return Int.ToString(); + } + } +} diff --git a/RailWorks_Joystick_API/Images/Background.png b/RailWorks_Joystick_API/Images/Background.png new file mode 100644 index 0000000..83bf53b Binary files /dev/null and b/RailWorks_Joystick_API/Images/Background.png differ diff --git a/RailWorks_Joystick_API/Images/BrakeKnob.png b/RailWorks_Joystick_API/Images/BrakeKnob.png new file mode 100644 index 0000000..9ba8f0d Binary files /dev/null and b/RailWorks_Joystick_API/Images/BrakeKnob.png differ diff --git a/RailWorks_Joystick_API/Images/BtnAWSActive1.png b/RailWorks_Joystick_API/Images/BtnAWSActive1.png new file mode 100644 index 0000000..51743d5 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnAWSActive1.png differ diff --git a/RailWorks_Joystick_API/Images/BtnAWSActive2.png b/RailWorks_Joystick_API/Images/BtnAWSActive2.png new file mode 100644 index 0000000..2483204 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnAWSActive2.png differ diff --git a/RailWorks_Joystick_API/Images/BtnAWSInactive.png b/RailWorks_Joystick_API/Images/BtnAWSInactive.png new file mode 100644 index 0000000..7ceab10 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnAWSInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnAlternateActive.png b/RailWorks_Joystick_API/Images/BtnAlternateActive.png new file mode 100644 index 0000000..d936a0a Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnAlternateActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnBellActive.png b/RailWorks_Joystick_API/Images/BtnBellActive.png new file mode 100644 index 0000000..6d2c581 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnBellActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnBlank.png b/RailWorks_Joystick_API/Images/BtnBlank.png new file mode 100644 index 0000000..3bdbe5e Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnBlank.png differ diff --git a/RailWorks_Joystick_API/Images/BtnCabActive.png b/RailWorks_Joystick_API/Images/BtnCabActive.png new file mode 100644 index 0000000..e1a3aeb Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnCabActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnCouplingActive.png b/RailWorks_Joystick_API/Images/BtnCouplingActive.png new file mode 100644 index 0000000..ed236f3 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnCouplingActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnCylinderCocksActive.png b/RailWorks_Joystick_API/Images/BtnCylinderCocksActive.png new file mode 100644 index 0000000..ea5c378 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnCylinderCocksActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnDriverGuideActive.png b/RailWorks_Joystick_API/Images/BtnDriverGuideActive.png new file mode 100644 index 0000000..8d686f0 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnDriverGuideActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnDriverGuideInactive.png b/RailWorks_Joystick_API/Images/BtnDriverGuideInactive.png new file mode 100644 index 0000000..8d686f0 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnDriverGuideInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnEBrakeActive.png b/RailWorks_Joystick_API/Images/BtnEBrakeActive.png new file mode 100644 index 0000000..8b9a465 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnEBrakeActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnEBrakeInactive.png b/RailWorks_Joystick_API/Images/BtnEBrakeInactive.png new file mode 100644 index 0000000..bad7b8a Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnEBrakeInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnExternalFrontActive.png b/RailWorks_Joystick_API/Images/BtnExternalFrontActive.png new file mode 100644 index 0000000..aa499eb Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnExternalFrontActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnExternalRearActive.png b/RailWorks_Joystick_API/Images/BtnExternalRearActive.png new file mode 100644 index 0000000..1cc86f1 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnExternalRearActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnFreeRoamActive.png b/RailWorks_Joystick_API/Images/BtnFreeRoamActive.png new file mode 100644 index 0000000..bd05e11 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnFreeRoamActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnHeadOutLeftActive.png b/RailWorks_Joystick_API/Images/BtnHeadOutLeftActive.png new file mode 100644 index 0000000..36bf7a8 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnHeadOutLeftActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnHeadOutRightActive.png b/RailWorks_Joystick_API/Images/BtnHeadOutRightActive.png new file mode 100644 index 0000000..7410ce5 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnHeadOutRightActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnHornActive.png b/RailWorks_Joystick_API/Images/BtnHornActive.png new file mode 100644 index 0000000..5ec220e Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnHornActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnJunctionAheadActive.png b/RailWorks_Joystick_API/Images/BtnJunctionAheadActive.png new file mode 100644 index 0000000..4770fba Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnJunctionAheadActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnJunctionAheadInactive.png b/RailWorks_Joystick_API/Images/BtnJunctionAheadInactive.png new file mode 100644 index 0000000..4770fba Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnJunctionAheadInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnJunctionBehindActive.png b/RailWorks_Joystick_API/Images/BtnJunctionBehindActive.png new file mode 100644 index 0000000..f62a19e Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnJunctionBehindActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnJunctionBehindInactive.png b/RailWorks_Joystick_API/Images/BtnJunctionBehindInactive.png new file mode 100644 index 0000000..f62a19e Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnJunctionBehindInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnLightsActive1.png b/RailWorks_Joystick_API/Images/BtnLightsActive1.png new file mode 100644 index 0000000..2821a10 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnLightsActive1.png differ diff --git a/RailWorks_Joystick_API/Images/BtnLightsActive2.png b/RailWorks_Joystick_API/Images/BtnLightsActive2.png new file mode 100644 index 0000000..c7f34c1 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnLightsActive2.png differ diff --git a/RailWorks_Joystick_API/Images/BtnLoadUnloadActive.png b/RailWorks_Joystick_API/Images/BtnLoadUnloadActive.png new file mode 100644 index 0000000..421bf13 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnLoadUnloadActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnManualCouplingActive.png b/RailWorks_Joystick_API/Images/BtnManualCouplingActive.png new file mode 100644 index 0000000..c9c206d Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnManualCouplingActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnManualCouplingInactive.png b/RailWorks_Joystick_API/Images/BtnManualCouplingInactive.png new file mode 100644 index 0000000..b901311 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnManualCouplingInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnMapActive.png b/RailWorks_Joystick_API/Images/BtnMapActive.png new file mode 100644 index 0000000..8984b73 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnMapActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnMapInactive.png b/RailWorks_Joystick_API/Images/BtnMapInactive.png new file mode 100644 index 0000000..8984b73 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnMapInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnNextCabActive.png b/RailWorks_Joystick_API/Images/BtnNextCabActive.png new file mode 100644 index 0000000..5af9162 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnNextCabActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPADAheadActive.png b/RailWorks_Joystick_API/Images/BtnPADAheadActive.png new file mode 100644 index 0000000..9426c2b Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPADAheadActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPADAheadInactive.png b/RailWorks_Joystick_API/Images/BtnPADAheadInactive.png new file mode 100644 index 0000000..9426c2b Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPADAheadInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPADBehindActive.png b/RailWorks_Joystick_API/Images/BtnPADBehindActive.png new file mode 100644 index 0000000..f3b313e Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPADBehindActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPADBehindInactive.png b/RailWorks_Joystick_API/Images/BtnPADBehindInactive.png new file mode 100644 index 0000000..f3b313e Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPADBehindInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPantographActive.png b/RailWorks_Joystick_API/Images/BtnPantographActive.png new file mode 100644 index 0000000..2a8590f Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPantographActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPassengerActive.png b/RailWorks_Joystick_API/Images/BtnPassengerActive.png new file mode 100644 index 0000000..18105f2 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPassengerActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnPreviousCabActive.png b/RailWorks_Joystick_API/Images/BtnPreviousCabActive.png new file mode 100644 index 0000000..681915a Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnPreviousCabActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnSanderActive.png b/RailWorks_Joystick_API/Images/BtnSanderActive.png new file mode 100644 index 0000000..b7eb911 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnSanderActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnSmallEjectorActive.png b/RailWorks_Joystick_API/Images/BtnSmallEjectorActive.png new file mode 100644 index 0000000..5529c88 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnSmallEjectorActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnStarterActive.png b/RailWorks_Joystick_API/Images/BtnStarterActive.png new file mode 100644 index 0000000..2c2aca4 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnStarterActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnStarterInactive.png b/RailWorks_Joystick_API/Images/BtnStarterInactive.png new file mode 100644 index 0000000..bfc2f8a Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnStarterInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnTracksideActive.png b/RailWorks_Joystick_API/Images/BtnTracksideActive.png new file mode 100644 index 0000000..4b8a884 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnTracksideActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnVigilanceActive.png b/RailWorks_Joystick_API/Images/BtnVigilanceActive.png new file mode 100644 index 0000000..5202357 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnVigilanceActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnVigilanceInactive.png b/RailWorks_Joystick_API/Images/BtnVigilanceInactive.png new file mode 100644 index 0000000..5202357 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnVigilanceInactive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnWipersActive.png b/RailWorks_Joystick_API/Images/BtnWipersActive.png new file mode 100644 index 0000000..b5b6420 Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnWipersActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnYardActive.png b/RailWorks_Joystick_API/Images/BtnYardActive.png new file mode 100644 index 0000000..b63a32b Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnYardActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnZoomInActive.png b/RailWorks_Joystick_API/Images/BtnZoomInActive.png new file mode 100644 index 0000000..eb793ab Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnZoomInActive.png differ diff --git a/RailWorks_Joystick_API/Images/BtnZoomOutActive.png b/RailWorks_Joystick_API/Images/BtnZoomOutActive.png new file mode 100644 index 0000000..b54a9ff Binary files /dev/null and b/RailWorks_Joystick_API/Images/BtnZoomOutActive.png differ diff --git a/RailWorks_Joystick_API/Images/ButtonControls1bg.png b/RailWorks_Joystick_API/Images/ButtonControls1bg.png new file mode 100644 index 0000000..e6e67c5 Binary files /dev/null and b/RailWorks_Joystick_API/Images/ButtonControls1bg.png differ diff --git a/RailWorks_Joystick_API/Images/ButtonControls2bg.png b/RailWorks_Joystick_API/Images/ButtonControls2bg.png new file mode 100644 index 0000000..1049948 Binary files /dev/null and b/RailWorks_Joystick_API/Images/ButtonControls2bg.png differ diff --git a/RailWorks_Joystick_API/Images/ControlSlot.png b/RailWorks_Joystick_API/Images/ControlSlot.png new file mode 100644 index 0000000..c2bc00c Binary files /dev/null and b/RailWorks_Joystick_API/Images/ControlSlot.png differ diff --git a/RailWorks_Joystick_API/Images/ControlSlotGear.png b/RailWorks_Joystick_API/Images/ControlSlotGear.png new file mode 100644 index 0000000..5c9c23b Binary files /dev/null and b/RailWorks_Joystick_API/Images/ControlSlotGear.png differ diff --git a/RailWorks_Joystick_API/Images/Digi0.png b/RailWorks_Joystick_API/Images/Digi0.png new file mode 100644 index 0000000..041bc28 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi0.png differ diff --git a/RailWorks_Joystick_API/Images/Digi1.png b/RailWorks_Joystick_API/Images/Digi1.png new file mode 100644 index 0000000..f67ff61 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi1.png differ diff --git a/RailWorks_Joystick_API/Images/Digi2.png b/RailWorks_Joystick_API/Images/Digi2.png new file mode 100644 index 0000000..3d3fac6 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi2.png differ diff --git a/RailWorks_Joystick_API/Images/Digi3.png b/RailWorks_Joystick_API/Images/Digi3.png new file mode 100644 index 0000000..322a876 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi3.png differ diff --git a/RailWorks_Joystick_API/Images/Digi4.png b/RailWorks_Joystick_API/Images/Digi4.png new file mode 100644 index 0000000..11e09a5 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi4.png differ diff --git a/RailWorks_Joystick_API/Images/Digi5.png b/RailWorks_Joystick_API/Images/Digi5.png new file mode 100644 index 0000000..6aa063c Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi5.png differ diff --git a/RailWorks_Joystick_API/Images/Digi6.png b/RailWorks_Joystick_API/Images/Digi6.png new file mode 100644 index 0000000..8f5d3d2 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi6.png differ diff --git a/RailWorks_Joystick_API/Images/Digi7.png b/RailWorks_Joystick_API/Images/Digi7.png new file mode 100644 index 0000000..b2ee453 Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi7.png differ diff --git a/RailWorks_Joystick_API/Images/Digi8.png b/RailWorks_Joystick_API/Images/Digi8.png new file mode 100644 index 0000000..96351ac Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi8.png differ diff --git a/RailWorks_Joystick_API/Images/Digi9.png b/RailWorks_Joystick_API/Images/Digi9.png new file mode 100644 index 0000000..07800be Binary files /dev/null and b/RailWorks_Joystick_API/Images/Digi9.png differ diff --git a/RailWorks_Joystick_API/Images/DigiBlank.png b/RailWorks_Joystick_API/Images/DigiBlank.png new file mode 100644 index 0000000..161bc10 Binary files /dev/null and b/RailWorks_Joystick_API/Images/DigiBlank.png differ diff --git a/RailWorks_Joystick_API/Images/DigiDot.png b/RailWorks_Joystick_API/Images/DigiDot.png new file mode 100644 index 0000000..917c7bc Binary files /dev/null and b/RailWorks_Joystick_API/Images/DigiDot.png differ diff --git a/RailWorks_Joystick_API/Images/DigiMinus.png b/RailWorks_Joystick_API/Images/DigiMinus.png new file mode 100644 index 0000000..97f2494 Binary files /dev/null and b/RailWorks_Joystick_API/Images/DigiMinus.png differ diff --git a/RailWorks_Joystick_API/Images/GearKnob.png b/RailWorks_Joystick_API/Images/GearKnob.png new file mode 100644 index 0000000..d35d6f3 Binary files /dev/null and b/RailWorks_Joystick_API/Images/GearKnob.png differ diff --git a/RailWorks_Joystick_API/Images/LabelPanel.png b/RailWorks_Joystick_API/Images/LabelPanel.png new file mode 100644 index 0000000..b7e8940 Binary files /dev/null and b/RailWorks_Joystick_API/Images/LabelPanel.png differ diff --git a/RailWorks_Joystick_API/Images/ReverserKnob.png b/RailWorks_Joystick_API/Images/ReverserKnob.png new file mode 100644 index 0000000..7772836 Binary files /dev/null and b/RailWorks_Joystick_API/Images/ReverserKnob.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBg200Day.png b/RailWorks_Joystick_API/Images/SpeedoBg200Day.png new file mode 100644 index 0000000..7ad5d22 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBg200Day.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBg200KPHDay.png b/RailWorks_Joystick_API/Images/SpeedoBg200KPHDay.png new file mode 100644 index 0000000..b37ebf9 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBg200KPHDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBg300KPHDay.png b/RailWorks_Joystick_API/Images/SpeedoBg300KPHDay.png new file mode 100644 index 0000000..ae65e50 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBg300KPHDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBg360KPHDay.png b/RailWorks_Joystick_API/Images/SpeedoBg360KPHDay.png new file mode 100644 index 0000000..c9e6c36 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBg360KPHDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgBlue.png b/RailWorks_Joystick_API/Images/SpeedoBgBlue.png new file mode 100644 index 0000000..1243f31 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgBlue.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgDay.png b/RailWorks_Joystick_API/Images/SpeedoBgDay.png new file mode 100644 index 0000000..6efb05d Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLarge200Day.png b/RailWorks_Joystick_API/Images/SpeedoBgLarge200Day.png new file mode 100644 index 0000000..0ab254a Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLarge200Day.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLarge200KPHDay.png b/RailWorks_Joystick_API/Images/SpeedoBgLarge200KPHDay.png new file mode 100644 index 0000000..a7fe527 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLarge200KPHDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLarge300KPHDay.png b/RailWorks_Joystick_API/Images/SpeedoBgLarge300KPHDay.png new file mode 100644 index 0000000..fd22ad6 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLarge300KPHDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLarge360KPHDay.png b/RailWorks_Joystick_API/Images/SpeedoBgLarge360KPHDay.png new file mode 100644 index 0000000..8e0e246 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLarge360KPHDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLargeBlue.png b/RailWorks_Joystick_API/Images/SpeedoBgLargeBlue.png new file mode 100644 index 0000000..c2de2ec Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLargeBlue.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLargeDay.png b/RailWorks_Joystick_API/Images/SpeedoBgLargeDay.png new file mode 100644 index 0000000..c7a0749 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLargeDay.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgLargeOrange.png b/RailWorks_Joystick_API/Images/SpeedoBgLargeOrange.png new file mode 100644 index 0000000..776a930 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgLargeOrange.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoBgOrange.png b/RailWorks_Joystick_API/Images/SpeedoBgOrange.png new file mode 100644 index 0000000..c06731e Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoBgOrange.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoGlass120.png b/RailWorks_Joystick_API/Images/SpeedoGlass120.png new file mode 100644 index 0000000..633366b Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoGlass120.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoGlass200.png b/RailWorks_Joystick_API/Images/SpeedoGlass200.png new file mode 100644 index 0000000..8438b0f Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoGlass200.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoGlassLarge120.png b/RailWorks_Joystick_API/Images/SpeedoGlassLarge120.png new file mode 100644 index 0000000..a3e7794 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoGlassLarge120.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoGlassLarge200.png b/RailWorks_Joystick_API/Images/SpeedoGlassLarge200.png new file mode 100644 index 0000000..9a05e7d Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoGlassLarge200.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoIndicator.png b/RailWorks_Joystick_API/Images/SpeedoIndicator.png new file mode 100644 index 0000000..67e16c9 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoIndicator.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoIndicatorBlue.png b/RailWorks_Joystick_API/Images/SpeedoIndicatorBlue.png new file mode 100644 index 0000000..6b11b91 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoIndicatorBlue.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoIndicatorLarge.png b/RailWorks_Joystick_API/Images/SpeedoIndicatorLarge.png new file mode 100644 index 0000000..e3bc8f7 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoIndicatorLarge.png differ diff --git a/RailWorks_Joystick_API/Images/SpeedoIndicatorLargeBlue.png b/RailWorks_Joystick_API/Images/SpeedoIndicatorLargeBlue.png new file mode 100644 index 0000000..0f3dfe5 Binary files /dev/null and b/RailWorks_Joystick_API/Images/SpeedoIndicatorLargeBlue.png differ diff --git a/RailWorks_Joystick_API/Images/ThrottleBrakeHandle.png b/RailWorks_Joystick_API/Images/ThrottleBrakeHandle.png new file mode 100644 index 0000000..d39b101 Binary files /dev/null and b/RailWorks_Joystick_API/Images/ThrottleBrakeHandle.png differ diff --git a/RailWorks_Joystick_API/Images/ThrottleHandle.png b/RailWorks_Joystick_API/Images/ThrottleHandle.png new file mode 100644 index 0000000..cf16877 Binary files /dev/null and b/RailWorks_Joystick_API/Images/ThrottleHandle.png differ diff --git a/RailWorks_Joystick_API/Images/btnPBrakeActive.png b/RailWorks_Joystick_API/Images/btnPBrakeActive.png new file mode 100644 index 0000000..957a357 Binary files /dev/null and b/RailWorks_Joystick_API/Images/btnPBrakeActive.png differ diff --git a/RailWorks_Joystick_API/Images/btnPBrakeInactive.png b/RailWorks_Joystick_API/Images/btnPBrakeInactive.png new file mode 100644 index 0000000..983898f Binary files /dev/null and b/RailWorks_Joystick_API/Images/btnPBrakeInactive.png differ diff --git a/RailWorks_Joystick_API/InputHandler.cs b/RailWorks_Joystick_API/InputHandler.cs new file mode 100644 index 0000000..b63c8bf --- /dev/null +++ b/RailWorks_Joystick_API/InputHandler.cs @@ -0,0 +1,903 @@ +using Microsoft.VisualBasic; +using RailWorks_Joystick_API.Properties; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace RailWorks_Joystick_API { + public class InputHandler { + + [DllImport("user32.dll")] + public static extern IntPtr GetForegroundWindow(); + [DllImport("user32.dll")] + public static extern int GetWindowText(IntPtr hWnd, System.Text.StringBuilder lpWindowText, int nMaxCount); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern void SetRailSimValue(ActionList Action, float Value); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern float GetRailSimValue(ActionList Action, GetValueModifier Value); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern bool GetRailSimConnected(); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern void SetRailSimConnected(bool Value); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern void SetRailDriverConnected(bool Value); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern bool GetRailSimCombinedThrottleBrake(); + + [DllImport("RailDriver.dll", CharSet = CharSet.Auto)] + public static extern bool GetRailSimLocoChanged(); + + public struct InputAxisStruct { + public int Value; + public int Delta; + + public string Name; + public InputAxisStruct(string AxisName, int AxisValue, int AxisDelta) { + Name = AxisName; + Value = AxisValue; + Delta = AxisDelta; + } + + public override string ToString() { + return string.Format("{0}: {1,-20}Delta: {2}", Name, Value, Delta); + } + + } + + public struct InputButtonStruct { + public bool Pressed; + + public string Name; + public InputButtonStruct(string ButtonName, bool ButtonPressed) { + Name = ButtonName; + Pressed = ButtonPressed; + } + + public override string ToString() { + return (Pressed ? string.Format("{0,-10}", Name) : "").ToString(); + } + } + + public struct DeviceStruct { + public string Name; + public int ID; + public List Axis; + + public List Buttons; + public DeviceStruct(string DeviceName, int DeviceID) { + Name = DeviceName; + ID = DeviceID; + Axis = new List(); + Buttons = new List(); + } + + public int FindAxis(string FindName) { + for(int I = 0; I <= Axis.Count - 1; I++) { + if(Axis[I].Name == FindName) + return I; + } + return -1; + } + + public int FindButton(string FindName) { + for(int I = 0; I <= Buttons.Count - 1; I++) { + if(Buttons[I].Name == FindName) + return I; + } + return -1; + } + + public override string ToString() { + System.Text.StringBuilder Txt = new System.Text.StringBuilder(); + Txt.AppendLine("Device: " + Name + " (" + ID + ")"); + Txt.AppendLine("Axis:"); + foreach(InputAxisStruct Axle in Axis) { + Txt.AppendLine(" " + Axle.ToString()); + } + Txt.AppendLine("Buttons:"); + int I = 0; + foreach(InputButtonStruct Button in Buttons) { + Txt.Append(Button.ToString()); + if(!(string.IsNullOrEmpty(Button.ToString()))) + I += 1; + if(I >= 8) { + Txt.AppendLine(); + I = 0; + } + } + return Txt.ToString(); + } + } + + public enum ActionList : int { + Invalid = -1, + Reverser, + Throttle, + CombinedThrottle, + GearLever, + TrainBrake, + LocomotiveBrake, + DynamicBrake, + EmergencyBrake, + HandBrake, + WarningSystemReset, + StartStopEngine, + Horn, + Wipers, + Sander, + Headlights, + Pantograph, + FireboxDoor, + ExhaustInjectorSteam, + ExhaustInjectorWater, + LiveInjectorSteam, + LiveInjectorWater, + Damper, + Blower, + Stoking, + CylinderCock, + Waterscoop, + SmallCompressor, + AWS, + AWSReset, + Startup, + Speedometer, + // Events + PromptSave, + ToggleLabels, + Toggle2DMap, + ToggleHud, + ToggleQut, + Pause, + DriverGuide, + ToggleRvNumber, + DialogAssignment, + SwitchJunktionAhead, + SwitchJunktionBehind, + LoadCargo, + UnloadCargo, + PassAtDangerAhead, + PassAtDangerBehind, + ManualCouple, + // Camera + CabCamera, + FollowCamera, + HeadOutCamera, + RearCamera, + TrackSideCamera, + CarriageCamera, + CouplingCamera, + YardCamera, + SwitchToNextFrontCab, + SwitchToNextRearCab, + FreeCamera, + Vigilance + } + + public enum GetValueModifier : int { + Current, + Min, + Max + } + + public List Devices = new List(); + public int APIInterval = 33; + private Thread RailWorksThread; + private bool _Running; + private bool _IsStopped = true; + public int AssignFilter = 1500; + public float AxisNotchOffset = 0.002f; + + public InputHandler(List DeviceNames) { + for(int I = 0; I <= DeviceNames.Count - 1; I++) { + DeviceStruct Dev = new DeviceStruct(DeviceNames[I], I); + Dev.Axis = new List(); + Dev.Buttons = new List(); + Devices.Add(Dev); + } + LoadBlank(); + Settings s = new Settings(); + Vigilance.MinDelay = s.MinDelay; + Vigilance.MaxDelay = s.MaxDelay; + Vigilance.EarlyTriggerChance = s.EarlyTriggerChance; + Vigilance.TrainSpeedOffsetFactor = s.TrainSpeedOffset; + Vigilance.MinimumTrainSpeed = s.MinimumTrainSpeed; + Vigilance.TriggerTimeout = s.TriggerTimeout; + Vigilance.UseVigilanceSystem = s.UseVigilance; + } + + public void UpdateAxis(int DeviceID, string AxisName, int AxisValue, int AxisDelta) { + DeviceStruct Dev = Devices[DeviceID]; + int Result = Dev.FindAxis(AxisName); + if(Result == -1) { + Dev.Axis.Add(new InputAxisStruct(AxisName, AxisValue, AxisDelta)); + return; + } + Dev.Axis[Result] = new InputAxisStruct(AxisName, AxisValue, AxisDelta); + Devices[DeviceID] = Dev; + CheckMappings(DeviceID, AxisName, AxisValue, AxisDelta); + } + + public void UpdateButton(int DeviceID, string ButtonName, int ButtonValue, int ButtonDelta) { + DeviceStruct Dev = Devices[DeviceID]; + int Result = Dev.FindButton(ButtonName); + bool ButtonPressed = Convert.ToBoolean(ButtonValue); + if(Result == -1) { + Dev.Buttons.Add(new InputButtonStruct(ButtonName, ButtonPressed)); + return; + } + Dev.Buttons[Result] = new InputButtonStruct(ButtonName, ButtonPressed); + Devices[DeviceID] = Dev; + CheckMappings(DeviceID, ButtonName, ButtonValue, ButtonDelta); + } + + public void StartAPI() { + _Running = true; + _IsStopped = false; + RailWorksThread = new Thread(RailWorksThreadMain); + RailWorksThread.IsBackground = true; + RailWorksThread.Start(); + } + + public string FileName = "LastUsed.CMap"; + public void SaveMaps(string FilePath = "") { + if(string.IsNullOrEmpty(FilePath)) + FilePath = FileName; + FileStream FStream = new FileStream(FilePath, FileMode.OpenOrCreate); + System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + try { + BFormatter.Serialize(FStream, Mappings); + } catch(Exception) { + Interaction.MsgBox("The settings could not be saved to " + FilePath + "!"); + } finally { + FStream.Close(); + } + } + + public void LoadMaps(string FilePath = "") { + FileStream FStream = default(FileStream); + try { + FStream = new FileStream(FilePath, FileMode.Open); + System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + + Mappings.Clear(); + Mappings = (List)BFormatter.Deserialize(FStream); + } catch(Exception) { + Interaction.MsgBox("The settings could not be loaded from " + FilePath + "!"); + } finally { + if(FStream != null) + FStream.Close(); + } + } + + public void ShiftMaps(int Direction) { + Map CMap = null; + InputMap IMap = null; + + for(int I = 0; I <= Mappings.Count - 1; I++) { + CMap = Mappings[I]; + Removed: + for(int J = 0; J <= CMap.InputMaps.Count - 1; J++) { + IMap = CMap.InputMaps[J]; + IMap.DeviceID += Direction; + if(IMap.DeviceID < 0 | IMap.DeviceID > Globals.DeviceNames.Count - 1) { + CMap.InputMaps.RemoveAt(J); + goto Removed; + } + CMap.InputMaps[J] = IMap; + } + Mappings[I] = CMap; + } + } + + public void StopAPI() { + SaveMaps(); + Settings s = new Settings(); + s.MinDelay = Vigilance.MinDelay; + s.MaxDelay = Vigilance.MaxDelay; + s.EarlyTriggerChance = Vigilance.EarlyTriggerChance; + s.TrainSpeedOffset = Vigilance.TrainSpeedOffsetFactor; + s.MinimumTrainSpeed = Vigilance.MinimumTrainSpeed; + s.TriggerTimeout = Vigilance.TriggerTimeout; + s.UseVigilance = Vigilance.UseVigilanceSystem; + _Running = false; + } + + public bool IsStopped() { + return _IsStopped; + } + + public void RailWorksThreadMain() { + + SetRailSimConnected(true); + SetRailDriverConnected(true); + while(_Running) { + IntPtr CurHWnd = GetForegroundWindow(); + System.Text.StringBuilder CurWindowText = new System.Text.StringBuilder(255); + GetWindowText(CurHWnd, CurWindowText, 255); + if(CurWindowText.ToString() == "RailWorks") { + Vigilance.InGame = true; + SendToRW(); + Vigilance.LastTrainSpeed = Math.Abs(GetRailSimValue(ActionList.Speedometer, GetValueModifier.Current)); + Debug.Print(GetRailSimValue(ActionList.EmergencyBrake, GetValueModifier.Current).ToString()); + if((Globals.ControlsWindow.Visible)) { + GetCurrentValues(); + } + } else { + Vigilance.InGame = false; + } + Thread.Sleep(APIInterval); + } + _IsStopped = true; + } + + private delegate void OneShotDelegate(ActionList Action, float Value); + private class OneShotArgs { + public ActionList Action; + public float Value; + + public OneShotDelegate OneShotDel; + public void OneShot() { + OneShotDel(Action, Value); + } + } + + + public VigilanceSystem Vigilance = new VigilanceSystem(); + public void SendToRW() { + Map[] Maps = Mappings.ToArray(); + foreach(Map CMap_loopVariable in Maps) { + Map CMap = CMap_loopVariable; + if(CMap.InputMaps.Count > 0) { + if(CMap.Action == ActionList.Vigilance) { + float Value = CMap.GetOutputPercent(); + if(Value > 0.5) { + Vigilance.ButtonState = VigilanceSystem.Actions.Press; + } else { + Vigilance.ButtonState = VigilanceSystem.Actions.Release; + } + continue; + } + if(Vigilance.State == VigilanceSystem.VigilanceState.Triggered) { + SetRailSimValue(ActionList.EmergencyBrake, 1); + continue; + } + if(CMap.APIType == InputMap.ControlType.Button) { + if(CMap.OneTimeShotConsumed) + continue; + CMap.OneTimeShotConsumed = true; + OneShotArgs OneShot = new OneShotArgs(); + OneShot.Action = CMap.Action; + OneShot.Value = CMap.GetOutputPercent(); + OneShot.OneShotDel = SendToRWOneShot; + Thread OneShotThread = new Thread(OneShot.OneShot); + OneShotThread.IsBackground = true; + OneShotThread.Start(); + } else { + float Value = CMap.GetOutputPercent(); + //Debug.Print("Sending " & Value & " to game with control " & CMap.Action.ToString) + switch(CMap.Action) { + case ActionList.Reverser: + Value = -1 + Value * 2; + SetRailSimValue(CMap.Action, Value); + break; + case ActionList.Throttle: + SetRailSimValue(CMap.Action, Value); + SetRailSimValue(ActionList.CombinedThrottle, Value); + break; + default: + SetRailSimValue(CMap.Action, Value); + break; + } + } + } + } + } + + public void SendToRWOneShot(ActionList Action, float Value) { + switch(Action) { + // The following are treated differently + case ActionList.Sander: + case ActionList.EmergencyBrake: + case ActionList.Horn: + case ActionList.SwitchJunktionAhead: + case ActionList.SwitchJunktionBehind: + case ActionList.SwitchToNextFrontCab: + case ActionList.SwitchToNextRearCab: + SetRailSimValue(Action, Value); + break; + case ActionList.LoadCargo: + SetRailSimValue(Action, Value); + SetRailSimValue(ActionList.UnloadCargo, Value); + Thread.Sleep(50); + SetRailSimValue(Action, 0); + SetRailSimValue(ActionList.UnloadCargo, 0); + break; + default: + SetRailSimValue(Action, Value); + Thread.Sleep(100); + SetRailSimValue(Action, 0); + break; + } + + } + + private delegate void GetFromRWDelegate(); + + public void GetCurrentValues() { + if((Globals.ControlsWindow.InvokeRequired)) { + GetFromRWDelegate Del = new GetFromRWDelegate(GetCurrentValues); + Globals.ControlsWindow.Invoke(Del); + return; + } + Dictionary DataMap = new Dictionary(); + // Get Speedometer + DataMap.Add("Speed", Math.Abs(GetRailSimValue(ActionList.Speedometer, GetValueModifier.Current))); + + // Get throttle etc + // TODO: Move this someplace else? + DataMap.Add("Throttle", Mappings[(int)ActionList.Throttle].GetOutputPercent()); + DataMap.Add("TrainBrake", Mappings[(int)ActionList.TrainBrake].GetOutputPercent()); + DataMap.Add("LocomotiveBrake", Mappings[(int)ActionList.LocomotiveBrake].GetOutputPercent()); + DataMap.Add("DynamicBrake", Mappings[(int)ActionList.DynamicBrake].GetOutputPercent()); + DataMap.Add("Reverser", Mappings[(int)ActionList.Reverser].GetOutputPercent()); + DataMap.Add("Gear", Mappings[(int)ActionList.GearLever].GetOutputPercent()); + + Globals.ControlsWindow.UpdateControls(DataMap); + + } + + + public List Mappings = new List(); + public void LoadBlank() { + + Mappings.Clear(); + + Mappings.Add(new Map(ActionList.Reverser, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.Throttle, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.CombinedThrottle, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.GearLever, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.TrainBrake, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.LocomotiveBrake, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.DynamicBrake, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.EmergencyBrake, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.HandBrake, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.WarningSystemReset, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.StartStopEngine, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Horn, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Wipers, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Sander, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Headlights, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Pantograph, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.FireboxDoor, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.ExhaustInjectorSteam, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.ExhaustInjectorWater, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.LiveInjectorSteam, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.LiveInjectorWater, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.Damper, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.Blower, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.Stoking, InputMap.ControlType.Axis)); + Mappings.Add(new Map(ActionList.CylinderCock, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Waterscoop, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.SmallCompressor, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.AWS, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.AWSReset, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Startup, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Speedometer, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.PromptSave, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.ToggleLabels, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Toggle2DMap, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.ToggleHud, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.ToggleQut, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.Pause, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.DriverGuide, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.ToggleRvNumber, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.DialogAssignment, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.SwitchJunktionAhead, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.SwitchJunktionBehind, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.LoadCargo, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.UnloadCargo, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.PassAtDangerAhead, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.PassAtDangerBehind, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.ManualCouple, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.CabCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.FollowCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.HeadOutCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.RearCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.TrackSideCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.CarriageCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.CouplingCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.YardCamera, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.SwitchToNextFrontCab, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.SwitchToNextRearCab, InputMap.ControlType.Button)); + Mappings.Add(new Map(ActionList.FreeCamera, InputMap.ControlType.Button)); + // Vigilance system is NOT part of the Raildriver dll. + Mappings.Add(new Map(ActionList.Vigilance, InputMap.ControlType.Button)); + + } + + private void CheckMappings(int DeviceID, string DeviceInputName, int Value, int Delta) { + Map CMap = null; + for(int I = 0; I <= Mappings.Count - 1; I++) { + CMap = Mappings[I]; + CheckInputMappings(ref CMap, DeviceID, DeviceInputName, Value, Delta); + Mappings[I] = CMap; + if(I == Globals.ControlManager.APIMapIndex & Globals.ControlManager.Visible) + Globals.ControlManager.UpdateSubscription(null,null); + } + } + + private void CheckInputMappings(ref Map CMap, int DeviceID, string DeviceInputName, int Value, int Delta) { + InputMap IMap = null; + bool WasAssigned = false; + for(int I = 0; I <= CMap.InputMaps.Count - 1; I++) { + IMap = CMap.InputMaps[I]; + if((IMap.TreatAs == InputMap.ControlType.NotAssigned)) { + IMap.MapName = ""; + IMap.DeviceID = -1; + continue; + } + if(IMap.TreatAs == InputMap.ControlType.Assigning & (Math.Abs(Delta) >= AssignFilter | DeviceInputName.Contains("B") | DeviceInputName.Contains("Pov"))) { + IMap.DeviceID = DeviceID; + IMap.MapName = DeviceInputName; + if(IMap.MapName.Contains("B") | IMap.MapName.Contains("Pov")) { + IMap.TreatAs = InputMap.ControlType.Button; + } else { + IMap.TreatAs = InputMap.ControlType.Axis; + } + if(Delta < 0) + IMap.Direction = InputMap.ControlDirection.Negative; + if(Delta > 0) + IMap.Direction = InputMap.ControlDirection.Positive; + if(Delta == 0) + IMap.Direction = InputMap.ControlDirection.Neutral; + // This shall NOT happen! + WasAssigned = true; + } + if((IMap.DeviceID == DeviceID & IMap.MapName == DeviceInputName)) { + IMap.DeviceValue = Value; + IMap.DeviceDelta = Delta; + CMap.InputMaps[I] = IMap; + if(WasAssigned) { + Globals.ControlManager.LoadControlMap(); + WasAssigned = false; + } + } + } + } + + public void StopAssigning() { + Map CMap = null; + InputMap IMap = null; + for(int I = 0; I <= Mappings.Count - 1; I++) { + CMap = Mappings[I]; + for(int J = 0; J <= Mappings[I].InputMaps.Count - 1; J++) { + IMap = CMap.InputMaps[J]; + if(IMap.TreatAs == InputMap.ControlType.Assigning) { + IMap.TreatAs = InputMap.ControlType.NotAssigned; + CMap.InputMaps[J] = IMap; + Mappings[I] = CMap; + } + } + } + } + } + + + // Map Class + [Serializable()] + public class Map { + public InputHandler.ActionList Action; + public InputMap.ControlType APIType; + public List InputMaps; + + public bool OneTimeShotConsumed; + public float LatchedValue; + private float RelativeLatch; + private int LastInput = -1; + + private int Toggle; + public Map(InputHandler.ActionList MapAction, InputMap.ControlType MapAPIType) { + Action = MapAction; + APIType = MapAPIType; + InputMaps = new List(); + } + + public void AddInput(ref InputMap IMap) { + IMap.GotInput += InputMaps_GotInput; + InputMaps.Add(IMap); + } + + public float GetPercent() { + InputMap IMap = null; + if((LastInput > InputMaps.Count - 1)) + LastInput = -1; + if((LastInput == -1)) { + if(InputMaps.Count == 0) + return 0; + LastInput = 0; + } + IMap = InputMaps[LastInput]; + return Globals.Clamp(IMap.GetPercent(), 0, 1); + } + + public float GetOutputPercent() { + InputMap IMap = null; + if((LastInput > InputMaps.Count - 1)) + LastInput = -1; + if((LastInput == -1)) { + if(InputMaps.Count == 0) + return 0; + LastInput = 0; + } + IMap = InputMaps[LastInput]; + switch(IMap.MapMode) { + case InputMap.ControlMode.Slider: // TODO: to InputMap.ControlMode.NotchedSliderTargets + if(IMap.IsNegativePositiveRange) + return Globals.Clamp(IMap.GetOutputPercent(), -1, 1); + return Globals.Clamp(IMap.GetOutputPercent(), 0, 1); + default: + if(IMap.IsNegativePositiveRange) + return Globals.Clamp(LatchedValue, -1, 1); + return Globals.Clamp(LatchedValue, 0, 1); + } + } + + private void InputMaps_GotInput(InputMap IMap) { + LastInput = InputMaps.IndexOf(IMap); + OneTimeShotConsumed = false; + switch(IMap.MapMode) { + case InputMap.ControlMode.Slider: // TODO: to InputMap.ControlMode.NotchedSliderTargets + break; + case InputMap.ControlMode.UpDownLatch: + // TODO: Check if we can use direction here too... + if(IMap.GetOutputPercent() > 0.501 & IMap.GetOutputPercent() > LatchedValue) { + LatchedValue = IMap.GetOutputPercent(); + } else if(IMap.GetOutputPercent() < 0.499 & IMap.GetOutputPercent() < LatchedValue) { + LatchedValue = IMap.GetOutputPercent(); + } + break; + case InputMap.ControlMode.UpDownRelative: + float OutputPercent = IMap.GetOutputPercent(); + float DeltaValue = 0; + if(OutputPercent > 0.501 & ((IMap.DeviceDelta > 0 & IMap.Direction == InputMap.ControlDirection.Positive) | (IMap.DeviceDelta < 0 & IMap.Direction == InputMap.ControlDirection.Negative))) { + DeltaValue = Convert.ToSingle(OutputPercent - RelativeLatch); + if(DeltaValue > 0) + LatchedValue += DeltaValue * 2; + } else if(IMap.GetOutputPercent() < 0.499 & ((IMap.DeviceDelta < 0 & IMap.Direction == InputMap.ControlDirection.Positive) | (IMap.DeviceDelta > 0 & IMap.Direction == InputMap.ControlDirection.Negative))) { + DeltaValue = Convert.ToSingle(OutputPercent - RelativeLatch); + if(DeltaValue < 0) + LatchedValue += DeltaValue * 2; + } + LatchedValue = Globals.Clamp(LatchedValue, 0, 1); + RelativeLatch = OutputPercent; + break; + case InputMap.ControlMode.Toggle: + if(IMap.NotchRanges.Count == 0) + return; + + if(IMap.DeviceDelta > 0 & IMap.Direction == InputMap.ControlDirection.Positive) { + Toggle += 1; + } + if(IMap.DeviceDelta > 0 & IMap.Direction == InputMap.ControlDirection.Negative) { + Toggle -= 1; + } + if(Toggle >= IMap.NotchRanges.Count) + Toggle = 0; + if(Toggle < 0) + Toggle = IMap.NotchRanges.Count - 1; + LatchedValue = Globals.Clamp(IMap.NotchRanges[Toggle], 0, 1); + break; + } + } + } + + + // InputMap Class + [Serializable()] + public class InputMap { + + public enum ControlDirection : int { + Negative = -1, + Neutral = 0, + Positive = 1 + } + public enum ControlType : int { + Assigning = -1, + NotAssigned, + Axis, + Button + } + + public enum ControlMode : int { + Slider, + NotchedSlider, + NotchedSliderRanges, + NotchedSliderTargets, + UpDownLatch, + UpDownRelative, + Toggle + } + + public int DeviceID; + + public string DeviceName { + get { + if(DeviceID < Globals.DeviceNames.Count) { + return Globals.DeviceNames[DeviceID]; + } + return ""; + } + } + public string MapName; + public ControlMode MapMode; + private int _DeviceValue; + public int DeviceValue { + get { return _DeviceValue; } + set { + DeviceDelta = value - _DeviceValue; + _DeviceValue = value; + if(GotInput != null) { + GotInput(this); + } + } + } + public int DeviceDelta; + public ControlDirection Direction; + + public ControlType TreatAs; + public List Notches; + public List NotchRanges; + + public bool IsNegativePositiveRange = false; + public event GotInputEventHandler GotInput; + public delegate void GotInputEventHandler(InputMap IMap); + + public InputMap(ControlType TreatAsValue) { + TreatAs = TreatAsValue; + MapMode = ControlMode.Slider; + Notches = new List(); + NotchRanges = new List(); + } + + public override string ToString() { + if((TreatAs == ControlType.NotAssigned)) { + return ""; + } else if((TreatAs == ControlType.Assigning)) { + return ""; + } else { + return string.Format("{0} ({1}), {2}, {3}", DeviceName, DeviceID, MapName, Direction.ToString()); + } + } + + public float GetPercent() { + + switch(TreatAs) { + case ControlType.Axis: + if(Direction == ControlDirection.Negative) { + if(IsNegativePositiveRange) + return -1 + (Globals.Clamp(1 - Convert.ToSingle(_DeviceValue / 65535), -1, 1) * 2); + return Globals.Clamp(1 - Convert.ToSingle(_DeviceValue / 65535), 0, 1); + } else { + if(IsNegativePositiveRange) + return -1 + (Globals.Clamp(Convert.ToSingle(_DeviceValue / 65535), -1, 1) * 2); + return Globals.Clamp(Convert.ToSingle(_DeviceValue / 65535), 0, 1); + } + case ControlType.Button: + if(Direction == ControlDirection.Negative) { + return 1 - Convert.ToSingle(Globals.Clamp(_DeviceValue, 0, 1)); + } else { + return Globals.Clamp(Convert.ToSingle(Globals.Clamp(_DeviceValue, 0, 1)), 0, 1); + } + } + return 0; + + } + + public float GetOutputPercent() { + float Perc = GetPercent(); + switch(MapMode) { + case ControlMode.Slider: + return Perc; + case ControlMode.NotchedSlider: + if(Notches.Count > 0) { + List ClosestNotches = GetClosestNotches(Perc, Notches); + if(IsNegativePositiveRange) + return -1 + (Globals.Clamp(Notches[ClosestNotches[0]], -1, 1) * 2); + return Globals.Clamp(Notches[ClosestNotches[0]], 0, 1); + } else { + return 0; + } + case ControlMode.NotchedSliderTargets: + if(Notches.Count > 1 & NotchRanges.Count > 1 & Notches.Count <= NotchRanges.Count) { + List ClosestNotches = GetClosestNotches(Perc, Notches); + if(IsNegativePositiveRange) + return -1 + (Globals.Clamp(NotchRanges[ClosestNotches[0]], -1, 1) * 2); + return Globals.Clamp(NotchRanges[ClosestNotches[0]], 0, 1); + } + break; + case ControlMode.NotchedSliderRanges: // TODO: to ControlMode.UpDownRelative + List ClosestNotches1 = default(List); + int ClosestNotchAbove = 0; + int ClosestNotchBelow = 0; + float NotchRange = 0; + float NotchPercent = 0; + float RangeRange = 0; + if(Notches.Count > 1 & NotchRanges.Count > 1 & Notches.Count <= NotchRanges.Count) { + ClosestNotches1 = GetClosestNotches(Perc, Notches); + ClosestNotchBelow = GetClosestNotch(false, Perc, ClosestNotches1, Notches); + ClosestNotchAbove = GetClosestNotch(true, Perc, ClosestNotches1, Notches); + NotchRange = Notches[ClosestNotchAbove] - Notches[ClosestNotchBelow]; + if(NotchRange == 0) { + NotchPercent = 0; + } else { + NotchPercent = (Perc - Notches[ClosestNotchBelow]) / NotchRange; + } + RangeRange = NotchRanges[ClosestNotchAbove] - NotchRanges[ClosestNotchBelow]; + if(IsNegativePositiveRange) + return -1 + (Globals.Clamp(NotchRanges[ClosestNotchBelow] + (RangeRange * NotchPercent), -1, 1) * 2); + return Globals.Clamp(NotchRanges[ClosestNotchBelow] + (RangeRange * NotchPercent), 0, 1); + } else { + return 0; + } + case ControlMode.Toggle: + return Perc; + } + return 0; + } + + private List GetClosestNotches(float InputPercent, List NotchList) + { + Dictionary SortDict = new Dictionary(); + float Notch = 0; + for (int I = 0; I <= NotchList.Count - 1; I++) { + Notch = NotchList[I]; + float KeyName = Math.Abs(InputPercent - Notch); + if (SortDict.ContainsKey(KeyName)) + KeyName += Convert.ToSingle(0.001); + SortDict.Add(Math.Abs(InputPercent - Notch), I); + } + List Keys = SortDict.Keys.ToList(); + Keys.Sort(); + List Ret = new List(); + foreach (float Key_loopVariable in Keys) { + float Key = Key_loopVariable; + Ret.Add(SortDict[Key]); + } + return Ret; + } + + private int GetClosestNotch(bool Above, float InputPercent, List ClosestList, List NotchList) { + switch(Above) { + case true: + for(int I = 0; I <= ClosestList.Count - 1; I++) { + if((NotchList[ClosestList[I]] >= InputPercent)) + return ClosestList[I]; + } + + return 1; + case false: + for(int I = 0; I <= ClosestList.Count - 1; I++) { + if((NotchList[ClosestList[I]] < InputPercent)) + return ClosestList[I]; + } + + return 0; + } + return 0; + } + + } +} diff --git a/RailWorks_Joystick_API/Joystick.cs b/RailWorks_Joystick_API/Joystick.cs new file mode 100644 index 0000000..1c15121 --- /dev/null +++ b/RailWorks_Joystick_API/Joystick.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.VisualBasic; +using System.Collections; +using System.Data; +using System.Diagnostics; +using Microsoft.DirectX; +using Microsoft.DirectX.DirectInput; +using System.Threading; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + public class Joystick { + + private List _Devices = new List(); + private Thread _PollThread; + private bool _Running; + private bool _IsStopped = true; + private List _lastDeviceStates = new List(); + public bool DeviceFound; + public int PollInterval = 20; + + public int AxisFilter = 0; + public event DeviceAxisChangedEventHandler DeviceAxisChanged; + public delegate void DeviceAxisChangedEventHandler(string DeviceName, int DeviceID, string AxisName, int NewValue, int Delta); + public event DeviceButtonChangedEventHandler DeviceButtonChanged; + public delegate void DeviceButtonChangedEventHandler(string DeviceName, int DeviceID, string ButtonName, int NewValue, int Delta); + + public Joystick(Form Handle) { + // Get list of attached Joysticks fron DInput + DeviceList _DeviceList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); + // If there are any devices in the list we add them and aquire them + if((_DeviceList.Count > 0)) { + foreach(DeviceInstance DevInstance in _DeviceList) { + try { + Microsoft.DirectX.DirectInput.Device TmpDev = new Device(DevInstance.InstanceGuid); + // TODO: Check to make sure we can set the cooperative lever to 0 + TmpDev.SetCooperativeLevel(Handle, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive); + TmpDev.SetDataFormat(DeviceDataFormat.Joystick); + TmpDev.Acquire(); + _Devices.Add(TmpDev); + DeviceFound = true; + } catch(Exception) { + DeviceFound = false; + break; // TODO: might not be correct. Was : Exit For + } + } + } + + } + + public void StartPolling() { + + _Running = true; + _IsStopped = false; + _PollThread = new Thread(PollThreadMain); + _PollThread.Start(); + + } + + public void StopPolling() { + _Running = false; + } + public bool IsStopped() { + return _IsStopped; + } + + public List GetDeviceNames() { + List Result = new List(); + foreach(Device Dev in _Devices) { + Result.Add(Dev.DeviceInformation.ProductName); + } + return Result; + } + + private void PollThreadMain() { + + Device _Dev = default(Device); + while(_Running) { + for(int I = 0; I <= _Devices.Count - 1; I++) { + _Dev = _Devices[I]; + _Dev.Poll(); + JoystickState _DeviceState = default(JoystickState); + _DeviceState = _Dev.CurrentJoystickState; + JoystickState j = new JoystickState(); + if((_lastDeviceStates.Count < _Devices.Count)) { + _lastDeviceStates.Add(j); + } + CheckDeviceEvents(I, ref _DeviceState, ref j); + } + Thread.Sleep(PollInterval); + } + _IsStopped = true; + } + + private void CheckDeviceEvents(int DeviceID, ref JoystickState CurrentState, ref JoystickState PreviousState) { + + // Check the Axis + CompareAxisState(DeviceID, "X", CurrentState.X, PreviousState.X); + CompareAxisState(DeviceID, "Y", CurrentState.Y, PreviousState.Y); + CompareAxisState(DeviceID, "Z", CurrentState.Z, PreviousState.Z); + CompareAxisState(DeviceID, "RX", CurrentState.Rx, PreviousState.Rx); + CompareAxisState(DeviceID, "RY", CurrentState.Ry, PreviousState.Ry); + CompareAxisState(DeviceID, "RZ", CurrentState.Rz, PreviousState.Rz); + + // Check sliders but treat them as Axis + int[] CurrentSliders = CurrentState.GetSlider(); + int[] PreviousSliders = PreviousState.GetSlider(); + for(int I = 0; I <= CurrentSliders.Length - 1; I++) { + CompareAxisState(DeviceID, "Slider" + I, CurrentSliders[I], PreviousSliders[I]); + } + + // Check POV and treat them as buttons + int[] CurrentPOV = CurrentState.GetPointOfView(); + int[] PreviousPOV = PreviousState.GetPointOfView(); + for(int I = 0; I <= _Devices[DeviceID].Caps.NumberPointOfViews - 1; I++) { + byte[] CPOVButtons = POVToButtons(CurrentPOV[I]); + byte[] PPOVButtons = POVToButtons(PreviousPOV[I]); + for(int J = 0; J <= 3; J++) { + CompareButtonState(DeviceID, "Pov" + I + ":" + J, CPOVButtons[J], PPOVButtons[J]); + } + } + + // Check the Buttons + byte[] CurrentButtons = CurrentState.GetButtons(); + byte[] PreviousButtons = PreviousState.GetButtons(); + for(int I = 0; I <= CurrentButtons.Length - 1; I++) { + CompareButtonState(DeviceID, "B" + I, CurrentButtons[I], PreviousButtons[I]); + } + + // Set the previous state to current. + PreviousState = CurrentState; + + } + + private byte[] POVToButtons(int PovState) { + byte[] Ret = new byte[4]; + switch(PovState) { + case 0: + Ret[0] = 128; + return Ret; + case 4500: + Ret[0] = 128; + Ret[1] = 128; + return Ret; + case 9000: + Ret[1] = 128; + return Ret; + case 13500: + Ret[1] = 128; + Ret[2] = 128; + return Ret; + case 18000: + Ret[2] = 128; + return Ret; + case 22500: + Ret[2] = 128; + Ret[3] = 128; + return Ret; + case 27000: + Ret[3] = 128; + return Ret; + case 31500: + Ret[3] = 128; + Ret[0] = 128; + return Ret; + default: + return Ret; + } + } + + private void CompareAxisState(int DeviceID, string Name, int NewVal, int OldVal) { + int Delta = NewVal - OldVal; + if((Math.Abs(Delta) > AxisFilter)) { + string DeviceName = _Devices[DeviceID].DeviceInformation.ProductName; + if(DeviceAxisChanged != null) { + DeviceAxisChanged(DeviceName, DeviceID, Name, NewVal, Delta); + } + } + } + + private void CompareButtonState(int DeviceID, string Name, int NewVal, int OldVal) { + int Delta = NewVal - OldVal; + if((Math.Abs(Delta) > 0)) { + string DeviceName = _Devices[DeviceID].DeviceInformation.ProductName; + if(DeviceButtonChanged != null) { + DeviceButtonChanged(DeviceName, DeviceID, Name, NewVal, Delta); + } + } + } + + } +} diff --git a/RailWorks_Joystick_API/Program.cs b/RailWorks_Joystick_API/Program.cs new file mode 100644 index 0000000..8b60930 --- /dev/null +++ b/RailWorks_Joystick_API/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + static class Program { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmMain()); + } + } +} diff --git a/RailWorks_Joystick_API/Properties/AssemblyInfo.cs b/RailWorks_Joystick_API/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a0cf130 --- /dev/null +++ b/RailWorks_Joystick_API/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("RailWorks_Joystick_API")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RailWorks_Joystick_API")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("a61c0100-31d0-4f97-bb22-a04950ce93c7")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RailWorks_Joystick_API/Properties/Resources.Designer.cs b/RailWorks_Joystick_API/Properties/Resources.Designer.cs new file mode 100644 index 0000000..3f454c9 --- /dev/null +++ b/RailWorks_Joystick_API/Properties/Resources.Designer.cs @@ -0,0 +1,1033 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.34209 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace RailWorks_Joystick_API.Properties { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RailWorks_Joystick_API.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Background { + get { + object obj = ResourceManager.GetObject("Background", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BrakeKnob { + get { + object obj = ResourceManager.GetObject("BrakeKnob", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnAlternateActive { + get { + object obj = ResourceManager.GetObject("BtnAlternateActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnAWSActive1 { + get { + object obj = ResourceManager.GetObject("BtnAWSActive1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnAWSActive2 { + get { + object obj = ResourceManager.GetObject("BtnAWSActive2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnAWSInactive { + get { + object obj = ResourceManager.GetObject("BtnAWSInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnBellActive { + get { + object obj = ResourceManager.GetObject("BtnBellActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnBlank { + get { + object obj = ResourceManager.GetObject("BtnBlank", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnCabActive { + get { + object obj = ResourceManager.GetObject("BtnCabActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnCouplingActive { + get { + object obj = ResourceManager.GetObject("BtnCouplingActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnCylinderCocksActive { + get { + object obj = ResourceManager.GetObject("BtnCylinderCocksActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnDriverGuideActive { + get { + object obj = ResourceManager.GetObject("BtnDriverGuideActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnDriverGuideInactive { + get { + object obj = ResourceManager.GetObject("BtnDriverGuideInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnEBrakeActive { + get { + object obj = ResourceManager.GetObject("BtnEBrakeActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnEBrakeInactive { + get { + object obj = ResourceManager.GetObject("BtnEBrakeInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnExternalFrontActive { + get { + object obj = ResourceManager.GetObject("BtnExternalFrontActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnExternalRearActive { + get { + object obj = ResourceManager.GetObject("BtnExternalRearActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnFreeRoamActive { + get { + object obj = ResourceManager.GetObject("BtnFreeRoamActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnHeadOutLeftActive { + get { + object obj = ResourceManager.GetObject("BtnHeadOutLeftActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnHeadOutRightActive { + get { + object obj = ResourceManager.GetObject("BtnHeadOutRightActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnHornActive { + get { + object obj = ResourceManager.GetObject("BtnHornActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnJunctionAheadActive { + get { + object obj = ResourceManager.GetObject("BtnJunctionAheadActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnJunctionAheadInactive { + get { + object obj = ResourceManager.GetObject("BtnJunctionAheadInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnJunctionBehindActive { + get { + object obj = ResourceManager.GetObject("BtnJunctionBehindActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnJunctionBehindInactive { + get { + object obj = ResourceManager.GetObject("BtnJunctionBehindInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnLightsActive1 { + get { + object obj = ResourceManager.GetObject("BtnLightsActive1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnLightsActive2 { + get { + object obj = ResourceManager.GetObject("BtnLightsActive2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnLoadUnloadActive { + get { + object obj = ResourceManager.GetObject("BtnLoadUnloadActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnManualCouplingActive { + get { + object obj = ResourceManager.GetObject("BtnManualCouplingActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnManualCouplingInactive { + get { + object obj = ResourceManager.GetObject("BtnManualCouplingInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnMapActive { + get { + object obj = ResourceManager.GetObject("BtnMapActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnMapInactive { + get { + object obj = ResourceManager.GetObject("BtnMapInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnNextCabActive { + get { + object obj = ResourceManager.GetObject("BtnNextCabActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPADAheadActive { + get { + object obj = ResourceManager.GetObject("BtnPADAheadActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPADAheadInactive { + get { + object obj = ResourceManager.GetObject("BtnPADAheadInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPADBehindActive { + get { + object obj = ResourceManager.GetObject("BtnPADBehindActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPADBehindInactive { + get { + object obj = ResourceManager.GetObject("BtnPADBehindInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPantographActive { + get { + object obj = ResourceManager.GetObject("BtnPantographActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPassengerActive { + get { + object obj = ResourceManager.GetObject("BtnPassengerActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap btnPBrakeActive { + get { + object obj = ResourceManager.GetObject("btnPBrakeActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap btnPBrakeInactive { + get { + object obj = ResourceManager.GetObject("btnPBrakeInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnPreviousCabActive { + get { + object obj = ResourceManager.GetObject("BtnPreviousCabActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnSanderActive { + get { + object obj = ResourceManager.GetObject("BtnSanderActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnSmallEjectorActive { + get { + object obj = ResourceManager.GetObject("BtnSmallEjectorActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnStarterActive { + get { + object obj = ResourceManager.GetObject("BtnStarterActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnStarterInactive { + get { + object obj = ResourceManager.GetObject("BtnStarterInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnTracksideActive { + get { + object obj = ResourceManager.GetObject("BtnTracksideActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnVigilanceActive { + get { + object obj = ResourceManager.GetObject("BtnVigilanceActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnVigilanceInactive { + get { + object obj = ResourceManager.GetObject("BtnVigilanceInactive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnWipersActive { + get { + object obj = ResourceManager.GetObject("BtnWipersActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnYardActive { + get { + object obj = ResourceManager.GetObject("BtnYardActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnZoomInActive { + get { + object obj = ResourceManager.GetObject("BtnZoomInActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap BtnZoomOutActive { + get { + object obj = ResourceManager.GetObject("BtnZoomOutActive", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ButtonControls1bg { + get { + object obj = ResourceManager.GetObject("ButtonControls1bg", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ButtonControls2bg { + get { + object obj = ResourceManager.GetObject("ButtonControls2bg", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ControlSlot { + get { + object obj = ResourceManager.GetObject("ControlSlot", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ControlSlotGear { + get { + object obj = ResourceManager.GetObject("ControlSlotGear", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi0 { + get { + object obj = ResourceManager.GetObject("Digi0", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi1 { + get { + object obj = ResourceManager.GetObject("Digi1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi2 { + get { + object obj = ResourceManager.GetObject("Digi2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi3 { + get { + object obj = ResourceManager.GetObject("Digi3", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi4 { + get { + object obj = ResourceManager.GetObject("Digi4", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi5 { + get { + object obj = ResourceManager.GetObject("Digi5", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi6 { + get { + object obj = ResourceManager.GetObject("Digi6", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi7 { + get { + object obj = ResourceManager.GetObject("Digi7", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi8 { + get { + object obj = ResourceManager.GetObject("Digi8", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Digi9 { + get { + object obj = ResourceManager.GetObject("Digi9", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap DigiBlank { + get { + object obj = ResourceManager.GetObject("DigiBlank", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap DigiDot { + get { + object obj = ResourceManager.GetObject("DigiDot", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap DigiMinus { + get { + object obj = ResourceManager.GetObject("DigiMinus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap GearKnob { + get { + object obj = ResourceManager.GetObject("GearKnob", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap LabelPanel { + get { + object obj = ResourceManager.GetObject("LabelPanel", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ReverserKnob { + get { + object obj = ResourceManager.GetObject("ReverserKnob", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBg200Day { + get { + object obj = ResourceManager.GetObject("SpeedoBg200Day", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBg200KPHDay { + get { + object obj = ResourceManager.GetObject("SpeedoBg200KPHDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBg300KPHDay { + get { + object obj = ResourceManager.GetObject("SpeedoBg300KPHDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBg360KPHDay { + get { + object obj = ResourceManager.GetObject("SpeedoBg360KPHDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgBlue { + get { + object obj = ResourceManager.GetObject("SpeedoBgBlue", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgDay { + get { + object obj = ResourceManager.GetObject("SpeedoBgDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLarge200Day { + get { + object obj = ResourceManager.GetObject("SpeedoBgLarge200Day", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLarge200KPHDay { + get { + object obj = ResourceManager.GetObject("SpeedoBgLarge200KPHDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLarge300KPHDay { + get { + object obj = ResourceManager.GetObject("SpeedoBgLarge300KPHDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLarge360KPHDay { + get { + object obj = ResourceManager.GetObject("SpeedoBgLarge360KPHDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLargeBlue { + get { + object obj = ResourceManager.GetObject("SpeedoBgLargeBlue", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLargeDay { + get { + object obj = ResourceManager.GetObject("SpeedoBgLargeDay", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgLargeOrange { + get { + object obj = ResourceManager.GetObject("SpeedoBgLargeOrange", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoBgOrange { + get { + object obj = ResourceManager.GetObject("SpeedoBgOrange", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoGlass120 { + get { + object obj = ResourceManager.GetObject("SpeedoGlass120", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoGlass200 { + get { + object obj = ResourceManager.GetObject("SpeedoGlass200", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoGlassLarge120 { + get { + object obj = ResourceManager.GetObject("SpeedoGlassLarge120", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoGlassLarge200 { + get { + object obj = ResourceManager.GetObject("SpeedoGlassLarge200", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoIndicator { + get { + object obj = ResourceManager.GetObject("SpeedoIndicator", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoIndicatorBlue { + get { + object obj = ResourceManager.GetObject("SpeedoIndicatorBlue", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoIndicatorLarge { + get { + object obj = ResourceManager.GetObject("SpeedoIndicatorLarge", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap SpeedoIndicatorLargeBlue { + get { + object obj = ResourceManager.GetObject("SpeedoIndicatorLargeBlue", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThrottleBrakeHandle { + get { + object obj = ResourceManager.GetObject("ThrottleBrakeHandle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ThrottleHandle { + get { + object obj = ResourceManager.GetObject("ThrottleHandle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/RailWorks_Joystick_API/Properties/Resources.resx b/RailWorks_Joystick_API/Properties/Resources.resx new file mode 100644 index 0000000..0eca9cc --- /dev/null +++ b/RailWorks_Joystick_API/Properties/Resources.resx @@ -0,0 +1,412 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Images\Background.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BrakeKnob.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnAlternateActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnAWSActive1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnAWSActive2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnAWSInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnBellActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnBlank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnCabActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnCouplingActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnCylinderCocksActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnDriverGuideActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnDriverGuideInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnEBrakeActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnEBrakeInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnExternalFrontActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnExternalRearActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnFreeRoamActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnHeadOutLeftActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnHeadOutRightActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnHornActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnJunctionAheadActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnJunctionAheadInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnJunctionBehindActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnJunctionBehindInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnLightsActive1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnLightsActive2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnLoadUnloadActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnManualCouplingActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnManualCouplingInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnMapActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnMapInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnNextCabActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPADAheadActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPADAheadInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPADBehindActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPADBehindInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPantographActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPassengerActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\btnPBrakeActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\btnPBrakeInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnPreviousCabActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnSanderActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnSmallEjectorActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnStarterActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnStarterInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnTracksideActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnVigilanceActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnVigilanceInactive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnWipersActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnYardActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnZoomInActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\BtnZoomOutActive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ButtonControls1bg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ButtonControls2bg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ControlSlot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ControlSlotGear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi0.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi3.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi4.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi6.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi7.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi8.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\Digi9.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\DigiBlank.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\DigiDot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\DigiMinus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\GearKnob.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\LabelPanel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ReverserKnob.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBg200Day.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBg200KPHDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBg300KPHDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBg360KPHDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgBlue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLarge200Day.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLarge200KPHDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLarge300KPHDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLarge360KPHDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLargeBlue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLargeDay.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgLargeOrange.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoBgOrange.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoGlass120.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoGlass200.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoGlassLarge120.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoGlassLarge200.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoIndicator.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoIndicatorBlue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoIndicatorLarge.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\SpeedoIndicatorLargeBlue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ThrottleBrakeHandle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Images\ThrottleHandle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/RailWorks_Joystick_API/Properties/Settings.Designer.cs b/RailWorks_Joystick_API/Properties/Settings.Designer.cs new file mode 100644 index 0000000..93ec3ab --- /dev/null +++ b/RailWorks_Joystick_API/Properties/Settings.Designer.cs @@ -0,0 +1,110 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.34209 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace RailWorks_Joystick_API.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("30000")] + public long MinDelay { + get { + return ((long)(this["MinDelay"])); + } + set { + this["MinDelay"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("90000")] + public long MaxDelay { + get { + return ((long)(this["MaxDelay"])); + } + set { + this["MaxDelay"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0.5")] + public float EarlyTriggerChance { + get { + return ((float)(this["EarlyTriggerChance"])); + } + set { + this["EarlyTriggerChance"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0.1")] + public float TrainSpeedOffset { + get { + return ((float)(this["TrainSpeedOffset"])); + } + set { + this["TrainSpeedOffset"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("5000")] + public long TriggerTimeout { + get { + return ((long)(this["TriggerTimeout"])); + } + set { + this["TriggerTimeout"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0.2")] + public float MinimumTrainSpeed { + get { + return ((float)(this["MinimumTrainSpeed"])); + } + set { + this["MinimumTrainSpeed"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool UseVigilance { + get { + return ((bool)(this["UseVigilance"])); + } + set { + this["UseVigilance"] = value; + } + } + } +} diff --git a/RailWorks_Joystick_API/Properties/Settings.settings b/RailWorks_Joystick_API/Properties/Settings.settings new file mode 100644 index 0000000..54a9c5b --- /dev/null +++ b/RailWorks_Joystick_API/Properties/Settings.settings @@ -0,0 +1,27 @@ + + + + + + 30000 + + + 90000 + + + 0.5 + + + 0.1 + + + 5000 + + + 0.2 + + + True + + + \ No newline at end of file diff --git a/RailWorks_Joystick_API/RailWorks_Joystick_API.csproj b/RailWorks_Joystick_API/RailWorks_Joystick_API.csproj new file mode 100644 index 0000000..af31fae --- /dev/null +++ b/RailWorks_Joystick_API/RailWorks_Joystick_API.csproj @@ -0,0 +1,241 @@ + + + + + Debug + AnyCPU + {5420C2F8-42A0-4A9C-9DFF-5AC66FF19B49} + WinExe + Properties + RailWorks_Joystick_API + RailWorks_Joystick_API + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.dll + + + False + C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.DirectInput.dll + + + + + + + + + + + + + + + + + + + + + Form + + + frmControls.cs + + + Form + + + frmMain.cs + + + Form + + + frmManageControls.cs + + + Form + + + frmSpeedo.cs + + + Form + + + frmVigilanceSystem.cs + + + + + + + + ucControls.xaml + + + ucLargeSpeedo.xaml + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RailWorks_Joystick_API/VigilanceSystem.cs b/RailWorks_Joystick_API/VigilanceSystem.cs new file mode 100644 index 0000000..d3f63ff --- /dev/null +++ b/RailWorks_Joystick_API/VigilanceSystem.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.VisualBasic; +using Microsoft.VisualBasic.Devices; + +namespace RailWorks_Joystick_API { + public class VigilanceSystem { + + public Stopwatch AlertTimer; + + public Stopwatch TriggerTimer; + public long MinDelay = 5000; + public long MaxDelay = 10000; + public float EarlyTriggerChance = 0.5f; + + public long EarlyTriggerOffset = 0; + public bool UseVigilanceSystem = false; + public float LastTrainSpeed; + public float MinimumTrainSpeed = 0.5f; + public long TrainSpeedOffset = 0; + + public float TrainSpeedOffsetFactor = 0.1f; + + public Actions ButtonState = Actions.Release; + + public long TriggerTimeout = 5000; + + public bool InGame = false; + public Audio audio = new Audio(); + public enum Actions { + Press, + Release + } + + public enum VigilanceState { + Vigilant, + Alert, + Triggered + } + + + public VigilanceState State = VigilanceState.Vigilant; + + public Actions ActionRequired = Actions.Release; + + private Thread VigilanceThread; + public VigilanceSystem() { + Start(); + } + + public void Start() { + Running = true; + AlertTimer = new Stopwatch(); + TriggerTimer = new Stopwatch(); + VigilanceThread = new Thread(VigilanceThreadMain); + VigilanceThread.IsBackground = true; + VigilanceThread.Start(); + } + + + public bool Running = false; + public void VigilanceThreadMain() { + + VBMath.Randomize(); + //bool EarlyTrigger = false; + while(Running) { + if(!UseVigilanceSystem) + continue; + if(AlertTimer == null | TriggerTimer == null) { + AlertTimer = new Stopwatch(); + TriggerTimer = new Stopwatch(); + } + if(!InGame) { + FileSystem.Reset(); + continue; + } + if(!AlertTimer.IsRunning) { + AlertTimer.Reset(); + AlertTimer.Start(); + if(VBMath.Rnd() < EarlyTriggerChance) { + EarlyTriggerOffset = Convert.ToInt32(VBMath.Rnd() * (MaxDelay - MinDelay)); + } else { + EarlyTriggerOffset = 0; + } + } + + long MS = AlertTimer.ElapsedMilliseconds; + + if(LastTrainSpeed < MinimumTrainSpeed & !(State == VigilanceState.Triggered)) { + FileSystem.Reset(); + continue; + } + if(MS < MinDelay & !TriggerTimer.IsRunning) { + ActionRequired = Actions.Press; + } + TrainSpeedOffset = Convert.ToInt64((LastTrainSpeed * TrainSpeedOffsetFactor) * 1000); + if(MS >= MaxDelay - EarlyTriggerOffset - TrainSpeedOffset & !TriggerTimer.IsRunning) { + ActionRequired = Actions.Release; + TriggerTimer.Reset(); + TriggerTimer.Start(); + } + if(ButtonState == ActionRequired) { + if(State == VigilanceState.Triggered & !(LastTrainSpeed < MinimumTrainSpeed)) { + } else { + if(TriggerTimer.IsRunning) + FileSystem.Reset(); + ChangeState(VigilanceState.Vigilant); + } + } else { + if(!(State == VigilanceState.Triggered)) + ChangeState(VigilanceState.Alert); + if(!TriggerTimer.IsRunning) { + TriggerTimer.Reset(); + TriggerTimer.Start(); + } + } + if(TriggerTimer.IsRunning & TriggerTimer.ElapsedMilliseconds > TriggerTimeout) { + ChangeState(VigilanceState.Triggered); + } + Thread.Sleep(100); + } + + } + + public void ChangeState(VigilanceState NewState) { + if(State == NewState) + return; + State = NewState; + //Debug.Print("Changed state to " & State.ToString) + switch(State) { + case VigilanceState.Vigilant: + audio.Stop(); + break; + case VigilanceState.Alert: + audio.Play("VigilanceAlert.wav", AudioPlayMode.BackgroundLoop); + break; + case VigilanceState.Triggered: + audio.Play("VigilanceTriggered.wav", AudioPlayMode.BackgroundLoop); + break; + } + } + + public void Reset() { + AlertTimer.Stop(); + AlertTimer.Reset(); + TriggerTimer.Stop(); + TriggerTimer.Reset(); + ActionRequired = Actions.Release; + audio.Stop(); + ChangeState(VigilanceState.Vigilant); + } + + } +} diff --git a/RailWorks_Joystick_API/app.config b/RailWorks_Joystick_API/app.config new file mode 100644 index 0000000..a1d407a --- /dev/null +++ b/RailWorks_Joystick_API/app.config @@ -0,0 +1,33 @@ + + + + +
+ + + + + + 30000 + + + 90000 + + + 0.5 + + + 0.1 + + + 5000 + + + 0.2 + + + True + + + + \ No newline at end of file diff --git a/RailWorks_Joystick_API/frmControls.Designer.cs b/RailWorks_Joystick_API/frmControls.Designer.cs new file mode 100644 index 0000000..4f789d6 --- /dev/null +++ b/RailWorks_Joystick_API/frmControls.Designer.cs @@ -0,0 +1,62 @@ +namespace RailWorks_Joystick_API { + partial class frmControls { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.ElementHost1 = new System.Windows.Forms.Integration.ElementHost(); + this.ControlsGUI = new RailWorks_Joystick_API.ucControls(); + this.Timer1 = new System.Windows.Forms.Timer(this.components); + this.SuspendLayout(); + // + // ElementHost1 + // + this.ElementHost1.Location = new System.Drawing.Point(0, 0); + this.ElementHost1.Name = "ElementHost1"; + this.ElementHost1.Size = new System.Drawing.Size(674, 500); + this.ElementHost1.TabIndex = 0; + this.ElementHost1.Text = "ElementHost1"; + this.ElementHost1.Child = this.ControlsGUI; + // + // Timer1 + // + // + // frmControls + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(673, 500); + this.Controls.Add(this.ElementHost1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "frmControls"; + this.Text = "Controls"; + this.ResumeLayout(false); + } + + private System.Windows.Forms.Integration.ElementHost ElementHost1; + private RailWorks_Joystick_API.ucControls ControlsGUI; + private System.Windows.Forms.Timer Timer1; + + #endregion + } +} \ No newline at end of file diff --git a/RailWorks_Joystick_API/frmControls.cs b/RailWorks_Joystick_API/frmControls.cs new file mode 100644 index 0000000..47fe39e --- /dev/null +++ b/RailWorks_Joystick_API/frmControls.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + public partial class frmControls : Form { + + + public float Speed; + + public float Cycle; + + public int ActiveButton; + + private void SetupAnalogControls(string ControlName, string Description) { + SetupMap(ControlName, Description); + Globals.ControlManager.Show(); + } + + private void SetupButtonControls(string ControlName, string Description) { + SetupMap(ControlName, Description); + Globals.ControlManager.Show(); + } + + public void UpdateControls(Dictionary DataMap) { + // Update the speedometer + ControlsGUI.Speed = DataMap["Speed"]; + if ((Globals.SpeedoWindow.Visible == true)) { + Globals.SpeedoWindow.SetSpeed(DataMap["Speed"]); + } + if ((DataMap.Count == 1)) { + return; + } + // Update throttle etc + ControlsGUI.Throttle.SetPercent(DataMap["Throttle"]); + ControlsGUI.TrainBrakes.SetPercent(DataMap["TrainBrake"]); + ControlsGUI.LocomotiveBrakes.SetPercent(DataMap["LocomotiveBrake"]); + ControlsGUI.DynamicBrakes.SetPercent(DataMap["DynamicBrake"]); + ControlsGUI.Reverser.SetPercent(DataMap["Reverser"]); + ControlsGUI.Gear.SetPercent(DataMap["Gear"]); + } + + public void SetupMap(string ControlName, string Description) { + switch (ControlName) { + case "Throttle": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Throttle; + break; + case "TrainBrake": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.TrainBrake; + break; + case "LocomotiveBrake": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.LocomotiveBrake; + break; + case "DynamicBrake": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.DynamicBrake; + break; + case "Reverser": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Reverser; + break; + case "Gear": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.GearLever; + break; + case "Wipers": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Wipers; + break; + case "Lights": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Headlights; + break; + case "Pantograph": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Pantograph; + break; + case "LoadUnload": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.LoadCargo; + break; + case "Sander": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Sander; + break; + case "SmallEjector": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.SmallCompressor; + break; + case "Horn": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Horn; + break; + case "CylinderCocks": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.CylinderCock; + break; + case "HeadOutLeft": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.HeadOutCamera; + break; + case "Cab": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.CabCamera; + break; + case "HeadOutRight": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.HeadOutCamera; + break; + case "Trackside": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.TrainBrake; + break; + case "ExternalFront": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.FollowCamera; + break; + case "ExternalRear": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.RearCamera; + break; + case "NextCab": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.SwitchToNextFrontCab; + break; + case "PreviousCab": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.SwitchToNextRearCab; + break; + case "Coupling": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.CouplingCamera; + break; + case "Yard": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.YardCamera; + break; + case "FreeRoam": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.FreeCamera; + break; + case "Starter": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.StartStopEngine; + break; + case "ManualCoupling": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.ManualCouple; + break; + case "AWS": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.AWSReset; + break; + case "EBrake": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.EmergencyBrake; + break; + case "PBrake": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.HandBrake; + break; + case "DriverGuide": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.DriverGuide; + break; + case "Map": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Toggle2DMap; + break; + case "PADAhead": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.PassAtDangerAhead; + break; + case "PADBehind": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.PassAtDangerBehind; + break; + case "JunctionAhead": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.SwitchJunktionAhead; + break; + case "JunctionBehind": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.SwitchJunktionBehind; + break; + case "Vigilance": + Globals.ControlManager.APIMapIndex = (int)InputHandler.ActionList.Vigilance; + break; + default: + Debug.Print(("Unknown/Unhandled control: " + ControlName)); + return; + } + Globals.ControlManager.Description = Description; + Globals.ControlManager.InputMapIndex = -1; + Globals.ControlManager.LoadControlMap(); + } + + private void frmControls_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { + this.Visible = false; + e.Cancel = true; + } + + // Old testing code, not used... + private float Spd; + + private void Timer1_Tick(object sender, System.EventArgs e) { + Timer1.Interval = 10; + Spd = (Spd + ((float)(0.3))); + Dictionary DataMap = new Dictionary(); + DataMap.Add("Speed", Spd); + UpdateControls(DataMap); + if ((Spd > 250)) { + Spd = 0; + } + } + + public frmControls() { + InitializeComponent(); + this.ControlsGUI.SetupAnalogControls += SetupAnalogControls; + this.ControlsGUI.SetupButtonControls += SetupButtonControls; + this.FormClosing +=frmControls_FormClosing; + this.Timer1.Tick+=Timer1_Tick; + } + } +} diff --git a/RailWorks_Joystick_API/frmMain.Designer.cs b/RailWorks_Joystick_API/frmMain.Designer.cs new file mode 100644 index 0000000..58ed982 --- /dev/null +++ b/RailWorks_Joystick_API/frmMain.Designer.cs @@ -0,0 +1,252 @@ +namespace RailWorks_Joystick_API { + partial class frmMain { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.Closer = new System.Windows.Forms.Timer(this.components); + this.txtDevStatus = new System.Windows.Forms.TextBox(); + this.TabControl1 = new System.Windows.Forms.TabControl(); + this.HomeTab = new System.Windows.Forms.TabPage(); + this.gbShiftMappings = new System.Windows.Forms.GroupBox(); + this.btnShiftUp = new System.Windows.Forms.Button(); + this.btnShiftDown = new System.Windows.Forms.Button(); + this.btnRemoveSelected = new System.Windows.Forms.Button(); + this.btnDuplicateSelected = new System.Windows.Forms.Button(); + this.btnSaveSelected = new System.Windows.Forms.Button(); + this.btnNew = new System.Windows.Forms.Button(); + this.btnLoadSelected = new System.Windows.Forms.Button(); + this.lstSettings = new System.Windows.Forms.ListBox(); + this.btnShowLargeSpeedo = new System.Windows.Forms.Button(); + this.ShowControlsBtn = new System.Windows.Forms.Button(); + this.DebugTab = new System.Windows.Forms.TabPage(); + this.lblCurrentDevice = new System.Windows.Forms.Label(); + this.btnAllDevice = new System.Windows.Forms.Button(); + this.btnNextDevice = new System.Windows.Forms.Button(); + this.btnPrevDevice = new System.Windows.Forms.Button(); + this.btnVigilanceSettings = new System.Windows.Forms.Button(); + this.TabControl1.SuspendLayout(); + this.HomeTab.SuspendLayout(); + this.gbShiftMappings.SuspendLayout(); + this.DebugTab.SuspendLayout(); + this.SuspendLayout(); + // + // Closer + // + this.Closer.Interval = 200; + // + // txtDevStatus + // + this.txtDevStatus.Font = new System.Drawing.Font("Lucida Console", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtDevStatus.Location = new System.Drawing.Point(0, 35); + this.txtDevStatus.Multiline = true; + this.txtDevStatus.Name = "txtDevStatus"; + this.txtDevStatus.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtDevStatus.Size = new System.Drawing.Size(811, 560); + this.txtDevStatus.TabIndex = 0; + // + // TabControl1 + // + this.TabControl1.Controls.Add(this.HomeTab); + this.TabControl1.Controls.Add(this.DebugTab); + this.TabControl1.Location = new System.Drawing.Point(12, 12); + this.TabControl1.Name = "TabControl1"; + this.TabControl1.SelectedIndex = 0; + this.TabControl1.Size = new System.Drawing.Size(822, 617); + this.TabControl1.TabIndex = 1; + // + // HomeTab + // + this.HomeTab.Controls.Add(this.btnVigilanceSettings); + this.HomeTab.Controls.Add(this.gbShiftMappings); + this.HomeTab.Controls.Add(this.btnRemoveSelected); + this.HomeTab.Controls.Add(this.btnDuplicateSelected); + this.HomeTab.Controls.Add(this.btnSaveSelected); + this.HomeTab.Controls.Add(this.btnNew); + this.HomeTab.Controls.Add(this.btnLoadSelected); + this.HomeTab.Controls.Add(this.lstSettings); + this.HomeTab.Controls.Add(this.btnShowLargeSpeedo); + this.HomeTab.Controls.Add(this.ShowControlsBtn); + this.HomeTab.Location = new System.Drawing.Point(4, 22); + this.HomeTab.Name = "HomeTab"; + this.HomeTab.Padding = new System.Windows.Forms.Padding(3); + this.HomeTab.Size = new System.Drawing.Size(814, 591); + this.HomeTab.TabIndex = 0; + this.HomeTab.Text = "Home"; + this.HomeTab.UseVisualStyleBackColor = true; + this.gbShiftMappings.Controls.Add(this.btnShiftUp); + this.gbShiftMappings.Controls.Add(this.btnShiftDown); + this.gbShiftMappings.Location = new System.Drawing.Point(6, 383); + this.gbShiftMappings.Name = "gbShiftMappings"; + this.gbShiftMappings.Size = new System.Drawing.Size(169, 51); + this.gbShiftMappings.TabIndex = 4; + this.gbShiftMappings.TabStop = false; + this.gbShiftMappings.Text = "Shift all mapped devices..."; + this.btnShiftUp.Location = new System.Drawing.Point(87, 19); + this.btnShiftUp.Name = "btnShiftUp"; + this.btnShiftUp.Size = new System.Drawing.Size(75, 22); + this.btnShiftUp.TabIndex = 3; + this.btnShiftUp.Text = "Up"; + this.btnShiftUp.UseVisualStyleBackColor = true; + this.btnShiftDown.Location = new System.Drawing.Point(6, 19); + this.btnShiftDown.Name = "btnShiftDown"; + this.btnShiftDown.Size = new System.Drawing.Size(75, 22); + this.btnShiftDown.TabIndex = 3; + this.btnShiftDown.Text = "Down"; + this.btnShiftDown.UseVisualStyleBackColor = true; + this.btnRemoveSelected.Location = new System.Drawing.Point(330, 354); + this.btnRemoveSelected.Name = "btnRemoveSelected"; + this.btnRemoveSelected.Size = new System.Drawing.Size(75, 23); + this.btnRemoveSelected.TabIndex = 2; + this.btnRemoveSelected.Text = "Remove"; + this.btnRemoveSelected.UseVisualStyleBackColor = true; + this.btnDuplicateSelected.Location = new System.Drawing.Point(249, 354); + this.btnDuplicateSelected.Name = "btnDuplicateSelected"; + this.btnDuplicateSelected.Size = new System.Drawing.Size(75, 23); + this.btnDuplicateSelected.TabIndex = 2; + this.btnDuplicateSelected.Text = "Duplicate"; + this.btnDuplicateSelected.UseVisualStyleBackColor = true; + this.btnSaveSelected.Location = new System.Drawing.Point(168, 354); + this.btnSaveSelected.Name = "btnSaveSelected"; + this.btnSaveSelected.Size = new System.Drawing.Size(75, 23); + this.btnSaveSelected.TabIndex = 2; + this.btnSaveSelected.Text = "Save"; + this.btnSaveSelected.UseVisualStyleBackColor = true; + this.btnNew.Location = new System.Drawing.Point(6, 354); + this.btnNew.Name = "btnNew"; + this.btnNew.Size = new System.Drawing.Size(75, 23); + this.btnNew.TabIndex = 2; + this.btnNew.Text = "New"; + this.btnNew.UseVisualStyleBackColor = true; + this.btnLoadSelected.Location = new System.Drawing.Point(87, 354); + this.btnLoadSelected.Name = "btnLoadSelected"; + this.btnLoadSelected.Size = new System.Drawing.Size(75, 23); + this.btnLoadSelected.TabIndex = 2; + this.btnLoadSelected.Text = "Load"; + this.btnLoadSelected.UseVisualStyleBackColor = true; + this.lstSettings.FormattingEnabled = true; + this.lstSettings.Location = new System.Drawing.Point(6, 6); + this.lstSettings.Name = "lstSettings"; + this.lstSettings.Size = new System.Drawing.Size(399, 342); + this.lstSettings.TabIndex = 1; + // + // btnShowLargeSpeedo + // + this.btnShowLargeSpeedo.Location = new System.Drawing.Point(692, 49); + this.btnShowLargeSpeedo.Name = "btnShowLargeSpeedo"; + this.btnShowLargeSpeedo.Size = new System.Drawing.Size(116, 52); + this.btnShowLargeSpeedo.TabIndex = 0; + this.btnShowLargeSpeedo.Text = "Show Large Speedometer"; + this.btnShowLargeSpeedo.UseVisualStyleBackColor = true; + this.ShowControlsBtn.Location = new System.Drawing.Point(692, 6); + this.ShowControlsBtn.Name = "ShowControlsBtn"; + this.ShowControlsBtn.Size = new System.Drawing.Size(116, 37); + this.ShowControlsBtn.TabIndex = 0; + this.ShowControlsBtn.Text = "Show Controls"; + this.ShowControlsBtn.UseVisualStyleBackColor = true; + this.DebugTab.BackColor = System.Drawing.SystemColors.ButtonFace; + this.DebugTab.Controls.Add(this.lblCurrentDevice); + this.DebugTab.Controls.Add(this.btnAllDevice); + this.DebugTab.Controls.Add(this.btnNextDevice); + this.DebugTab.Controls.Add(this.btnPrevDevice); + this.DebugTab.Controls.Add(this.txtDevStatus); + this.DebugTab.Location = new System.Drawing.Point(4, 22); + this.DebugTab.Name = "DebugTab"; + this.DebugTab.Padding = new System.Windows.Forms.Padding(3); + this.DebugTab.Size = new System.Drawing.Size(814, 591); + this.DebugTab.TabIndex = 1; + this.DebugTab.Text = "Debug"; + this.lblCurrentDevice.Font = new System.Drawing.Font("Arial", 9.75f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblCurrentDevice.Location = new System.Drawing.Point(318, 6); + this.lblCurrentDevice.Name = "lblCurrentDevice"; + this.lblCurrentDevice.Size = new System.Drawing.Size(490, 23); + this.lblCurrentDevice.TabIndex = 2; + this.lblCurrentDevice.Text = "Listening to: ALL Devices..."; + this.lblCurrentDevice.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // btnAllDevice + // + this.btnAllDevice.Location = new System.Drawing.Point(110, 6); + this.btnAllDevice.Name = "btnAllDevice"; + this.btnAllDevice.Size = new System.Drawing.Size(98, 23); + this.btnAllDevice.TabIndex = 1; + this.btnAllDevice.Text = "Listen to all"; + this.btnAllDevice.UseVisualStyleBackColor = true; + this.btnNextDevice.Location = new System.Drawing.Point(214, 6); + this.btnNextDevice.Name = "btnNextDevice"; + this.btnNextDevice.Size = new System.Drawing.Size(98, 23); + this.btnNextDevice.TabIndex = 1; + this.btnNextDevice.Text = "Next Device"; + this.btnNextDevice.UseVisualStyleBackColor = true; + this.btnPrevDevice.Location = new System.Drawing.Point(6, 6); + this.btnPrevDevice.Name = "btnPrevDevice"; + this.btnPrevDevice.Size = new System.Drawing.Size(98, 23); + this.btnPrevDevice.TabIndex = 1; + this.btnPrevDevice.Text = "Previous Device"; + this.btnPrevDevice.UseVisualStyleBackColor = true; + this.btnVigilanceSettings.Location = new System.Drawing.Point(692, 107); + this.btnVigilanceSettings.Name = "btnVigilanceSettings"; + this.btnVigilanceSettings.Size = new System.Drawing.Size(116, 52); + this.btnVigilanceSettings.TabIndex = 5; + this.btnVigilanceSettings.Text = "Show Vigilance System Settings"; + this.btnVigilanceSettings.UseVisualStyleBackColor = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(846, 641); + this.Controls.Add(this.TabControl1); + this.Name = "frmMain"; + this.Text = "RailWorks Joystick API"; + this.TabControl1.ResumeLayout(false); + this.HomeTab.ResumeLayout(false); + this.gbShiftMappings.ResumeLayout(false); + this.DebugTab.ResumeLayout(false); + this.DebugTab.PerformLayout(); + this.ResumeLayout(false); + } + + + private System.Windows.Forms.Timer Closer; + private System.Windows.Forms.TextBox txtDevStatus; + private System.Windows.Forms.TabControl TabControl1; + private System.Windows.Forms.TabPage HomeTab; + private System.Windows.Forms.TabPage DebugTab; + private System.Windows.Forms.Button btnPrevDevice; + private System.Windows.Forms.Button btnNextDevice; + private System.Windows.Forms.Button ShowControlsBtn; + private System.Windows.Forms.Button btnRemoveSelected; + private System.Windows.Forms.Button btnDuplicateSelected; + private System.Windows.Forms.Button btnSaveSelected; + private System.Windows.Forms.Button btnLoadSelected; + private System.Windows.Forms.ListBox lstSettings; + private System.Windows.Forms.Button btnNew; + private System.Windows.Forms.Button btnShowLargeSpeedo; + private System.Windows.Forms.Button btnAllDevice; + private System.Windows.Forms.Label lblCurrentDevice; + private System.Windows.Forms.GroupBox gbShiftMappings; + private System.Windows.Forms.Button btnShiftUp; + private System.Windows.Forms.Button btnShiftDown; + private System.Windows.Forms.Button btnVigilanceSettings; + + #endregion + } +} \ No newline at end of file diff --git a/RailWorks_Joystick_API/frmMain.cs b/RailWorks_Joystick_API/frmMain.cs new file mode 100644 index 0000000..eaa5c98 --- /dev/null +++ b/RailWorks_Joystick_API/frmMain.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + public partial class frmMain : Form { + + private void frmMain_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { + Globals.JoyDevices.StopPolling(); + Globals.IHandler.StopAPI(); + Globals.ControlManager.Running = false; + if(!(Globals.JoyDevices.IsStopped() && Globals.IHandler.IsStopped())) { + Closer.Enabled = true; + e.Cancel = true; + } + Globals.ControlManager.Close(); + } + + private void frmMain_Load(object sender, System.EventArgs e) { + Globals.JoyDevices = new Joystick(this); + if(!Globals.JoyDevices.DeviceFound) { + MessageBox.Show("No devices found!", "Error",MessageBoxButtons.OK,MessageBoxIcon.Stop); + } + Globals.DeviceNames = Globals.JoyDevices.GetDeviceNames(); + Globals.DevStatus = txtDevStatus; + Globals.DevStatus.Text = string.Join("\r\n", Globals.DeviceNames.ToArray()); + this.Show(); + Application.DoEvents(); + Globals.IHandler = new InputHandler(Globals.DeviceNames); + System.Threading.Thread.Sleep(100); + Globals.JoyDevices.StartPolling(); + Globals.IHandler.StartAPI(); + FileVersionInfo VI = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); + Text += (" (VERSION: "+ (VI.ProductMajorPart.ToString() + ("."+ (VI.ProductMinorPart.ToString() + (" BUILD: "+ (VI.ProductBuildPart.ToString() + ")")))))); + PopulateSettingsList(); + } + + private void PopulateSettingsList() { + DirectoryInfo DI = new DirectoryInfo(Application.StartupPath); + FileInfo[] Files = DI.GetFiles("*.CMAP"); + lstSettings.Items.Clear(); + foreach (FileInfo FI in Files) { + lstSettings.Items.Add(FI.Name); + } + } + + private void ShowControlsBtn_Click(object sender, System.EventArgs e) { + Globals.ControlsWindow.Show(); + } + + private void btnShowLargeSpeedo_Click(object sender, System.EventArgs e) { + Globals.SpeedoWindow.Show(); + } + + private void btnVigilanceSettings_Click(object sender, System.EventArgs e) { + new frmVigilanceSystem().Show(); + } + + private void Closer_Tick(object sender, System.EventArgs e) { + this.Close(); + } + + private void btnNew_Click(object sender, System.EventArgs e) { + string FileName = Microsoft.VisualBasic.Interaction.InputBox(("!!! THIS WILL CLEAR ANY CHANGES MADE SINCE LAST SAVE !!!" + ("\r\n" + ("\r\n" + "Enter filename:"))), "Create new settings"); + if((FileName == "")) { + return; + } + + FileName += ".CMap"; + Globals.ControlsWindow.Visible = false; + Globals.ControlManager.Visible = false; + Globals.IHandler.LoadBlank(); + Globals.IHandler.SaveMaps(FileName); + PopulateSettingsList(); + } + + private void btnLoadSelected_Click(object sender, System.EventArgs e) { + if((lstSettings.SelectedIndex == -1)) { + return; + } + Globals.ControlsWindow.Visible = false; + Globals.ControlManager.Visible = false; + Globals.IHandler.LoadMaps(lstSettings.Items[lstSettings.SelectedIndex].ToString()); + PopulateSettingsList(); + } + + private void btnSaveSelected_Click(object sender, System.EventArgs e) { + if((lstSettings.SelectedIndex == -1)) { + return; + } + Globals.IHandler.SaveMaps(lstSettings.Items[lstSettings.SelectedIndex].ToString()); + PopulateSettingsList(); + } + + private void btnDuplicateSelected_Click(object sender, System.EventArgs e) { + if((lstSettings.SelectedIndex == -1)) { + return; + } + string FileName = Microsoft.VisualBasic.Interaction.InputBox(("This will copy the selected file, did you save first?" + ("\r\n" + ("\r\n" + "Enter filename:"))), "Create new settings"); + if((FileName == "")) { + return; + } + FileName += ".CMap"; + try { + File.Copy(lstSettings.Items[lstSettings.SelectedIndex].ToString(), FileName); + } catch(Exception) { + MessageBox.Show("The file could not be duplicated/copied!"); + } + PopulateSettingsList(); + } + + private void btnRemoveSelected_Click(object sender, System.EventArgs e) { + if((lstSettings.SelectedIndex == -1)) { + return; + } + MessageBox.Show("This will delete the selected file! Are you sure?", "Are you sure?",MessageBoxButtons.YesNo); + File.Delete(lstSettings.Items[lstSettings.SelectedIndex].ToString()); + PopulateSettingsList(); + } + + private void btnPrevDevice_Click(object sender, System.EventArgs e) { + Globals.DevStatusID = Globals.Clamp((Globals.DevStatusID - 1), 0, (Globals.DeviceNames.Count - 1)); + lblCurrentDevice.Text = ("Listening to: " + Globals.DeviceNames[Globals.DevStatusID]); + } + + private void btnNextDevice_Click(object sender, System.EventArgs e) { + Globals.DevStatusID = Globals.Clamp((Globals.DevStatusID + 1), 0, (Globals.DeviceNames.Count - 1)); + lblCurrentDevice.Text = ("Listening to: " + Globals.DeviceNames[Globals.DevStatusID]); + } + + private void btnAllDevice_Click(object sender, System.EventArgs e) { + Globals.DevStatusID = -1; + lblCurrentDevice.Text = "Listening to: ALL Devices..."; + } + + private void btnShiftDown_Click(object sender, System.EventArgs e) { + Globals.IHandler.ShiftMaps(-1); + } + + private void btnShiftUp_Click(object sender, System.EventArgs e) { + Globals.IHandler.ShiftMaps(1); + } + + public frmMain() { + InitializeComponent(); + this.FormClosing += frmMain_FormClosing; + this.Load += frmMain_Load; + this.ShowControlsBtn.Click +=ShowControlsBtn_Click; + this.btnShowLargeSpeedo.Click+=btnShowLargeSpeedo_Click; + this.btnVigilanceSettings.Click+=btnVigilanceSettings_Click; + this.Closer.Tick+=Closer_Tick; + this.btnNew.Click+=btnNew_Click; + this.btnLoadSelected.Click+=btnLoadSelected_Click; + this.btnSaveSelected.Click+=btnSaveSelected_Click; + this.btnDuplicateSelected.Click+=btnDuplicateSelected_Click; + this.btnRemoveSelected.Click+=btnRemoveSelected_Click; + this.btnPrevDevice.Click+=btnPrevDevice_Click; + this.btnNextDevice.Click+=btnNextDevice_Click; + this.btnAllDevice.Click+=btnAllDevice_Click; + this.btnShiftDown.Click+=btnShiftDown_Click; + this.btnShiftUp.Click+=btnShiftUp_Click; + } + } +} diff --git a/RailWorks_Joystick_API/frmManageControls.Designer.cs b/RailWorks_Joystick_API/frmManageControls.Designer.cs new file mode 100644 index 0000000..d093735 --- /dev/null +++ b/RailWorks_Joystick_API/frmManageControls.Designer.cs @@ -0,0 +1,424 @@ +namespace RailWorks_Joystick_API { + partial class frmManageControls { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.gbInputList = new System.Windows.Forms.GroupBox(); + this.btnExport = new System.Windows.Forms.Button(); + this.btnImport = new System.Windows.Forms.Button(); + this.btnRemoveInput = new System.Windows.Forms.Button(); + this.lswInputList = new System.Windows.Forms.ListView(); + this.InputListHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.btnAssignSelected = new System.Windows.Forms.Button(); + this.btnAddInput = new System.Windows.Forms.Button(); + this.gbTreatAs = new System.Windows.Forms.GroupBox(); + this.cbTreatAs = new System.Windows.Forms.ComboBox(); + this.gbCommandDescription = new System.Windows.Forms.GroupBox(); + this.lbCommandDescription = new System.Windows.Forms.Label(); + this.gbMode = new System.Windows.Forms.GroupBox(); + this.cbMode = new System.Windows.Forms.ComboBox(); + this.pbInputValue = new System.Windows.Forms.PictureBox(); + this.gbInputValue = new System.Windows.Forms.GroupBox(); + this.gbOutputValue = new System.Windows.Forms.GroupBox(); + this.pbOutputValue = new System.Windows.Forms.PictureBox(); + this.gbNotches = new System.Windows.Forms.GroupBox(); + this.txtNotches = new System.Windows.Forms.TextBox(); + this.cbNotchPresets = new System.Windows.Forms.ComboBox(); + this.gbNotchRanges = new System.Windows.Forms.GroupBox(); + this.txtRanges = new System.Windows.Forms.TextBox(); + this.cbRangePresets = new System.Windows.Forms.ComboBox(); + this.btnReload = new System.Windows.Forms.Button(); + this.gbAPIOutput = new System.Windows.Forms.GroupBox(); + this.pbAPIOutput = new System.Windows.Forms.PictureBox(); + this.chkIsNegativePositiveRange = new System.Windows.Forms.CheckBox(); + this.gbInputList.SuspendLayout(); + this.gbTreatAs.SuspendLayout(); + this.gbCommandDescription.SuspendLayout(); + this.gbMode.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbInputValue)).BeginInit(); + this.gbInputValue.SuspendLayout(); + this.gbOutputValue.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbOutputValue)).BeginInit(); + this.gbNotches.SuspendLayout(); + this.gbNotchRanges.SuspendLayout(); + this.gbAPIOutput.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pbAPIOutput)).BeginInit(); + this.SuspendLayout(); + // + // gbInputList + // + this.gbInputList.Controls.Add(this.btnExport); + this.gbInputList.Controls.Add(this.btnImport); + this.gbInputList.Controls.Add(this.btnRemoveInput); + this.gbInputList.Controls.Add(this.lswInputList); + this.gbInputList.Controls.Add(this.btnAssignSelected); + this.gbInputList.Controls.Add(this.btnAddInput); + this.gbInputList.Location = new System.Drawing.Point(12, 80); + this.gbInputList.Name = "gbInputList"; + this.gbInputList.Size = new System.Drawing.Size(506, 274); + this.gbInputList.TabIndex = 0; + this.gbInputList.TabStop = false; + this.gbInputList.Text = "Inputs"; + this.btnExport.Location = new System.Drawing.Point(425, 245); + this.btnExport.Name = "btnExport"; + this.btnExport.Size = new System.Drawing.Size(75, 23); + this.btnExport.TabIndex = 1; + this.btnExport.Text = "Export"; + this.btnExport.UseVisualStyleBackColor = true; + this.btnImport.Location = new System.Drawing.Point(344, 245); + this.btnImport.Name = "btnImport"; + this.btnImport.Size = new System.Drawing.Size(75, 23); + this.btnImport.TabIndex = 1; + this.btnImport.Text = "Import"; + this.btnImport.UseVisualStyleBackColor = true; + this.btnRemoveInput.Location = new System.Drawing.Point(222, 245); + this.btnRemoveInput.Name = "btnRemoveInput"; + this.btnRemoveInput.Size = new System.Drawing.Size(100, 23); + this.btnRemoveInput.TabIndex = 1; + this.btnRemoveInput.Text = "Remove Selected"; + this.btnRemoveInput.UseVisualStyleBackColor = true; + this.lswInputList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.InputListHeader}); + this.lswInputList.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lswInputList.ForeColor = System.Drawing.Color.Red; + this.lswInputList.FullRowSelect = true; + this.lswInputList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.lswInputList.HideSelection = false; + this.lswInputList.Location = new System.Drawing.Point(10, 19); + this.lswInputList.MultiSelect = false; + this.lswInputList.Name = "lswInputList"; + this.lswInputList.ShowGroups = false; + this.lswInputList.Size = new System.Drawing.Size(490, 220); + this.lswInputList.TabIndex = 1; + this.lswInputList.UseCompatibleStateImageBehavior = false; + this.lswInputList.View = System.Windows.Forms.View.Details; + // + // InputListHeader + // + this.InputListHeader.Text = "Should not see"; + this.InputListHeader.Width = 486; + // + // btnAssignSelected + // + this.btnAssignSelected.Location = new System.Drawing.Point(116, 245); + this.btnAssignSelected.Name = "btnAssignSelected"; + this.btnAssignSelected.Size = new System.Drawing.Size(100, 23); + this.btnAssignSelected.TabIndex = 1; + this.btnAssignSelected.Text = "Assign Selected"; + this.btnAssignSelected.UseVisualStyleBackColor = true; + this.btnAddInput.Location = new System.Drawing.Point(10, 245); + this.btnAddInput.Name = "btnAddInput"; + this.btnAddInput.Size = new System.Drawing.Size(100, 23); + this.btnAddInput.TabIndex = 1; + this.btnAddInput.Text = "Add Input"; + this.btnAddInput.UseVisualStyleBackColor = true; + this.gbTreatAs.Controls.Add(this.cbTreatAs); + this.gbTreatAs.Location = new System.Drawing.Point(12, 360); + this.gbTreatAs.Name = "gbTreatAs"; + this.gbTreatAs.Size = new System.Drawing.Size(250, 50); + this.gbTreatAs.TabIndex = 0; + this.gbTreatAs.TabStop = false; + this.gbTreatAs.Text = "Treat as..."; + this.cbTreatAs.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbTreatAs.Enabled = false; + this.cbTreatAs.FormattingEnabled = true; + this.cbTreatAs.Items.AddRange(new object[] { + "Not Assigned", + "Axis", + "Button"}); + this.cbTreatAs.Location = new System.Drawing.Point(10, 19); + this.cbTreatAs.Name = "cbTreatAs"; + this.cbTreatAs.Size = new System.Drawing.Size(234, 21); + this.cbTreatAs.TabIndex = 0; + // + // gbCommandDescription + // + this.gbCommandDescription.Controls.Add(this.lbCommandDescription); + this.gbCommandDescription.Location = new System.Drawing.Point(12, 12); + this.gbCommandDescription.Name = "gbCommandDescription"; + this.gbCommandDescription.Size = new System.Drawing.Size(740, 62); + this.gbCommandDescription.TabIndex = 0; + this.gbCommandDescription.TabStop = false; + this.gbCommandDescription.Text = "Command..."; + this.lbCommandDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbCommandDescription.ForeColor = System.Drawing.Color.Green; + this.lbCommandDescription.Location = new System.Drawing.Point(6, 16); + this.lbCommandDescription.Name = "lbCommandDescription"; + this.lbCommandDescription.Size = new System.Drawing.Size(728, 43); + this.lbCommandDescription.TabIndex = 0; + this.lbCommandDescription.Text = "NOTHING"; + this.lbCommandDescription.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // gbMode + // + this.gbMode.Controls.Add(this.cbMode); + this.gbMode.Location = new System.Drawing.Point(268, 360); + this.gbMode.Name = "gbMode"; + this.gbMode.Size = new System.Drawing.Size(250, 50); + this.gbMode.TabIndex = 0; + this.gbMode.TabStop = false; + this.gbMode.Text = "Mode..."; + this.cbMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbMode.Enabled = false; + this.cbMode.FormattingEnabled = true; + this.cbMode.Items.AddRange(new object[] { + "Slider", + "Notched slider", + "Notched slider with ranges", + "Up/Down latch", + "Up/Down relative"}); + this.cbMode.Location = new System.Drawing.Point(10, 19); + this.cbMode.Name = "cbMode"; + this.cbMode.Size = new System.Drawing.Size(234, 21); + this.cbMode.TabIndex = 0; + // + // pbInputValue + // + this.pbInputValue.Location = new System.Drawing.Point(6, 19); + this.pbInputValue.Name = "pbInputValue"; + this.pbInputValue.Size = new System.Drawing.Size(55, 530); + this.pbInputValue.TabIndex = 1; + this.pbInputValue.TabStop = false; + this.gbInputValue.Controls.Add(this.pbInputValue); + this.gbInputValue.Location = new System.Drawing.Point(527, 80); + this.gbInputValue.Name = "gbInputValue"; + this.gbInputValue.Size = new System.Drawing.Size(69, 555); + this.gbInputValue.TabIndex = 0; + this.gbInputValue.TabStop = false; + this.gbInputValue.Text = "Input"; + this.gbOutputValue.Controls.Add(this.pbOutputValue); + this.gbOutputValue.Location = new System.Drawing.Point(602, 80); + this.gbOutputValue.Name = "gbOutputValue"; + this.gbOutputValue.Size = new System.Drawing.Size(69, 555); + this.gbOutputValue.TabIndex = 0; + this.gbOutputValue.TabStop = false; + this.gbOutputValue.Text = "Output"; + this.pbOutputValue.Location = new System.Drawing.Point(6, 19); + this.pbOutputValue.Name = "pbOutputValue"; + this.pbOutputValue.Size = new System.Drawing.Size(55, 530); + this.pbOutputValue.TabIndex = 1; + this.pbOutputValue.TabStop = false; + this.gbNotches.Controls.Add(this.txtNotches); + this.gbNotches.Controls.Add(this.cbNotchPresets); + this.gbNotches.Location = new System.Drawing.Point(12, 416); + this.gbNotches.Name = "gbNotches"; + this.gbNotches.Size = new System.Drawing.Size(506, 50); + this.gbNotches.TabIndex = 0; + this.gbNotches.TabStop = false; + this.gbNotches.Text = "Notches..."; + this.gbNotches.Visible = false; + this.txtNotches.Location = new System.Drawing.Point(10, 20); + this.txtNotches.Name = "txtNotches"; + this.txtNotches.Size = new System.Drawing.Size(250, 20); + this.txtNotches.TabIndex = 1; + // + // cbNotchPresets + // + this.cbNotchPresets.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbNotchPresets.FormattingEnabled = true; + this.cbNotchPresets.Items.AddRange(new object[] { + "Evenly distribute...", + "2 Notches", + "3 Notches", + "4 Notches", + "5 Notches", + "6 Notches", + "7 Notches", + "8 Notches", + "9 Notches", + "10 Notches", + "11 Notches", + "12 Notches", + "13 Notches", + "14 Notches", + "15 Notches", + "16 Notches", + "17 Notches", + "18 Notches", + "19 Notches", + "20 Notches", + "21 Notches", + "22 Notches", + "23 Notches", + "24 Notches", + "25 Notches", + "26 Notches", + "27 Notches", + "28 Notches", + "29 Notches"}); + this.cbNotchPresets.Location = new System.Drawing.Point(266, 19); + this.cbNotchPresets.Name = "cbNotchPresets"; + this.cbNotchPresets.Size = new System.Drawing.Size(234, 21); + this.cbNotchPresets.TabIndex = 0; + // + // gbNotchRanges + // + this.gbNotchRanges.Controls.Add(this.txtRanges); + this.gbNotchRanges.Controls.Add(this.cbRangePresets); + this.gbNotchRanges.Location = new System.Drawing.Point(12, 472); + this.gbNotchRanges.Name = "gbNotchRanges"; + this.gbNotchRanges.Size = new System.Drawing.Size(506, 50); + this.gbNotchRanges.TabIndex = 0; + this.gbNotchRanges.TabStop = false; + this.gbNotchRanges.Text = "Ranges..."; + this.gbNotchRanges.Visible = false; + this.txtRanges.Location = new System.Drawing.Point(10, 20); + this.txtRanges.Name = "txtRanges"; + this.txtRanges.Size = new System.Drawing.Size(250, 20); + this.txtRanges.TabIndex = 1; + // + // cbRangePresets + // + this.cbRangePresets.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbRangePresets.FormattingEnabled = true; + this.cbRangePresets.Items.AddRange(new object[] { + "Evenly distribute...", + "2 Notches", + "3 Notches", + "4 Notches", + "5 Notches", + "6 Notches", + "7 Notches", + "8 Notches", + "9 Notches", + "10 Notches", + "11 Notches", + "12 Notches", + "13 Notches", + "14 Notches", + "15 Notches", + "16 Notches", + "17 Notches", + "18 Notches", + "19 Notches", + "20 Notches", + "21 Notches", + "22 Notches", + "23 Notches", + "24 Notches", + "25 Notches", + "26 Notches", + "27 Notches", + "28 Notches", + "29 Notches"}); + this.cbRangePresets.Location = new System.Drawing.Point(266, 19); + this.cbRangePresets.Name = "cbRangePresets"; + this.cbRangePresets.Size = new System.Drawing.Size(234, 21); + this.cbRangePresets.TabIndex = 0; + // + // btnReload + // + this.btnReload.Enabled = false; + this.btnReload.Location = new System.Drawing.Point(446, 612); + this.btnReload.Name = "btnReload"; + this.btnReload.Size = new System.Drawing.Size(75, 23); + this.btnReload.TabIndex = 1; + this.btnReload.Text = "Reload"; + this.btnReload.UseVisualStyleBackColor = true; + this.gbAPIOutput.Controls.Add(this.pbAPIOutput); + this.gbAPIOutput.Location = new System.Drawing.Point(677, 80); + this.gbAPIOutput.Name = "gbAPIOutput"; + this.gbAPIOutput.Size = new System.Drawing.Size(75, 555); + this.gbAPIOutput.TabIndex = 0; + this.gbAPIOutput.TabStop = false; + this.gbAPIOutput.Text = "RW Output"; + this.pbAPIOutput.Location = new System.Drawing.Point(10, 19); + this.pbAPIOutput.Name = "pbAPIOutput"; + this.pbAPIOutput.Size = new System.Drawing.Size(55, 530); + this.pbAPIOutput.TabIndex = 1; + this.pbAPIOutput.TabStop = false; + this.chkIsNegativePositiveRange.AutoSize = true; + this.chkIsNegativePositiveRange.Location = new System.Drawing.Point(22, 528); + this.chkIsNegativePositiveRange.Name = "chkIsNegativePositiveRange"; + this.chkIsNegativePositiveRange.Size = new System.Drawing.Size(369, 17); + this.chkIsNegativePositiveRange.TabIndex = 2; + this.chkIsNegativePositiveRange.Text = "Treat as -100% to +100% (used for certain combined throttle locomotives)"; + this.chkIsNegativePositiveRange.UseVisualStyleBackColor = true; + this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(765, 647); + this.Controls.Add(this.chkIsNegativePositiveRange); + this.Controls.Add(this.btnReload); + this.Controls.Add(this.gbMode); + this.Controls.Add(this.gbAPIOutput); + this.Controls.Add(this.gbOutputValue); + this.Controls.Add(this.gbInputValue); + this.Controls.Add(this.gbNotchRanges); + this.Controls.Add(this.gbNotches); + this.Controls.Add(this.gbTreatAs); + this.Controls.Add(this.gbCommandDescription); + this.Controls.Add(this.gbInputList); + this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "frmManageControls"; + this.Text = "Control Manager"; + this.gbInputList.ResumeLayout(false); + this.gbTreatAs.ResumeLayout(false); + this.gbCommandDescription.ResumeLayout(false); + this.gbMode.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pbInputValue)).EndInit(); + this.gbInputValue.ResumeLayout(false); + this.gbOutputValue.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pbOutputValue)).EndInit(); + this.gbNotches.ResumeLayout(false); + this.gbNotches.PerformLayout(); + this.gbNotchRanges.ResumeLayout(false); + this.gbNotchRanges.PerformLayout(); + this.gbAPIOutput.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pbAPIOutput)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + } + + private System.Windows.Forms.GroupBox gbInputList; + private System.Windows.Forms.GroupBox gbTreatAs; + private System.Windows.Forms.ComboBox cbTreatAs; + private System.Windows.Forms.GroupBox gbCommandDescription; + private System.Windows.Forms.Label lbCommandDescription; + private System.Windows.Forms.GroupBox gbMode; + private System.Windows.Forms.ComboBox cbMode; + private System.Windows.Forms.PictureBox pbInputValue; + private System.Windows.Forms.GroupBox gbInputValue; + private System.Windows.Forms.GroupBox gbOutputValue; + private System.Windows.Forms.PictureBox pbOutputValue; + private System.Windows.Forms.ListView lswInputList; + private System.Windows.Forms.ColumnHeader InputListHeader; + private System.Windows.Forms.Button btnAddInput; + private System.Windows.Forms.Button btnRemoveInput; + private System.Windows.Forms.Button btnAssignSelected; + private System.Windows.Forms.GroupBox gbNotches; + private System.Windows.Forms.TextBox txtNotches; + private System.Windows.Forms.ComboBox cbNotchPresets; + private System.Windows.Forms.GroupBox gbNotchRanges; + private System.Windows.Forms.TextBox txtRanges; + private System.Windows.Forms.ComboBox cbRangePresets; + private System.Windows.Forms.Button btnReload; + private System.Windows.Forms.GroupBox gbAPIOutput; + private System.Windows.Forms.PictureBox pbAPIOutput; + private System.Windows.Forms.Button btnExport; + private System.Windows.Forms.Button btnImport; + private System.Windows.Forms.CheckBox chkIsNegativePositiveRange; + + #endregion + } +} \ No newline at end of file diff --git a/RailWorks_Joystick_API/frmManageControls.cs b/RailWorks_Joystick_API/frmManageControls.cs new file mode 100644 index 0000000..df66615 --- /dev/null +++ b/RailWorks_Joystick_API/frmManageControls.cs @@ -0,0 +1,470 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + public partial class frmManageControls : Form { + public delegate void LoadControlMapDelegate(object sender, EventArgs e); + public delegate void UpdateCurrentDelegate(object sender, EventArgs e); + public int APIMapIndex = -1; + public int InputMapIndex = -1; + public string Description; + public bool Running = true; + bool AssignMode; + bool InLoadControl; + + private void frmManageControls_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { + Globals.IHandler.StopAssigning(); + if(Running) { + this.Visible = false; + e.Cancel = true; + } + } + + private void frmManageControls_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { + if((AssignMode + && (e.KeyCode == Keys.Escape))) { + AssignMode = false; + Globals.IHandler.StopAssigning(); + LoadControlMap(); + } + } + + public void LoadControlMap() { + this.LoadControlMap(null, null); + } + + public void LoadControlMap(object sender, EventArgs e) { + if(!Running) { + return; + } + InLoadControl = true; + if(lbCommandDescription.InvokeRequired) { + LoadControlMapDelegate Del = new LoadControlMapDelegate(new System.EventHandler(this.LoadControlMap)); + lbCommandDescription.Invoke(Del); + return; + } + lbCommandDescription.Text = Description.Replace("&", "&&"); + cbMode.SelectedIndex = 0; + cbTreatAs.SelectedIndex = 0; + btnReload.Enabled = false; + Map CMap; + InputMap IMap; + if((APIMapIndex >= 0)) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + if((InputMapIndex >= 0)) { + IMap = CMap.InputMaps[InputMapIndex]; + if((IMap.TreatAs == InputMap.ControlType.Assigning)) { + IMap.TreatAs = InputMap.ControlType.NotAssigned; + } + CMap.InputMaps[InputMapIndex] = IMap; + cbTreatAs.Enabled = true; + cbMode.Enabled = true; + if(((IMap.MapMode == InputMap.ControlMode.NotchedSlider) + || ((IMap.MapMode == InputMap.ControlMode.NotchedSliderRanges) + || ((IMap.MapMode == InputMap.ControlMode.NotchedSliderTargets) + || ((IMap.MapMode == InputMap.ControlMode.UpDownLatch) + || (IMap.MapMode == InputMap.ControlMode.UpDownRelative)))))) { + gbNotches.Visible = true; + cbNotchPresets.SelectedIndex = 0; + string txt = ""; + for(int I = 0; (I <= (IMap.Notches.Count - 1)); I++) { + txt += (IMap.Notches[I] * 100).ToString(); + if((I < (IMap.Notches.Count - 1))) { + txt += ", "; + } + } + txtNotches.Text = txt; + } else { + gbNotches.Visible = false; + } + if(((IMap.MapMode == InputMap.ControlMode.NotchedSliderRanges) + || ((IMap.MapMode == InputMap.ControlMode.NotchedSliderTargets) + || ((IMap.MapMode == InputMap.ControlMode.UpDownLatch) + || ((IMap.MapMode == InputMap.ControlMode.UpDownRelative) + || (IMap.MapMode == InputMap.ControlMode.Toggle)))))) { + if((IMap.MapMode == InputMap.ControlMode.Toggle)) { + gbNotchRanges.Top = 416; + gbNotchRanges.Text = "Toggles..."; + } else if((IMap.MapMode == InputMap.ControlMode.NotchedSliderTargets)) { + gbNotchRanges.Top = 472; + gbNotchRanges.Text = "Targets..."; + } else { + gbNotchRanges.Top = 472; + gbNotchRanges.Text = "Ranges..."; + } + gbNotchRanges.Visible = true; + cbRangePresets.SelectedIndex = 0; + string txt = ""; + for(int I = 0; (I <= (IMap.NotchRanges.Count - 1)); I++) { + txt += (IMap.NotchRanges[I] * 100).ToString(); + if((I < (IMap.NotchRanges.Count - 1))) { + txt += ", "; + } + } + txtRanges.Text = txt; + } else { + gbNotchRanges.Visible = false; + } + } else { + cbTreatAs.Enabled = false; + cbMode.Enabled = false; + } + Globals.IHandler.Mappings[APIMapIndex] = CMap; + } else { + Debug.Print(("APIMapIndex sent to frmManageControls.LoadControlMap was invalid: " + APIMapIndex.ToString())); + return; + } + lswInputList.Items.Clear(); + foreach(InputMap IM in CMap.InputMaps) { + lswInputList.Items.Add(IM.ToString()); + if(!(IM.TreatAs == InputMap.ControlType.NotAssigned)) { + lswInputList.Items[(lswInputList.Items.Count - 1)].ForeColor = Color.Green; + } + } + lswInputList.SelectedIndices.Clear(); + lswInputList.SelectedItems.Clear(); + if((lswInputList.Items.Count == 0)) { + InputMapIndex = -1; + } + lbCommandDescription.Text = Description.Replace("&", "&&"); + LoadInput(); + InLoadControl = false; + } + + public void LoadInput() { + Map CMap; + InputMap IMap; + if((InputMapIndex >= 0)) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + lswInputList.Items[InputMapIndex].Selected = true; + cbTreatAs.Items.Clear(); + string[] Names = Enum.GetNames(typeof(InputMap.ControlType)); + //object Preserve; + //Names[2]; + cbTreatAs.Items.AddRange(Names); + cbTreatAs.SelectedIndex = (int)IMap.TreatAs; + cbMode.Items.Clear(); + cbMode.Items.AddRange(Enum.GetNames(typeof(InputMap.ControlMode))); + cbMode.SelectedIndex = (int)IMap.MapMode; + chkIsNegativePositiveRange.Checked = IMap.IsNegativePositiveRange; + UpdateSubscription(null, null); + } + } + + public void UpdateSubscription(object sender, EventArgs e) { + if(pbInputValue.InvokeRequired) { + UpdateCurrentDelegate Del = new UpdateCurrentDelegate(new System.EventHandler(this.UpdateSubscription)); + if((pbInputValue.IsHandleCreated && Running)) { + pbInputValue.Invoke(Del); + } + // Damn threading... TODO: Fix crash that occurs when the device is spazzing sending messages after form close. + return; + } + pbInputValue.Refresh(); + pbOutputValue.Refresh(); + pbAPIOutput.Refresh(); + } + + private void pbInputValue_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { + Map CMap; + InputMap IMap; + float Percent = 0; + if((InputMapIndex >= 0)) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + if((((PictureBox)(sender)).Name == "pbInputValue")) { + Percent = IMap.GetPercent(); + } else if((((PictureBox)(sender)).Name == "pbOutputValue")) { + Percent = IMap.GetOutputPercent(); + } else { + Percent = CMap.GetOutputPercent(); + } + } + double CurVal; + CurVal = (530 * Percent); + Graphics G = e.Graphics; + Rectangle Rect = new Rectangle(0, 0, 55, 530); + Rectangle RectCurrent = new Rectangle(0, (530 - int.Parse(CurVal.ToString())), 55, 530); + LinearGradientBrush lgBrushFill = new LinearGradientBrush(Rect, Color.Red, Color.LimeGreen, 90); + LinearGradientBrush lgBrushFillBg = new LinearGradientBrush(Rect, Color.Gray, Color.Black, 90); + LinearGradientBrush lgBrushFrame = new LinearGradientBrush(Rect, Color.Blue, Color.Black, 90); + Pen pnFrame = new Pen(Brushes.Black, 4); + Pen pnPercentSmall = new Pen(Brushes.White, 1); + Pen pnPercentLarge = new Pen(Brushes.White, 2); + G.FillRectangle(lgBrushFillBg, Rect); + G.FillRectangle(lgBrushFill, RectCurrent); + G.DrawLine(pnFrame, new Point(0, (530 - int.Parse(CurVal.ToString()))), new Point(55, (530 - int.Parse(CurVal.ToString())))); + for(int I = 530; (I <= 0); I = (I + -53)) { + G.DrawLine(pnPercentSmall, new Point(50, ((530 - I) + + 26)), new Point(55, ((530 - I) + + 26))); + G.DrawLine(pnPercentLarge, new Point(45, (530 - I)), new Point(55, (530 - I))); + } + G.DrawRectangle(pnFrame, Rect); + G.DrawString((((Percent * 100)).ToString("0.#") + "%"), new Font("Arial", 11), Brushes.White, new Point(10, 10)); + } + + private void cbMode_SelectedIndexChanged(object sender, System.EventArgs e) { + Map CMap; + InputMap IMap; + if((!InLoadControl + && (InputMapIndex >= 0))) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + IMap.MapMode = ((InputMap.ControlMode)(cbMode.SelectedIndex)); + CMap.InputMaps[InputMapIndex] = IMap; + Globals.IHandler.Mappings[APIMapIndex] = CMap; + LoadControlMap(); + } + } + + private void cbTreatAs_SelectedIndexChanged(object sender, System.EventArgs e) { + Map CMap; + InputMap IMap; + if((!InLoadControl + && (InputMapIndex >= 0))) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + IMap.TreatAs = ((InputMap.ControlType)(cbTreatAs.SelectedIndex)); + if((!(IMap.TreatAs == InputMap.ControlType.NotAssigned) + && ((IMap.DeviceID == -1) + && (IMap.MapName == "")))) { + btnAssignSelected_Click(btnAssignSelected, new System.EventArgs()); + return; + } + if((IMap.TreatAs == InputMap.ControlType.NotAssigned)) { + IMap.MapName = ""; + IMap.DeviceID = -1; + } + CMap.InputMaps[InputMapIndex] = IMap; + Globals.IHandler.Mappings[APIMapIndex] = CMap; + LoadControlMap(); + } + } + + private void lswInputList_Click(object sender, System.EventArgs e) { + if((!InLoadControl + && (lswInputList.SelectedIndices.Count > 0))) { + InputMapIndex = lswInputList.SelectedIndices[0]; + LoadControlMap(); + } + } + + private void btnAddInput_Click(object sender, System.EventArgs e) { + InputMap IMap = new InputMap(InputMap.ControlType.NotAssigned); + Globals.IHandler.Mappings[APIMapIndex].AddInput(ref IMap); + LoadControlMap(); + } + + private void btnRemoveInput_Click(object sender, System.EventArgs e) { + if((InputMapIndex >= 0)) { + Globals.IHandler.Mappings[APIMapIndex].InputMaps.RemoveAt(InputMapIndex); + } + InputMapIndex = -1; + LoadControlMap(); + } + + private void btnImport_Click(object sender, System.EventArgs e) { + FileStream FStream; + System.Windows.Forms.OpenFileDialog Dlg = new System.Windows.Forms.OpenFileDialog(); + InputMap IMap; + Dlg.InitialDirectory = Application.StartupPath; + Dlg.DefaultExt = ".IMAP"; + Dlg.Filter = "Input map files (*.IMAP)|*.IMAP"; + Dlg.FilterIndex = 0; + Dlg.RestoreDirectory = true; + Dlg.Title = "Import input map from..."; + Dlg.AddExtension = true; + if((Dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)) { + try { + FStream = new FileStream(Dlg.FileName, FileMode.Open); + System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + IMap = ((InputMap)(BFormatter.Deserialize(FStream))); + switch(MessageBox.Show(("Would you like to import the assigned device in this input map as well?" + ("\r\n" + "If you do, remember that the assigned device and axis/button might not exist/be connected to your com" + + "puter...")), "Import assigned Device + Axis/Button?", MessageBoxButtons.YesNoCancel)) { + case System.Windows.Forms.DialogResult.Yes: + break; + case System.Windows.Forms.DialogResult.No: + IMap.DeviceID = -1; + IMap.MapName = ""; + IMap.TreatAs = InputMap.ControlType.NotAssigned; + break; + case System.Windows.Forms.DialogResult.Cancel: + return; + } + Globals.IHandler.Mappings[APIMapIndex].AddInput(ref IMap); + LoadControlMap(); + } catch(Exception) { + System.Windows.Forms.MessageBox.Show(("The input map could not be loaded from " + + (Dlg.FileName + "!"))); + } finally { + //FStream.Close(); + } + } + } + + void btnExport_Click(object sender, System.EventArgs e) { + InputMap IMap; + if((InputMapIndex >= 0)) { + IMap = Globals.IHandler.Mappings[APIMapIndex].InputMaps[InputMapIndex]; + System.Windows.Forms.SaveFileDialog Dlg = new System.Windows.Forms.SaveFileDialog(); + Dlg.InitialDirectory = Application.StartupPath; + Dlg.DefaultExt = ".IMAP"; + Dlg.Filter = "Input map files (*.IMAP)|*.IMAP"; + Dlg.FilterIndex = 0; + Dlg.OverwritePrompt = true; + Dlg.RestoreDirectory = true; + Dlg.AddExtension = true; + Dlg.Title = "Export input map to..."; + if((Dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)) { + FileStream FStream = new FileStream(Dlg.FileName, FileMode.OpenOrCreate); + System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + try { + BFormatter.Serialize(FStream, IMap); + } catch(Exception) { + System.Windows.Forms.MessageBox.Show(("The input map could not be saved to " + + (Dlg.FileName + "!"))); + } finally { + FStream.Close(); + } + } + } + } + + private void btnAssignSelected_Click(object sender, System.EventArgs e) { + Map CMap; + InputMap IMap; + if((InputMapIndex >= 0)) { + AssignMode = true; + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + IMap.TreatAs = InputMap.ControlType.Assigning; + lswInputList.Items[InputMapIndex].Text = IMap.ToString(); + CMap.InputMaps[InputMapIndex] = IMap; + Globals.IHandler.Mappings[APIMapIndex] = CMap; + } + } + + private void cbNotchPresets_SelectedIndexChanged(object sender, System.EventArgs e) { + int Notches; + if((((ComboBox)(sender)).Name == "cbNotchPresets")) { + Notches = cbNotchPresets.SelectedIndex; + } else { + Notches = cbRangePresets.SelectedIndex; + } + string txt = "0, "; + if((Notches < 1)) { + txt = ""; + } else { + float NotchSize = float.Parse((100 / Notches).ToString()); + for(int I = 1; (I <= (Notches - 1)); I++) { + txt += (Math.Round((NotchSize * I), 1).ToString() + ", "); + } + txt += "100"; + } + if((((ComboBox)(sender)).Name == "cbNotchPresets")) { + txtNotches.Text = txt; + } else { + txtRanges.Text = txt; + } + } + + private bool NotchNonNumberEntered; + + private void txtNotches_TextChanged(object sender, System.EventArgs e) { + if(!InLoadControl) { + string[] Notches; + if((((TextBox)(sender)).Name == "txtNotches")) { + Notches = txtNotches.Text.Replace(" ", "").Split(','); + } else { + Notches = txtRanges.Text.Replace(" ", "").Split(','); + } + Map CMap; + InputMap IMap; + if((InputMapIndex >= 0)) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + if((((TextBox)(sender)).Name == "txtNotches")) { + IMap.Notches.Clear(); + } else { + IMap.NotchRanges.Clear(); + } + try { + foreach(string Notch in Notches) { + string notch = Notch; + if((Notch == "")) { + // TODO: Continue For... Warning!!! not translated + } + if((float.Parse(Notch) > 0)) { + notch = (float.Parse(Notch) / 100).ToString(); + } + if((((TextBox)(sender)).Name == "txtNotches")) { + IMap.Notches.Add(float.Parse(Notch)); + } else { + IMap.NotchRanges.Add(float.Parse(Notch)); + } + } + CMap.InputMaps[InputMapIndex] = IMap; + Globals.IHandler.Mappings[APIMapIndex] = CMap; + btnReload.Enabled = true; + } catch(Exception) { + } + } + } + } + + private void btnReload_Click(object sender, System.EventArgs e) { + LoadControlMap(); + } + + private void chkIsNegativePositiveRange_CheckedChanged(object sender, System.EventArgs e) { + Map CMap; + InputMap IMap; + if((InputMapIndex >= 0)) { + CMap = Globals.IHandler.Mappings[APIMapIndex]; + IMap = CMap.InputMaps[InputMapIndex]; + IMap.IsNegativePositiveRange = chkIsNegativePositiveRange.Checked; + CMap.InputMaps[InputMapIndex] = IMap; + Globals.IHandler.Mappings[APIMapIndex] = CMap; + } + } + + public frmManageControls() { + InitializeComponent(); + this.FormClosing+=frmManageControls_FormClosing; + this.KeyDown+=frmManageControls_KeyDown; + this.cbMode.KeyDown += frmManageControls_KeyDown; + this.cbTreatAs.KeyDown += frmManageControls_KeyDown; + this.cbNotchPresets.KeyDown += frmManageControls_KeyDown; + this.cbRangePresets.KeyDown += frmManageControls_KeyDown; + this.pbInputValue.Paint+=pbInputValue_Paint; + this.pbOutputValue.Paint += pbInputValue_Paint; + this.pbAPIOutput.Paint += pbInputValue_Paint; + this.cbMode.SelectedIndexChanged+=cbMode_SelectedIndexChanged; + this.cbTreatAs.SelectedIndexChanged+=cbTreatAs_SelectedIndexChanged; + this.lswInputList.Click+=lswInputList_Click; + this.btnAddInput.Click+=btnAddInput_Click; + this.btnRemoveInput.Click+=btnRemoveInput_Click; + this.btnImport.Click+=btnImport_Click; + this.btnExport.Click+=btnExport_Click; + this.btnAssignSelected.Click+=btnAssignSelected_Click; + this.cbNotchPresets.SelectedIndexChanged+=cbNotchPresets_SelectedIndexChanged; + this.cbRangePresets.SelectedIndexChanged += cbNotchPresets_SelectedIndexChanged; + this.txtNotches.TextChanged+=txtNotches_TextChanged; + this.txtRanges.TextChanged += txtNotches_TextChanged; + this.btnReload.Click+=btnReload_Click; + this.chkIsNegativePositiveRange.CheckedChanged+=chkIsNegativePositiveRange_CheckedChanged; + } + } +} diff --git a/RailWorks_Joystick_API/frmSpeedo.Designer.cs b/RailWorks_Joystick_API/frmSpeedo.Designer.cs new file mode 100644 index 0000000..3247651 --- /dev/null +++ b/RailWorks_Joystick_API/frmSpeedo.Designer.cs @@ -0,0 +1,55 @@ +namespace RailWorks_Joystick_API { + partial class frmSpeedo { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.ElementHost1 = new System.Windows.Forms.Integration.ElementHost(); + this.ControlsSpeedo = new RailWorks_Joystick_API.ucLargeSpeedo(); + this.SuspendLayout(); + // + // ElementHost1 + // + this.ElementHost1.Location = new System.Drawing.Point(-1, -2); + this.ElementHost1.Name = "ElementHost1"; + this.ElementHost1.Size = new System.Drawing.Size(600, 600); + this.ElementHost1.TabIndex = 0; + this.ElementHost1.Text = "ElementHost1"; + this.ElementHost1.Child = this.ControlsSpeedo; + // + // frmSpeedo + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(599, 597); + this.Controls.Add(this.ElementHost1); + this.Name = "frmSpeedo"; + this.Text = "Large Speedometer"; + this.ResumeLayout(false); + } + + private System.Windows.Forms.Integration.ElementHost ElementHost1; + private RailWorks_Joystick_API.ucLargeSpeedo ControlsSpeedo; + + #endregion + } +} \ No newline at end of file diff --git a/RailWorks_Joystick_API/frmSpeedo.cs b/RailWorks_Joystick_API/frmSpeedo.cs new file mode 100644 index 0000000..859c75e --- /dev/null +++ b/RailWorks_Joystick_API/frmSpeedo.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + public partial class frmSpeedo : Form { + + public void SetSpeed(float Speed) { + ControlsSpeedo.Speed = Speed; + } + + private void frmSpeedo_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { + this.Visible = false; + e.Cancel = true; + } + + public frmSpeedo() { + InitializeComponent(); + this.FormClosing+=frmSpeedo_FormClosing; + } + } +} diff --git a/RailWorks_Joystick_API/frmVigilanceSystem.Designer.cs b/RailWorks_Joystick_API/frmVigilanceSystem.Designer.cs new file mode 100644 index 0000000..c3b5b16 --- /dev/null +++ b/RailWorks_Joystick_API/frmVigilanceSystem.Designer.cs @@ -0,0 +1,183 @@ +namespace RailWorks_Joystick_API { + partial class frmVigilanceSystem { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if(disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); + this.tmUpdateInfo = new System.Windows.Forms.Timer(this.components); + this.lstStatus = new System.Windows.Forms.ListBox(); + this.chkUseVigilanceSystem = new System.Windows.Forms.CheckBox(); + this.txtMinDelay = new System.Windows.Forms.TextBox(); + this.lblMinDelay = new System.Windows.Forms.Label(); + this.lblMaxDelay = new System.Windows.Forms.Label(); + this.txtMaxDelay = new System.Windows.Forms.TextBox(); + this.lblEarlyTriggerChance = new System.Windows.Forms.Label(); + this.txtEarlyTriggerChance = new System.Windows.Forms.TextBox(); + this.lblTrainSpeedFactor = new System.Windows.Forms.Label(); + this.txtTrainSpeedFactor = new System.Windows.Forms.TextBox(); + this.lblMinTrainSpeed = new System.Windows.Forms.Label(); + this.txtMinTrainSpeed = new System.Windows.Forms.TextBox(); + this.lblTimeout = new System.Windows.Forms.Label(); + this.txtTimeout = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // tmUpdateInfo + // + this.tmUpdateInfo.Enabled = true; + this.lstStatus.FormattingEnabled = true; + this.lstStatus.Location = new System.Drawing.Point(12, 12); + this.lstStatus.Name = "lstStatus"; + this.lstStatus.Size = new System.Drawing.Size(256, 199); + this.lstStatus.TabIndex = 0; + // + // chkUseVigilanceSystem + // + this.chkUseVigilanceSystem.AutoSize = true; + this.chkUseVigilanceSystem.Location = new System.Drawing.Point(275, 13); + this.chkUseVigilanceSystem.Name = "chkUseVigilanceSystem"; + this.chkUseVigilanceSystem.Size = new System.Drawing.Size(149, 17); + this.chkUseVigilanceSystem.TabIndex = 1; + this.chkUseVigilanceSystem.Text = "Use the vigilance system?"; + this.chkUseVigilanceSystem.UseVisualStyleBackColor = true; + this.txtMinDelay.Location = new System.Drawing.Point(444, 36); + this.txtMinDelay.Name = "txtMinDelay"; + this.txtMinDelay.Size = new System.Drawing.Size(112, 20); + this.txtMinDelay.TabIndex = 2; + // + // lblMinDelay + // + this.lblMinDelay.AutoSize = true; + this.lblMinDelay.Location = new System.Drawing.Point(274, 39); + this.lblMinDelay.Name = "lblMinDelay"; + this.lblMinDelay.Size = new System.Drawing.Size(142, 13); + this.lblMinDelay.TabIndex = 3; + this.lblMinDelay.Text = "Minimum delay (Milliseconds)"; + this.lblMaxDelay.AutoSize = true; + this.lblMaxDelay.Location = new System.Drawing.Point(274, 65); + this.lblMaxDelay.Name = "lblMaxDelay"; + this.lblMaxDelay.Size = new System.Drawing.Size(145, 13); + this.lblMaxDelay.TabIndex = 5; + this.lblMaxDelay.Text = "Maximum delay (Milliseconds)"; + this.txtMaxDelay.Location = new System.Drawing.Point(444, 62); + this.txtMaxDelay.Name = "txtMaxDelay"; + this.txtMaxDelay.Size = new System.Drawing.Size(112, 20); + this.txtMaxDelay.TabIndex = 4; + // + // lblEarlyTriggerChance + // + this.lblEarlyTriggerChance.AutoSize = true; + this.lblEarlyTriggerChance.Location = new System.Drawing.Point(274, 91); + this.lblEarlyTriggerChance.Name = "lblEarlyTriggerChance"; + this.lblEarlyTriggerChance.Size = new System.Drawing.Size(147, 13); + this.lblEarlyTriggerChance.TabIndex = 7; + this.lblEarlyTriggerChance.Text = "Early trigger chance (Percent)"; + this.txtEarlyTriggerChance.Location = new System.Drawing.Point(444, 88); + this.txtEarlyTriggerChance.Name = "txtEarlyTriggerChance"; + this.txtEarlyTriggerChance.Size = new System.Drawing.Size(112, 20); + this.txtEarlyTriggerChance.TabIndex = 6; + // + // lblTrainSpeedFactor + // + this.lblTrainSpeedFactor.AutoSize = true; + this.lblTrainSpeedFactor.Location = new System.Drawing.Point(274, 117); + this.lblTrainSpeedFactor.Name = "lblTrainSpeedFactor"; + this.lblTrainSpeedFactor.Size = new System.Drawing.Size(93, 13); + this.lblTrainSpeedFactor.TabIndex = 10; + this.lblTrainSpeedFactor.Text = "Train speed factor"; + this.txtTrainSpeedFactor.Location = new System.Drawing.Point(444, 114); + this.txtTrainSpeedFactor.Name = "txtTrainSpeedFactor"; + this.txtTrainSpeedFactor.Size = new System.Drawing.Size(112, 20); + this.txtTrainSpeedFactor.TabIndex = 9; + // + // lblMinTrainSpeed + // + this.lblMinTrainSpeed.AutoSize = true; + this.lblMinTrainSpeed.Location = new System.Drawing.Point(274, 143); + this.lblMinTrainSpeed.Name = "lblMinTrainSpeed"; + this.lblMinTrainSpeed.Size = new System.Drawing.Size(103, 13); + this.lblMinTrainSpeed.TabIndex = 12; + this.lblMinTrainSpeed.Text = "Minimum train speed"; + this.txtMinTrainSpeed.Location = new System.Drawing.Point(444, 140); + this.txtMinTrainSpeed.Name = "txtMinTrainSpeed"; + this.txtMinTrainSpeed.Size = new System.Drawing.Size(112, 20); + this.txtMinTrainSpeed.TabIndex = 11; + // + // lblTimeout + // + this.lblTimeout.AutoSize = true; + this.lblTimeout.Location = new System.Drawing.Point(274, 169); + this.lblTimeout.Name = "lblTimeout"; + this.lblTimeout.Size = new System.Drawing.Size(167, 13); + this.lblTimeout.TabIndex = 14; + this.lblTimeout.Text = "Time before EBrake (Milliseconds)"; + this.txtTimeout.Location = new System.Drawing.Point(444, 166); + this.txtTimeout.Name = "txtTimeout"; + this.txtTimeout.Size = new System.Drawing.Size(112, 20); + this.txtTimeout.TabIndex = 13; + // + // frmVigilanceSystem + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(570, 218); + this.Controls.Add(this.lblTimeout); + this.Controls.Add(this.txtTimeout); + this.Controls.Add(this.lblMinTrainSpeed); + this.Controls.Add(this.txtMinTrainSpeed); + this.Controls.Add(this.lblTrainSpeedFactor); + this.Controls.Add(this.txtTrainSpeedFactor); + this.Controls.Add(this.lblEarlyTriggerChance); + this.Controls.Add(this.txtEarlyTriggerChance); + this.Controls.Add(this.lblMaxDelay); + this.Controls.Add(this.txtMaxDelay); + this.Controls.Add(this.lblMinDelay); + this.Controls.Add(this.txtMinDelay); + this.Controls.Add(this.chkUseVigilanceSystem); + this.Controls.Add(this.lstStatus); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "frmVigilanceSystem"; + this.Text = "Vigilance System Settings"; + this.ResumeLayout(false); + this.PerformLayout(); + } + + private System.Windows.Forms.Timer tmUpdateInfo; + private System.Windows.Forms.ListBox lstStatus; + private System.Windows.Forms.CheckBox chkUseVigilanceSystem; + private System.Windows.Forms.TextBox txtMinDelay; + private System.Windows.Forms.Label lblMinDelay; + private System.Windows.Forms.Label lblMaxDelay; + private System.Windows.Forms.TextBox txtMaxDelay; + private System.Windows.Forms.Label lblEarlyTriggerChance; + private System.Windows.Forms.TextBox txtEarlyTriggerChance; + private System.Windows.Forms.Label lblTrainSpeedFactor; + private System.Windows.Forms.TextBox txtTrainSpeedFactor; + private System.Windows.Forms.Label lblMinTrainSpeed; + private System.Windows.Forms.TextBox txtMinTrainSpeed; + private System.Windows.Forms.Label lblTimeout; + private System.Windows.Forms.TextBox txtTimeout; + + #endregion + } +} \ No newline at end of file diff --git a/RailWorks_Joystick_API/frmVigilanceSystem.cs b/RailWorks_Joystick_API/frmVigilanceSystem.cs new file mode 100644 index 0000000..303fb00 --- /dev/null +++ b/RailWorks_Joystick_API/frmVigilanceSystem.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace RailWorks_Joystick_API { + public partial class frmVigilanceSystem : Form { + + private void tmUpdateInfo_Tick(object sender, System.EventArgs e) { + try { + lstStatus.Items.Clear(); + lstStatus.Items.Add(("AlertTimer: " + Globals.IHandler.Vigilance.AlertTimer.ElapsedMilliseconds)); + lstStatus.Items.Add(("TriggerTimer: " + Globals.IHandler.Vigilance.TriggerTimer.ElapsedMilliseconds)); + lstStatus.Items.Add(("MinDelay: " + Globals.IHandler.Vigilance.MinDelay)); + lstStatus.Items.Add(("MaxDelay: " + Globals.IHandler.Vigilance.MaxDelay)); + lstStatus.Items.Add(("EarlyTriggerChance: " + Globals.IHandler.Vigilance.EarlyTriggerChance)); + lstStatus.Items.Add(("EarlyTriggerOffset: " + Globals.IHandler.Vigilance.EarlyTriggerOffset)); + lstStatus.Items.Add(("UseVigilanceSystem: " + Globals.IHandler.Vigilance.UseVigilanceSystem)); + lstStatus.Items.Add(("LastTrainSpeed: " + Globals.IHandler.Vigilance.LastTrainSpeed)); + lstStatus.Items.Add(("MinimumTrainSpeed: " + Globals.IHandler.Vigilance.MinimumTrainSpeed)); + lstStatus.Items.Add(("TrainSpeedOffset: " + Globals.IHandler.Vigilance.TrainSpeedOffset)); + lstStatus.Items.Add(("TrainSpeedOffsetFactor: " + Globals.IHandler.Vigilance.TrainSpeedOffsetFactor)); + lstStatus.Items.Add(("TriggerTimeout: " + Globals.IHandler.Vigilance.TriggerTimeout)); + lstStatus.Items.Add(("Button: " + Globals.IHandler.Vigilance.ButtonState.ToString())); + lstStatus.Items.Add(("Required: " + Globals.IHandler.Vigilance.ActionRequired.ToString())); + lstStatus.Items.Add(("State: " + Globals.IHandler.Vigilance.State.ToString())); + } catch(Exception Ex) { + Debug.Print(("Something went wrong in the VigilanceSystem form: " + Ex.Message)); + } + } + + private void frmVigilanceSystem_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { + this.Visible = false; + e.Cancel = true; + } + + private void txtMinDelay_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { + if((e.KeyCode == Keys.Return)) { + long MinDelay; + long MaxDelay; + long Timeout; + float EarlyTriggerChance; + float MinTrainSpeed; + float TrainSpeedFactor; + try { + MinDelay = long.Parse(txtMinDelay.Text); + MaxDelay = long.Parse(txtMaxDelay.Text); + EarlyTriggerChance = float.Parse(txtEarlyTriggerChance.Text); + MinTrainSpeed = float.Parse(txtMinTrainSpeed.Text); + TrainSpeedFactor = float.Parse(txtTrainSpeedFactor.Text); + Timeout = long.Parse(txtTimeout.Text); + Globals.IHandler.Vigilance.MinDelay = MinDelay; + Globals.IHandler.Vigilance.MaxDelay = MaxDelay; + Globals.IHandler.Vigilance.EarlyTriggerChance = (EarlyTriggerChance / 100); + Globals.IHandler.Vigilance.MinimumTrainSpeed = MinTrainSpeed; + Globals.IHandler.Vigilance.TrainSpeedOffsetFactor = TrainSpeedFactor; + Globals.IHandler.Vigilance.TriggerTimeout = Timeout; + } catch(Exception) { + MessageBox.Show("Invalid values... Check to see that there are no letters or decimals where there are milliseconds", "ERROR!",MessageBoxButtons.OK,MessageBoxIcon.Error); + } + } + } + + private void frmVigilanceSystem_Shown(object sender, System.EventArgs e) { + txtMinDelay.Text = Globals.IHandler.Vigilance.MinDelay.ToString(); + txtMaxDelay.Text = Globals.IHandler.Vigilance.MaxDelay.ToString(); + txtEarlyTriggerChance.Text = (Globals.IHandler.Vigilance.EarlyTriggerChance * 100).ToString(); + txtMinTrainSpeed.Text = Globals.IHandler.Vigilance.MinimumTrainSpeed.ToString(); + txtTrainSpeedFactor.Text = Globals.IHandler.Vigilance.TrainSpeedOffsetFactor.ToString(); + txtTimeout.Text = Globals.IHandler.Vigilance.TriggerTimeout.ToString(); + chkUseVigilanceSystem.Checked = Globals.IHandler.Vigilance.UseVigilanceSystem; + } + + private void chkUseVigilanceSystem_CheckedChanged(object sender, System.EventArgs e) { + Globals.IHandler.Vigilance.UseVigilanceSystem = chkUseVigilanceSystem.Checked; + } + + public frmVigilanceSystem() { + InitializeComponent(); + this.tmUpdateInfo.Tick+=tmUpdateInfo_Tick; + this.FormClosing+=frmVigilanceSystem_FormClosing; + this.txtMinDelay.KeyDown+=txtMinDelay_KeyDown; + this.txtMaxDelay.KeyDown += txtMinDelay_KeyDown; + this.txtEarlyTriggerChance.KeyDown += txtMinDelay_KeyDown; + this.txtMinTrainSpeed.KeyDown += txtMinDelay_KeyDown; + this.txtTrainSpeedFactor.KeyDown += txtMinDelay_KeyDown; + this.txtTimeout.KeyDown += txtMinDelay_KeyDown; + this.Shown+=frmVigilanceSystem_Shown; + this.chkUseVigilanceSystem.CheckedChanged+=chkUseVigilanceSystem_CheckedChanged; + } + } +} diff --git a/RailWorks_Joystick_API/ucControls.xaml b/RailWorks_Joystick_API/ucControls.xaml new file mode 100644 index 0000000..fb60e2e --- /dev/null +++ b/RailWorks_Joystick_API/ucControls.xaml @@ -0,0 +1,245 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Steam controls + Will go here in + A future build. + + + + + + + + + + + Throttle / + + Combined Throttle&Brakes + + + + + + + + + + Throttle + + + + + + + + + + + + TrainBrakes + + + + + + + + + + + + LocomotiveBrakes + + + + + + + + + + + + DynamicBrakes + + + + + + + + + + + + Reverser + + + + + + + + + + + + Gear + + + + + + + + + diff --git a/RailWorks_Joystick_API/ucControls.xaml.cs b/RailWorks_Joystick_API/ucControls.xaml.cs new file mode 100644 index 0000000..bb57d62 --- /dev/null +++ b/RailWorks_Joystick_API/ucControls.xaml.cs @@ -0,0 +1,523 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace RailWorks_Joystick_API { + /// + /// Interaktionslogik für ucControls.xaml + /// + public partial class ucControls : UserControl { + + public struct AnalogControl { + + public int Min; + + public int Max; + + public int Current; + + private StackPanel Ctrl; + + public AnalogControl(ref StackPanel ControlGrid, int MinValue, int MaxValue, int CurrentValue) { + Ctrl = ControlGrid; + Min = MinValue; + Max = MaxValue; + Current = 0; + SetAdjusted(CurrentValue); + } + + public int GetRange() { + return (Max - Min); + } + + public int GetAdjustedNeg() { + return (Math.Abs(Min) + Current); + } + + public void SetAdjustedNeg(int Value) { + Current = Globals.Clamp((Min + Value), Min, Max); + Update(); + } + + public int GetAdjusted() { + return (GetRange() - GetAdjustedNeg()); + } + + public void SetAdjusted(int Value) { + SetAdjustedNeg((GetRange() - Value)); + } + + public float GetPercentNeg() { + return float.Parse(((float)GetAdjustedNeg() / (Max - Min)).ToString()); + } + + public void SetPercentNeg(float Value) { + SetAdjustedNeg(int.Parse((Value * GetRange()).ToString())); + } + + public float GetPercent() { + return (1 - GetPercentNeg()); + } + + public void SetPercent(float Value) { + SetPercentNeg((1 - Value)); + } + + private void Update() { + double SizeAdjust = ((Image)(((Grid)(Ctrl.Children[0])).Children[1])).Height; + Thickness Marg = new Thickness(0, (Current + - (SizeAdjust / 2)), 0, 0); + ((Image)(((Grid)(Ctrl.Children[0])).Children[1])).Margin = Marg; + if((Ctrl.Name == "GearControls")) { + int Gear = (int.Parse((GetPercent() * 4).ToString()) + 1); + ((Label)(((Grid)(Ctrl.Children[0])).Children[2])).Content = Gear.ToString(); + } else { + ((Label)(((Grid)(Ctrl.Children[0])).Children[2])).Content = (int.Parse((GetPercent() * 100).ToString()).ToString() + "%"); + } + } + } + + public struct ButtonControl { + + public int State; + + public void SetState(int Value) { + if((StateImages == null)) { + StateImages = new List(); + if(((Ctrl.Name == "StarterActive") + || ((Ctrl.Name == "ManualCouplingActive") + || ((Ctrl.Name == "AWSActive") + || ((Ctrl.Name == "EBrakeActive") + || ((Ctrl.Name == "PBrakeActive") + || ((Ctrl.Name == "DriverGuideActive") + || ((Ctrl.Name == "MapActive") + || ((Ctrl.Name == "PADAheadActive") + || ((Ctrl.Name == "PADBehindActive") + || ((Ctrl.Name == "JunctionAheadActive") + || ((Ctrl.Name == "JunctionBehindActive") + || (Ctrl.Name == "VigilanceActive"))))))))))))) { + StateImages.Add(("Images/Btn" + + (Ctrl.Name.Replace("Active", "") + "Inactive.png"))); + } else { + StateImages.Add("Images/BtnBlank.png"); + } + } + State = Globals.Clamp(Value, 0, Max); + State = Globals.Clamp(State, 0, (StateImages.Count - 1)); + Update(); + } + + public int Max; + + private Image Ctrl; + + public List StateImages; + + public ButtonControl(ref Image ControlImage, int StateValue, int MaxValue) { + Ctrl = ControlImage; + MaxValue = Globals.Clamp(MaxValue, 0, MaxValue); + Max = MaxValue; + StateImages = new List(); + State = 0; + SetState(StateValue); + } + + public void Toggle() { + if((Ctrl.Name == "AWSActive")) { + if((State > 0)) { + SetState((1 + 1) ^ (State - 1)); + return; + } + return; + } + if((State >= Max)) { + SetState(0); + } else { + SetState((State + 1)); + } + } + + public void Update() { + System.Windows.Media.Imaging.BitmapImage ImgSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(StateImages[State], UriKind.Relative)); + Ctrl.Source = ImgSource; + } + } + + public AnalogControl Throttle; + + public AnalogControl TrainBrakes; + + public AnalogControl LocomotiveBrakes; + + public AnalogControl DynamicBrakes; + + public AnalogControl Reverser; + + public AnalogControl Gear; + + public ButtonControl Wipers; + + public ButtonControl Lights; + + public ButtonControl Pantograph; + + public ButtonControl LoadUnload; + + public ButtonControl Sander; + + public ButtonControl SmallEjector; + + public ButtonControl Horn; + + public ButtonControl Bell; + + public ButtonControl CylinderCocks; + + public ButtonControl HeadOutLeft; + + public ButtonControl Cab; + + public ButtonControl HeadOutRight; + + public ButtonControl Trackside; + + public ButtonControl Alternate; + + public ButtonControl ExternalFront; + + public ButtonControl ExternalRear; + + public ButtonControl Passenger; + + public ButtonControl NextCab; + + public ButtonControl PreviousCab; + + public ButtonControl Coupling; + + public ButtonControl Yard; + + public ButtonControl FreeRoam; + + public ButtonControl ZoomIn; + + public ButtonControl ZoomOut; + + public ButtonControl Starter; + + public ButtonControl ManualCoupling; + + public ButtonControl AWS; + + public ButtonControl EBrake; + + public ButtonControl PBrake; + + public ButtonControl DriverGuide; + + public ButtonControl Map; + + public ButtonControl PADAhead; + + public ButtonControl PADBehind; + + public ButtonControl JunctionAhead; + + public ButtonControl JunctionBehind; + + public ButtonControl Vigilance; + + private int _SpeedometerIndex = 0; + + public int SpeedometerIndex { + get { + return _SpeedometerIndex; + } + set { + _SpeedometerIndex = value; + SpeedometerData S = Speedos[_SpeedometerIndex]; + SpeedoBG.Source = S.Background; + SpeedoIndicator.Source = S.Indicator; + SpeedoGlass.Source = S.Glass; + } + } + + public float Speed { + set { + if((Speedos.Count == 0)) { + // TODO: Exit + } + SpeedometerData S = Speedos[_SpeedometerIndex]; + if(S.IsKPH) { + value *= ((float)(1.609344)); + } + float Range = (S.EndAngle - S.StartAngle); + float Angle = float.Parse(((Globals.Clamp(value, 0, S.MaxSpeed) + * (Range / S.MaxSpeed)) + + S.StartAngle).ToString()); + System.Windows.Media.RotateTransform RT = new System.Windows.Media.RotateTransform(Angle); + SpeedoIndicator.RenderTransform = RT; + value = Globals.Clamp(value, 0f, 999.9f); + char[] SpeedString = string.Format("{0,5:###.0}", Math.Round(value, 1)).ToCharArray(); + System.Windows.Media.Imaging.BitmapImage ImgSource = new System.Windows.Media.Imaging.BitmapImage(); + string Num; + for(int I = 0; (I + <= (SpeedString.Length - 1)); I++) { + Num = SpeedString[I].ToString(); + if(((I == 2) + && (Num == " "))) { + Num = "0"; + } + if((Num == " ")) { + Num = "Blank"; + } + if((Num == ".")) { + // TODO: Continue For... Warning!!! not translated + } + ImgSource = new System.Windows.Media.Imaging.BitmapImage(new Uri(("Images/Digi" + + (Num + ".png")), UriKind.Relative)); + ((Image)(((Grid)(DigitalSpeedo.Children[I])).Children[0])).Source = ImgSource; + } + } + } + + private struct SpeedometerData { + + public System.Windows.Media.Imaging.BitmapImage Background; + + public System.Windows.Media.Imaging.BitmapImage Indicator; + + public System.Windows.Media.Imaging.BitmapImage Glass; + + public float MaxSpeed; + + public float StartAngle; + + public float EndAngle; + + public bool IsKPH; + + public SpeedometerData(string BackgroundPath, string IndicatorPath, string GlassPath, float MaxSpeedValue, float StartAngleValue, float EndAngleValue, bool IsKPHValue) { + Background = new System.Windows.Media.Imaging.BitmapImage(new Uri(BackgroundPath, UriKind.Relative)); + Indicator = new System.Windows.Media.Imaging.BitmapImage(new Uri(IndicatorPath, UriKind.Relative)); + Glass = new System.Windows.Media.Imaging.BitmapImage(new Uri(GlassPath, UriKind.Relative)); + MaxSpeed = MaxSpeedValue; + StartAngle = StartAngleValue; + EndAngle = EndAngleValue; + IsKPH = IsKPHValue; + } + } + + private List Speedos = new List(); + + private void SpeedoGlass_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { + if((e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)) { + if((SpeedometerIndex + == (Speedos.Count - 1))) { + SpeedometerIndex = 0; + } else { + SpeedometerIndex++; + } + } + } + + private bool _CombinedThrottleBrakes; + + public bool CombinedThrottleBrakes { + get { + return _CombinedThrottleBrakes; + } + set { + _CombinedThrottleBrakes = value; + if(_CombinedThrottleBrakes) { + System.Windows.Media.Imaging.BitmapImage ImgSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("Images/ThrottleBrakeHandle.png", UriKind.Relative)); + ((Image)(((Grid)(ThrottleControls.Children[0])).Children[1])).Source = ImgSource; + ((TextBlock)(((Grid)(ThrottleControls.Children[1])).Children[1])).Text = ("Combined" + ("\r\n" + ("Throttle /" + ("\r\n" + "Brakes")))); + } else { + ((TextBlock)(((Grid)(ThrottleControls.Children[1])).Children[1])).Text = "Throttle"; + } + } + } + + private void ucControls_Loaded(object sender, System.Windows.RoutedEventArgs e) { + Throttle = new AnalogControl(ref ThrottleControls, -4, 86, 0); + TrainBrakes = new AnalogControl(ref TrainBrakeControls, 0, 90, 0); + LocomotiveBrakes = new AnalogControl(ref LocomotiveBrakeControls, 0, 90, 0); + DynamicBrakes = new AnalogControl(ref DynamicBrakeControls, 0, 90, 0); + Reverser = new AnalogControl(ref ReverserControls, 0, 90, 0); + Gear = new AnalogControl(ref GearControls, 0, 80, 0); + CombinedThrottleBrakes = false; + Wipers = new ButtonControl(ref WipersActive, 0, 1); + Lights = new ButtonControl(ref LightsActive, 0, 2); + Pantograph = new ButtonControl(ref PantographActive, 0, 1); + LoadUnload = new ButtonControl(ref LoadUnloadActive, 0, 1); + Sander = new ButtonControl(ref SanderActive, 0, 1); + SmallEjector = new ButtonControl(ref SmallEjectorActive, 0, 1); + Horn = new ButtonControl(ref HornActive, 0, 1); + Bell = new ButtonControl(ref BellActive, 0, 1); + CylinderCocks = new ButtonControl(ref CylinderCocksActive, 0, 1); + Wipers.StateImages.Add("Images/BtnWipersActive.png"); + Lights.StateImages.Add("Images/BtnLightsActive1.png"); + Lights.StateImages.Add("Images/BtnLightsActive2.png"); + Pantograph.StateImages.Add("Images/BtnPantographActive.png"); + LoadUnload.StateImages.Add("Images/BtnLoadUnloadActive.png"); + Sander.StateImages.Add("Images/BtnSanderActive.png"); + SmallEjector.StateImages.Add("Images/BtnSmallEjectorActive.png"); + Horn.StateImages.Add("Images/BtnHornActive.png"); + Bell.StateImages.Add("Images/BtnBellActive.png"); + CylinderCocks.StateImages.Add("Images/BtnCylinderCocksActive.png"); + HeadOutLeft = new ButtonControl(ref HeadOutLeftActive, 0, 1); + Cab = new ButtonControl(ref CabActive, 0, 1); + HeadOutRight = new ButtonControl(ref HeadOutRightActive, 0, 1); + Trackside = new ButtonControl(ref TracksideActive, 0, 1); + Alternate = new ButtonControl(ref AlternateActive, 0, 1); + ExternalFront = new ButtonControl(ref ExternalFrontActive, 0, 1); + ExternalRear = new ButtonControl(ref ExternalRearActive, 0, 1); + Passenger = new ButtonControl(ref PassengerActive, 0, 1); + NextCab = new ButtonControl(ref NextCabActive, 0, 1); + PreviousCab = new ButtonControl(ref PreviousCabActive, 0, 1); + Coupling = new ButtonControl(ref CouplingActive, 0, 1); + Yard = new ButtonControl(ref YardActive, 0, 1); + FreeRoam = new ButtonControl(ref FreeRoamActive, 0, 1); + ZoomIn = new ButtonControl(ref ZoomInActive, 0, 1); + ZoomOut = new ButtonControl(ref ZoomOutActive, 0, 1); + HeadOutLeft.StateImages.Add("Images/BtnHeadOutLeftActive.png"); + Cab.StateImages.Add("Images/BtnCabActive.png"); + HeadOutRight.StateImages.Add("Images/BtnHeadOutRightActive.png"); + Trackside.StateImages.Add("Images/BtnTracksideActive.png"); + Alternate.StateImages.Add("Images/BtnAlternateActive.png"); + ExternalFront.StateImages.Add("Images/BtnExternalFrontActive.png"); + ExternalRear.StateImages.Add("Images/BtnExternalRearActive.png"); + Passenger.StateImages.Add("Images/BtnPassengerActive.png"); + NextCab.StateImages.Add("Images/BtnNextCabActive.png"); + PreviousCab.StateImages.Add("Images/BtnPreviousCabActive.png"); + Coupling.StateImages.Add("Images/BtnCouplingActive.png"); + Yard.StateImages.Add("Images/BtnYardActive.png"); + FreeRoam.StateImages.Add("Images/BtnFreeRoamActive.png"); + ZoomIn.StateImages.Add("Images/BtnZoomInActive.png"); + ZoomOut.StateImages.Add("Images/BtnZoomOutActive.png"); + Starter = new ButtonControl(ref StarterActive, 0, 1); + ManualCoupling = new ButtonControl(ref ManualCouplingActive, 0, 1); + AWS = new ButtonControl(ref AWSActive, 0, 2); + EBrake = new ButtonControl(ref EBrakeActive, 0, 1); + Starter.StateImages.Add("Images/BtnStarterActive.png"); + ManualCoupling.StateImages.Add("Images/BtnManualCouplingActive.png"); + AWS.StateImages.Add("Images/BtnAWSActive1.png"); + AWS.StateImages.Add("Images/BtnAWSActive2.png"); + EBrake.StateImages.Add("Images/BtnEBrakeActive.png"); + PBrake = new ButtonControl(ref PBrakeActive, 0, 1); + DriverGuide = new ButtonControl(ref DriverGuideActive, 0, 1); + Map = new ButtonControl(ref MapActive, 0, 1); + PADAhead = new ButtonControl(ref PADAheadActive, 0, 1); + PADBehind = new ButtonControl(ref PADBehindActive, 0, 1); + JunctionAhead = new ButtonControl(ref JunctionAheadActive, 0, 1); + JunctionBehind = new ButtonControl(ref JunctionBehindActive, 0, 1); + PBrake.StateImages.Add("Images/BtnPBrakeActive.png"); + DriverGuide.StateImages.Add("Images/BtnDriverGuideActive.png"); + Map.StateImages.Add("Images/Btn2DMapActive.png"); + PADAhead.StateImages.Add("Images/BtnPADAheadActive.png"); + PADBehind.StateImages.Add("Images/BtnPADBehindActive.png"); + JunctionAhead.StateImages.Add("Images/BtnJunctionAheadActive.png"); + JunctionBehind.StateImages.Add("Images/BtnJunctionBehindActive.png"); + Vigilance = new ButtonControl(ref VigilanceActive, 0, 1); + Vigilance.StateImages.Add("Images/BtnVigilanceActive.png"); + Speedos.Add(new SpeedometerData("Images/SpeedoBgDay.png", "Images/SpeedoIndicator.png", "Images/SpeedoGlass120.png", 120, 0, 270, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgOrange.png", "Images/SpeedoIndicator.png", "Images/SpeedoGlass120.png", 120, 0, 270, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgBlue.png", "Images/SpeedoIndicatorBlue.png", "Images/SpeedoGlass120.png", 120, 0, 270, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBg200Day.png", "Images/SpeedoIndicator.png", "Images/SpeedoGlass200.png", 200, 0, 315, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBg200KPHDay.png", "Images/SpeedoIndicator.png", "Images/SpeedoGlass200.png", 200, 0, 315, true)); + Speedos.Add(new SpeedometerData("Images/SpeedoBg300KPHDay.png", "Images/SpeedoIndicator.png", "Images/SpeedoGlass200.png", 300, 0, 315, true)); + Speedos.Add(new SpeedometerData("Images/SpeedoBg360KPHDay.png", "Images/SpeedoIndicator.png", "Images/SpeedoGlass200.png", 360, 0, 315, true)); + } + public delegate void SetupControlEvent(string Name, string Description); + public event SetupControlEvent SetupButtonControls; + public event SetupControlEvent SetupAnalogControls; + + private string Description; + + + + private void AnalogControl_MouseDown(object Sender, System.Windows.Input.MouseButtonEventArgs e) { + if((e.RightButton == System.Windows.Input.MouseButtonState.Pressed)) { + StackPanel Ctrl = ((StackPanel)(Sender)); + string CtrlName = Ctrl.Name.Replace("Controls", ""); + string Description; + if((CtrlName == "Throttle")) { + Description = "Throttle / Combined Throttle & Brakes"; + } else { + Description = Ctrl.ToolTip.ToString(); + } + SetupAnalogControls(CtrlName, Description); + } + } + + private void ButtonControl_MouseDown(object Sender, System.Windows.Input.MouseButtonEventArgs e) { + // Not included because there is no Action ID for this + // BellActive.MouseDown, _ + // AlternateActive.MouseDown, _ + // PassengerActive.MouseDown, _ + // ZoomInActive.MouseDown, _ + // ZoomOutActive.MouseDown, _ + if((e.RightButton == System.Windows.Input.MouseButtonState.Pressed)) { + Image Ctrl = ((Image)(Sender)); + string CtrlName = Ctrl.Name.Replace("Active", ""); + string Description = Ctrl.ToolTip.ToString(); + SetupButtonControls(CtrlName, Description); + } + } + + public ucControls() { + InitializeComponent(); + this.SpeedoGlass.MouseDown+=SpeedoGlass_MouseDown; + this.Loaded+=ucControls_Loaded; + this.ThrottleControls.MouseDown+=AnalogControl_MouseDown; + this.TrainBrakeControls.MouseDown += AnalogControl_MouseDown; + this.LocomotiveBrakeControls.MouseDown += AnalogControl_MouseDown; + this.DynamicBrakeControls.MouseDown += AnalogControl_MouseDown; + this.ReverserControls.MouseDown += AnalogControl_MouseDown; + this.GearControls.MouseDown += AnalogControl_MouseDown; + this.WipersActive.MouseDown+=ButtonControl_MouseDown; + this.LightsActive.MouseDown+=ButtonControl_MouseDown; + this.PantographActive.MouseDown+=ButtonControl_MouseDown; + this.LoadUnloadActive.MouseDown+=ButtonControl_MouseDown; + this.SanderActive.MouseDown+=ButtonControl_MouseDown; + this.SmallEjectorActive.MouseDown+=ButtonControl_MouseDown; + this.HornActive.MouseDown+=ButtonControl_MouseDown; + this.CylinderCocksActive.MouseDown+=ButtonControl_MouseDown; + this.HeadOutLeftActive.MouseDown+=ButtonControl_MouseDown; + this.CabActive.MouseDown+=ButtonControl_MouseDown; + this.HeadOutRightActive.MouseDown+=ButtonControl_MouseDown; + this.TracksideActive.MouseDown+=ButtonControl_MouseDown; + this.ExternalFrontActive.MouseDown+=ButtonControl_MouseDown; + this.ExternalRearActive.MouseDown+=ButtonControl_MouseDown; + this.NextCabActive.MouseDown+=ButtonControl_MouseDown; + this.PreviousCabActive.MouseDown+=ButtonControl_MouseDown; + this.CouplingActive.MouseDown+=ButtonControl_MouseDown; + this.YardActive.MouseDown+=ButtonControl_MouseDown; + this.FreeRoamActive.MouseDown+=ButtonControl_MouseDown; + this.StarterActive.MouseDown+=ButtonControl_MouseDown; + this.ManualCouplingActive.MouseDown+=ButtonControl_MouseDown; + this.AWSActive.MouseDown+=ButtonControl_MouseDown; + this.EBrakeActive.MouseDown+=ButtonControl_MouseDown; + this.PBrakeActive.MouseDown+=ButtonControl_MouseDown; + this.DriverGuideActive.MouseDown+=ButtonControl_MouseDown; + this.MapActive.MouseDown+=ButtonControl_MouseDown; + this.PADAheadActive.MouseDown+=ButtonControl_MouseDown; + this.PADBehindActive.MouseDown+=ButtonControl_MouseDown; + this.JunctionAheadActive.MouseDown+=ButtonControl_MouseDown; + this.JunctionBehindActive.MouseDown+=ButtonControl_MouseDown; + this.VigilanceActive.MouseDown += ButtonControl_MouseDown; + } + } +} diff --git a/RailWorks_Joystick_API/ucLargeSpeedo.xaml b/RailWorks_Joystick_API/ucLargeSpeedo.xaml new file mode 100644 index 0000000..955afa4 --- /dev/null +++ b/RailWorks_Joystick_API/ucLargeSpeedo.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/RailWorks_Joystick_API/ucLargeSpeedo.xaml.cs b/RailWorks_Joystick_API/ucLargeSpeedo.xaml.cs new file mode 100644 index 0000000..b39f711 --- /dev/null +++ b/RailWorks_Joystick_API/ucLargeSpeedo.xaml.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace RailWorks_Joystick_API { + /// + /// Interaktionslogik für ucLargeSpeedo.xaml + /// + public partial class ucLargeSpeedo : UserControl { + + private int _SpeedometerIndex = 0; + + public int SpeedometerIndex { + get { + return _SpeedometerIndex; + } + set { + _SpeedometerIndex = value; + SpeedometerData S = Speedos[_SpeedometerIndex]; + SpeedoBG.Source = S.Background; + SpeedoIndicator.Source = S.Indicator; + SpeedoGlass.Source = S.Glass; + } + } + + public float Speed { + set { + SpeedometerData S = Speedos[_SpeedometerIndex]; + if(S.IsKPH) { + value *= ((float)(1.609344)); + } + float Range = (S.EndAngle - S.StartAngle); + float Angle = float.Parse(((Globals.Clamp(value, 0, S.MaxSpeed) + * (Range / S.MaxSpeed)) + + S.StartAngle).ToString()); + System.Windows.Media.RotateTransform RT = new System.Windows.Media.RotateTransform(Angle); + SpeedoIndicator.RenderTransform = RT; + } + } + + private struct SpeedometerData { + + public System.Windows.Media.Imaging.BitmapImage Background; + + public System.Windows.Media.Imaging.BitmapImage Indicator; + + public System.Windows.Media.Imaging.BitmapImage Glass; + + public float MaxSpeed; + + public float StartAngle; + + public float EndAngle; + + public bool IsKPH; + + public SpeedometerData(string BackgroundPath, string IndicatorPath, string GlassPath, float MaxSpeedValue, float StartAngleValue, float EndAngleValue, bool IsKPHValue) { + Background = new System.Windows.Media.Imaging.BitmapImage(new Uri(BackgroundPath, UriKind.Relative)); + Indicator = new System.Windows.Media.Imaging.BitmapImage(new Uri(IndicatorPath, UriKind.Relative)); + Glass = new System.Windows.Media.Imaging.BitmapImage(new Uri(GlassPath, UriKind.Relative)); + MaxSpeed = MaxSpeedValue; + StartAngle = StartAngleValue; + EndAngle = EndAngleValue; + IsKPH = IsKPHValue; + } + } + + private List Speedos = new List(); + + private void SpeedoGlass_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { + if((e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)) { + if((SpeedometerIndex + == (Speedos.Count - 1))) { + SpeedometerIndex = 0; + } else { + SpeedometerIndex++; + } + } + } + + private void ucLargeSpeedo_Loaded(object sender, System.Windows.RoutedEventArgs e) { + Speedos.Add(new SpeedometerData("Images/SpeedoBgLargeDay.png", "Images/SpeedoIndicatorLarge.png", "Images/SpeedoGlassLarge120.png", 120, 0, 270, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgLargeOrange.png", "Images/SpeedoIndicatorLarge.png", "Images/SpeedoGlassLarge120.png", 120, 0, 270, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgLargeBlue.png", "Images/SpeedoIndicatorLargeBlue.png", "Images/SpeedoGlassLarge120.png", 120, 0, 270, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgLarge200Day.png", "Images/SpeedoIndicatorLarge.png", "Images/SpeedoGlassLarge200.png", 200, 0, 315, false)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgLarge200KPHDay.png", "Images/SpeedoIndicatorLarge.png", "Images/SpeedoGlassLarge200.png", 200, 0, 315, true)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgLarge300KPHDay.png", "Images/SpeedoIndicatorLarge.png", "Images/SpeedoGlassLarge200.png", 300, 0, 315, true)); + Speedos.Add(new SpeedometerData("Images/SpeedoBgLarge360KPHDay.png", "Images/SpeedoIndicatorLarge.png", "Images/SpeedoGlassLarge200.png", 360, 0, 315, true)); + } + + public ucLargeSpeedo() { + InitializeComponent(); + this.SpeedoGlass.MouseDown+=SpeedoGlass_MouseDown; + this.Loaded+=ucLargeSpeedo_Loaded; + + } + } +}