Пример #1
0
		static void RaiseCaptureEvent(Contact contact, RoutedEvent routedEvent, DependencyObject source, long timestamp)
		{
			ContactEventArgs args = new ContactEventArgs(contact, timestamp);
			args.RoutedEvent = routedEvent;
			args.Source = source;
			MultitouchLogic.RaiseEvent(source, args);
		}
Пример #2
0
 public ElementRoutedEventArgs(FrameworkElement element, Point offset, ContactEventArgs e)
 {
     contactEventArgs = e;
     contact = e.Contact;
     this.element = element;
     this.offset = offset;
 }
Пример #3
0
		void OnLostContactCapture(object sender, ContactEventArgs e)
		{
			IsDragging = false;

			RaiseEvent(new DragCompletedEventArgs(screenTotalDelta.X, screenTotalDelta.Y, false));
			originalThumbPosition.X = 0.0;
			originalThumbPosition.Y = 0.0;
		}
Пример #4
0
		void OnContactMoved(object sender, ContactEventArgs e)
		{
			if(IsDragging)
			{
				Point currentPosition = e.GetPosition(this);
				if (currentPosition != lastThumbPosition)
				{
					e.Handled = true;
					RaiseEvent(new DragDeltaEventArgs(currentPosition.X - lastThumbPosition.X, currentPosition.Y - lastThumbPosition.Y));
					lastThumbPosition = currentPosition;
				}
			}
		}
Пример #5
0
		void InvokeHandler(ContactEventHandler handler, ContactEventArgs e)
		{
			if (handler != null)
			{
				handler(this, e);

				if (executeOnNextContact != null)
				{
					Action<Contact> action = executeOnNextContact;
					executeOnNextContact = null;
					action(e.Contact);
				}
			}
		}
Пример #6
0
		void OnContactRemoved(object sender, ContactEventArgs e)
		{
			if (ClickMode != ClickMode.Hover)
			{
				e.Handled = true;
				if (e.Contact.Captured == this)
				{
					e.Contact.ReleaseCapture();
					if (MultitouchScreen.GetContactsCaptured(this).Count() == 0)
					{
						StopTimer();
						IsPressed = false;
					}
				}
			}
		}
Пример #7
0
		void OnContactRemoved(object sender, ContactEventArgs e)
		{
			if (ClickMode != ClickMode.Hover)
			{
				e.Handled = true;
				if (e.Contact.Captured == this)
				{
					bool shouldMakeClick = IsPressed && ClickMode == ClickMode.Release;
					e.Contact.ReleaseCapture();
					if (MultitouchScreen.GetContactsCaptured(this).Count() == 0)
					{
						if(shouldMakeClick)
							OnClick();
						IsPressed = false;
					}
				}
			}
		}
Пример #8
0
		void OnGotContactCapture(object sender, ContactEventArgs e)
		{
			if (!IsDragging)
			{
				IsDragging = true;

				screenTotalDelta = new Vector();
				originalThumbPosition = e.GetPosition(this);
				lastThumbPosition = originalThumbPosition;

				bool failed = true;
				try
				{
					RaiseEvent(new DragStartedEventArgs(originalThumbPosition.X, originalThumbPosition.Y));
					failed = false;
				}
				finally
				{
					if (failed)
						CancelDrag();
				}
			}
		}
Пример #9
0
		void OnGotContactCapture(object sender, ContactEventArgs e)
		{
			FrameworkElement element = (FrameworkElement)e.Source;
			FrameworkElement container = ItemsControl.ContainerFromElement(null, element) as FrameworkElement;
			if (container != null)
				element = container;

			Body body;
			if (elementToBody.TryGetValue(element, out body))
			{
				Point position = e.GetPosition(this);
				Vector2D contactPoint = position.ToVector2D();
				if (body.Shape.CanGetIntersection)
				{
					Vector2D temp = body.Matrices.ToBody * contactPoint;
					IntersectionInfo intersectionInfo;
					if (body.Shape.TryGetIntersection(temp, out intersectionInfo))
					{
						FixedHingeJoint joint = new FixedHingeJoint(body, contactPoint, new Lifespan());
						joint.Softness = 0.3;
						engine.AddJoint(joint);
						contactJoints[e.Contact.Id] = joint;
					}
				}
			}
			SetZTop(element);
		}
Пример #10
0
 	static void OnContactRemoved(object sender, ContactEventArgs e)
     {
     	if (e.Contact.Captured == e.Source)
     		e.Contact.Capture(null);
     }
Пример #11
0
		void OnContactRemoved(object sender, ContactEventArgs e)
		{
			e.Handled = true;
			if (e.Contact.Captured == this)
				e.Contact.Capture(null);
		}
Пример #12
0
		void OnContactMoved(object sender, ContactEventArgs e)
		{
			Point position = e.GetPosition(this);

			FixedHingeJoint joint;
			if (contactJoints.TryGetValue(e.Contact.Id, out joint))
			{
				joint.Anchor = position.ToVector2D();

				//scale
				Body body = joint.Bodies.First();
				FrameworkElement frameworkElement = body.Tag as FrameworkElement;
				if (frameworkElement != null && GetIsScalable(frameworkElement))
				{
					ScaleState state;
					if (elementToScale.TryGetValue(frameworkElement, out state))
					{
						IEnumerable<Contact> contacts = MultitouchScreen.GetContactsCaptured((IInputElement)e.Source);
						double previousDistance = 0;
						double currentDistance = 0;
						int divisor = 0;
						Contact[] contactsArray = contacts.ToArray();

						Point center = new Point(frameworkElement.ActualWidth / 2, frameworkElement.ActualHeight / 2);

						for (int i = 0; i < contactsArray.Length; i++)
						{
							for (int j = i + 1; j < contactsArray.Length; j++)
							{
								Point currFirst = contactsArray[j].GetPosition(this);
								Point currSecond = contactsArray[i].GetPosition(this);
								Vector vector = frameworkElement.PointFromScreen(currFirst) - frameworkElement.PointFromScreen(currSecond);
								currentDistance += vector.Length;

								Point prevFirst = contactsArray[j].GetPoints(this).FirstOrDefault();
								if (default(Point) == prevFirst)
									prevFirst = currFirst;
								Point prevSecond = contactsArray[i].GetPoints(this).FirstOrDefault();
								if (default(Point) == prevSecond)
									prevSecond = currSecond;
								Vector previousVector = frameworkElement.PointFromScreen(prevFirst) - frameworkElement.PointFromScreen(prevSecond);
								previousDistance += previousVector.Length;
								divisor++;
							}
						}
						if (divisor == 0)
							divisor = 1;

						previousDistance /= divisor;
						currentDistance /= divisor;

						double delta = currentDistance / previousDistance;
						if (double.IsNaN(delta))
							delta = 1;

						var newScale = state.Scale * delta;
						if (newScale > MaxScale)
							delta = MaxScale / state.Scale;
						else if (newScale < MinScale)
							delta = MinScale / state.Scale;

						state.Scale *= delta;
						state.Center = center;
						body.Transformation *= Matrix2x3.FromScale(new Vector2D(delta, delta));
					}
				}
			}
		}
Пример #13
0
        public void createButton_Click(object sender, ContactEventArgs e)
        {
            //if (this.appState != APPSTATE_DEFAULT) return;

            /*
                        Int32 id = this.nodes.Keys.Count;
                        Node n = new Node(MainGrid, new System.Windows.Point(600, 600),
                                this, id);
                        this.nodes.Add(id, n);
            */
            Node created = new Node(mainGrid, new Point(300, 300), this, nodes.Count);
            nodes.Add(created);
            /*            Node n = Node.ForWPFContext(this, MainGrid);
            this.nodes.Add(n.data.id, n);*/
        }
Пример #14
0
 private void list1_ContactMoved(object sender, ContactEventArgs e)
 {
     Contacts1.Remove(e.Contact);
     Contacts1.Add(e.Contact);
 }
Пример #15
0
		void OnContactRemoved(object sender, ContactEventArgs e)
		{
			InvokeHandler(ContactRemoved, e);
		}
Пример #16
0
        public void editButton_Click(object sender, ContactEventArgs e)
        {
            if (this.appState == APPSTATE_CHOOSE_NODE_TO_EDIT)
            {
                this.changeAppStateTo(APPSTATE_DEFAULT);
                //get rid of the popup here
                return;
            }

            //to me this is disabling potential gestures since we're changing the state anyways. are there interum states we aren't covering?
            /*if (this.appState != APPSTATE_DEFAULT)
                return;
            */
            this.changeAppStateTo(APPSTATE_CHOOSE_NODE_TO_EDIT);
        }
Пример #17
0
        void OnContactMoved(object sender, ContactEventArgs e)
        {
            HitTestResult hitTestResult = VisualTreeHelper.HitTest(this, e.GetPosition(this));
            if (hitTestResult != null) return;

            if (contactElements.ContainsKey(e.Contact.Id) && eltOffset.ContainsKey(contactElements[e.Contact.Id]))
            {
                var contactElement = contactElements[e.Contact.Id] as FrameworkElement;
                var offset = eltOffset[contactElements[e.Contact.Id]];

                eltOffset.Remove(contactElements[e.Contact.Id]);
                
                RaiseElementDraggedEvent(contactElement, offset, e);
                
                e.Contact.ReleaseCapture();
            }
        }
Пример #18
0
		void OnContactLeave(object sender, ContactEventArgs e)
		{
			InvokeHandler(ContactLeave, e);
		}
Пример #19
0
		private void list1_ContactEnter(object sender, ContactEventArgs e)
		{
			Contacts1.Add(e.Contact);
		}
Пример #20
0
 private void list1_ContactLeave(object sender, ContactEventArgs e)
 {
     Contacts1.Remove(e.Contact);
 }
Пример #21
0
 private void list1_ContactEnter(object sender, ContactEventArgs e)
 {
     Contacts1.Add(e.Contact);
 }
Пример #22
0
		void OnLostContactCapture(object sender, ContactEventArgs e)
		{
			FixedHingeJoint removedJoint;
            if (contactJoints.TryGetValue(e.Contact.Id, out removedJoint))
            {
                removedJoint.Lifetime.IsExpired = true;
                contactJoints.Remove(e.Contact.Id);
            }
        }
Пример #23
0
        void OnContactLeave(object sender, ContactEventArgs e)
        {
            HitTestResult htr = VisualTreeHelper.HitTest(this, e.GetPosition(this));
            if (htr != null) return;

            OnContactRemoved(sender, e);
        }
Пример #24
0
        public void trashButton_Click(object sender, ContactEventArgs e)
        {
            if (this.appState == APPSTATE_CHOOSE_NODE_TO_DELETE)
            {
                this.changeAppStateTo(APPSTATE_DEFAULT);
                //get rid of the popup here
                return;
            }
            /*
            if (this.appState != APPSTATE_DEFAULT)
                return;*/

            this.changeAppStateTo(APPSTATE_CHOOSE_NODE_TO_DELETE);
        }
Пример #25
0
		private void list1_ContactMoved(object sender, ContactEventArgs e)
		{
			Contacts1.Remove(e.Contact);
			Contacts1.Add(e.Contact);
		}
Пример #26
0
		void OnPreviewContactMoved(object sender, ContactEventArgs e)
		{
			InvokeHandler(PreviewContactMoved, e);
		}
Пример #27
0
        public void connectionButton_Click(object sender, ContactEventArgs e)
        {
            if (this.appState == APPSTATE_CHOOSE_FIRST_NODE_TO_TOGGLE_CONNECTION ||
                    this.appState == APPSTATE_CHOOSE_SECOND_NODE_TO_TOGGLE_CONNECTION)
            {
                this.changeAppStateTo(APPSTATE_DEFAULT);
                //get rid of the popup here
                return;
            }

            //if (this.appState != APPSTATE_DEFAULT)
            //    return;

            this.changeAppStateTo(APPSTATE_CHOOSE_FIRST_NODE_TO_TOGGLE_CONNECTION);
        }
Пример #28
0
		void OnGotContactCapture(object sender, ContactEventArgs e)
		{
			InvokeHandler(GotContactCapture, e);
		}
Пример #29
0
		private void list1_ContactLeave(object sender, ContactEventArgs e)
		{
			Contacts1.Remove(e.Contact);
		}
Пример #30
0
		void OnContactEnter(object sender, ContactEventArgs e)
		{
			InvokeHandler(ContactEnter, e);
		}
Пример #31
0
 private void RaiseElementDraggedEvent(FrameworkElement element, Point offset, ContactEventArgs e)
 {
     ElementRoutedEventArgs newEventArgs = new ElementRoutedEventArgs(element, offset, e);
     newEventArgs.RoutedEvent = ElementDraggedEvent;
     RaiseEvent(newEventArgs);
 }
Пример #32
0
 private void button_ContactRemoved(object sender, ContactEventArgs e)
 {
     Button b = (Button)sender;
     b.Background = Brushes.White;
     b.Foreground = Brushes.DarkTurquoise;
 }
Пример #33
0
		void OnContactRemoved(object sender, ContactEventArgs e)
		{
			if (e.Contact.Id == firstContactId)
			{
				scrollJoint.Lifetime.IsExpired = true;
				scrollJoint = null;
				firstContactId = null;
			}
		}