/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> protected void OnTouchContactDownHandler(object src, TouchContactEventArgs args) { args.TouchContact.Capture(this); //We use Reflection to access the private method "HandleMouseButtonDown" and invoke it MethodInfo startTimerMethod = this.GetType().GetMethod("HandleMouseButtonDown", BindingFlags.NonPublic | BindingFlags.Instance); startTimerMethod.Invoke(this, new object[]{ MouseButton.Left }); }
private void Stash_TouchDown(object sender, TouchContactEventArgs e) { //ids associated with shit. IDProperties idProperties = this.GetID(e.TouchContact.ID); if (!players.ContainsKey(idProperties.ID)) { switch (idProperties.ID) { case 0: this.players.Add(idProperties.ID, player1); break; case 1: this.players.Add(idProperties.ID, player2); break; case 2: this.players.Add(idProperties.ID, player1); break; case 3: this.players.Add(idProperties.ID, player2); break; } } Pie pie = new Pie(this.canvas, this.players, idProperties.ID, players[idProperties.ID], e.TouchContact.Position); pie.SetValue(Canvas.LeftProperty, e.TouchContact.Position.X); pie.SetValue(Canvas.TopProperty, e.TouchContact.Position.Y); this.canvas.Children.Add(pie); //its already known, so create a different pie for that user.. if (!contactPies.ContainsKey(idProperties.ID)) { this.contactPies.Add(idProperties.ID, pie); } }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> protected void OnTouchContactUpHandler(object src, TouchContactEventArgs args) { if (args.TouchContact.CapturedElement == this) { args.TouchContact.Release(); //no reflection needed } }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> protected void OnTouchContactDownHandler(object src, TouchContactEventArgs args) { args.TouchContact.Capture(this); base.IsPressed = true; //We use Reflection to access the private method "StartTimer" and invoke it MethodInfo startTimerMethod = this.GetType().GetMethod("StartTimer", BindingFlags.NonPublic | BindingFlags.Instance); startTimerMethod.Invoke(this, System.Type.EmptyTypes); }
protected override void OnTouchContactDownHandler(object src, TouchContactEventArgs args) { args.TouchContact.Capture(this); base.IsPressed = true; if (ClickMode == ClickMode.Press) { OnClick(); } }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> protected void OnTouchContactUpHandler(object src, TouchContactEventArgs args) { if (args.TouchContact.CapturedElement == this) { base.IsPressed = false; args.TouchContact.Release(); //We use Reflection to access the private method "StopTimer" and invoke it MethodInfo stopTimerMethod = this.GetType().GetMethod("StopTimer", BindingFlags.NonPublic | BindingFlags.Instance); stopTimerMethod.Invoke(this, System.Type.EmptyTypes); } }
protected override void OnTouchContactUpHandler(object src, TouchContactEventArgs args) { if (args.TouchContact.CapturedElement == this ) { base.IsPressed = false; if (ClickMode == ClickMode.Release) { OnClick(); } args.TouchContact.Release(); } }
void AssociatedObject_TouchDown(object sender, TouchContactEventArgs e) { //we can only lock if there is 1 Finger on the object. if (touchID != int.MinValue) { LockTimer.Dispose(); //stop the timer! return; } HardReset(); touchX = e.TouchContact.Position.X; touchY = e.TouchContact.Position.Y; touchID = e.TouchContact.ID; //Console.Out.WriteLine("Touch Down: "+touchID+" ("+touchX + ", "+touchY+")"); LockTimer.Start(); }
public void UpdateActiveTouchPoints(TouchAction2 action, TouchContactEventArgs e) { Point position = e.TouchContact.GetPosition(GestureFramework.LayoutRoot); TouchInfo info = new TouchInfo(); info.ActionType = action; info.Position = position; info.TouchDeviceId = e.TouchContact.ID; TouchPoint2 touchPoint = null; //If it is contact down, we want to add the point, otherwise we want to update that particular point if (action == TouchAction2.Down) { //add the new touch point to the base touchPoint = base.AddNewTouchPoint(info, e.OriginalSource as UIElement); } else { touchPoint = base.UpdateActiveTouchPoint(info); } // Update local cache if (_activeTouchPoints.ContainsKey(info.TouchDeviceId)) { _activeTouchPoints[info.TouchDeviceId] = touchPoint; _activeTouchInfos[info.TouchDeviceId] = info; } else { _activeTouchPoints.Add(info.TouchDeviceId, touchPoint); _activeTouchInfos.Add(info.TouchDeviceId, info); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrameworkElement_TouchContactUp(object sender, TouchContactEventArgs e) { if (this._elementTouchContacts.ContainsKey(e.TouchContact.ID)) { this._elementTouchContacts.Remove(e.TouchContact.ID); } if (e.TouchContact == this._keyTouchContact) { if (this._elementTouchContacts.Count > 0) { this._keyTouchContact = this._elementTouchContacts.Last<KeyValuePair<int, TouchContact>>().Value; } else { this._keyTouchContact = null; } } _previousKeyPosition = null; _previousPosition = null; _previousObjectParent = null; }
private void card_TouchDown(object sender, TouchContactEventArgs e) { if(OnContentCardTouchDown != null) { OnContentCardTouchDown((ContentCardBase)sender, e.TouchContact); } if (!cardsHeldDown.Contains((ContentCardBase)sender)) { cardsHeldDown.Add((ContentCardBase)sender); if (cardsHeldDown.Count == 1 && OnContentCardsHeldDown != null) { OnContentCardsHeldDown(); } } }
public void Kill_Building_Popup(Object sender, TouchContactEventArgs e) { object c = ((InteractiveBorder)sender).Parent; PrimaryCanvas.Children.Remove((Canvas)c); }
public void singleClick(object sender, TouchContactEventArgs e) { Console.WriteLine("This only happends when the single click event is satisfied"); Point point = new Point(); point = ((TouchContactEventArgs)e).TouchContact.GetPosition((InteractiveBorder)sender); Console.WriteLine(point.ToString()); Get_Region_For_Single_Click(point); }
private void TouchContactDown(object sender, TouchContactEventArgs e) { UpdateActiveTouchPoints(TouchAction2.Down, e); }
private void TouchMove(object sender, TouchContactEventArgs e) { UpdateActiveTouchPoints(TouchAction2.Move, e); }
void AssociatedObject_TouchUp(object sender, TouchContactEventArgs e) { HardReset(); double tX = e.TouchContact.Position.X; double tY = e.TouchContact.Position.Y; int tID = e.TouchContact.ID; //Console.Out.WriteLine("Touch Up: "+tID+" ("+tX + ", "+tY+")"); //if (touchID == e.TouchContact.ID) //{ touchID = int.MinValue; //} }
void AssociatedObject_TouchMove(object sender, TouchContactEventArgs e) { ReadOnlyCollection<TouchContact> roc = TouchInputManager.GetTouchContactsCaptured(AssociatedObject); if (roc.Count > 1) { return; //only works if there is 1 contact only } //check to see if the threshold has been reached, and that it has not gone over the distance threshold double dx = e.TouchContact.Position.X - touchX; double dy = e.TouchContact.Position.Y - touchY; double r2pow = dx * dx + dy * dy; if (r2pow > MAXRADIUS) { ResetTimer(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrameworkElement_TouchContactMove(object sender, TouchContactEventArgs e) { if (!this._elementTouchContacts.ContainsKey(e.TouchContact.ID)) { if (e.TouchContact.CapturedElement != this.AssociatedObject) { e.TouchContact.Release(); e.TouchContact.Capture(this.AssociatedObject); } if (!this._elementTouchContacts.ContainsKey(e.TouchContact.ID)) { this._elementTouchContacts.Add(e.TouchContact.ID, e.TouchContact); } this._keyTouchContact = e.TouchContact; this._previousKeyPosition = null; this._previousPosition = null; this._previousObjectParent = null; } else if (e.TouchContact == this._keyTouchContact) { UIElement parent = AssociatedObject.Parent as UIElement; if ((this._previousObjectParent != null) && (parent != this._previousObjectParent)) { this._previousObjectParent = parent; parent = null; } if (parent != null) { Point point = new Point(0.0, 0.0); foreach (TouchContact contact in this._elementTouchContacts.Values) { Point point2 = contact.GetPosition(parent); point.X += point2.X; point.Y += point2.Y; } point.X /= (double)this._elementTouchContacts.Count; point.Y /= (double)this._elementTouchContacts.Count; Point position = this._keyTouchContact.GetPosition(parent); if ((this._previousPosition.HasValue) && (this._previousKeyPosition.HasValue)) { double num; double num2; double num3; double num4; if (this._elementTouchContacts.Count == 1) { Point point4 = new Point(); if (AssociatedObject is ICentroid) { point4 = ((ICentroid)AssociatedObject).getCentroid(); } else { point4.X = this.AssociatedObject.ActualWidth / 2.0; point4.Y = this.AssociatedObject.ActualHeight / 2.0; } point4 = this.AssociatedObject.TranslatePoint(point4, parent); num = this._previousPosition.Value.X - point4.X; num2 = _previousPosition.Value.Y - point4.Y; num3 = point.X - point4.X; num4 = point.Y - point4.Y; } else { num = this._previousPosition.Value.X - this._previousKeyPosition.Value.X; num2 = this._previousPosition.Value.Y - this._previousKeyPosition.Value.Y; num3 = point.X - position.X; num4 = point.Y - position.Y; } double num5 = Math.Sqrt((num * num) + (num2 * num2)); double num6 = Math.Sqrt((num3 * num3) + (num4 * num4)); num /= num5; num2 /= num5; num3 /= num6; num4 /= num6; double d = (num * num3) + (num2 * num4); double num8 = (num * num4) - (num3 * num2); double num9 = (Math.Acos(d) * 180.0) / Math.PI; if ((_isRotateEnabled && (num9 > 0.0)) && (num9 <= 180.0)) { if (num8 > 0.0) { this._rotateTransform.Angle += num9; } else { this._rotateTransform.Angle -= num9; } if (AssociatedObject is ICentroid) { Point centroid = ((ICentroid)AssociatedObject).getCentroid(); _rotateTransform.CenterX = centroid.X; _rotateTransform.CenterY = centroid.Y; } else { _rotateTransform.CenterX = this.AssociatedObject.ActualWidth / 2.0; _rotateTransform.CenterY = this.AssociatedObject.ActualHeight / 2.0; } AssociatedObject.RenderTransform = _rotateTransform; } } this._previousKeyPosition = new Point(position.X, position.Y); this._previousPosition = new Point(point.X, point.Y); } } }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> private void AssociatedObject_TouchContactDown(object src, TouchContactEventArgs args) { if (!_touchContacts.ContainsKey(args.TouchContact.ID)) { _touchContacts.Add(args.TouchContact.ID, args.TouchContact); args.TouchContact.Capture(this.AssociatedObject); _keyTouchContact = args.TouchContact; } }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> private void AssociatedObject_TouchContactUp(object src, TouchContactEventArgs args) { if (args.TouchContact.CapturedElement == AssociatedObject) { _touchContacts.Remove(args.TouchContact.ID); args.TouchContact.Release(); } if (args.TouchContact == this._keyTouchContact) { if (_touchContacts.Count > 0) { //use the last touch contact as the new key. _keyTouchContact = _touchContacts.Last<KeyValuePair<int, TouchContact>>().Value; } else { _keyTouchContact = null; } } _previousDistance = 0; _previousObjectParent = null; _previousPosition = null; _previousKeyPosition = null; }
/// <summary> /// /// </summary> /// <param name="src"></param> /// <param name="args"></param> private void AssociatedObject_TouchContactMoved(object src, TouchContactEventArgs args) { //make sure that we have the key if (!this._touchContacts.ContainsKey(args.TouchContact.ID)) { if (args.TouchContact.CapturedElement != this.AssociatedObject) { args.TouchContact.Release(); args.TouchContact.Capture(this.AssociatedObject); this._touchContacts.Add(args.TouchContact.ID, args.TouchContact); } this._keyTouchContact = args.TouchContact; this._previousKeyPosition = null; this._previousPosition = null; this._previousDistance = 0.0; this._previousObjectParent = null; } else if ((this._touchContacts.Count >= 2)) { if (args.TouchContact != this._keyTouchContact) { return; //dont waste my time } UIElement parent = AssociatedObject.Parent as UIElement; if ((this._previousObjectParent != null) && (parent != _previousObjectParent)) { this._previousObjectParent = parent; parent = null; } if (parent != null) { Point point = new Point(0.0, 0.0); foreach (TouchContact contact in this._touchContacts.Values) { Point point2 = contact.GetPosition(this.AssociatedObject); point.X += point2.X; point.Y += point2.Y; } point.X /= (double)this._touchContacts.Count; point.Y /= (double)this._touchContacts.Count; Point point3 = this.AssociatedObject.TranslatePoint(point, parent); double num = 0.0; foreach (TouchContact contact2 in this._touchContacts.Values) { Point point4 = contact2.GetPosition(parent); num += Math.Sqrt(((point4.X - point3.X) * (point4.X - point3.X)) + ((point4.Y - point3.Y) * (point4.Y - point3.Y))); } num /= (double)this._touchContacts.Count; Point position = this._keyTouchContact.GetPosition(parent); if ((this._previousKeyPosition.HasValue && _previousPosition.HasValue) && (this._touchContacts.Count >= 1)) { double num2 = this._previousPosition.Value.X - this._previousKeyPosition.Value.X; double num3 = this._previousPosition.Value.Y - this._previousKeyPosition.Value.Y; double num4 = point3.X - position.X; double num5 = point3.Y - position.Y; double num6 = Math.Sqrt((num2 * num2) + (num3 * num3)); double num7 = Math.Sqrt((num4 * num4) + (num5 * num5)); num2 /= num6; num3 /= num6; num4 /= num7; num5 /= num7; double d = (num2 * num4) + (num3 * num5); double num9 = (num2 * num5) - (num4 * num3); double num10 = (Math.Acos(d) * 180.0) / 3.1415926535897931; if ((this._rotateEnabled && (num10 > 0.0)) && (num10 <= 180.0)) { if (num9 > 0.0) { this.AssociatedObject.RotateTransform.Angle += num10; } else { this.AssociatedObject.RotateTransform.Angle -= num10; } // //this.AssociatedObject.NotifyRotateTransformUpdated(); } } this._previousKeyPosition = new Point(position.X, position.Y); #region SCALECODE //SCALE CODE REMOVED /*if (this.m_bIsScaleEnabled && this.m_dPreviousDistance.HasValue) { double num11 = num / this.m_dPreviousDistance.Value; if ((((this.m_scaleTransform.ScaleX * num11) < base.AssociatedObject.MinScale) || ((this.m_scaleTransform.ScaleY * num11) < base.AssociatedObject.MinScale)) && (num11 < 1.0)) { this.m_scaleTransform.ScaleX = base.AssociatedObject.MinScale; this.m_scaleTransform.ScaleY = base.AssociatedObject.MinScale; } else if ((((this.m_scaleTransform.ScaleX * num11) > base.AssociatedObject.MaxScale) || ((this.m_scaleTransform.ScaleX * num11) > base.AssociatedObject.MaxScale)) && (num11 > 1.0)) { this.m_scaleTransform.ScaleX = base.AssociatedObject.MaxScale; this.m_scaleTransform.ScaleY = base.AssociatedObject.MaxScale; } else { this.m_scaleTransform.ScaleX *= num11; this.m_scaleTransform.ScaleY *= num11; } Point point6 = this.m_element.TranslatePoint(point, parent); this.m_translateTransform.X += point3.X - point6.X; this.m_translateTransform.Y += point3.Y - point6.Y; base.AssociatedObject.NotifyScaleTransformUpdated(); }*/ #endregion this._previousDistance = num; if (this._translateEnabled && this._previousPosition.HasValue) { this.AssociatedObject.TranslateTransform.X += point3.X - this._previousPosition.Value.X; this.AssociatedObject.TranslateTransform.Y += point3.Y - this._previousPosition.Value.Y; //Console.WriteLine("Moving " + (point3.X - this._previousPosition.Value.X)); //base.AssociatedObject.NotifyTranslateTransformUpdated(); } this._previousPosition = point3; } } else if (this._touchContacts.Count == 1) //specific version for rotation around a point { if (args.TouchContact != this._keyTouchContact) { return; //dont waste my time } UIElement parent = AssociatedObject.Parent as UIElement; if ((this._previousObjectParent != null) && (parent != _previousObjectParent)) { this._previousObjectParent = parent; parent = null; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrameworkElement_TouchContactDown(object sender, TouchContactEventArgs e) { _elementTouchContacts.Add(e.TouchContact.ID, e.TouchContact); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrameworkElement_TouchContactMove(object sender, TouchContactEventArgs e) { try { if (!IsRotateEnabled) { return; } if (!this._elementTouchContacts.ContainsKey(e.TouchContact.ID)) { if (e.TouchContact.CapturedElement != this.AssociatedObject) { e.TouchContact.Release(); e.TouchContact.Capture(this.AssociatedObject); } if (!this._elementTouchContacts.ContainsKey(e.TouchContact.ID)) { this._elementTouchContacts.Add(e.TouchContact.ID, e.TouchContact); } this._keyTouchContact = e.TouchContact; this._previousKeyPosition = null; this._previousPosition = null; this._previousObjectParent = null; } else if (e.TouchContact == this._keyTouchContact) { UIElement parent = AssociatedObject.Parent as UIElement; if ((this._previousObjectParent != null) && (parent != this._previousObjectParent)) { this._previousObjectParent = parent; parent = null; } if (parent != null) { Point point = new Point(0.0, 0.0); foreach (TouchContact contact in this._elementTouchContacts.Values) { Point point2 = contact.GetPosition(parent); point.X += point2.X; point.Y += point2.Y; } point.X /= (double)this._elementTouchContacts.Count; point.Y /= (double)this._elementTouchContacts.Count; Point position = this._keyTouchContact.GetPosition(parent); if ((this._previousPosition.HasValue) && (this._previousKeyPosition.HasValue)) { double num; double num2; double num3; double num4; if (this._elementTouchContacts.Count == 1) { Point point4 = AssociatedObject.getCentroid(); point4 = this.AssociatedObject.TranslatePoint(point4, parent); num = this._previousPosition.Value.X - point4.X; num2 = _previousPosition.Value.Y - point4.Y; num3 = point.X - point4.X; num4 = point.Y - point4.Y; } else { num = this._previousPosition.Value.X - this._previousKeyPosition.Value.X; num2 = this._previousPosition.Value.Y - this._previousKeyPosition.Value.Y; num3 = point.X - position.X; num4 = point.Y - position.Y; } double num5 = Math.Sqrt((num * num) + (num2 * num2)); double num6 = Math.Sqrt((num3 * num3) + (num4 * num4)); num /= num5; num2 /= num5; num3 /= num6; num4 /= num6; double d = (num * num3) + (num2 * num4); double num8 = (num * num4) - (num3 * num2); double num9 = (Math.Acos(d) * 180.0) / Math.PI; if ((_isRotateEnabled && (num9 > 0.0)) && (num9 <= 180.0)) { if (num8 > 0.0) { AssociatedObject.StartAngle -= num9; AssociatedObject.EndAngle -= num9; } else { AssociatedObject.StartAngle += num9; AssociatedObject.EndAngle += num9; } } } this._previousKeyPosition = new Point(position.X, position.Y); this._previousPosition = new Point(point.X, point.Y); } } } catch (Exception exc) { Console.WriteLine(exc); Console.WriteLine(exc.InnerException); } }
private void card_TouchUp(object sender, TouchContactEventArgs e) { if (OnContentCardTouchUp != null) { OnContentCardTouchUp((ContentCardBase)sender, e.TouchContact); } if (cardsHeldDown.Contains((ContentCardBase)sender)) { cardsHeldDown.Remove((ContentCardBase)sender); if (cardsHeldDown.Count == 0 && OnContentCardsReleased != null) { OnContentCardsReleased(); } } }
void AssociatedObject_TouchDown(object sender, TouchContactEventArgs e) { ReadOnlyCollection<TouchContact> roc = TouchInputManager.GetTouchContactsCaptured(AssociatedObject); if (roc.Count > 1) { return; //only works if there is 1 contact only } touchX = e.TouchContact.Position.X; touchY = e.TouchContact.Position.Y; ResetTimer(); updateTimer.Start(); }
private void m_onLockableUntouched(object src, TouchContactEventArgs args) { if (IsLocked()) { //Console.Out.WriteLine("lock effect"); Effect = lockEffect; } else { //Console.Out.WriteLine("unlock effect"); Effect = unlockEffect; } }
void AssociatedObject_TouchUp(object sender, TouchContactEventArgs e) { ResetTimer(); touchX = double.MaxValue; touchY = double.MinValue; }
protected virtual void OnTouchContactUpHandler(object src, TouchContactEventArgs args) { }
void AssociatedObject_TouchMove(object sender, TouchContactEventArgs e) { if (e.TouchContact.ID != touchID) { return; //not going to waste time with silly calculations } double dx = e.TouchContact.Position.X - touchX; double dy = e.TouchContact.Position.Y - touchY; double r2pow = dx * dx + dy * dy; if (r2pow > MAXRADIUS) { touchID = int.MinValue; //Console.Out.WriteLine("Reset: " + r2pow); //debug HardReset(); } }
private void card_TouchMove(object sender, TouchContactEventArgs e) { if (OnContentCardTouchMove != null) { OnContentCardTouchMove((ContentCardBase)sender, e.TouchContact); } }