@@ -56,7 +56,7 @@ public int SelectedTabIndex
5656 OnPropertyChanged ( ) ;
5757 }
5858 }
59-
59+
6060 #region Sessions
6161 ICollectionView _puTTYSessions ;
6262 public ICollectionView PuTTYSessions
@@ -189,54 +189,11 @@ public ICommand ConnectNewSessionCommand
189189 get { return new RelayCommand ( p => ConnectNewSessionAction ( ) ) ; }
190190 }
191191
192- private async void ConnectNewSessionAction ( )
192+ private void ConnectNewSessionAction ( )
193193 {
194- CustomDialog customDialog = new CustomDialog ( )
195- {
196- Title = LocalizationManager . GetStringByKey ( "String_Header_Connect" )
197- } ;
198-
199- PuTTYSessionConnectViewModel puTTYSessionConnectViewModel = new PuTTYSessionConnectViewModel ( instance =>
200- {
201- dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
202- ConfigurationManager . Current . FixAirspace = false ;
203-
204- // Add host to history
205- AddHostToHistory ( instance . Host ) ;
206- AddSerialLineToHistory ( instance . SerialLine ) ;
207- AddPortToHistory ( instance . Port . ToString ( ) ) ;
208- AddBaudToHistory ( instance . Baud . ToString ( ) ) ;
209- AddUsernameToHistory ( instance . Username ) ;
210- AddProfileToHistory ( instance . Profile ) ;
211-
212- // Create session info
213- Models . PuTTY . PuTTYSessionInfo puTTYSessionInfo = new Models . PuTTY . PuTTYSessionInfo
214- {
215- HostOrSerialLine = instance . ConnectionMode == PuTTY . ConnectionMode . Serial ? instance . SerialLine : instance . Host ,
216- Mode = instance . ConnectionMode ,
217- PortOrBaud = instance . ConnectionMode == PuTTY . ConnectionMode . Serial ? instance . Baud : instance . Port ,
218- Username = instance . Username ,
219- Profile = instance . Profile ,
220- AdditionalCommandLine = instance . AdditionalCommandLine
221- } ;
222-
223- // Connect
224- ConnectSession ( puTTYSessionInfo ) ;
225- } , instance =>
226- {
227- dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
228- ConfigurationManager . Current . FixAirspace = false ;
229- } ) ;
230-
231- customDialog . Content = new PuTTYSessionConnectDialog
232- {
233- DataContext = puTTYSessionConnectViewModel
234- } ;
235-
236- ConfigurationManager . Current . FixAirspace = true ;
237- await dialogCoordinator . ShowMetroDialogAsync ( this , customDialog ) ;
194+ ConnectNewSession ( ) ;
238195 }
239-
196+
240197 public ICommand AddSessionCommand
241198 {
242199 get { return new RelayCommand ( p => AddSessionAction ( ) ) ; }
@@ -277,26 +234,21 @@ public ICommand ConnectSessionCommand
277234
278235 private void ConnectSessionAction ( )
279236 {
280- // Connect
281- ConnectSession ( Models . PuTTY . PuTTYSessionInfo . Parse ( SelectedSession ) , SelectedSession . Name ) ;
237+ ConnectSession ( ) ;
282238 }
283239
240+
241+
284242 public ICommand ConnectSessionExternalCommand
285243 {
286244 get { return new RelayCommand ( p => ConnectSessionExternalAction ( ) ) ; }
287245 }
288246
289247 private void ConnectSessionExternalAction ( )
290248 {
291- ProcessStartInfo info = new ProcessStartInfo
292- {
293- FileName = SettingsManager . Current . PuTTY_PuTTYLocation ,
294- Arguments = PuTTY . BuildCommandLine ( Models . PuTTY . PuTTYSessionInfo . Parse ( SelectedSession ) )
295- } ;
296-
297- Process . Start ( info ) ;
249+ ConnectSessionExternal ( ) ;
298250 }
299-
251+
300252 public ICommand EditSessionCommand
301253 {
302254 get { return new RelayCommand ( p => EditSessionAction ( ) ) ; }
@@ -453,7 +405,74 @@ private void CheckIfPuTTYConfigured()
453405 IsPuTTYConfigured = false ;
454406 }
455407
456- private void ConnectSession ( Models . PuTTY . PuTTYSessionInfo sessionInfo , string Header = null )
408+ private async void ConnectNewSession ( string host = null )
409+ {
410+ CustomDialog customDialog = new CustomDialog ( )
411+ {
412+ Title = LocalizationManager . GetStringByKey ( "String_Header_Connect" )
413+ } ;
414+
415+ PuTTYSessionConnectViewModel puTTYSessionConnectViewModel = new PuTTYSessionConnectViewModel ( instance =>
416+ {
417+ dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
418+ ConfigurationManager . Current . FixAirspace = false ;
419+
420+ // Add host to history
421+ AddHostToHistory ( instance . Host ) ;
422+ AddSerialLineToHistory ( instance . SerialLine ) ;
423+ AddPortToHistory ( instance . Port . ToString ( ) ) ;
424+ AddBaudToHistory ( instance . Baud . ToString ( ) ) ;
425+ AddUsernameToHistory ( instance . Username ) ;
426+ AddProfileToHistory ( instance . Profile ) ;
427+
428+ // Create session info
429+ Models . PuTTY . PuTTYSessionInfo puTTYSessionInfo = new Models . PuTTY . PuTTYSessionInfo
430+ {
431+ HostOrSerialLine = instance . ConnectionMode == PuTTY . ConnectionMode . Serial ? instance . SerialLine : instance . Host ,
432+ Mode = instance . ConnectionMode ,
433+ PortOrBaud = instance . ConnectionMode == PuTTY . ConnectionMode . Serial ? instance . Baud : instance . Port ,
434+ Username = instance . Username ,
435+ Profile = instance . Profile ,
436+ AdditionalCommandLine = instance . AdditionalCommandLine
437+ } ;
438+
439+ // Connect
440+ Connect ( puTTYSessionInfo ) ;
441+ } , instance =>
442+ {
443+ dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
444+ ConfigurationManager . Current . FixAirspace = false ;
445+ } )
446+ {
447+ Host = host
448+ } ;
449+
450+ customDialog . Content = new PuTTYSessionConnectDialog
451+ {
452+ DataContext = puTTYSessionConnectViewModel
453+ } ;
454+
455+ ConfigurationManager . Current . FixAirspace = true ;
456+ await dialogCoordinator . ShowMetroDialogAsync ( this , customDialog ) ;
457+ }
458+
459+ private void ConnectSession ( )
460+ {
461+ Connect ( Models . PuTTY . PuTTYSessionInfo . Parse ( SelectedSession ) , SelectedSession . Name ) ;
462+ }
463+
464+ private void ConnectSessionExternal ( )
465+ {
466+ ProcessStartInfo info = new ProcessStartInfo
467+ {
468+ FileName = SettingsManager . Current . PuTTY_PuTTYLocation ,
469+ Arguments = PuTTY . BuildCommandLine ( Models . PuTTY . PuTTYSessionInfo . Parse ( SelectedSession ) )
470+ } ;
471+
472+ Process . Start ( info ) ;
473+ }
474+
475+ private void Connect ( Models . PuTTY . PuTTYSessionInfo sessionInfo , string Header = null )
457476 {
458477 // Add PuTTY path here...
459478 sessionInfo . PuTTYLocation = SettingsManager . Current . PuTTY_PuTTYLocation ;
@@ -463,6 +482,11 @@ private void ConnectSession(Models.PuTTY.PuTTYSessionInfo sessionInfo, string He
463482 SelectedTabIndex = TabItems . Count - 1 ;
464483 }
465484
485+ public void AddTab ( string host )
486+ {
487+ ConnectNewSession ( host ) ;
488+ }
489+
466490 // Modify history list
467491 private void AddHostToHistory ( string host )
468492 {
0 commit comments