@@ -50,6 +50,8 @@ protected override ControlLayout Layout(ControlLayout layout)
5050
5151 TrainCar trainCar = Viewer . PlayerTrain . Cars [ CarPosition ] ;
5252 BrakeSystem brakeSystem = ( trainCar as MSTSWagon ) . BrakeSystem ;
53+ MSTSLocomotive locomotive = trainCar as MSTSLocomotive ;
54+ MSTSWagon wagon = trainCar as MSTSWagon ;
5355
5456 BrakeSystem rearBrakeSystem = null ;
5557 if ( CarPosition + 1 < Viewer . PlayerTrain . Cars . Count )
@@ -58,11 +60,14 @@ protected override ControlLayout Layout(ControlLayout layout)
5860 rearBrakeSystem = ( rearTrainCar as MSTSWagon ) . BrakeSystem ;
5961 }
6062
63+ bool isElectricDieselLocomotive = ( Viewer . PlayerTrain . Cars [ CarPosition ] is MSTSElectricLocomotive ) || ( Viewer . PlayerTrain . Cars [ CarPosition ] is MSTSDieselLocomotive ) ;
64+
6165 var vbox = base . Layout ( layout ) . AddLayoutVertical ( ) ;
62- vbox . Add ( ID = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Car ID" ) + " " + ( CarPosition >= Viewer . PlayerTrain . Cars . Count ? " " : Viewer . PlayerTrain . Cars [ CarPosition ] . CarID ) , LabelAlignment . Center ) ) ;
66+ vbox . Add ( ID = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Car ID" ) + " " + ( CarPosition >= Viewer . PlayerTrain . Cars . Count ? " " : Viewer . PlayerTrain . Cars [ CarPosition ] . CarID ) , LabelAlignment . Center ) ) ;
6367 ID . Color = Color . Red ;
6468 vbox . AddHorizontalSeparator ( ) ;
6569
70+ // Handbrake
6671 string buttonHandbrakeText = "" ;
6772 if ( ( trainCar as MSTSWagon ) . GetTrainHandbrakeStatus ( ) )
6873 buttonHandbrakeText = Viewer . Catalog . GetString ( "Unset Handbrake" ) ;
@@ -71,15 +76,38 @@ protected override ControlLayout Layout(ControlLayout layout)
7176 vbox . Add ( buttonHandbrake = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , buttonHandbrakeText , LabelAlignment . Center ) ) ;
7277 vbox . AddHorizontalSeparator ( ) ;
7378
74- vbox . Add ( buttonTogglePower = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Toggle Power" ) , LabelAlignment . Center ) ) ;
79+ // Power Supply
80+ if ( locomotive != null )
81+ if ( locomotive . LocomotivePowerSupply . MainPowerSupplyOn )
82+ vbox . Add ( buttonTogglePower = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Power Off" ) , LabelAlignment . Center ) ) ;
83+ else
84+ vbox . Add ( buttonTogglePower = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Power On" ) , LabelAlignment . Center ) ) ;
85+ else
86+ vbox . Add ( buttonTogglePower = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Power On" ) , LabelAlignment . Center ) ) ;
7587 vbox . AddHorizontalSeparator ( ) ;
76- vbox . Add ( buttonToggleMU = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Toggle MU Connection" ) , LabelAlignment . Center ) ) ;
88+
89+ // MU Connection
90+ if ( ( locomotive != null ) && ( locomotive . RemoteControlGroup >= 0 ) )
91+ vbox . Add ( buttonToggleMU = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Disconnect MU Connection" ) , LabelAlignment . Center ) ) ;
92+ else
93+ vbox . Add ( buttonToggleMU = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Connect MU Connection" ) , LabelAlignment . Center ) ) ;
7794 vbox . AddHorizontalSeparator ( ) ;
78- vbox . Add ( buttonToggleBatterySwitch = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Toggle Battery Switch" ) , LabelAlignment . Center ) ) ;
95+
96+ // Battery Switch
97+ if ( ( wagon != null ) && ( wagon . PowerSupply is IPowerSupply ) && ( wagon . PowerSupply . BatterySwitch . On ) )
98+ vbox . Add ( buttonToggleBatterySwitch = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Battery Switch Off" ) , LabelAlignment . Center ) ) ;
99+ else
100+ vbox . Add ( buttonToggleBatterySwitch = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Battery Switch On" ) , LabelAlignment . Center ) ) ;
79101 vbox . AddHorizontalSeparator ( ) ;
80- vbox . Add ( buttonToggleElectricTrainSupplyCable = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Toggle Electric Train Supply Connection" ) , LabelAlignment . Center ) ) ;
102+
103+ // Electric Train Supply Connection
104+ if ( ( wagon . PowerSupply != null ) && wagon . PowerSupply . FrontElectricTrainSupplyCableConnected )
105+ vbox . Add ( buttonToggleElectricTrainSupplyCable = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Disonnect Electric Train Supply" ) , LabelAlignment . Center ) ) ;
106+ else
107+ vbox . Add ( buttonToggleElectricTrainSupplyCable = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Connect Electric Train Supply" ) , LabelAlignment . Center ) ) ;
81108 vbox . AddHorizontalSeparator ( ) ;
82109
110+ // Front Brake Hose
83111 string buttonToggleFronBrakeHoseText = "" ;
84112 if ( brakeSystem . FrontBrakeHoseConnected )
85113 buttonToggleFronBrakeHoseText = Viewer . Catalog . GetString ( "Disconnect Front Brake Hose" ) ;
@@ -88,6 +116,7 @@ protected override ControlLayout Layout(ControlLayout layout)
88116 vbox . Add ( buttonToggleFrontBrakeHose = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , buttonToggleFronBrakeHoseText , LabelAlignment . Center ) ) ;
89117 vbox . AddHorizontalSeparator ( ) ;
90118
119+ // Rear Brake Hose
91120 string buttonToggleRearBrakeHoseText = "" ;
92121 if ( ( ( CarPosition + 1 ) < Viewer . PlayerTrain . Cars . Count ) && ( rearBrakeSystem . FrontBrakeHoseConnected ) )
93122 buttonToggleRearBrakeHoseText = Viewer . Catalog . GetString ( "Disconnect Rear Brake Hose" ) ;
@@ -96,6 +125,7 @@ protected override ControlLayout Layout(ControlLayout layout)
96125 vbox . Add ( buttonToggleRearBrakeHose = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , buttonToggleRearBrakeHoseText , LabelAlignment . Center ) ) ;
97126 vbox . AddHorizontalSeparator ( ) ;
98127
128+ // Front Angle Cock
99129 string buttonToggleAngleCockAText = "" ;
100130 if ( brakeSystem . AngleCockAOpen )
101131 buttonToggleAngleCockAText = Viewer . Catalog . GetString ( "Close Front Angle Cock" ) ;
@@ -104,6 +134,7 @@ protected override ControlLayout Layout(ControlLayout layout)
104134 vbox . Add ( buttonToggleAngleCockA = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , buttonToggleAngleCockAText , LabelAlignment . Center ) ) ;
105135 vbox . AddHorizontalSeparator ( ) ;
106136
137+ // Rear Angle Cock
107138 string buttonToggleAngleCockBText = "" ;
108139 if ( brakeSystem . AngleCockBOpen )
109140 buttonToggleAngleCockBText = Viewer . Catalog . GetString ( "Close Rear Angle Cock" ) ;
@@ -112,6 +143,7 @@ protected override ControlLayout Layout(ControlLayout layout)
112143 vbox . Add ( buttonToggleAngleCockB = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , buttonToggleAngleCockBText , LabelAlignment . Center ) ) ;
113144 vbox . AddHorizontalSeparator ( ) ;
114145
146+ // Bleed Off Valve
115147 string buttonToggleBleedOffValveAText = "" ;
116148 if ( brakeSystem . BleedOffValveOpen )
117149 buttonToggleBleedOffValveAText = Viewer . Catalog . GetString ( "Close Bleed Off Valve" ) ;
@@ -120,29 +152,63 @@ protected override ControlLayout Layout(ControlLayout layout)
120152 vbox . Add ( buttonToggleBleedOffValve = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , buttonToggleBleedOffValveAText , LabelAlignment . Center ) ) ;
121153 vbox . AddHorizontalSeparator ( ) ;
122154
155+ // Close button
123156 vbox . Add ( buttonClose = new Label ( vbox . RemainingWidth , Owner . TextFontDefault . Height , Viewer . Catalog . GetString ( "Close window" ) , LabelAlignment . Center ) ) ;
124157
158+ // add click controls
159+
160+ // Handbrake
125161 if ( ( trainCar as MSTSWagon ) . HandBrakePresent )
126162 buttonHandbrake . Click += new Action < Control , Point > ( buttonHandbrake_Click ) ;
127163 else
128164 buttonHandbrake . Color = Color . Gray ;
129- buttonTogglePower . Click += new Action < Control , Point > ( buttonTogglePower_Click ) ;
130- buttonToggleMU . Click += new Action < Control , Point > ( buttonToggleMU_Click ) ;
131- buttonToggleBatterySwitch . Click += new Action < Control , Point > ( buttonToggleBatterySwitch_Click ) ;
132- buttonToggleElectricTrainSupplyCable . Click += new Action < Control , Point > ( buttonToggleElectricTrainSupplyCable_Click ) ;
133165
166+ // Power Supply
167+ if ( isElectricDieselLocomotive )
168+ buttonTogglePower . Click += new Action < Control , Point > ( buttonTogglePower_Click ) ;
169+ else
170+ buttonTogglePower . Color = Color . Gray ;
171+
172+ // MU Connection
173+ if ( isElectricDieselLocomotive )
174+ buttonToggleMU . Click += new Action < Control , Point > ( buttonToggleMU_Click ) ;
175+ else
176+ buttonToggleMU . Color = Color . Gray ;
177+
178+ // Battery Switch
179+ if ( ( wagon != null ) && ( wagon . PowerSupply is IPowerSupply ) )
180+ buttonToggleBatterySwitch . Click += new Action < Control , Point > ( buttonToggleBatterySwitch_Click ) ;
181+ else
182+ buttonToggleBatterySwitch . Color = Color . Gray ;
183+
184+ // Electric Train Supply Connection
185+ if ( ( wagon != null ) && ( wagon . PowerSupply != null ) )
186+ buttonToggleElectricTrainSupplyCable . Click += new Action < Control , Point > ( buttonToggleElectricTrainSupplyCable_Click ) ;
187+ else
188+ buttonToggleElectricTrainSupplyCable . Color = Color . Gray ;
189+
190+ // Front Brake Hose
134191 if ( CarPosition > 0 )
135192 buttonToggleFrontBrakeHose . Click += new Action < Control , Point > ( buttonToggleFrontBrakeHose_Click ) ;
136193 else
137194 buttonToggleFrontBrakeHose . Color = Color . Gray ;
195+
196+ // Rear Brake Hose
138197 if ( CarPosition < ( Viewer . PlayerTrain . Cars . Count - 1 ) )
139198 buttonToggleRearBrakeHose . Click += new Action < Control , Point > ( buttonToggleRearBrakeHose_Click ) ;
140199 else
141200 buttonToggleRearBrakeHose . Color = Color . Gray ;
142201
202+ // Front Angle Cock
143203 buttonToggleAngleCockA . Click += new Action < Control , Point > ( buttonToggleAngleCockA_Click ) ;
204+
205+ // Rear Angle Cock
144206 buttonToggleAngleCockB . Click += new Action < Control , Point > ( buttonToggleAngleCockB_Click ) ;
207+
208+ // Bleed Off Valve
145209 buttonToggleBleedOffValve . Click += new Action < Control , Point > ( buttonToggleBleedOffValve_Click ) ;
210+
211+ // Close button
146212 buttonClose . Click += new Action < Control , Point > ( buttonClose_Click ) ;
147213
148214 return vbox ;
0 commit comments