//and set its initial value:
private int counter = 0;
//We declare and set the number N_Interval of intervals,
//after which one text is replaced by another:
private int N_Interval = 3;
//We declare and nullify the i_Interval_Stop counter,
//which calculates the number of intervals
//to an animation stop:
private int i_Interval_Stop = 0;
//We declare and set the number N_Interval_Stop of intervals,
//on reaching which animation stops:
private int N_Interval_Stop = 10;
private void timer1_Tick (object sender, EventArgs e)
{
//Value of the i_Interval_Stop counter,
//which calculates the number of intervals
//to an animation stop, we increase on 1:
i_Interval_Stop = i_Interval_Stop +1;
//We check the number i_Interval_Stop of intervals,
//on reaching which animation stops:
if (i_Interval_Stop> = N_Interval_Stop)
timer1.Enabled = false;
//We check, value of the counter
//equally or yet is not present to number N_Interval of
//intervals,
//after which one text is replaced by another:
if (counter> = N_Interval)
{
//If value of the counter collected and is equal
//N_Interval, we output other text:
this. Text = «Calculator»;
//We nullify value of the counter again:
counter = 0;
}
else
{
//If value of the counter did not collect yet
//and N_Interval is not equal,
//that we output the first text:
this. Text = «Calculator with animation»;
//We increase value of the counter on 1:
counter = counter +1;
}
}
Так как здесь мы впервые применили метод timer1_Tick, а далее постоянно будем его применять, то дадим краткие пояснения.
Автоматически сгенерированный заголовок метода
private void timer1_Tick (object sender, EventArgs e)
говорит нам о том, что метод timer1_Tick обрабатывает (Handles) событие Tick, периодически (с заданным интервалом при помощи свойства Interval) возбуждаемое объектом (таймером) timer1. В строке (bool myText = false;) мы объявляем булеву глобальную переменную myText выше метода timer1_Tick. Если бы переменную myText мы задали в виде локальной переменной внутри метода timer1_Tick, то при каждом новом вызове (с заданным интервалом) этого метода timer1_Tick значение переменной myText оставалось бы неизменным, и анимации не получилось бы.
По какому-либо одному варианту кода, например, по первому варианту строим программу и запускаем на выполнение обычным образом: Build, Build Selection; Debug, Start Without Debugging.