/// <summary> /// NoChanges则继续,HaveChangd则重新计时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetLightTimeBtn_Click(object sender, RoutedEventArgs e) { //WrtLightCd(string rCount, string yCount, string gCount) tempTextRedAfter = Lights.FetchNum(redCount.Text).ToString(); tempTextYellowAfter = Lights.FetchNum(yellowCount.Text).ToString(); tempTextGreenAfter = Lights.FetchNum(greenCount.Text).ToString(); bool redCountChanged = Lights.IsTextChanged(tempTextRedBefore, tempTextRedAfter); bool yellowCountChangded = Lights.IsTextChanged(tempTextYellowBefore, tempTextYellowAfter); bool greenCountChanged = Lights.IsTextChanged(tempTextGreenBefore, tempTextGreenAfter); //把更改后的内容保存到App.config中 string rCount = Lights.IsValueChanged(redCountChanged, tempTextRedAfter); string yCount = Lights.IsValueChanged(yellowCountChangded, tempTextYellowAfter); string gCount = Lights.IsValueChanged(greenCountChanged, tempTextGreenAfter); Lights.WrtLightCd(rCount, yCount, gCount); if (redCountChanged || yellowCountChangded || greenCountChanged) { Lights.StopTimer(); ReIniParamThenRestart(); } else { Lights.ProceedTimer(); } SetLightTimeBtn.Foreground = new SolidColorBrush(Lights.Green); }
//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(); }