//********* Event Handlers ************ // Tick Event handler for the Timer control. Handle fade in and fade out. Also // handle the smoothed progress bar. private void timer1_Tick(object sender, EventArgs e) { lblStatus.Text = ms_sStatus; if (m_dblOpacityIncrement > 0) { // Form is fading in m_iActualTicks++; if (this.Opacity < 1) { this.Opacity += m_dblOpacityIncrement; } } else { // Form is fading out if (this.Opacity > 0) { this.Opacity += m_dblOpacityIncrement; } else { StoreIncrements(); this.Close(); } } var showPeriods = true; if (!m_bFirstLaunch && m_dblLastCompletionFraction <= m_dblCompletionFraction) { m_dblLastCompletionFraction += m_dblPBIncrementPerTimerInterval; var width = (int)Math.Floor(pnlStatus.ClientRectangle.Width * m_dblLastCompletionFraction); var height = pnlStatus.ClientRectangle.Height; var x = pnlStatus.ClientRectangle.X; var y = pnlStatus.ClientRectangle.Y; if (width > 0 && height > 0) { m_rProgress = new Rectangle(x, y, width, height); pnlStatus.Invalidate(m_rProgress); var iSecondsLeft = 1 + (int) (TIMER_INTERVAL * ((1.0 - m_dblLastCompletionFraction) / m_dblPBIncrementPerTimerInterval)) / 1000; if (iSecondsLeft > 1) { lblTimeRemaining.Text = string.Format("{0} seconds remaining", iSecondsLeft); showPeriods = false; } else { if (iSecondsLeft == 1) { lblTimeRemaining.Text = "1 second remaining"; showPeriods = false; } } } } if (showPeriods) { if (m_ValidatingPackagesStartTime > DateTime.UtcNow.AddDays(-1) && DateTime.UtcNow.AddSeconds(-2) > m_LastSecondsRemainingUpdate) { var periodCount = (int)(Math.Round(DateTime.UtcNow.Subtract(m_ValidatingPackagesStartTime).TotalSeconds)) % 8 + 1; lblTimeRemaining.Text = new string('.', periodCount); } } else { m_LastSecondsRemainingUpdate = DateTime.UtcNow; } // Check for status "Validating R Packages" being visible for more than 3 seconds if (ms_sStatus == VALIDATING_R_PACKAGES) { if (m_ValidatingPackagesState == PackageValidationState.Initializing) { m_ValidatingPackagesState = PackageValidationState.Started; m_ValidatingPackagesStartTime = DateTime.UtcNow; } else if (m_ValidatingPackagesState == PackageValidationState.Started) { if (DateTime.UtcNow.Subtract(m_ValidatingPackagesStartTime).TotalSeconds >= 3) { m_ValidatingPackagesState = PackageValidationState.OverThreeSeconds; ms_sStatus = "Validating R Packages ... If prompted 'Would you like to use a personal library?' Answer 'Yes' to each of the questions."; } } } else { if (m_ValidatingPackagesState == PackageValidationState.OverThreeSeconds && DateTime.UtcNow.Subtract(m_ValidatingPackagesStartTime).TotalSeconds >= 6) { lblStatus.BackColor = Color.Chocolate; m_ValidatingPackagesState = PackageValidationState.OverSixSeconds; } } }
//********* Event Handlers ************ // Tick Event handler for the Timer control. Handle fade in and fade out. Also // handle the smoothed progress bar. private void timer1_Tick(object sender, EventArgs e) { lblStatus.Text = ms_sStatus; if( m_dblOpacityIncrement > 0 ) { // Form is fading in m_iActualTicks++; if( this.Opacity < 1 ) this.Opacity += m_dblOpacityIncrement; } else { // Form is fading out if( this.Opacity > 0 ) this.Opacity += m_dblOpacityIncrement; else { StoreIncrements(); this.Close(); } } var showPeriods = true; if( m_bFirstLaunch == false && m_dblLastCompletionFraction <= m_dblCompletionFraction ) { m_dblLastCompletionFraction += m_dblPBIncrementPerTimerInterval; var width = (int)Math.Floor(pnlStatus.ClientRectangle.Width * m_dblLastCompletionFraction); var height = pnlStatus.ClientRectangle.Height; var x = pnlStatus.ClientRectangle.X; var y = pnlStatus.ClientRectangle.Y; if (width > 0 && height > 0) { m_rProgress = new Rectangle(x, y, width, height); pnlStatus.Invalidate(m_rProgress); var iSecondsLeft = 1 + (int)(TIMER_INTERVAL * ((1.0 - m_dblLastCompletionFraction) / m_dblPBIncrementPerTimerInterval)) / 1000; if (iSecondsLeft > 1) { lblTimeRemaining.Text = string.Format("{0} seconds remaining", iSecondsLeft); showPeriods = false; } else { if (iSecondsLeft == 1) { lblTimeRemaining.Text = "1 second remaining"; showPeriods = false; } } } } if (showPeriods) { if (m_ValidatingPackagesStartTime > DateTime.UtcNow.AddDays(-1) && DateTime.UtcNow.AddSeconds(-2) > m_LastSecondsRemainingUpdate) { var periodCount = (int)(Math.Round(DateTime.UtcNow.Subtract(m_ValidatingPackagesStartTime).TotalSeconds)) % 8 + 1; lblTimeRemaining.Text = new string('.', periodCount); } } else { m_LastSecondsRemainingUpdate = DateTime.UtcNow; } // Check for status "Validating R Packages" being visible for more than 3 seconds if (ms_sStatus == VALIDATING_R_PACKAGES) { if (m_ValidatingPackagesState == PackageValidationState.Initializing) { m_ValidatingPackagesState = PackageValidationState.Started; m_ValidatingPackagesStartTime = DateTime.UtcNow; } else if (m_ValidatingPackagesState == PackageValidationState.Started) { if (DateTime.UtcNow.Subtract(m_ValidatingPackagesStartTime).TotalSeconds >= 3) { m_ValidatingPackagesState = PackageValidationState.OverThreeSeconds; ms_sStatus = "Validating R Packages ... If prompted 'Would you like to use a personal library?' Answer 'Yes' to each of the questions."; } } } else { if (m_ValidatingPackagesState == PackageValidationState.OverThreeSeconds && DateTime.UtcNow.Subtract(m_ValidatingPackagesStartTime).TotalSeconds >= 6) { lblStatus.BackColor = Color.Chocolate; m_ValidatingPackagesState = PackageValidationState.OverSixSeconds; } } }