protected override IWindow CreateWindow(IActivationState activationState) { Microsoft.Maui.Controls.Compatibility.Forms.Init(activationState); this.On <Microsoft.Maui.Controls.PlatformConfiguration.Windows>() .SetImageDirectory("Assets"); AppEngine.Provider.UseKnowEngines(); var window = new Microsoft.Maui.Controls.Window(new HomePage()); return(window); }
private void ContentPage_Loaded(object sender, EventArgs e) { _window = this.GetParentWindow(); _overlay = new WindowOverlay(_window); _overlay.AddWindowElement(this); _window.AddOverlay(_overlay); _allChildren = this.GetVisualTreeDescendants() .OfType <Microsoft.Maui.Controls.View>() .Where(x => x != RectangleSelectionCheckBox) .ToArray(); #if WINDOWS var platformChildren = _allChildren.Select(v => v.Handler.PlatformView).OfType <Microsoft.UI.Xaml.UIElement>(); foreach (var element in platformChildren) { Debug.Print(element.GetType().FullName); element.Tapped += DoHandleTapped; element.PointerMoved += DoHandlePointerMoved; } void DoHandleTapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs args) { var pos = args.GetPosition(null); Debug.WriteLine($"Tapped {sender.GetType().FullName} @ ({pos.X};{pos.Y})"); HandleTapped(pos.X, pos.Y); } void DoHandlePointerMoved(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs args) { var pos = args.GetCurrentPoint(null); HandlePointerMoved(pos.Position.X, pos.Position.Y); } #else RectangleSelectionCheckBox.IsEnabled = false; _overlay.Tapped += DoHandleOverlayTapped; void DoHandleOverlayTapped(object sender, WindowOverlayTappedEventArgs e) { var p = e.Point; Debug.Print($"{sender.GetType().Name} tapped! ({p.X};{p.Y})"); _tappedWithoutMove = false; // No mouse move on iOS/Android HandleTapped(p.X, p.Y); } #endif }