@@ -165,28 +165,74 @@ public DispatchViewer(Simulator simulator, Viewer viewer)
165165
166166 this . simulator = simulator ;
167167 this . Viewer = viewer ;
168- TimetableWindow = new TimetableWindow ( this ) ;
168+ TimetableWindow = new TimetableWindow ( this ) ;
169169
170- nodes = simulator . TDB . TrackDB . TrackNodes ;
170+ nodes = simulator . TDB . TrackDB . TrackNodes ;
171171
172172 // initialise the timer used to handle user input
173173 UITimer = new Timer ( ) ;
174174 UITimer . Interval = 100 ;
175175 UITimer . Tick += new System . EventHandler ( UITimer_Tick ) ;
176176 UITimer . Start ( ) ;
177+ }
178+
179+ public int RedrawCount ;
180+ public Font trainFont ;
181+ public Font sidingFont ;
182+ public Font PlatformFont ;
183+ public Font SignalFont ;
184+ public SolidBrush trainBrush ;
185+ public SolidBrush sidingBrush ;
186+ public SolidBrush PlatformBrush ;
187+ public SolidBrush SignalBrush ;
188+ public SolidBrush InactiveTrainBrush ;
189+
190+ private double lastUpdateTime ;
191+
192+ /// <summary>
193+ /// When the user holds down the "L", "R", "U", "D" buttons,
194+ /// shift the view. Avoids the case when the user has to click
195+ /// buttons like crazy.
196+ /// </summary>
197+ /// <param name="sender"></param>
198+ /// <param name="e"></param>
199+ void UITimer_Tick ( object sender , EventArgs e )
200+ {
201+ if ( Viewer . DebugViewerEnabled == false ) // Ctrl+9 sets this true to initialise the window and make it visible
202+ {
203+ this . Visible = false ;
204+ firstShow = true ;
205+ return ;
206+ }
177207
178- ViewWindow = new RectangleF ( 0 , 0 , 5000f , 5000f ) ;
179- windowSizeUpDown . Accelerations . Add ( new NumericUpDownAcceleration ( 1 , 100 ) ) ;
180- boxSetSignal . Items . Add ( "System Controlled" ) ;
181- boxSetSignal . Items . Add ( "Stop" ) ;
182- boxSetSignal . Items . Add ( "Approach" ) ;
183- boxSetSignal . Items . Add ( "Proceed" ) ;
184- chkAllowUserSwitch . Checked = false ;
185- selectedTrainList = new List < Train > ( ) ;
186- if ( MultiPlayer . MPManager . IsMultiPlayer ( ) ) { MultiPlayer . MPManager . AllowedManualSwitch = false ; }
208+ if ( firstShow )
209+ {
210+ InitializeWindow ( ) ;
211+ }
212+ this . Visible = true ;
187213
188- InitData ( ) ;
189- InitImage ( ) ;
214+ if ( Program . Simulator . GameTime - lastUpdateTime < 1 )
215+ return ;
216+
217+ lastUpdateTime = Program . Simulator . GameTime ;
218+
219+ GenerateView ( ) ;
220+ }
221+
222+ private void InitializeWindow ( )
223+ {
224+ ViewWindow = new RectangleF ( 0 , 0 , 5000f , 5000f ) ;
225+ windowSizeUpDown . Accelerations . Add ( new NumericUpDownAcceleration ( 1 , 100 ) ) ;
226+ boxSetSignal . Items . Add ( "System Controlled" ) ;
227+ boxSetSignal . Items . Add ( "Stop" ) ;
228+ boxSetSignal . Items . Add ( "Approach" ) ;
229+ boxSetSignal . Items . Add ( "Proceed" ) ;
230+ chkAllowUserSwitch . Checked = false ;
231+ selectedTrainList = new List < Train > ( ) ;
232+ if ( MultiPlayer . MPManager . IsMultiPlayer ( ) ) { MultiPlayer . MPManager . AllowedManualSwitch = false ; }
233+
234+ InitData ( ) ;
235+ InitImage ( ) ;
190236
191237 /*
192238 if (MultiPlayer.MPManager.IsMultiPlayer())
@@ -213,40 +259,8 @@ public DispatchViewer(Simulator simulator, Viewer viewer)
213259 tWindow . SelectedIndex = ( MPManager . IsMultiPlayer ( ) ) ? 0 : 1 ;
214260 TimetableWindow . SetControls ( ) ;
215261 }
216-
217- public int RedrawCount ;
218- public Font trainFont ;
219- public Font sidingFont ;
220- public Font PlatformFont ;
221- public Font SignalFont ;
222- public SolidBrush trainBrush ;
223- public SolidBrush sidingBrush ;
224- public SolidBrush PlatformBrush ;
225- public SolidBrush SignalBrush ;
226- public SolidBrush InactiveTrainBrush ;
227-
228- private double lastUpdateTime ;
229-
230- /// <summary>
231- /// When the user holds down the "L", "R", "U", "D" buttons,
232- /// shift the view. Avoids the case when the user has to click
233- /// buttons like crazy.
234- /// </summary>
235- /// <param name="sender"></param>
236- /// <param name="e"></param>
237- void UITimer_Tick ( object sender , EventArgs e )
238- {
239- if ( Viewer . DebugViewerEnabled == false ) { this . Visible = false ; firstShow = true ; return ; }
240- else this . Visible = true ;
241-
242- if ( Program . Simulator . GameTime - lastUpdateTime < 1 ) return ;
243- lastUpdateTime = Program . Simulator . GameTime ;
244-
245- GenerateView ( ) ;
246- }
247-
248- #region initData
249- private void InitData ( )
262+ #region initData
263+ private void InitData ( )
250264 {
251265 if ( ! loaded )
252266 {
0 commit comments