11using Dragablz ;
22using MahApps . Metro . Controls . Dialogs ;
3+ using MahApps . Metro . SimpleChildWindow ;
34using NETworkManager . Controls ;
45using NETworkManager . Localization . Resources ;
56using NETworkManager . Models ;
@@ -517,16 +518,15 @@ private static void CloseItemAction(ItemActionCallbackArgs<TabablzControl> args)
517518 #region Methods
518519
519520 // Connect via Dialog
520- private async Task Connect ( string host = null )
521+ private Task Connect ( string host = null )
521522 {
522- var customDialog = new CustomDialog
523- {
524- Title = Strings . Connect
525- } ;
523+ var childWindow = new RemoteDesktopConnectChildWindow ( Application . Current . MainWindow ) ;
526524
527- var remoteDesktopConnectViewModel = new RemoteDesktopConnectViewModel ( async instance =>
525+ var childWindowViewModel = new RemoteDesktopConnectViewModel ( instance =>
528526 {
529- await _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
527+ childWindow . IsOpen = false ;
528+ ConfigurationManager . Current . IsChildWindowOpen = false ;
529+
530530 ConfigurationManager . OnDialogClose ( ) ;
531531
532532 // Create new session info with default settings
@@ -560,22 +560,26 @@ private async Task Connect(string host = null)
560560 AddHostToHistory ( instance . Host ) ;
561561
562562 Connect ( sessionInfo ) ;
563- } , async _ =>
563+ } , _ =>
564564 {
565- await _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
565+ childWindow . IsOpen = false ;
566+ ConfigurationManager . Current . IsChildWindowOpen = false ;
567+
566568 ConfigurationManager . OnDialogClose ( ) ;
567569 } )
568570 {
569571 Host = host
570572 } ;
571573
572- customDialog . Content = new RemoteDesktopConnectDialog
573- {
574- DataContext = remoteDesktopConnectViewModel
575- } ;
574+ childWindow . Title = Strings . Connect ;
575+
576+ childWindow . DataContext = childWindowViewModel ;
577+
578+ ConfigurationManager . Current . IsChildWindowOpen = true ;
576579
577580 ConfigurationManager . OnDialogOpen ( ) ;
578- await _dialogCoordinator . ShowMetroDialogAsync ( this , customDialog ) ;
581+
582+ return ( Application . Current . MainWindow as MainWindow ) . ShowChildWindowAsync ( childWindow ) ;
579583 }
580584
581585 // Connect via Profile
@@ -589,20 +593,19 @@ private void ConnectProfile()
589593 }
590594
591595 // Connect via Profile with Credentials
592- private async Task ConnectProfileAs ( )
596+ private Task ConnectProfileAs ( )
593597 {
594598 var profileInfo = SelectedProfile ;
595599
596600 var sessionInfo = RemoteDesktop . CreateSessionInfo ( profileInfo ) ;
597601
598- var customDialog = new CustomDialog
599- {
600- Title = Strings . ConnectAs
601- } ;
602+ var childWindow = new RemoteDesktopConnectChildWindow ( Application . Current . MainWindow ) ;
602603
603- var remoteDesktopConnectViewModel = new RemoteDesktopConnectViewModel ( async instance =>
604+ var childWindowViewModel = new RemoteDesktopConnectViewModel ( instance =>
604605 {
605- await _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
606+ childWindow . IsOpen = false ;
607+ ConfigurationManager . Current . IsChildWindowOpen = false ;
608+
606609 ConfigurationManager . OnDialogClose ( ) ;
607610
608611 if ( instance . UseCredentials )
@@ -617,9 +620,11 @@ private async Task ConnectProfileAs()
617620 sessionInfo . AdminSession = instance . AdminSession ;
618621
619622 Connect ( sessionInfo , instance . Name ) ;
620- } , async _ =>
623+ } , _ =>
621624 {
622- await _dialogCoordinator . HideMetroDialogAsync ( this , customDialog ) ;
625+ childWindow . IsOpen = false ;
626+ ConfigurationManager . Current . IsChildWindowOpen = false ;
627+
623628 ConfigurationManager . OnDialogClose ( ) ;
624629 } ,
625630 (
@@ -628,13 +633,15 @@ private async Task ConnectProfileAs()
628633 true
629634 ) ) ;
630635
631- customDialog . Content = new RemoteDesktopConnectDialog
632- {
633- DataContext = remoteDesktopConnectViewModel
634- } ;
636+ childWindow . Title = Strings . ConnectAs ;
637+
638+ childWindow . DataContext = childWindowViewModel ;
639+
640+ ConfigurationManager . Current . IsChildWindowOpen = true ;
635641
636642 ConfigurationManager . OnDialogOpen ( ) ;
637- await _dialogCoordinator . ShowMetroDialogAsync ( this , customDialog ) ;
643+
644+ return ( Application . Current . MainWindow as MainWindow ) . ShowChildWindowAsync ( childWindow ) ;
638645 }
639646
640647 private void Connect ( RemoteDesktopSessionInfo sessionInfo , string header = null )
0 commit comments