11using Dragablz ;
22using log4net ;
33using MahApps . Metro . Controls . Dialogs ;
4+ using MahApps . Metro . SimpleChildWindow ;
45using NETworkManager . Controls ;
56using NETworkManager . Localization . Resources ;
67using NETworkManager . Models ;
@@ -239,7 +240,7 @@ public bool IsProfileFilterSet
239240 OnPropertyChanged ( ) ;
240241 }
241242 }
242-
243+
243244 private readonly GroupExpanderStateStore _groupExpanderStateStore = new ( ) ;
244245 public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore ;
245246
@@ -504,7 +505,7 @@ public ICommand TextBoxSearchLostFocusCommand
504505 private void OpenProfileFilterAction ( )
505506 {
506507 ConfigurationManager . Current . IsProfileFilterPopupOpen = true ;
507-
508+
508509 ProfileFilterIsOpen = true ;
509510 }
510511
@@ -524,7 +525,7 @@ private void ClearProfileFilterAction()
524525 _searchDisabled = true ;
525526 Search = string . Empty ;
526527 _searchDisabled = false ;
527-
528+
528529 foreach ( var tag in ProfileFilterTags )
529530 tag . IsSelected = false ;
530531
@@ -547,7 +548,7 @@ private void CollapseAllProfileGroupsAction()
547548 {
548549 SetIsExpandedForAllProfileGroups ( false ) ;
549550 }
550-
551+
551552 public ICommand OpenSettingsCommand => new RelayCommand ( _ => OpenSettingsAction ( ) ) ;
552553
553554 private static void OpenSettingsAction ( )
@@ -588,16 +589,15 @@ private void TryFindExecutable()
588589 Log . Warn ( "Install PuTTY or configure the path in the settings." ) ;
589590 }
590591
591- private async Task Connect ( string host = null )
592+ private Task Connect ( string host = null )
592593 {
593- var customDialog = new CustomDialog
594- {
595- Title = Strings . Connect
596- } ;
594+ var childWindow = new PuTTYConnectChildWindow ( ) ;
597595
598- var connectViewModel = new PuTTYConnectViewModel ( async instance =>
596+ var childWindowViewModel = new PuTTYConnectViewModel ( instance =>
599597 {
600- await _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
598+ childWindow . IsOpen = false ;
599+ ConfigurationManager . Current . IsChildWindowOpen = false ;
600+
601601 ConfigurationManager . OnDialogClose ( ) ;
602602
603603 // Create profile info
@@ -630,19 +630,23 @@ private async Task Connect(string host = null)
630630 AddProfileToHistory ( instance . Profile ) ;
631631
632632 Connect ( sessionInfo ) ;
633- } , async _ =>
634- {
635- await _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
636- ConfigurationManager . OnDialogClose ( ) ;
637- } , host ) ;
633+ } , _ =>
634+ {
635+ childWindow . IsOpen = false ;
636+ ConfigurationManager . Current . IsChildWindowOpen = false ;
638637
639- customDialog . Content = new PuTTYConnectDialog
640- {
641- DataContext = connectViewModel
642- } ;
638+ ConfigurationManager . OnDialogClose ( ) ;
639+ } , host ) ;
640+
641+ childWindow . Title = Strings . Connect ;
642+
643+ childWindow . DataContext = childWindowViewModel ;
644+
645+ ConfigurationManager . Current . IsChildWindowOpen = true ;
643646
644647 ConfigurationManager . OnDialogOpen ( ) ;
645- await _dialogCoordinator . ShowMetroDialogAsync ( this , customDialog ) ;
648+
649+ return ( Application . Current . MainWindow as MainWindow ) . ShowChildWindowAsync ( childWindow ) ;
646650 }
647651
648652 private void ConnectProfile ( )
@@ -660,7 +664,7 @@ private void ConnectProfileExternal()
660664 ProcessStartInfo info = new ( )
661665 {
662666 FileName = SettingsManager . Current . PuTTY_ApplicationFilePath ,
663- Arguments = Models . PuTTY . PuTTY . BuildCommandLine ( sessionInfo )
667+ Arguments = PuTTY . BuildCommandLine ( sessionInfo )
664668 } ;
665669
666670 Process . Start ( info ) ;
@@ -761,7 +765,7 @@ private void SetIsExpandedForAllProfileGroups(bool isExpanded)
761765 foreach ( var group in Profiles . Groups . Cast < CollectionViewGroup > ( ) )
762766 GroupExpanderStateStore [ group . Name . ToString ( ) ] = isExpanded ;
763767 }
764-
768+
765769 private void ResizeProfile ( bool dueToChangedSize )
766770 {
767771 _canProfileWidthChange = false ;
@@ -907,7 +911,7 @@ public void OnProfileFilterClosed()
907911 {
908912 ConfigurationManager . Current . IsProfileFilterPopupOpen = false ;
909913 }
910-
914+
911915 public void OnProfileManagerDialogOpen ( )
912916 {
913917 ConfigurationManager . OnDialogOpen ( ) ;
0 commit comments