55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using Blahblah.FlowerStory.Data;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Blahblah.FlowerStory
|
|
{
|
|
public partial class MainPage : ContentPage
|
|
{
|
|
int count = 0;
|
|
readonly FlowerDatabase database;
|
|
|
|
private readonly ILogger logger;
|
|
public MainPage(FlowerDatabase database, ILogger<MainPage> logger)
|
|
{
|
|
this.logger = logger;
|
|
|
|
this.database = database;
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void OnCounterClicked(object sender, EventArgs e)
|
|
{
|
|
count++;
|
|
|
|
if (count == 1)
|
|
CounterBtn.Text = $"Clicked {count} time";
|
|
else
|
|
CounterBtn.Text = $"Clicked {count} times";
|
|
|
|
SemanticScreenReader.Announce(CounterBtn.Text);
|
|
}
|
|
|
|
protected override void OnAppearing()
|
|
{
|
|
base.OnAppearing();
|
|
|
|
Task.Run(async () =>
|
|
{
|
|
try
|
|
{
|
|
var list = await database.GetFlowers();
|
|
logger.LogInformation("got {count} flowers.", list.Count);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError("error occurs, {exception}", ex);
|
|
}
|
|
});
|
|
}
|
|
|
|
private void canvasView_PaintSurface(object sender, SkiaSharp.Views.Maui.SKPaintSurfaceEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |