using Xui.Core.Canvas; using Xui.Core.Math2D; using Xui.Core.UI; using Xui.Core.UI.Input; public sealed class CounterView : View { private int count; public override void OnPointerEvent(ref PointerEventRef e, EventPhase phase) { if (phase != EventPhase.Bubble || e.Type != PointerEventType.Down) return; count++; InvalidateRender(); } protected override void RenderCore(IContext context) { context.Save(); try { context.SetFill(new Color(0xFAF7FFFF)); context.FillRect(Frame); context.SetFill(new Color(0x8538CEFF)); context.BeginPath(); context.Arc((Frame.X + Frame.Width / 2, Frame.Y + Frame.Height / 2), 80, 0, System.Runtime.InteropServices.NFloat.Pi * 2); context.Fill(); context.TextAlign = TextAlign.Center; context.TextBaseline = TextBaseline.Middle; context.SetFont(new Font(48, "Inter")); context.SetFill(Colors.White); context.FillText(count.ToString(), (Frame.X + Frame.Width / 2, Frame.Y + Frame.Height / 2)); context.SetFont(new Font(16, "Inter")); context.SetFill(new Color(0x492571FF)); context.FillText("Tap anywhere to count", (Frame.X + Frame.Width / 2, Frame.Y + Frame.Height / 2 + 120)); } finally { context.Restore(); } } }