. Net language APP development platform -- scycler Learning Log: How to quickly implement the Timer timing function, scyclertimer
Smobiler is a development platform that uses the. Net language to develop apps in the VS environment. It may be more convenient than Xamarin.
1. Target Style
The following operations are required to achieve the effect:
1. Drag a Timer control, a TextBox Control, a Button control, a label control, and an Image control from the "scycler Components" on the toolbar to the form interface.
2. Tick event of the Timer control
VB: Private Sub timer1_Tick(sender As Object, e As EventArgs) Handles timer1.Tick Me.TextBox1.Text = (Convert.ToInt32(Me.textBox1.Text.ToString()) - 1).ToString() End Sub
C#: private void timer1_Tick(object sender, EventArgs e) { this.textBox1.Text =(Convert.ToInt32(this.textBox1.Text.ToString()) -1).ToString(); }
Note: Call the Timer control
3. TextChanged event of TextBox
VB: Private Sub textBox1_TextChanged(sender As Object, e As EventArgs) Handles textBox1.TextChanged If Me.textBox1.Text = "0" Then timer1.Stop() Else timer1.Start() End If End Sub
C#: private void textBox1_TextChanged(object sender, EventArgs e) { if(this.textBox1.Text =="0") { timer1.Stop(); } else { timer1.Start(); } }
Note: Determine whether to start or stop the timer based on the conditions.
4. Click events of the Button control
VB: Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click Me.textBox1.Text = "60" End Sub
C#: private void button1_Click(object sender, EventArgs e) { this.textBox1.Text ="60"; }
5. Modify the attribute a. Interval of the Timer control.
Interval for triggering a Tick event, in seconds. The default value is 1, indicating that the interval is 1 second;
Ii. Mobile phone effect display
The following figure shows the effect after the button is pressed: