private static void CheckMouseEvent(TestWindow window, IInputElement button, RoutedEvent routedEvent, bool shouldBeHandled)
 {
     var args = new MouseButtonEventArgs(Mouse.PrimaryDevice, (int) DateTime.Now.Ticks, MouseButton.Left);
     args.RoutedEvent = routedEvent;
     button.RaiseEvent(args);
     window.ProcessEvents();
     Assert.AreEqual(shouldBeHandled, args.Handled);
 }
예제 #2
0
        public void Setup()
        {
            Window = new TestWindow() { Width = 300, Height = 300 };
            Window.Show();
            Window.Activate();
            Window.ProcessEvents();

            AfterSetup();
        }
예제 #3
0
        public void Setup()
        {
            Window = new TestWindow()
            {
                Width = 300, Height = 300
            };
            Window.Show();
            Window.Activate();
            Window.ProcessEvents();

            AfterSetup();
        }
        public void CanCreateNavigatorForASourceElementWhenInATree()
        {
            var frame = new Frame();
            var button = new Button();
            frame.Content = button;

            var window = new TestWindow(frame);
            window.Show();
            window.ProcessEvents();

            var resolver = new Mock<IRouteResolver>();
            var factory = new NavigatorFactory(resolver.Object);
            var navigator = factory.GetOwningNavigator(button);
            navigator.ResetHistory();

            window.Close();
        }
        public void ToggleSuppressInputTest()
        {
            var button = new Button();
            var window = new TestWindow(button);
            window.Show();
            
            CheckMouseEvent(window, button, UIElement.PreviewMouseUpEvent, false);
            CheckMouseEvent(window, button, UIElement.PreviewMouseDownEvent, false);
            
            window.ToggleSuppressInput(true);

            CheckMouseEvent(window, button, UIElement.PreviewMouseUpEvent, true);
            CheckMouseEvent(window, button, UIElement.PreviewMouseDownEvent, true);
            
            window.ToggleSuppressInput(false);

            CheckMouseEvent(window, button, UIElement.PreviewMouseUpEvent, false);
            CheckMouseEvent(window, button, UIElement.PreviewMouseDownEvent, false);
            
            window.Close();
        }