public void CreateWindowOverlayAndElements() { var app = new TestApp(); var window = app.CreateWindow() as IWindow; app.LoadPage(new ContentPage()); var windowOverlay = new WindowOverlay(window) as IWindowOverlay; // First time inserted, should be true. Assert.True(window.AddOverlay(windowOverlay)); var element = new TestWindowElement(); // Adding element for the first time, should be true. Assert.True(windowOverlay.AddWindowElement(element)); Assert.True(windowOverlay.WindowElements.Count > 0); // Can't add same element again, should be false. Assert.False(windowOverlay.AddWindowElement(element)); // First time removing element, should be true. Assert.True(windowOverlay.RemoveWindowElement(element)); Assert.True(windowOverlay.WindowElements.Count == 0); }
/// <summary /> public void Ctor() { GameProcess = new GameProcess(); GameData = new GameData(GameProcess); WindowOverlay = new WindowOverlay(GameProcess); GameProcess.Start(); GameData.Start(); WindowOverlay.Start(); }
/// <inheritdoc /> public void Dispose() { WindowOverlay.Dispose(); WindowOverlay = default; GameData.Dispose(); GameData = default; GameProcess.Dispose(); GameProcess = default; }
/// <summary /> public void Ctor() { GameProcess = new GameProcess(); GameData = new GameData(GameProcess); WindowOverlay = new WindowOverlay(GameProcess); Graphics = new Graphics(WindowOverlay, GameProcess, GameData); TriggerBot = new TriggerBot(GameProcess, GameData); GameProcess.Start(); GameData.Start(); WindowOverlay.Start(); Graphics.Start(); TriggerBot.Start(); }
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 }
/// <inheritdoc /> public void Dispose() { TriggerBot.Dispose(); TriggerBot = default; Graphics.Dispose(); Graphics = default; WindowOverlay.Dispose(); WindowOverlay = default; GameData.Dispose(); GameData = default; GameProcess.Dispose(); GameProcess = default; }
public void ShowPopup(IHostedControl control, string title, bool moveable, bool animate) { _popupContainer = new PopupContainer(control, title); var overlay = new WindowOverlay(DockPanelMainWindow); AdornerLayer parentAdorner = AdornerLayer.GetAdornerLayer(DockPanelMainWindow); if (parentAdorner == null) { return; } parentAdorner.Add(overlay); _popupContainer.Owner = this; _popupContainer.AnimateToCenterOnSizeChanged = animate; _popupContainer.ShowDialog(); _popupContainer.Close(); parentAdorner.Remove(overlay); _popupContainer = null; }
public void CreateAndRemoveOverlayWindow() { var app = new TestApp(); var window = app.CreateWindow() as IWindow; app.LoadPage(new ContentPage()); var windowOverlay = new WindowOverlay(window) as IWindowOverlay; // If not processed by a window, should be false. Assert.False(windowOverlay.IsNativeViewInitialized); // First time inserted, should be true. Assert.True(window.AddOverlay(windowOverlay)); // Should now be initialized. Assert.True(windowOverlay.IsNativeViewInitialized); Assert.True(window.Overlays.Count > 0); // Can't insert same window overlay again, should be false. Assert.False(window.AddOverlay(windowOverlay)); // Should remove from collection, should be true. Assert.True(window.RemoveOverlay(windowOverlay)); // Not in collection, should be false. Assert.False(window.RemoveOverlay(windowOverlay)); // Window was uninitialized, should be false. Assert.False(windowOverlay.IsNativeViewInitialized); // Second time inserted, should be true. Assert.True(window.AddOverlay(windowOverlay)); // Should now be initialized again. Assert.True(windowOverlay.IsNativeViewInitialized); }
public TestOverlayElement(WindowOverlay overlay) { _overlay = overlay; }
public Mouse(WindowOverlay overlay) { this.overlay = overlay; this.windMouse = new WindMouse(this); this.mousePosition = new Point(-1, -1); this.mousePath = new MousePath(); this.movementPositions = new LinkedList<Point>(); this.mouseCrossPen = new Pen(Color.Red, 2); }