Оценить:
 Рейтинг: 0

Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 7: Программирование на Visual C# искусственного интеллекта. Издание 2

Год написания книги
2023
Теги
<< 1 2 3 4 5 6 7 8 9 10 ... 34 >>
На страницу:
6 из 34
Настройки чтения
Размер шрифта
Высота строк
Поля

this.Text = "Calculator";

//We nullify the 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;

}

}

И наконец, изучим третий вариант, когда анимация выполняется столько времени, какое число интервалов времени N_Interval_Stop мы задали, и после этого времени анимационный объект останавливается в заданном нами положении. Для этого в файле Form1.cs выше того же (что и в предыдущем варианте) автоматически сгенерированного шаблона метода объявляем большее число переменных, а в шаблон записываем более общий код, как показано на следующем листинге.

Листинг 2.5. Код для создания анимации. Вариант 3.

//We declare the counter of number of intervals

//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;
<< 1 2 3 4 5 6 7 8 9 10 ... 34 >>
На страницу:
6 из 34

Другие электронные книги автора Валерий Алексеевич Жарков