public void ContactMovedEvent()
        {
            ContactData contactData = GetContactData(0, ContactState.New);

            Run(() =>
            {
                window = new TestWindow();
                window.ContactMoved        += HandleEvent;
                window.PreviewContactMoved += HandleEvent;
                window.Show();

                HwndSource source = (HwndSource)PresentationSource.FromVisual(window);
                contactData.Hwnd  = source.Handle;

                RawMultitouchReport report = new RawMultitouchReport(CreateContact(contactData, 0, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved), 0, source));
                InputManager.Current.ProcessInput(report);

                Dispatcher.ExitAllFrames();

                resetEvent.Set();
            });

            resetEvent.WaitOne();

            Assert.AreEqual(2, events.Count);

            RoutedEventArgsInfo dequeue = events.Dequeue();

            Assert.AreEqual <RoutedEvent>(MultitouchScreen.PreviewContactMovedEvent, dequeue.RoutedEvent);
            dequeue = events.Dequeue();
            Assert.AreEqual <RoutedEvent>(MultitouchScreen.ContactMovedEvent, dequeue.RoutedEvent);
        }
Exemplo n.º 2
0
        public void CaptureElement()
        {
            Run(() =>
            {
                window                 = new TestWindow();
                window.NewContact     += HandleEvent;
                window.ContactMoved   += HandleEvent;
                window.ContactRemoved += HandleEvent;
                window.Show();

                HwndSource source = (HwndSource)PresentationSource.FromVisual(window);

                window.ExecuteOnNextContact(c => c.Capture(window.testElement));

                RawMultitouchReport report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.New, new Point(100, 100)), 0, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(130, 100)), 1, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(200, 100)), 2, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Removed, new Point(250, 100)), 3, source));
                InputManager.Current.ProcessInput(report);

                Dispatcher.ExitAllFrames();

                resetEvent.Set();
            });
            resetEvent.WaitOne();

            Assert.AreEqual(4, events.Count);

            RoutedEventArgsInfo dequeue = events.Dequeue();

            CheckContactEventArgs(dequeue, MultitouchScreen.NewContactEvent, window.testElement);             // 100,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactMovedEvent, window.testElement);           //130,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactMovedEvent, window.testElement);           //200,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactRemovedEvent, window.testElement);         //250,100
        }
 protected static void CheckContactEventArgs(RoutedEventArgsInfo e, RoutedEvent routedEvent, object source)
 {
     Assert.AreEqual(source, e.Source, "Source failed");
     Assert.AreEqual(routedEvent, e.RoutedEvent, "RoutedEvent failed");
 }
        public void EnterLeaveEvents()
        {
            Run(() =>
            {
                window = new TestWindow();

                window.PreviewNewContact += HandleEvent;
                window.NewContact        += HandleEvent;

                window.PreviewContactMoved += HandleEvent;
                window.ContactMoved        += HandleEvent;

                window.PreviewContactRemoved += HandleEvent;
                window.ContactRemoved        += HandleEvent;

                window.ContactEnter += HandleEvent;
                window.ContactLeave += HandleEvent;

                MultitouchScreen.AddContactEnterHandler(window.canvas, HandleEvent);
                MultitouchScreen.AddContactLeaveHandler(window.canvas, HandleEvent);

                window.testElement.ContactEnter += HandleEvent;
                window.testElement.ContactLeave += HandleEvent;

                window.Show();

                HwndSource source = (HwndSource)PresentationSource.FromVisual(window);

                RawMultitouchReport report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.New, new Point(30, 100)), 0, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(49, 100)), 1, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(100, 100)), 2, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(150, 100)), 3, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(200, 100)), 4, source));
                InputManager.Current.ProcessInput(report);

                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Removed, new Point(200, 100)), 5, source));
                InputManager.Current.ProcessInput(report);

                Dispatcher.ExitAllFrames();

                resetEvent.Set();
            });

            resetEvent.WaitOne();

            Assert.AreEqual(18, events.Count);

            RoutedEventArgsInfo dequeue = events.Dequeue();

            CheckContactEventArgs(dequeue, MultitouchScreen.ContactEnterEvent, window);             // 30,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.PreviewNewContactEvent, window);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.NewContactEvent, window);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.PreviewContactMovedEvent, window);             // 49,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactMovedEvent, window);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactEnterEvent, window.testElement);             //100,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactEnterEvent, window.canvas);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.PreviewContactMovedEvent, window.testElement);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactMovedEvent, window.testElement);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.PreviewContactMovedEvent, window.testElement);             //150,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactMovedEvent, window.testElement);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactLeaveEvent, window.testElement);             //200,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactLeaveEvent, window.canvas);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.PreviewContactMovedEvent, window);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactMovedEvent, window);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.PreviewContactRemovedEvent, window);             //200,100
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactRemovedEvent, window);
            dequeue = events.Dequeue();
            CheckContactEventArgs(dequeue, MultitouchScreen.ContactLeaveEvent, window);
        }
Exemplo n.º 5
0
		protected static void CheckContactEventArgs(RoutedEventArgsInfo e, RoutedEvent routedEvent, object source)
		{
			Assert.AreEqual(source, e.Source, "Source failed");
			Assert.AreEqual(routedEvent, e.RoutedEvent, "RoutedEvent failed");
		}