public override void HandlerActionTouch(TouchControllersState state, TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; Vector3 point1 = Vector3.zero; Vector3 point2 = Vector3.zero; Vector3 point1Delta = Vector3.zero; Vector3 point2Delta = Vector3.zero; if (touchOne != null) { point1 = touchOne[0].position; point1Delta = touchOne[0].deltaPosition; } if (touchTwo != null) { point2 = touchTwo[0].position; point2Delta = touchTwo[0].deltaPosition; } #if UNITY_EDITOR if (MouseButtonState) { point1 = Start_editorMousposition; point2 = Input.mousePosition + new Vector3(100.0f * -mouseScrollWheel, 100.0f * -mouseScrollWheel, 100.0f * -mouseScrollWheel); point1Delta = new Vector3(100.0f * (mouseScrollWheelOld - mouseScrollWheel), 100.0f * (mouseScrollWheelOld - mouseScrollWheel), 100.0f * (mouseScrollWheelOld - mouseScrollWheel)); point2Delta = new Vector3(100.0f * (mouseScrollWheelOld - mouseScrollWheel), 100.0f * (mouseScrollWheelOld - mouseScrollWheel), 100.0f * (mouseScrollWheelOld - mouseScrollWheel)); } #endif ZoomEvent(stateT, point1, point2, point1Delta, point2Delta); }
/// <summary> /// Überprüft, ob die Angaben im Dialog korrekt sind und beendet anschließend (ggf.) den DIalog /// </summary> /// <param name="element"></param> /// <param name="points"></param> private void ConnectCallback(UIElement element, TouchGroup points) { this.Invoke(new Action(() => { try { IPAddress ip = IPAddress.Parse(_ipaddress.Text); int port = int.Parse(_port.Text); if (port > 0 && port <= 9999) { OnDialogFinished(new Events.DialogEventArgs(this, CONNECT, port, ip)); } else { DialogControl <MessageDialog> .ShowDialog(DialogParent.Surface, DialogInfo.CreateMessageInfo("The port must be between 0 and 9999!", true)); } } catch { DialogControl <MessageDialog> .ShowDialog(DialogParent.Surface, DialogInfo.CreateMessageInfo(this._ipaddress.Text + " is not a valid ip adress", true)); } })); }
/// <summary> /// Ruft das Event "AfterValidation" auf /// </summary> /// <param name="ui">Das Element, auf welcher diese Geste validiert wird</param> /// <param name="points">Die Berührungspunkte, die für diese Geste einfluss haben</param> protected virtual void OnAfterValidation(UIElement ui, TouchGroup points, bool valid) { if (AfterValidation != null) { AfterValidation(this, new GestureValidationEventArgs(true, valid, ui, points, this)); } }
/// <summary> /// Ruft das Event "BeforeValidation" auf /// </summary> /// <param name="ui">Das Element, auf welcher diese Geste validiert wird</param> /// <param name="points">Die Berührungspunkte, die für diese Geste einfluss haben</param> protected virtual void OnBeforeValidation(UIElement ui, TouchGroup points) { if (BeforeValidation != null) { BeforeValidation(this, new GestureValidationEventArgs(false, false, ui, points, this)); } }
protected override bool InternalValidation(System.Windows.UIElement ui, TouchGroup points) { //Maximal eine Berührungs ist für diese Geste zulässig! if (points.MaxPoints == 1 && points.Count == 1) { TouchPoint tp = points[0]; //Mindestens vier Positionen müssen bisher gespeichert sein, //außerdem muss die Berührung gerade entfernt worden sein if (tp.PathLength > 4 && tp.Mode == TouchPoint.TouchMode.UP) { //Länge der Berührung als Summe der Distanzen aller Zwischenpunkte float total_dist = tp.Distance; //Distanz zwischen Start und Endpunkt der Berührung float start_end = tp.StartPoint.GetDistance(tp.CurrentPoint); //Mindestens 50% der Oberflächengröße lang if (tp.DistanceRelative > 0.5) { //10% Abweichung einer perfekten Linie (berechnet in start_end) //ist zulässig, dadurch werden auch Linien mit einer leichten //krümmung erkannt return((start_end / total_dist) > 0.9); } } } return(false); }
/// <summary> /// Initialisiert neue GestureValidationEventArgs /// </summary> /// <param name="hasvalidated">Wurde die Geste bereits validiert?</param> /// <param name="isvalid">Wurde die Geste erkannt?</param> /// <param name="ui">Das UIElement, auf dem diese Geste validiert werden soll/wurde</param> /// <param name="points">Die Berührungspunkte, die für diese Geste betrachtet werden/wurden</param> /// <param name="gesture">Die Geste, die dieses Event aufgerufen hat.</param> public GestureValidationEventArgs(bool hasvalidated, bool isvalid, UIElement ui, TouchGroup points, GestureBase gesture) { HasValidated = hasvalidated; IsValid = isvalid; Element = ui; Points = points; Gesture = gesture; }
protected virtual void EditorToggleCallback(UIElement element, TouchGroup points) { if (State == STATE_VIEW) { StartEditing(); } else { EndEditing(); } }
/// <summary> /// Bei jeder neun Berührung: Creation Feedback (größer werdendes Rechteck) beginnt! /// </summary> /// <param name="element"></param> /// <param name="points"></param> private void TouchDownCallback(UIElement element, TouchGroup points) { if (points.Count == 1) { StartCreationFeedback(points[0].CurrentPoint); } else { RemoveCreationFeedback(); } }
protected override bool InternalValidation(System.Windows.UIElement ui, TouchGroup points) { foreach (TouchPoint tp in points) { if (tp.Mode == TouchPoint.TouchMode.UP || tp.Mode == TouchPoint.TouchMode.DOWN) { return(true); } } return(false); }
public override TouchControllersState HandlerFindTouch(TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; if (stateT == TouchControllersState.TCS_None) { if (touchOne != null) { /* * Начало свайпа: * Случай 1: (1 B)(1 S)(1 M) * Случай 2: (1 B)(1 M) */ if ((/*touchOne[2].phase == TouchPhase.Began&&*/ touchOne[1].phase == TouchPhase.Stationary && touchOne[0].phase == TouchPhase.Moved) || (/*touchOne[2].phase == TouchPhase.Began &&*/ touchOne[0].phase == TouchPhase.Moved)) { stateT = TouchControllersState.TCS_Start; return(stateT); } } } else if (stateT == TouchControllersState.TCS_Start) { stateT = TouchControllersState.TCS_Action; return(stateT); } else if (stateT == TouchControllersState.TCS_Action) { /* * Свайп * Случай 1: (1 M) * Случай 2: (1 S) * Конец свайпа: * Случай 1: (1 M)(1 E) * Случай 1: (1 S)(1 E) */ if (touchOne == null || touchTwo != null || (touchOne[1].phase == TouchPhase.Stationary && touchOne[0].phase == TouchPhase.Ended) || (touchOne[1].phase == TouchPhase.Moved && touchOne[0].phase == TouchPhase.Ended)) { stateT = TouchControllersState.TCS_End; return(stateT); } } else if (stateT == TouchControllersState.TCS_End) { stateT = TouchControllersState.TCS_None; return(stateT); } return(stateT); }
/// <summary> /// Einer der Berührungspunkte muss korrekt validiert werden. /// </summary> /// <param name="ui">Das UIElement, auf dem diese Geste validiert wird</param> /// <param name="points">Die Berührungspunkte, die für diese Validierung betrachtet werden</param> /// <returns>TRUE wenn mindestens ein Berührungspunkt korrekt validiert wird</returns> protected override bool InternalValidation(System.Windows.UIElement ui, TouchGroup points) { if (points.MaxPoints == FingerCount && points.Count == FingerCount) { bool valid = false; for (int i = 0; i < FingerCount; i++) { valid = ValidateFinger(points[i], ui, points) || valid; } return(valid); } return(false); }
public override void HandlerActionTouch(TouchControllersState state, TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; Vector3 point1 = Vector3.zero; if (touchOne != null) { point1 = touchOne[0].position; HoldEvent(state, point1, touchOneStateTime, checkingRay(point1)); } }
/// <summary> /// Einmaliges antippen der Epic verändert die Visibility /// </summary> /// <param name="element"></param> /// <param name="points"></param> private void ToggleVisibility(System.Windows.UIElement element, TouchGroup points) { bool visibility = !Epic.IsVisible; Epic.IsVisible = visibility; foreach (UserStory us in Epic.UserStories) { us.IsVisible = visibility; } CheckVisibility(); }
/// <summary> /// Validiert diese Geste. Gibt True zurück, falls die Anforderungen erfüllt wurden. /// </summary> /// <param name="ui">Das UIElement, auf welchem diese Geste validiert wird</param> /// <param name="points">Die Berührungspunkte, die für die Validierung betrachtet werden</param> /// <returns>TRUE wenn die Geste erkannt wurde, sonst FALSE</returns> public bool Validate(UIElement ui, TouchGroup points) { if (!IsActive) { return(false); } else { OnBeforeValidation(ui, points); bool valid = InternalValidation(ui, points); OnAfterValidation(ui, points, valid); return(valid); } }
protected override bool ValidateFinger(TouchPoint point, UIElement ui, TouchGroup allPoints) { if (point.Mode != TouchPoint.TouchMode.UP) { return(false); } if (point.Distance > 50) { return(false); } int sofar = point.DurationMS; return(Compare(sofar)); }
public void removeTuioCursor(TuioCursor tcur) { if (GestureManager != null) { TouchGroup tg = GestureManager.GetTouchGroup(tcur.getSessionID()); if (tg != null) { TouchPoint tp = tg.Get(tcur.getSessionID()); tp.Mode = TouchPoint.TouchMode.UP; this.UpdateTouchPoint(tp, tcur); OnTouchUp(tp); } } }
public override TouchControllersState HandlerFindTouch(TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; if (touchOne != null) { if (touchOne[0].phase == TouchPhase.Stationary) { return(TouchControllersState.TCS_Action); } } return(TouchControllersState.TCS_None); }
protected virtual void ResizeCallback(UIElement element, TouchGroup points) { RemoveResizeAnimation(); Vector vec1 = VectorExtension.FromPoints(points[0].CurrentPoint, points[1].CurrentPoint); Vector vec2 = VectorExtension.FromPoints(points[0].PreviousPoint, points[1].PreviousPoint); double distanceChange = vec1.Length - vec2.Length; double w = this.ScaledWidth + distanceChange; double h = this.ScaledHeight + distanceChange; //Neue Größe festlegen. Die aufgerufene Methode passt den Skalierungsfaktor der Größe an this.SetSize(w, h); }
protected virtual void TouchDownCallback(UIElement element, TouchGroup points) { this.Invoke( new Action(() => { _backgroundanim = true; Animation.Animator.AnimateColor( this.UserInterface, Controls.Style.StyleHelper.GetBackgroundColor(Item), Color.FromRgb(0, 0, 0), new Duration(TimeSpan .FromMilliseconds(DefinedGestures.HOLD_LENGTH + 100))); }) ); }
public override void BreakTouch(TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { if (stateT == TouchControllersState.TCS_End) { return; } Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; Vector3 point1 = Vector3.zero; Vector3 point2 = Vector3.zero; Vector3 point1Delta = Vector3.zero; Vector3 point2Delta = Vector3.zero; if (touchOne != null) { point1 = touchOne[0].position; point1Delta = touchOne[0].deltaPosition; } if (touchTwo != null) { point2 = touchTwo[0].position; point2Delta = touchTwo[0].deltaPosition; } ZoomModel zoom = new ZoomModel { point1 = point1, point1Delta = point1Delta, point2 = point2, point2Delta = point2Delta, stateT = stateT }; if (stateT == TouchControllersState.TCS_Start) { MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Zoom, zoom); zoom.stateT = TouchControllersState.TCS_Action; MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Zoom, zoom); zoom.stateT = TouchControllersState.TCS_End; MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Zoom, zoom); } else if (stateT == TouchControllersState.TCS_Action) { MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Zoom, zoom); zoom.stateT = TouchControllersState.TCS_End; MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Zoom, zoom); } }
public override TouchControllersState HandlerFindTouch(TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; if (stateT == TouchControllersState.TCS_None) { if (touchOne != null && touchTwo == null) { /* * Начало Драга: * Случай 1: (1 B)(1 S) + S(>0.3C) */ if ((touchOne[1].phase == TouchPhase.Began || touchOne[0].phase == TouchPhase.Stationary) && checkingRay(touchOne[0].position)) { stateT = TouchControllersState.TCS_Start; return(stateT); } } } else if (stateT == TouchControllersState.TCS_Start) { stateT = TouchControllersState.TCS_Action; return(stateT); } else if (stateT == TouchControllersState.TCS_Action) { /* * Драг * Случай 1: (1 M) * Конец Драга: * Случай 1: (1 E) */ if ((touchOne == null || touchTwo != null || touchOne[0].phase == TouchPhase.Ended)) { touchOneStateTime = 0; stateT = TouchControllersState.TCS_End; return(stateT); } } else if (stateT == TouchControllersState.TCS_End) { stateT = TouchControllersState.TCS_None; return(stateT); } return(stateT); }
protected virtual void RotateCallback(UIElement element, TouchGroup points) { RemoveRotateAnimation(); Vector vec1 = VectorExtension.FromPoints(points[0].CurrentPoint, points[1].CurrentPoint); Vector vec2 = VectorExtension.FromPoints(points[0].PreviousPoint, points[1].PreviousPoint); double slopeChanged = vec2.GetAngle(vec1); if (!rotateInProgress && slopeChanged != 0) { //Neuen Winkel festlegen durch Addition this.RotateAngle += slopeChanged; rotateInProgress = false; } }
/// <summary> /// Halte-Geste zum erstellen einer neuen User Story /// Das Creation Feedback ist so ausgelegt, /// dass das Rechteck nicht weiter wächst, wenn die User Story durch loslassen /// erstellt werden kann /// </summary> /// <param name="element"></param> /// <param name="points"></param> private void HoldGesture(UIElement element, TouchGroup points) { this.Invoke(() => { UserStory us = new UserStory(); Database.AddItem(us); us.Representations[0].MoveCenter(points[0].CurrentPoint.X, points[0].CurrentPoint.Y); //Automatisch den Winkel bestimmen us.Representations[0].RotateAngle = InitialAngleHelper.GetInitialAngle( this.ActualWidth, this.ActualHeight, points[0].CurrentPoint); OnItemCreated(us); }); }
public override TouchControllersState HandlerFindTouch(TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; if (touchOne != null) { if ((touchOne[2].phase == TouchPhase.Began && touchOne[1].phase == TouchPhase.Stationary && touchOne[0].phase == TouchPhase.Ended) || (touchOne[1].phase == TouchPhase.Began && touchOne[0].phase == TouchPhase.Ended) || (touchOne[2].phase == TouchPhase.Began && touchOne[1].phase == TouchPhase.Moved && touchOne[0].phase == TouchPhase.Ended && touchOneStateMoveTime < 0.15f)) { touchOneStateMoveTime = 10.0f; return(TouchControllersState.TCS_Action); } } return(TouchControllersState.TCS_None); }
private void SaveSettings(UIElement element, TouchGroup points) { this.Invoke(new Action(() => { int tcp_port; int udp_port; string client_name = _clientname.Text; if (client_name.Length > 0) { if (int.TryParse(_tcpport.Text, out tcp_port) & tcp_port < 9999 & tcp_port > 0) { if (int.TryParse(_udpport.Text, out udp_port) & udp_port < 9999 & udp_port > 0) { if (udp_port != tcp_port) { //Endlich sind alle Bedingungen erfüllt -> Daten speichern Utilities.Settings.Default.CLIENT_NAME = client_name; Utilities.Settings.Default.STD_TCP_PORT = tcp_port; Utilities.Settings.Default.UDP_PORT = udp_port; Utilities.Settings.Default.Save(); OnDialogFinished(new Events.DialogEventArgs(SAVE, this)); } else { MessageDialog.ShowMessage(DialogParent.Surface, "UDP and TCP Port can not be the same", true); } } else { MessageDialog.ShowMessage(DialogParent.Surface, "The UDP Port has to be a valid number between 0 and 9999", true); } } else { MessageDialog.ShowMessage(DialogParent.Surface, "The TCP Port has to be a valid number between 0 and 9999", true); } } else { MessageDialog.ShowMessage(DialogParent.Surface, "You have to enter a name for this client.", true); } })); }
protected override bool InternalValidation(System.Windows.UIElement ui, TouchGroup points) { if (points.Count == 1) { if (_mode == TouchPoint.TouchMode.ANY) { return(true); } else { if (points[0].Mode == _mode) { return(true); } } } return(false); }
protected override bool InternalValidation(UIElement ui, TouchGroup points) { bool valid = false; bool create = true; //Validiere, ob es eine Tap-Geste ist. if (tapValidator.Validate(ui, points)) { lock (currentElements) { //Suche nach dem entsprechendem Objekt auf der Oberfläche. //Falls dieses bereits gespeichert wurde, wird überprüft //ob die Pause zwischen diesem und dem vorhergehendem "Tap" kurz genug war. //Anschließend wird die Zeit mit dem entsprechenden Objekt für diesen Tap gespeichert. if (currentElements.ContainsKey(ui)) { long lastTap = currentElements[ui]; long thisTap = points[0].CurrentTimeMS; if (lastTap != thisTap) { if (thisTap - lastTap <= DefinedGestures.DOUBLE_TAP_BREAK) { valid = true; create = false; } else { currentElements.Remove(ui); } } else { create = false; } } if (create) { currentElements.Add(ui, points[0].CurrentTimeMS); } } } return(valid); }
public override void BreakTouch(TouchGroup touches, float touchOneStateMoveTime = 0.0f, float touchOneStateTime = 0.0f, CheckingRayIntoObject checkingRay = null) { if (stateT == TouchControllersState.TCS_End) { return; } Touch[] touchOne = touches.touchOne; Touch[] touchTwo = touches.touchTwo; Touch[] touchTree = touches.touchTree; Vector3 point1 = Vector3.zero; Vector3 point1Delta = Vector3.zero; if (touchOne != null) { point1 = touchOne[0].position; point1Delta = touchOne[0].deltaPosition; } DragModel dragModel = new DragModel() { stateT = stateT, EventTime = touchOneStateTime, point1 = point1, point1Delta = point1Delta }; if (stateT == TouchControllersState.TCS_Start) { MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Drag, dragModel); dragModel.stateT = TouchControllersState.TCS_Action; MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Drag, dragModel); dragModel.stateT = TouchControllersState.TCS_End; MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Drag, dragModel); } else if (stateT == TouchControllersState.TCS_Action) { MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Drag, dragModel); dragModel.stateT = TouchControllersState.TCS_End; MainContextView.DispatchStrangeEvent(EventGlobal.E_TouchAndMouseGestures_Drag, dragModel); } }
private void TapGestureCallback(System.Windows.UIElement element, TouchGroup points) { Toggle = !Toggle; OnTapped(); }
private void TouchDownCallback(System.Windows.UIElement element, TouchGroup points) { SetBackgroundColor(_touchcolor); }