11using log4net ;
22using MahApps . Metro . Controls ;
3- using MahApps . Metro . Controls . Dialogs ;
43using MahApps . Metro . SimpleChildWindow ;
54using NETworkManager . Controls ;
65using NETworkManager . Localization ;
@@ -31,12 +30,10 @@ public class SNMPViewModel : ViewModelBase
3130{
3231 #region Contructor, load settings
3332
34- public SNMPViewModel ( IDialogCoordinator instance , Guid tabId , SNMPSessionInfo sessionInfo )
33+ public SNMPViewModel ( Guid tabId , SNMPSessionInfo sessionInfo )
3534 {
3635 _isLoading = true ;
3736
38- _dialogCoordinator = instance ;
39-
4037 ConfigurationManager . Current . SNMPTabCount ++ ;
4138
4239 _tabId = tabId ;
@@ -57,36 +54,34 @@ public SNMPViewModel(IDialogCoordinator instance, Guid tabId, SNMPSessionInfo se
5754 Oid = sessionInfo ? . OID ;
5855
5956 // Modes
60- Modes = new List < SNMPMode > { SNMPMode . Get , SNMPMode . Walk , SNMPMode . Set } ;
57+ Modes = [ SNMPMode . Get , SNMPMode . Walk , SNMPMode . Set ] ;
6158 Mode = Modes . FirstOrDefault ( x => x == sessionInfo ? . Mode ) ;
6259
6360 // Versions (v1, v2c, v3)
64- Versions = Enum . GetValues ( typeof ( SNMPVersion ) ) . Cast < SNMPVersion > ( ) . ToList ( ) ;
61+ Versions = Enum . GetValues < SNMPVersion > ( ) . Cast < SNMPVersion > ( ) . ToList ( ) ;
6562 Version = Versions . FirstOrDefault ( x => x == sessionInfo ? . Version ) ;
6663
6764 // Community
6865 if ( Version != SNMPVersion . V3 )
6966 Community = sessionInfo ? . Community ;
7067
7168 // Security
72- Securities = new List < SNMPV3Security >
73- { SNMPV3Security . NoAuthNoPriv , SNMPV3Security . AuthNoPriv , SNMPV3Security . AuthPriv } ;
69+ Securities = [ SNMPV3Security . NoAuthNoPriv , SNMPV3Security . AuthNoPriv , SNMPV3Security . AuthPriv ] ;
7470 Security = Securities . FirstOrDefault ( x => x == sessionInfo ? . Security ) ;
7571
7672 // Username
7773 if ( Version == SNMPVersion . V3 )
7874 Username = sessionInfo ? . Username ;
7975
8076 // Auth
81- AuthenticationProviders = Enum . GetValues ( typeof ( SNMPV3AuthenticationProvider ) )
82- . Cast < SNMPV3AuthenticationProvider > ( ) . ToList ( ) ;
77+ AuthenticationProviders = [ .. Enum . GetValues < SNMPV3AuthenticationProvider > ( ) . Cast < SNMPV3AuthenticationProvider > ( ) ] ;
8378 AuthenticationProvider = AuthenticationProviders . FirstOrDefault ( x => x == sessionInfo ? . AuthenticationProvider ) ;
8479
8580 if ( Version == SNMPVersion . V3 && Security != SNMPV3Security . NoAuthNoPriv )
8681 Auth = sessionInfo ? . Auth ;
8782
8883 // Priv
89- PrivacyProviders = Enum . GetValues ( typeof ( SNMPV3PrivacyProvider ) ) . Cast < SNMPV3PrivacyProvider > ( ) . ToList ( ) ;
84+ PrivacyProviders = [ .. Enum . GetValues < SNMPV3PrivacyProvider > ( ) . Cast < SNMPV3PrivacyProvider > ( ) ] ;
9085 PrivacyProvider = PrivacyProviders . FirstOrDefault ( x => x == sessionInfo ? . PrivacyProvider ) ;
9186
9287 if ( Version == SNMPVersion . V3 && Security == SNMPV3Security . AuthPriv )
@@ -100,8 +95,6 @@ public SNMPViewModel(IDialogCoordinator instance, Guid tabId, SNMPSessionInfo se
10095 #region Variables
10196 private static readonly ILog Log = LogManager . GetLogger ( typeof ( SNMPViewModel ) ) ;
10297
103- private readonly IDialogCoordinator _dialogCoordinator ;
104-
10598 private CancellationTokenSource _cancellationTokenSource ;
10699
107100 private readonly Guid _tabId ;
@@ -656,25 +649,27 @@ private async Task OpenOIDProfileSelection()
656649 {
657650 var window = Application . Current . Windows . OfType < Window > ( ) . FirstOrDefault ( x => x . IsActive ) ;
658651
659- var customDialog = new CustomDialog
660- {
661- Title = Strings . SelectOIDProfile
662- } ;
652+ var childWindow = new SNMPOIDProfilesChildWindow ( window ) ;
663653
664- var viewModel = new SNMPOIDProfilesViewModel ( async instance =>
654+ var childWindowViewModel = new SNMPOIDProfilesViewModel ( async instance =>
665655 {
666- await _dialogCoordinator . HideMetroDialogAsync ( window , customDialog ) ;
656+ childWindow . IsOpen = false ;
657+ ConfigurationManager . Current . IsChildWindowOpen = false ;
667658
668659 Mode = instance . SelectedOIDProfile . Mode ;
669660 Oid = instance . SelectedOIDProfile . OID ;
670- } , async _ => { await _dialogCoordinator . HideMetroDialogAsync ( window , customDialog ) ; } ) ;
661+ } , async _ => {
662+ childWindow . IsOpen = false ;
663+ ConfigurationManager . Current . IsChildWindowOpen = false ;
664+ } ) ;
671665
672- customDialog . Content = new SNMPOIDProfilesDialog
673- {
674- DataContext = viewModel
675- } ;
666+ childWindow . Title = Strings . SelectOIDProfile ;
667+
668+ childWindow . DataContext = childWindowViewModel ;
669+
670+ ConfigurationManager . Current . IsChildWindowOpen = true ;
676671
677- await _dialogCoordinator . ShowMetroDialogAsync ( window , customDialog ) ;
672+ await window . ShowChildWindowAsync ( childWindow ) ;
678673 }
679674
680675 private void AddHostToHistory ( string host )
0 commit comments