1- using log4net ;
1+ using Dragablz ;
2+ using log4net ;
23using MahApps . Metro . Controls . Dialogs ;
34using MahApps . Metro . SimpleChildWindow ;
45using NETworkManager . Controls ;
910using NETworkManager . Models . AWS ;
1011using NETworkManager . Models . EventSystem ;
1112using NETworkManager . Models . Network ;
12- using NETworkManager . Models . PowerShell ;
13- using NETworkManager . Models . PuTTY ;
1413using NETworkManager . Profiles ;
1514using NETworkManager . Settings ;
1615using NETworkManager . Update ;
1918using NETworkManager . Views ;
2019using System ;
2120using System . Collections . Generic ;
22- using System . Collections . ObjectModel ;
2321using System . ComponentModel ;
2422using System . Diagnostics ;
2523using System . Drawing ;
26- using System . IO ;
2724using System . Linq ;
2825using System . Net . NetworkInformation ;
2926using System . Runtime . CompilerServices ;
3835using System . Windows . Interop ;
3936using System . Windows . Markup ;
4037using System . Windows . Threading ;
41- using Dragablz ;
4238using Application = System . Windows . Application ;
4339using ContextMenu = System . Windows . Controls . ContextMenu ;
4440using MouseEventArgs = System . Windows . Forms . MouseEventArgs ;
@@ -116,21 +112,6 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
116112 private bool _isInTray ;
117113 private bool _isClosing ;
118114
119- private bool _isWelcomeWindowOpen ;
120-
121- public bool IsWelcomeWindowOpen
122- {
123- get => _isWelcomeWindowOpen ;
124- set
125- {
126- if ( value == _isWelcomeWindowOpen )
127- return ;
128-
129- _isWelcomeWindowOpen = value ;
130- OnPropertyChanged ( ) ;
131- }
132- }
133-
134115 private bool _applicationViewIsExpanded ;
135116
136117 public bool ApplicationViewIsExpanded
@@ -412,7 +393,7 @@ public ProfileFileInfo SelectedProfileFile
412393 {
413394 if ( ! _isProfileFileUpdating )
414395 LoadProfile ( value ) ;
415-
396+
416397 ConfigurationManager . Current . ProfileManagerShowUnlock = value . IsEncrypted && ! value . IsPasswordValid ;
417398 SettingsManager . Current . Profiles_LastSelected = value . Name ;
418399 }
@@ -492,13 +473,13 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset,
492473 if ( SettingsManager . Current . WelcomeDialog_Show )
493474 {
494475
495- var welcomeChildWindow = new WelcomeChildWindow ( ) ;
476+ var childWindow = new WelcomeChildWindow ( ) ;
496477
497- var welcomeViewModel = new WelcomeViewModel ( async instance =>
478+ var viewModel = new WelcomeViewModel ( instance =>
498479 {
499- IsWelcomeWindowOpen = false ;
480+ childWindow . IsOpen = false ;
500481
501- welcomeChildWindow . IsOpen = false ;
482+ ConfigurationManager . Current . IsChildWindowOpen = false ;
502483
503484 // Set settings based on user choice
504485 SettingsManager . Current . Update_CheckForUpdatesAtStartup = instance . CheckForUpdatesAtStartup ;
@@ -511,21 +492,13 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset,
511492 instance . PowerShellModifyGlobalProfile ;
512493
513494 // Generate lists at runtime
514- SettingsManager . Current . General_ApplicationList =
515- new ObservableSetCollection < ApplicationInfo > ( ApplicationManager . GetDefaultList ( ) ) ;
516- SettingsManager . Current . IPScanner_CustomCommands =
517- new ObservableCollection < CustomCommandInfo > ( IPScannerCustomCommand . GetDefaultList ( ) ) ;
518- SettingsManager . Current . PortScanner_PortProfiles =
519- new ObservableCollection < PortProfileInfo > ( PortProfile . GetDefaultList ( ) ) ;
520- SettingsManager . Current . DNSLookup_DNSServers =
521- new ObservableCollection < DNSServerConnectionInfoProfile > ( DNSServer . GetDefaultList ( ) ) ;
522- SettingsManager . Current . AWSSessionManager_AWSProfiles =
523- new ObservableCollection < AWSProfileInfo > ( AWSProfile . GetDefaultList ( ) ) ;
524- SettingsManager . Current . SNMP_OidProfiles =
525- new ObservableCollection < SNMPOIDProfileInfo > ( SNMPOIDProfile . GetDefaultList ( ) ) ;
526- SettingsManager . Current . SNTPLookup_SNTPServers =
527- new ObservableCollection < ServerConnectionInfoProfile > ( SNTPServer . GetDefaultList ( ) ) ;
528-
495+ SettingsManager . Current . General_ApplicationList = [ .. ApplicationManager . GetDefaultList ( ) ] ;
496+ SettingsManager . Current . IPScanner_CustomCommands = [ .. IPScannerCustomCommand . GetDefaultList ( ) ] ;
497+ SettingsManager . Current . PortScanner_PortProfiles = [ .. PortProfile . GetDefaultList ( ) ] ;
498+ SettingsManager . Current . DNSLookup_DNSServers = [ .. DNSServer . GetDefaultList ( ) ] ;
499+ SettingsManager . Current . AWSSessionManager_AWSProfiles = [ .. AWSProfile . GetDefaultList ( ) ] ;
500+ SettingsManager . Current . SNMP_OidProfiles = [ .. SNMPOIDProfile . GetDefaultList ( ) ] ;
501+ SettingsManager . Current . SNTPLookup_SNTPServers = [ .. SNTPServer . GetDefaultList ( ) ] ;
529502 SettingsManager . Current . WelcomeDialog_Show = false ;
530503
531504 // Save it to create a settings file
@@ -534,11 +507,11 @@ await this.ShowMessageAsync(Strings.SettingsHaveBeenReset,
534507 Load ( ) ;
535508 } ) ;
536509
537- welcomeChildWindow . DataContext = welcomeViewModel ;
510+ childWindow . DataContext = viewModel ;
538511
539- IsWelcomeWindowOpen = true ;
512+ ConfigurationManager . Current . IsChildWindowOpen = true ;
540513
541- await this . ShowChildWindowAsync ( welcomeChildWindow ) ;
514+ await this . ShowChildWindowAsync ( childWindow ) ;
542515 }
543516 else
544517 {
@@ -1395,7 +1368,7 @@ private void LoadProfiles()
13951368 . FirstOrDefault ( x => x . Name == SettingsManager . Current . Profiles_LastSelected ) ;
13961369 SelectedProfileFile ??= ProfileFiles . SourceCollection . Cast < ProfileFileInfo > ( ) . FirstOrDefault ( ) ;
13971370 }
1398-
1371+
13991372 private async void LoadProfile ( ProfileFileInfo info , bool showWrongPassword = false )
14001373 {
14011374 // Disable profile management while switching profiles
@@ -1404,34 +1377,37 @@ private async void LoadProfile(ProfileFileInfo info, bool showWrongPassword = fa
14041377
14051378 if ( info . IsEncrypted && ! info . IsPasswordValid )
14061379 {
1407- var customDialog = new CustomDialog
1408- {
1409- Title = Strings . UnlockProfileFile
1410- } ;
1380+ var childWindow = new CredentialsPasswordProfileFileChildWindow ( ) ;
14111381
1412- var viewModel = new CredentialsPasswordProfileFileViewModel ( async instance =>
1382+ var viewModel = new CredentialsPasswordProfileFileViewModel ( instance =>
14131383 {
1414- await this . HideMetroDialogAsync ( customDialog ) ;
1384+ childWindow . IsOpen = false ;
1385+
1386+ ConfigurationManager . Current . IsChildWindowOpen = false ;
1387+
14151388 ConfigurationManager . OnDialogClose ( ) ;
14161389
14171390 info . Password = instance . Password ;
14181391
14191392 SwitchProfile ( info ) ;
1420- } , async _ =>
1393+ } , _ =>
14211394 {
1422- await this . HideMetroDialogAsync ( customDialog ) ;
1395+ childWindow . IsOpen = false ;
1396+
1397+ ConfigurationManager . Current . IsChildWindowOpen = false ;
1398+
14231399 ConfigurationManager . OnDialogClose ( ) ;
14241400
14251401 ProfileManager . Unload ( ) ;
14261402 } , info . Name , showWrongPassword ) ;
14271403
1428- customDialog . Content = new CredentialsPasswordProfileFileDialog
1429- {
1430- DataContext = viewModel
1431- } ;
1404+ childWindow . DataContext = viewModel ;
14321405
14331406 ConfigurationManager . OnDialogOpen ( ) ;
1434- await this . ShowMetroDialogAsync ( customDialog ) ;
1407+
1408+ ConfigurationManager . Current . IsChildWindowOpen = true ;
1409+
1410+ await this . ShowChildWindowAsync ( childWindow ) ;
14351411 }
14361412 else
14371413 {
@@ -1566,7 +1542,7 @@ private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref
15661542
15671543 // Handle system commands (like maximize and restore)
15681544 case WmSysCommand :
1569-
1545+
15701546 switch ( wParam . ToInt32 ( ) )
15711547 {
15721548 // Window is maximized
@@ -1584,7 +1560,7 @@ private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref
15841560
15851561 return IntPtr . Zero ;
15861562 }
1587-
1563+
15881564 private void UpdateOnWindowResize ( )
15891565 {
15901566 foreach ( var tabablzControl in VisualTreeHelper . FindVisualChildren < TabablzControl > ( this ) )
@@ -1609,6 +1585,7 @@ private void UpdateOnWindowResize()
16091585 private static extern bool RegisterHotKey ( IntPtr hWnd , int id , int fsModifiers , int vk ) ;
16101586
16111587 [ DllImport ( "user32.dll" ) ]
1588+
16121589 private static extern bool UnregisterHotKey ( IntPtr hWnd , int id ) ;
16131590
16141591 // WM_HOTKEY
@@ -1920,7 +1897,7 @@ private void ConfigureDNSServer()
19201897
19211898 DNSClient . GetInstance ( ) . Configure ( dnsSettings ) ;
19221899 }
1923-
1900+
19241901 #endregion
19251902
19261903 #region Status window
0 commit comments