/// <summary> /// timer tick specifically for fades, /// when running, attempts to go 1/ms = 1000/s /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fadetimer_Tick(object sender, EventArgs e) { //increment timer ticking fadetimertime++; //update time/date during fade updateTimeDate(); //fadeout related code #region Fade Out if (cD_tstate == timerstate.fadeout) { //computes amount of change in opacity per clock tick then applies it double double_change_in_opacity_per_tick = (Convert.ToDouble(OpacityLevel)) / Convert.ToDouble(int_fade_milliseconds) * 1 / 10; this.Opacity = (Convert.ToDouble(OpacityLevel) * 1 / 100) - (Convert.ToDouble(fadetimertime) * double_change_in_opacity_per_tick); if (this.Opacity <= 0) { cD_tstate = timerstate.fadein; this.Opacity = 0; this.Visible = false; fadetimertime = 0; fadetimer.Stop(); //go to next image in slideshows rotateCPic(); } } #endregion Fade Out //fade in related code #region Fade In if (cD_tstate == timerstate.fadein) { //computes amount of change in opacity per clock tick then applies it double double_change_in_opacity_per_tick = (Convert.ToDouble(OpacityLevel)) / Convert.ToDouble(int_fade_milliseconds) * 1 / 10; this.Opacity = fadetimertime * double_change_in_opacity_per_tick; if (this.Opacity >= (Convert.ToDouble(OpacityLevel) * 1 / 100)) { cD_tstate = timerstate.indash; //We set the timerstate to indash to allow for timekeeping this.Opacity = Convert.ToDouble(OpacityLevel) / 100; fadetimertime = 0; fadetimer.Stop(); } } #endregion Fade In }
/// <summary> /// cues the form's fade in process /// </summary> private void fade_in() { moveToPrimaryMonitor(); //ensures proper form sizing updateTimeDate(); //updates time/date on form cD_tstate = (int)timerstate.fadein; //cD_tstate is the timer state this.Visible = true; updateCBattery(); //updates all cBattery updateCMote(); //updates all cMote fadetimer.Start(); //begin timer }
/// <summary> /// cues the form's fade out process /// </summary> public void fade_out() { cD_tstate = timerstate.fadeout; fadetimer.Start(); }