18 internal System.Drawing.Point ToScreenPx(
double x,
double y)
20 ??
new System.Drawing.Point((
int)Math.Floor(x), (
int)Math.Floor(y));
22 private const string DefaultCanvasStyle =
23 "width: 100%; height: 100%; display: block; outline: none;";
25 internal event Action<KeyboardEventArgs>? KeyDown;
26 internal event Action<KeyboardEventArgs>? KeyUp;
27 internal event Action<MouseEventArgs>? MouseMove;
28 internal event Action<MouseEventArgs>? MouseDown;
29 internal event Action<MouseEventArgs>? MouseUp;
30 internal event Action<WheelEventArgs>? Wheel;
31 internal event Action<TouchEventArgs>? TouchStart;
32 internal event Action<TouchEventArgs>? TouchMove;
33 internal event Action<TouchEventArgs>? TouchEnd;
34 internal event Action<TouchEventArgs>? TouchCancel;
39 [Parameter(CaptureUnmatchedValues =
true)]
50 protected string CanvasStyle {
get;
private set; } = DefaultCanvasStyle;
67 var attributes =
new Dictionary<string, object>(
69 StringComparer.OrdinalIgnoreCase);
71 attributes.Remove(
"style");
77 protected void HandleKeyDown(KeyboardEventArgs e) => KeyDown?.Invoke(e);
81 protected void HandleKeyUp(KeyboardEventArgs e) => KeyUp?.Invoke(e);
97 protected void HandleWheel(WheelEventArgs e) => Wheel?.Invoke(e);
99 internal readonly record
struct CanvasOffset(float Left, float Top);
101 internal virtual ValueTask<CanvasOffset> GetCanvasOffsetAsync() => ValueTask.FromResult(
default(CanvasOffset));
103 private async Task ForwardTouch(TouchEventArgs args, Action<TouchEventArgs>? handler)
108 var offset = await GetCanvasOffsetAsync();
110 foreach (var point
in args.ChangedTouches)
112 point.ClientX -= offset.Left;
113 point.ClientY -= offset.Top;