static void OnDaemonNetworkInformationChanged(object sender, NetworkInformationChangedEventArgs e) { // Get important data about the network's changes here var networkInformation = e.NetworkInformation; Console.WriteLine( "Current block height: {0} (Downloaded: {1})", networkInformation.BlockHeightTotal, networkInformation.BlockHeightDownloaded ); }
static void OnDaemonRpcNetworkInformationChanged(object sender, NetworkInformationChangedEventArgs e) { IsSafeShutdownAllowed = true; var networkInformation = e.NetworkInformation; var connectionCount = networkInformation.ConnectionCountTotal; var blockTimeRemainingString = networkInformation.BlockTimeRemaining.ToStringReadable(); var syncBarProgressPercentage = (double)networkInformation.BlockHeightDownloaded / networkInformation.BlockHeightTotal * 100; var syncBarText = string.Format( Utilities.InvariantCulture, Desktop.Properties.Resources.StatusBarSyncTextMain, networkInformation.BlockHeightRemaining, blockTimeRemainingString ); var syncStatusIndicatorText = string.Format( Utilities.InvariantCulture, Desktop.Properties.Resources.StatusBarStatusTextMain, networkInformation.BlockHeightDownloaded, networkInformation.BlockHeightTotal, syncBarProgressPercentage.ToString("F2", CultureManager.CurrentCulture), blockTimeRemainingString ); Application.Instance.AsyncInvoke(() => { var statusBarViewModel = StatusBarView.ViewModel; statusBarViewModel.ConnectionCount = connectionCount; statusBarViewModel.SyncStatusIndicatorText = syncStatusIndicatorText; if (statusBarViewModel.IsBlockchainSynced) { return; } statusBarViewModel.SyncStatusText = Desktop.Properties.Resources.StatusBarStatusSynchronizing; statusBarViewModel.SyncBarProgressValue = (int)Math.Floor(syncBarProgressPercentage * 100); statusBarViewModel.SyncBarText = syncBarText; statusBarViewModel.IsSyncBarVisible = true; }); }
static void OnDaemonRpcNetworkInformationChanged(object sender, NetworkInformationChangedEventArgs e) { IsSafeShutdownAllowed = true; var networkInformation = e.NetworkInformation; var connectionCount = networkInformation.ConnectionCountTotal; var blockTimeRemainingString = networkInformation.BlockTimeRemaining.ToStringReadable(); var syncBarProgressPercentage = (double)networkInformation.BlockHeightDownloaded / networkInformation.BlockHeightTotal * 100; var syncBarText = string.Format( Utilities.InvariantCulture, Desktop.Properties.Resources.StatusBarSyncTextMain, networkInformation.BlockHeightRemaining, blockTimeRemainingString ); var syncStatusIndicatorText = string.Format( Utilities.InvariantCulture, Desktop.Properties.Resources.StatusBarStatusTextMain, networkInformation.BlockHeightDownloaded, networkInformation.BlockHeightTotal, syncBarProgressPercentage.ToString("F2", CultureManager.CurrentCulture), blockTimeRemainingString ); Application.Instance.AsyncInvoke(() => { var statusBarViewModel = StatusBarView.ViewModel; statusBarViewModel.ConnectionCount = connectionCount; statusBarViewModel.SyncStatusIndicatorText = syncStatusIndicatorText; if (statusBarViewModel.IsBlockchainSynced) return; statusBarViewModel.SyncStatusText = Desktop.Properties.Resources.StatusBarStatusSynchronizing; statusBarViewModel.SyncBarProgressValue = (int)Math.Floor(syncBarProgressPercentage * 100); statusBarViewModel.SyncBarText = syncBarText; statusBarViewModel.IsSyncBarVisible = true; }); }