22using System . Windows . Input ;
33using MahApps . Metro . Controls . Dialogs ;
44using System ;
5+ using System . ComponentModel ;
56using NETworkManager . Utilities ;
67using System . Net ;
78using System . Net . NetworkInformation ;
@@ -293,7 +294,6 @@ public IPAddress PublicIPAddress
293294 }
294295
295296 private string _publicHostname ;
296-
297297 public string PublicHostname
298298 {
299299 get => _publicHostname ;
@@ -308,7 +308,6 @@ public string PublicHostname
308308 }
309309
310310 private string _internetDetails ;
311-
312311 public string InternetDetails
313312 {
314313 get => _internetDetails ;
@@ -322,6 +321,36 @@ public string InternetDetails
322321 }
323322 }
324323 #endregion
324+
325+ private string _publicIPAddressCheckDisabledNote1 ;
326+ public string PublicIPAddressCheckDisabledNote1
327+ {
328+ get => _publicIPAddressCheckDisabledNote1 ;
329+ set
330+ {
331+ if ( value == _publicIPAddressCheckDisabledNote1 )
332+ return ;
333+
334+ _publicIPAddressCheckDisabledNote1 = value ;
335+ OnPropertyChanged ( ) ;
336+ }
337+ }
338+
339+ private string _publicIPAddressCheckDisabledNote2 ;
340+ public string PublicIPAddressCheckDisabledNote2
341+ {
342+ get => _publicIPAddressCheckDisabledNote2 ;
343+ set
344+ {
345+ if ( value == _publicIPAddressCheckDisabledNote2 )
346+ return ;
347+
348+ _publicIPAddressCheckDisabledNote2 = value ;
349+ OnPropertyChanged ( ) ;
350+ }
351+ }
352+
353+ public bool CheckPublicIPAddress => SettingsManager . Current . Dashboard_CheckPublicIPAddress ;
325354 #endregion
326355
327356 #region Constructor, load settings
@@ -336,6 +365,9 @@ public DashboardViewModel(IDialogCoordinator instance)
336365
337366 LoadSettings ( ) ;
338367
368+ // Detect if settings have changed...
369+ SettingsManager . Current . PropertyChanged += SettingsManager_PropertyChanged ;
370+
339371 CheckConnectionAsync ( ) ;
340372 }
341373
@@ -761,6 +793,13 @@ public void CheckConnection()
761793 return ;
762794 }
763795 }
796+ else
797+ {
798+ var note = Resources . Localization . Strings . PublicIPAddressCheckIsDisabled . Replace ( "\n " , "" ) . Split ( '\r ' ) ;
799+
800+ PublicIPAddressCheckDisabledNote1 = note [ 0 ] ;
801+ PublicIPAddressCheckDisabledNote2 = note [ 1 ] ;
802+ }
764803
765804 IsInternetCheckRunning = false ;
766805 IsInternetCheckComplete = true ;
@@ -789,19 +828,32 @@ private void AddToInternetDetails(ConnectionState state, string message)
789828 if ( ! string . IsNullOrEmpty ( InternetDetails ) )
790829 InternetDetails += Environment . NewLine ;
791830
792- InternetDetails += $ "[{ LocalizationManager . TranslateConnectionState ( state ) } ] { message } ";
831+ if ( state != ConnectionState . None )
832+ InternetDetails += $ "[{ LocalizationManager . TranslateConnectionState ( state ) } ] { message } ";
793833 }
794834
795835 public void OnViewVisible ( )
796836 {
797-
837+
798838 }
799839
800840 public void OnViewHide ( )
801841 {
802842
803843 }
804844 #endregion
845+
846+ #region Events
847+ private void SettingsManager_PropertyChanged ( object sender , PropertyChangedEventArgs e )
848+ {
849+ switch ( e . PropertyName )
850+ {
851+ case nameof ( SettingsInfo . Dashboard_CheckPublicIPAddress ) :
852+ OnPropertyChanged ( nameof ( CheckPublicIPAddress ) ) ;
853+ break ;
854+ }
855+ }
856+ #endregion
805857 }
806858}
807859
0 commit comments