Пример #1
0
 /// <summary>
 /// MainTimer.Tick事件调用的方法
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainCycleTimer_Tick(object sender, EventArgs e)
 {
     IniPerLightRunTime(chooseLightColor.SelectedIndex); //交通灯 三个灯的倒计时时间
     Lights.IniParamsInMainTimer();
     Lights.TrafficLightsRuntime();                      //初始化MainTimer.Interval
     Lights.IniLightsUpSequenceColor(chooseLightColor.SelectedIndex);
     mainTimerTb.Text = "mainTick次数:" + (++mainTimerCount).ToString() + ";" + "mainInterval:" + Lights.trafficLightsTime;
 }
Пример #2
0
        //private void RestartTimer()
        //{
        //    Lights.StopTimer();
        //    ReInitializeParamThenRestart();
        //}
        /// <summary>
        /// 重启两个计时器(注意Timer.Start()的顺序)
        /// </summary>
        private void ReIniParamThenRestart()
        {
            //循环之初要处理的数据(MainTimer_Tick)
            IniPerLightRunTime(chooseLightColor.SelectedIndex);//交通灯 三个灯的倒计时时间
            Lights.IniParamsInMainTimer();
            Lights.IniLightsUpSequenceColor(chooseLightColor.SelectedIndex);

            //每个循环要做的事情(UnitTimer_Tick)
            Lights.LightsUp(chooseLightColor.SelectedIndex);
            countdownCurrenLightupTbk.Text       = Lights.countdownToUI.ToString();
            countdownLightsTbk.Text              = (Lights.trafficLightsTime2 + 1).ToString();
            countdownCurrenLightupTbk.Foreground = new SolidColorBrush(Lights.textFontColor);
            redLight.Fill    = new SolidColorBrush(Lights.rLColor);
            yellowLight.Fill = new SolidColorBrush(Lights.yLColor);
            greenLight.Fill  = new SolidColorBrush(Lights.gLColor);

            //启动计时器,第一个Tick发生在Interval时间之后
            Lights.ProceedTimer();
        }