public partial class MainPage : ContentPage
{
private System.Timers.Timer \_timer;
private int count = 0;
public MainPage()
{
InitializeComponent();
}
void Main()
{
\_timer = new System.Timers.Timer();
//trigger event every second
\_timer.Interval = 1000;
\_timer.Elapsed += OnTimedEvent;
}
private void OnTimedEvent(object sender, EventArgs e) {
count--;
\_timer.Enabled = true;
TimerLabel.Text = count.ToString();
if (count==0)
{
\_timer.Stop();
}
}
private void IncrementCounterClicked(object sender, EventArgs e)
{
count++;
TimerLabel.Text = count.ToString();
}
private void IncrementCounterClicked\_1(object sender, EventArgs e)
{
count+=5;
TimerLabel.Text = count.ToString();
}
private void ClearClicked(object sender, EventArgs e)
{
count = 0;
TimerLabel.Text = count.ToString();
}
}
}
**And my main page:**
<Label Text="00:00"
HorizontalOptions="Center"
FontSize="Title"
x:Name="TimerLabel"
TextColor="Silver"
\> </Label>
<Button Text="Start"
Clicked="OnTimedEvent"
FontSize="Body"
WidthRequest="80"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
<Button Text="+1"
Clicked="IncrementCounterClicked"
FontSize="Body"
WidthRequest="50"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
<Button Text="+5"
Clicked="IncrementCounterClicked\_1"
FontSize="Body"
WidthRequest="50"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
<Button Text="Clear"
Clicked="ClearClicked"
FontSize="Body"
WidthRequest="80"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
</StackLayout>
Ive really got no idea how to get it working or what to do. Im stuck and ive no idea where to find help
{
private System.Timers.Timer \_timer;
private int count = 0;
public MainPage()
{
InitializeComponent();
}
void Main()
{
\_timer = new System.Timers.Timer();
//trigger event every second
\_timer.Interval = 1000;
\_timer.Elapsed += OnTimedEvent;
}
private void OnTimedEvent(object sender, EventArgs e) {
count--;
\_timer.Enabled = true;
TimerLabel.Text = count.ToString();
if (count==0)
{
\_timer.Stop();
}
}
private void IncrementCounterClicked(object sender, EventArgs e)
{
count++;
TimerLabel.Text = count.ToString();
}
private void IncrementCounterClicked\_1(object sender, EventArgs e)
{
count+=5;
TimerLabel.Text = count.ToString();
}
private void ClearClicked(object sender, EventArgs e)
{
count = 0;
TimerLabel.Text = count.ToString();
}
}
}
**And my main page:**
<Label Text="00:00"
HorizontalOptions="Center"
FontSize="Title"
x:Name="TimerLabel"
TextColor="Silver"
\> </Label>
<Button Text="Start"
Clicked="OnTimedEvent"
FontSize="Body"
WidthRequest="80"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
<Button Text="+1"
Clicked="IncrementCounterClicked"
FontSize="Body"
WidthRequest="50"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
<Button Text="+5"
Clicked="IncrementCounterClicked\_1"
FontSize="Body"
WidthRequest="50"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
<Button Text="Clear"
Clicked="ClearClicked"
FontSize="Body"
WidthRequest="80"
BackgroundColor="CornflowerBlue"
HorizontalOptions="Center"
\></Button>
</StackLayout>
Ive really got no idea how to get it working or what to do. Im stuck and ive no idea where to find help