Exemplo n.º 1
0
		public void ContactRemovedEvent()
		{
			ContactData contactData = GetContactData(0, ContactState.New);

			Run(() =>
				{
					window = new TestWindow();
					window.ContactRemoved += HandleEvent;
					window.PreviewContactRemoved += 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.Removed), 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.PreviewContactRemovedEvent, dequeue.RoutedEvent);
			dequeue = events.Dequeue();
			Assert.AreEqual<RoutedEvent>(MultitouchScreen.ContactRemovedEvent, dequeue.RoutedEvent);
		}
        public void TestAllEvents()
        {
            Run(() =>
            {
                window                        = new TestWindow();
                window.NewContact            += HandleEvent;
                window.PreviewNewContact     += HandleEvent;
                window.ContactMoved          += HandleEvent;
                window.PreviewContactMoved   += HandleEvent;
                window.ContactRemoved        += HandleEvent;
                window.PreviewContactRemoved += HandleEvent;
                window.Show();

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

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

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

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

                Dispatcher.ExitAllFrames();

                resetEvent.Set();
            });

            resetEvent.WaitOne();

            Assert.AreEqual(6, events.Count);

            RoutedEventArgsInfo dequeue = events.Dequeue();

            Assert.AreEqual <RoutedEvent>(MultitouchScreen.PreviewNewContactEvent, dequeue.RoutedEvent);
            dequeue = events.Dequeue();
            Assert.AreEqual <RoutedEvent>(MultitouchScreen.NewContactEvent, dequeue.RoutedEvent);
            dequeue = events.Dequeue();
            Assert.AreEqual <RoutedEvent>(MultitouchScreen.PreviewContactMovedEvent, dequeue.RoutedEvent);
            dequeue = events.Dequeue();
            Assert.AreEqual <RoutedEvent>(MultitouchScreen.ContactMovedEvent, dequeue.RoutedEvent);
            dequeue = events.Dequeue();
            Assert.AreEqual <RoutedEvent>(MultitouchScreen.PreviewContactRemovedEvent, dequeue.RoutedEvent);
            dequeue = events.Dequeue();
            Assert.AreEqual <RoutedEvent>(MultitouchScreen.ContactRemovedEvent, dequeue.RoutedEvent);
        }
Exemplo n.º 3
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
        }
Exemplo n.º 4
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
		}
Exemplo n.º 5
0
        public void TouchablePanelCapture()
        {
            Run(() =>
            {
                window = new TestWindow();
                window.Show();

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

                Point rectPosition    = GetPosition(window.panel, window.rect, true);
                Point contactPosition = rectPosition;
                contactPosition.Offset(-20, 0);
                MultitouchScreen.AddContactEnterHandler(window.rect, (sender, e) => e.Contact.Capture((IInputElement)e.Source));

                RawMultitouchReport report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.New, contactPosition), 1, source));
                InputManager.Current.ProcessInput(report);
                Assert.AreEqual(rectPosition, GetPosition(window.panel, window.rect, true));

                contactPosition.Offset(20, 0);
                report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, contactPosition), 2, source));
                InputManager.Current.ProcessInput(report);
                Assert.AreEqual(rectPosition, GetPosition(window.panel, window.rect, true));

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

                Point newPosition = rectPosition;
                newPosition.Offset(20, 0);

                Point position = GetPosition(window.panel, window.rect, true);
                Assert.AreNotEqual(rectPosition, position);
                Assert.AreEqual(newPosition, position);

                Dispatcher.ExitAllFrames();
                resetEvent.Set();
            });
            resetEvent.WaitOne();
        }
Exemplo n.º 6
0
		public void ContactHistory()
		{
			Run(() =>
				{
					window = new TestWindow();
					window.Show();

					ContactsManager manager = MultitouchLogic.Current.ContactsManager;

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

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

					Assert.AreEqual(1, manager.ExistingContacts.Count);
					Contact contact = manager.ExistingContacts.First().Value;
					Assert.AreEqual(0, contact.GetPoints(null).Count());

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

					Assert.AreEqual(1, manager.ExistingContacts.Count);
					contact = manager.ExistingContacts.First().Value;
					Assert.AreEqual(1, contact.GetPoints(null).Count());
                    
					report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, new Point(130, 120)), 2, source));
					InputManager.Current.ProcessInput(report);

					Assert.AreEqual(1, manager.ExistingContacts.Count);
					contact = manager.ExistingContacts.First().Value;
					Assert.AreEqual(2, contact.GetPoints(null).Count());

					report = new RawMultitouchReport(CreateContact(GetContactData(1, ContactState.New, new Point(130, 120)), 2, source));
					InputManager.Current.ProcessInput(report);

					Assert.AreEqual(2, manager.ExistingContacts.Count);
					contact = manager.ExistingContacts.First().Value;
					Assert.AreEqual(2, contact.GetPoints(null).Count());
					contact = manager.ExistingContacts.ElementAt(1).Value;
					Assert.AreEqual(0, contact.GetPoints(null).Count());
                    
					report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Removed, new Point(130, 120)), 3, source));
					InputManager.Current.ProcessInput(report);

					Assert.AreEqual(1, manager.ExistingContacts.Count);
					contact = manager.ExistingContacts.First().Value;
					Assert.AreEqual(0, contact.GetPoints(null).Count());

					report = new RawMultitouchReport(CreateContact(GetContactData(1, ContactState.Moved, new Point(140, 120)), 3, source));
					InputManager.Current.ProcessInput(report);

					Assert.AreEqual(1, manager.ExistingContacts.Count);
					contact = manager.ExistingContacts.First().Value;
					Assert.AreEqual(1, contact.GetPoints(null).Count());

					report = new RawMultitouchReport(CreateContact(GetContactData(1, ContactState.Removed, new Point(140, 120)), 4, source));
					InputManager.Current.ProcessInput(report);

					Assert.AreEqual(0, manager.ExistingContacts.Count);

					Dispatcher.ExitAllFrames();
					resetEvent.Set();
				});
			resetEvent.WaitOne();
		}
Exemplo n.º 7
0
		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);
		}
        public void ContactHistory()
        {
            Run(() =>
            {
                window = new TestWindow();
                window.Show();

                ContactsManager manager = MultitouchLogic.Current.ContactsManager;

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

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

                Assert.AreEqual(1, manager.ExistingContacts.Count);
                Contact contact = manager.ExistingContacts.First().Value;
                Assert.AreEqual(0, contact.GetPoints(null).Count());

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

                Assert.AreEqual(1, manager.ExistingContacts.Count);
                contact = manager.ExistingContacts.First().Value;
                Assert.AreEqual(1, contact.GetPoints(null).Count());

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

                Assert.AreEqual(1, manager.ExistingContacts.Count);
                contact = manager.ExistingContacts.First().Value;
                Assert.AreEqual(2, contact.GetPoints(null).Count());

                report = new RawMultitouchReport(CreateContact(GetContactData(1, ContactState.New, new Point(130, 120)), 2, source));
                InputManager.Current.ProcessInput(report);

                Assert.AreEqual(2, manager.ExistingContacts.Count);
                contact = manager.ExistingContacts.First().Value;
                Assert.AreEqual(2, contact.GetPoints(null).Count());
                contact = manager.ExistingContacts.ElementAt(1).Value;
                Assert.AreEqual(0, contact.GetPoints(null).Count());

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

                Assert.AreEqual(1, manager.ExistingContacts.Count);
                contact = manager.ExistingContacts.First().Value;
                Assert.AreEqual(0, contact.GetPoints(null).Count());

                report = new RawMultitouchReport(CreateContact(GetContactData(1, ContactState.Moved, new Point(140, 120)), 3, source));
                InputManager.Current.ProcessInput(report);

                Assert.AreEqual(1, manager.ExistingContacts.Count);
                contact = manager.ExistingContacts.First().Value;
                Assert.AreEqual(1, contact.GetPoints(null).Count());

                report = new RawMultitouchReport(CreateContact(GetContactData(1, ContactState.Removed, new Point(140, 120)), 4, source));
                InputManager.Current.ProcessInput(report);

                Assert.AreEqual(0, manager.ExistingContacts.Count);

                Dispatcher.ExitAllFrames();
                resetEvent.Set();
            });
            resetEvent.WaitOne();
        }
        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.º 10
0
		public void TouchablePanelCapture()
		{
			Run(() =>
				{
					window = new TestWindow();
					window.Show();

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

					Point rectPosition = GetPosition(window.panel, window.rect, true);
					Point contactPosition = rectPosition;
					contactPosition.Offset(-20, 0);
					MultitouchScreen.AddContactEnterHandler(window.rect, (sender, e) => e.Contact.Capture((IInputElement)e.Source));

					RawMultitouchReport report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.New, contactPosition), 1, source));
					InputManager.Current.ProcessInput(report);
					Assert.AreEqual(rectPosition, GetPosition(window.panel, window.rect, true));

					contactPosition.Offset(20, 0);
					report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, contactPosition), 2, source));
					InputManager.Current.ProcessInput(report);
					Assert.AreEqual(rectPosition, GetPosition(window.panel, window.rect, true));

					contactPosition.Offset(20, 0);
					report = new RawMultitouchReport(CreateContact(GetContactData(0, ContactState.Moved, contactPosition), 3, source));
					InputManager.Current.ProcessInput(report);
					
					Point newPosition = rectPosition;
					newPosition.Offset(20, 0);

					Point position = GetPosition(window.panel, window.rect, true);
					Assert.AreNotEqual(rectPosition, position);
					Assert.AreEqual(newPosition, position);

					Dispatcher.ExitAllFrames();
					resetEvent.Set();
				});
			resetEvent.WaitOne();
		}
Exemplo n.º 11
0
		public void MultipleContactsCaptureSameObject()
		{
			Run(()=>
			    {
			    	window = new TestWindow();
					window.NewContact += HandleEvent;
					window.Show();

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

					Assert.AreEqual(0, MultitouchScreen.GetContactsCaptured(window.testElement2).Count());
					Assert.AreEqual(0, MultitouchScreen.GetContactsCaptured(window.testElement).Count());
					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);

					Assert.AreEqual(1, MultitouchScreen.GetContactsCaptured(window.testElement).Count());
                    window.ExecuteOnNextContact(c => c.Capture(window.testElement));

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

					Assert.AreEqual(2, MultitouchScreen.GetContactsCaptured(window.testElement).Count());
					Assert.AreEqual(0, MultitouchScreen.GetContactsCaptured(window.testElement2).Count());

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