void Touch_FrameReported(object sender, TouchFrameEventArgs e) { int pointsNumber = e.GetTouchPoints(drawCanvas).Count; TouchPointCollection pointCollection = e.GetTouchPoints(drawCanvas); for (int i = 0; i < pointsNumber; i++) { if (pointCollection[i].Action == TouchAction.Down) { preXArray[i] = pointCollection[i].Position.X; preYArray[i] = pointCollection[i].Position.Y; } if (pointCollection[i].Action == TouchAction.Move) { Line line = new Line(); line.X1 = preXArray[i]; line.Y1 = preYArray[i]; line.X2 = pointCollection[i].Position.X; line.Y2 = pointCollection[i].Position.Y; line.Stroke = new SolidColorBrush(Colors.Red); line.Fill = new SolidColorBrush(Colors.Red); line.StrokeThickness = 5; drawCanvas.Children.Add(line); preXArray[i] = pointCollection[i].Position.X; preYArray[i] = pointCollection[i].Position.Y; } } }
public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo) { TouchPointCollection collection = new TouchPointCollection(); UIElement element = relativeTo as UIElement; if (element == null) return collection; foreach (HandPointEventArgs e in intermediateEvents) { Point point = screen.MapPositionToScreen(e.Session); if (relativeTo != null) { point = this.ActiveSource.RootVisual.TransformToDescendant((Visual)relativeTo).Transform(point); } //Rect rect = e.BoundingRect; Rect rect = new Rect(screen.MapPositionToScreen(e.Session), new Size(1, 1)); TouchAction action = TouchAction.Move; if (lastEventArgs.Status == HandPointStatus.Down) { action = TouchAction.Down; } else if (lastEventArgs.Status == HandPointStatus.Up) { action = TouchAction.Up; } collection.Add(new TouchPoint(this, point, rect, action)); } return collection; }
private void CleanUp(TouchPointCollection tpc) { List <int> ToDelete = new List <int>(); foreach (TrackedTouchPoint ttp in trackedTouchPoints) { var query = from point in tpc where point.TouchDevice.Id == ttp.ID select point; if (query.Count() == 0) { ToDelete.Add(ttp.ID); } } foreach (int i in ToDelete) { var query = from point in trackedTouchPoints where point.ID == i select point; if (query.Count() != 0) { trackedTouchPoints.Remove(query.First()); } } if (trackedTouchPoints.Count == 0) { DrawCanvas.Children.Clear(); } }
public void Process(TouchPointCollection points) { _points = points; UpdateMode(); Update(); }
/// <summary> /// Creates a new instance of <see cref="TangibleObject"/>. /// </summary> /// <param name="point1">The first point.</param> /// <param name="point2">The second point.</param> /// <param name="point3">The third point. This should be the direction point.</param> internal TangibleObject(TouchPoint point1, TouchPoint point2, TouchPoint point3) { Check.NotNull(point1, "point1"); Check.NotNull(point2, "point2"); Check.NotNull(point3, "point3"); // Validate the points if (point1.IsDirectionPoint || point2.IsDirectionPoint) throw new InvalidOperationException("The first two points should not be direction points!"); if (!point3.IsDirectionPoint) throw new InvalidOperationException("No direction point specified!"); Points = new TouchPointCollection(); Points.AddPoint(point1); Points.AddPoint(point2); Points.AddPoint(point3); // Create the bottom line _bottomLine = new TouchLine(point1, point2); // Calculate the top line _topLine = CalculateTopLine(_bottomLine, point3); _topLine.Owner = this; // Set the owner of the points. //Points.ForEach(p => p.Owner = this); foreach (var point in Points) { point.Owner = this; point.Changed += OnPointChanged; } }
public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo) { TouchPointCollection collection = new TouchPointCollection(); UIElement element = relativeTo as UIElement; if (element == null) { return(collection); } foreach (InteropTouchEventArgs e in intermediateEvents) { Point point = new Point(e.Location.X, e.Location.Y); if (relativeTo != null) { point = this.ActiveSource.RootVisual.TransformToDescendant((Visual)relativeTo).Transform(point); } Rect rect = e.BoundingRect; TouchAction action = TouchAction.Move; if (e.IsTouchDown) { action = TouchAction.Down; } else if (e.IsTouchUp) { action = TouchAction.Up; } collection.Add(new TouchPoint(this, point, rect, action)); } return(collection); }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { try { int pointsNumber = e.GetTouchPoints(ellipseSense).Count; TouchPointCollection pointCollection = e.GetTouchPoints(ellipseSense); for (int i = 0; i < pointsNumber; i++) { if (pointCollection[i].Position.X > 0 && pointCollection[i].Position.X < ellipseSense.ActualWidth) { if (pointCollection[i].Position.Y > 0 && pointCollection[i].Position.Y < ellipseSense.ActualHeight) { // Update Shpero speed and direction Point p = pointCollection[i].Position; Point center = new Point(ellipseSense.ActualWidth / 2, ellipseSense.ActualHeight / 2); double distance = Math.Sqrt(Math.Pow((p.X - center.X), 2) + Math.Pow((p.Y - center.Y), 2)); double distanceRel = distance * 255 / (ellipseSense.ActualWidth / 2); if (distanceRel > 255) { distanceRel = 255; } double angle = Math.Atan2(p.Y - center.Y, p.X - center.X) * 180 / Math.PI; if (angle > 0) { angle += 90; } else { angle = 270 + (180 + angle); if (angle >= 360) { angle -= 360; } } direction = Convert.ToInt16(angle); speed = Convert.ToInt16(distanceRel); // Set Joystick Pos newX = p.X - (ellipseSense.ActualWidth / 2); newY = p.Y - (ellipseSense.ActualWidth / 2); if (moveJoystick) { MoveJoystick(newX, newY); } } } } } catch { } }
void TouchFrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection tpc = e.GetTouchPoints(ContentCanvas); tpc.ToList().ForEach(p => { // p.Action of type ActionType: Up, Down, Move Ellipse el = TouchUtils.CreateEllipse(p.Position); ContentCanvas.Children.Add(el); }); }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPoint primaryTouchPoint = e.GetPrimaryTouchPoint(null); TouchPointCollection touchPoints = e.GetTouchPoints(null); foreach (TouchPoint tp in touchPoints) { if (tp.Action == TouchAction.Move) { var t = TransformToVisual(ContentPanel); var absposition = t.Transform(new Point(tp.Position.X, tp.Position.Y)); if (absposition.X > 0 && absposition.X < btnBreak.ActualHeight && absposition.Y > 0 && absposition.Y < btnBreak.ActualWidth) { //btn BREAK tbBrakeInfo.Text = "b-> x: " + absposition.X + " y:" + absposition.Y; double val = Normalize(absposition.X, absposition.Y, btnBreak.ActualHeight); tbBrakeInfo.Text += " " + (1 - val); if (val > 1) { btnBreak_MouseLeave(null, null); } input.breakVal = 1 - (float)val; } if (absposition.X < btnAcceleration.ActualHeight && absposition.X > 0 && absposition.Y < ContentPanel.ActualWidth && absposition.Y > ContentPanel.ActualWidth - btnAcceleration.ActualWidth) { //btn ACCEL var yp = absposition.Y - (ContentPanel.ActualWidth - btnAcceleration.ActualWidth); tbAccelInfo.Text = "a-> x: " + absposition.X + " y:" + yp; double val = Normalize(absposition.X, yp, btnAcceleration.ActualHeight); tbAccelInfo.Text += " " + (1 - val); if (val > 1) { btnAcceleration_MouseLeave(null, null); } input.acceleration = 1 - (float)val; } } } }
/// <summary> /// Creates a new instance of <see cref="TangibleObjectManager"/>. /// </summary> /// <param name="container">The tangible canvas.</param> public TangibleObjectManager(TangibleCanvas container) { Check.NotNull(container, "container"); _container = container; // Initialize fields _detectedObjects = new List<TangibleObject>(); _detectedTouchPoints = new TouchPointCollection(TouchHelper.MaxTouchPoints); // Debugging //_detectedTouchPoints.AddPoint(new TouchPoint()); // Initialize detection logic SubscribeEvents(_container); }
private void Touch_OnFrameReported(object sender, TouchFrameEventArgs e) { int num1 = Math.Min(1, ((PresentationFrameworkCollection <TouchPoint>)e.GetTouchPoints((UIElement)this.drawCanvas)).Count); TouchPointCollection touchPoints = e.GetTouchPoints((UIElement)this.drawCanvas); for (int index = 0; index < num1; ++index) { TouchPoint touchPoint = ((PresentationFrameworkCollection <TouchPoint>)touchPoints)[index]; Point position = touchPoint.Position; bool isPointInBounds = this.GetIsPointInBounds(position); position.Y = position.Y - 20.0; switch (touchPoint.Action) { case TouchAction.Down: if (isPointInBounds) { this._isDrawing = true; this.gridPallete.IsHitTestVisible = false; this.HandleTouchPoint(position, false); this.UpdateUndoOpacity(); break; } break; case TouchAction.Move: if (this._isDrawing) { this.HandleTouchPoint(position, false); break; } break; case TouchAction.Up: if (this._isDrawing) { this.HandleTouchPoint(position, true); this._isDrawing = false; this.gridPallete.IsHitTestVisible = true; break; } break; } } }
void OnTouchFrameReported(object sender, TouchFrameEventArgs args) { TouchPoint primaryTouchPoint = args.GetPrimaryTouchPoint(null); if (primaryTouchPoint != null && primaryTouchPoint.Action == TouchAction.Down) { args.SuspendMousePromotionUntilTouchUp(); } TouchPointCollection touchPoints = args.GetTouchPoints(inkPresenter); foreach (TouchPoint touchPoint in touchPoints) { Point pt = touchPoint.Position; int id = touchPoint.TouchDevice.Id; switch (touchPoint.Action) { case TouchAction.Down: Stroke stroke = new Stroke(); stroke.DrawingAttributes.Color = appSettings.Foreground; stroke.DrawingAttributes.Height = appSettings.StrokeWidth; stroke.DrawingAttributes.Width = appSettings.StrokeWidth; stroke.StylusPoints.Add(new StylusPoint(pt.X, pt.Y)); inkPresenter.Strokes.Add(stroke); activeStrokes.Add(id, stroke); break; case TouchAction.Move: activeStrokes[id].StylusPoints.Add(new StylusPoint(pt.X, pt.Y)); break; case TouchAction.Up: activeStrokes[id].StylusPoints.Add(new StylusPoint(pt.X, pt.Y)); activeStrokes.Remove(id); TitleAndAppbarUpdate(); break; } } }
protected override void OnTouch(TouchPointCollection touchPoints) { SuppressMapGestures = touchPoints.Count == 3; if (touchPoints.Count == 3) { if (!_initialPitchYLocation.HasValue) { _initialPitchYLocation = touchPoints[0].Position.Y; } var delta = touchPoints[0].Position.Y - _initialPitchYLocation.Value; var newPitch = Math.Max(0, Math.Min(75, (Map.Pitch + delta*Sensitivity))); Map.Pitch = newPitch; _initialPitchYLocation = touchPoints[0].Position.Y; } else { _initialPitchYLocation = null; } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection tpc = e.GetTouchPoints(this); foreach (TouchPoint t in tpc) { if (t.Action == TouchAction.Down) { System.Windows.Media.Color pickedColor = PickTappedColor(t.Position.X, t.Position.Y); DrumKitComponent component = (from d in drum where d.maskColor == pickedColor select d).SingleOrDefault <DrumKitComponent>(); if (component != null) { SoundEffect se = SoundEffect.FromStream(TitleContainer.OpenStream(component.audioFileName)); se.Play(); } } } }
protected override void OnTouch(TouchPointCollection touchPoints) { if (touchPoints.Count == 2) { // for the initial touch, record the angle between the fingers if (!_previousAngle.HasValue) { _previousAngle = AngleBetweenPoints(touchPoints[0], touchPoints[1]); } // should we rotate? if (!_isRotating) { var angle = AngleBetweenPoints(touchPoints[0], touchPoints[1]); var delta = angle - _previousAngle.Value; if (Math.Abs(delta) > MinimumRotation) { _isRotating = true; SuppressMapGestures = true; } } // rotate me if (_isRotating) { var angle = AngleBetweenPoints(touchPoints[0], touchPoints[1]); var delta = angle - _previousAngle.Value; Map.Heading -= delta; _previousAngle = angle; } } else { _previousAngle = null; _isRotating = false; SuppressMapGestures = false; } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { try { int pointsNumber = e.GetTouchPoints(ellipseSense).Count; TouchPointCollection pointCollection = e.GetTouchPoints(ellipseSense); for (int i = 0; i < pointsNumber; i++) { if (pointCollection[i].Position.X > 0 && pointCollection[i].Position.X < ellipseSense.ActualWidth) { if (pointCollection[i].Position.Y > 0 && pointCollection[i].Position.Y < ellipseSense.ActualHeight) { Touch_FrameReported(pointCollection[i].Position); } } } } catch { } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection touches = e.GetTouchPoints(ContentPanel); if (touches.Count == 2) { if ((onePoint.X - e.GetTouchPoints(ContentPanel)[0].Position.X) < (towPoint.X - e.GetTouchPoints(ContentPanel)[1].Position.X)) { player.Height += 2; player.Width += 2; } else if ((towPoint.X - onePoint.X) < (e.GetTouchPoints(ContentPanel)[1].Position.X - e.GetTouchPoints(ContentPanel)[0].Position.X)) { if (player.Height > 50) { player.Height -= 2; player.Width -= 2; } } onePoint = touches[0].Position; towPoint = touches[1].Position; } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection touches = e.GetTouchPoints(viewPort); if (touches.Count == 2) { if ((onePoint.X - e.GetTouchPoints(viewPort)[0].Position.X) < (towPoint.X - e.GetTouchPoints(viewPort)[1].Position.X)) { viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width, viewPort.Bounds.Height + 10); viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width + 10, viewPort.Bounds.Height); } else if ((towPoint.X - onePoint.X) < (e.GetTouchPoints(viewPort)[1].Position.X - e.GetTouchPoints(viewPort)[0].Position.X)) { if (image.Height > 50) { viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width, viewPort.Bounds.Height - 10); viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width - 10, viewPort.Bounds.Height); } } onePoint = touches[0].Position; towPoint = touches[1].Position; } }
public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo) { TouchPointCollection collection = new TouchPointCollection(); UIElement element = relativeTo as UIElement; if (element == null) return collection; try { foreach (IntermediateContact c in Contact.GetIntermediateContacts()) { Point point = c.GetPosition(null); if (relativeTo != null) { point = this.ActiveSource.RootVisual.TransformToDescendant((Visual)relativeTo).Transform(point); } collection.Add(new TouchPoint(this, point, c.BoundingRect, TouchAction.Move)); } } //Ignore InvalidOperationException due to race condition on Surface hardware catch (InvalidOperationException) { } return collection; }
internal static TouchPointCollection GetTouchPoints(IInputElement relativeTo) { TouchPointCollection points = new TouchPointCollection(); if (_activeDevices != null) { int count = _activeDevices.Count; for (int i = 0; i < count; i++) { TouchDevice device = _activeDevices[i]; points.Add(device.GetTouchPoint(relativeTo)); } } return points; }
/// <summary> /// Every touch action will rise this event handler. /// </summary> void Touch_FrameReported(object sender, TouchFrameEventArgs e) { int pointsNumber = e.GetTouchPoints(drawCanvas).Count; TouchPointCollection pointCollection = e.GetTouchPoints(drawCanvas); for (int i = 0; i < pointsNumber; i++) { if (pointCollection[i].Action == TouchAction.Down) { preXArray[i] = pointCollection[i].Position.X; preYArray[i] = pointCollection[i].Position.Y; } if (pointCollection[i].Action == TouchAction.Move) { Line line = new Line(); line.X1 = preXArray[i]; line.Y1 = preYArray[i]; line.X2 = pointCollection[i].Position.X; line.Y2 = pointCollection[i].Position.Y; line.StrokeThickness = linePixel; if (lineColor == "red") { line.Stroke = new SolidColorBrush(Colors.Red); line.Fill = new SolidColorBrush(Colors.Red); } else if (lineColor == "blue") { line.Stroke = new SolidColorBrush(Colors.Blue); line.Fill = new SolidColorBrush(Colors.Blue); } else if (lineColor == "sky") { line.Stroke = new SolidColorBrush(Colors.Cyan); line.Fill = new SolidColorBrush(Colors.Cyan); } else if (lineColor == "yellow") { line.Stroke = new SolidColorBrush(Colors.Yellow); line.Fill = new SolidColorBrush(Colors.Yellow); } else if (lineColor == "green") { line.Stroke = new SolidColorBrush(Colors.Green); line.Fill = new SolidColorBrush(Colors.Green); } else if (lineColor == "orange") { line.Stroke = new SolidColorBrush(Colors.Orange); line.Fill = new SolidColorBrush(Colors.Orange); } else if (lineColor == "violate") { line.Stroke = new SolidColorBrush(Colors.Purple); line.Fill = new SolidColorBrush(Colors.Purple); } else if (lineColor == "megenta") { line.Stroke = new SolidColorBrush(Colors.Magenta); line.Fill = new SolidColorBrush(Colors.Magenta); } else if (lineColor == "white") { line.Stroke = new SolidColorBrush(Colors.White); line.Fill = new SolidColorBrush(Colors.White); } else if (lineColor == "black") { line.Stroke = new SolidColorBrush(Colors.Black); line.Fill = new SolidColorBrush(Colors.Black); } else { line.Stroke = new SolidColorBrush(Colors.Black); line.Fill = new SolidColorBrush(Colors.Black); } drawCanvas.Children.Add(line); preXArray[i] = pointCollection[i].Position.X; preYArray[i] = pointCollection[i].Position.Y; } } }
/// <summary> /// Provides all of the known points the device hit since the last reported position update. /// </summary> /// <param name="relativeTo">Defines the coordinate space.</param> /// <returns>A list of points in the coordinate space of relativeTo.</returns> public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo) { // Retrieve the stylus points StylusPointCollection stylusPoints = _stylusDevice.GetStylusPoints(relativeTo, _stylusPointDescription); int count = stylusPoints.Count; TouchPointCollection touchPoints = new TouchPointCollection(); GeneralTransform elementToRoot; GeneralTransform rootToElement; GetRootTransforms(relativeTo, out elementToRoot, out rootToElement); // Convert the stylus points into touch points for (int i = 0; i < count; i++) { StylusPoint stylusPoint = stylusPoints[i]; Point position = new Point(stylusPoint.X, stylusPoint.Y); Rect rectBounds = GetBounds(stylusPoint, position, relativeTo, elementToRoot, rootToElement); TouchPoint touchPoint = new TouchPoint(this, position, rectBounds, _lastAction); touchPoints.Add(touchPoint); } return touchPoints; }
private void Touch_OnFrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection touchPoints = e.GetTouchPoints((UIElement)this.gridRecordOverlay); if (((PresentationFrameworkCollection <TouchPoint>)touchPoints).Count == 0) { return; } TouchPoint touchPoint = ((PresentationFrameworkCollection <TouchPoint>)touchPoints)[0]; Point position = touchPoint.Position; Point point1; if (!this._previousPoint.HasValue) { point1 = new Point(0.0, 0.0); } else { // ISSUE: explicit reference operation double x1 = ((Point)@position).X; Point point2 = this._previousPoint.Value; // ISSUE: explicit reference operation double x2 = ((Point)@point2).X; double num1 = x1 - x2; // ISSUE: explicit reference operation double y1 = ((Point)@position).Y; Point point3 = this._previousPoint.Value; // ISSUE: explicit reference operation double y2 = ((Point)@point3).Y; double num2 = y1 - y2; point1 = new Point(num1, num2); } Point point4 = point1; this._previousPoint = new Point?(position); // ISSUE: explicit reference operation double x = ((Point)@point4).X; TouchAction action = touchPoint.Action; if (action != TouchAction.Move) { if (action != TouchAction.Up || this._isInSendState) { return; } // ISSUE: explicit reference operation if (((Point)@position).Y < -80.0 && !this._isInSendState) { this.GoToSendState(); } else if (this.transformButton.TranslateX > -160.0) { if (this._viewModel.RecordDuration > 500) { this.StopRecordingAndSend(); } else { this.IsOpened = false; } } else { if (this.transformButton.TranslateX > -16.0) { this.transformButton.CenterX = 44.0; } this.IsOpened = false; } } else { if (this._isInSendState) { return; } // ISSUE: explicit reference operation if (((Point)@position).Y > -80.0) { if (this._isInInitial) { this._isInInitial = false; // ISSUE: explicit reference operation this.MoveToPosition(((Point)@position).X); } else { CompositeTransform transformButton1 = this.transformButton; double num1 = transformButton1.TranslateX + x; transformButton1.TranslateX = num1; if (this.transformButton.TranslateX > 0.0) { this.transformButton.TranslateX = 0.0; } else if (this.transformButton.TranslateX > -160.0) { this.ShowHideCancelOverlay(false); } else { this.ShowHideCancelOverlay(true); CompositeTransform transformButton2 = this.transformButton; double num2 = transformButton2.TranslateX - x / 2.0; transformButton2.TranslateX = num2; } this.translateRecordDuration.X = this.transformButton.TranslateX; ((UIElement)this.panelSlideToCancel).Opacity = (AudioRecorderUC.GetSlideToCancelOpacity(this.transformButton.TranslateX)); } } else { this.MoveToInitial(); } } }
private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if ((Visibility == Visibility.Collapsed) || (false == this.IsEnabled)) { return; } TouchPointCollection pointCollection = e.GetTouchPoints(this); for (int i = 0; i < pointCollection.Count; i++) { if (idPointer == -1) { if ((pointCollection[i].Action == TouchAction.Down) && IsControlChild(pointCollection[i].TouchDevice.DirectlyOver)) { idPointer = pointCollection[i].TouchDevice.Id; sp = pointCollection[i].Position; } } else if ((pointCollection[i].TouchDevice.Id == idPointer) && (pointCollection[i].Action == TouchAction.Up)) { idPointer = -1; dragTranslation.Y = 0; dragTranslation.X = 0; UpdatePosition(0.0f); } else if ((pointCollection[i].TouchDevice.Id == idPointer) && (pointCollection[i].Action == TouchAction.Move)) { Point dp = pointCollection[i].Position; dragTranslation.X = dp.X - sp.X; dragTranslation.Y = dp.Y - sp.Y; int d = 75; if (this.orientation == Orientation.Vertical) { this.dragTranslation.Y = 0; if (dragTranslation.X > d) { dragTranslation.X = d; } if (dragTranslation.X < -d) { dragTranslation.X = -d; } UpdatePosition((float)dragTranslation.X / d); } else { this.dragTranslation.X = 0; if (dragTranslation.Y > d) { dragTranslation.Y = d; } if (dragTranslation.Y < -d) { dragTranslation.Y = -d; } UpdatePosition((float)dragTranslation.Y / d); } } } }
//터치 이벤트를 모두 처리한다. void Touch_FrameReported(object sender, TouchFrameEventArgs e) { //메인페이지가 아닌곳에서 발생되면 무시 if (this.NavigationService.CurrentSource.OriginalString != Constant.PAGE_MAIN || (layerGettingStart.Visibility == System.Windows.Visibility.Visible && LayoutRoot.Children.Contains(layerGettingStart))) { return; } //이벤트 시작 TouchPoint pTouchInfo = e.GetPrimaryTouchPoint(LayoutRoot); //버튼이 눌린 경우 이벤트 무시 if (IsButtonsArea(pTouchInfo.Position)) { return; } //키보드 밖을 터치하거나 움직이면 키보드 숨김 if (pTouchInfo.Action == TouchAction.Down || pTouchInfo.Action == TouchAction.Move) { if (UIUtils.IsVisible(keybdLayer) && !isAnimating) { isAnimating = true; Storyboard sb = new Storyboard(); sb.Children.Add(GetKeyboardAnimation(false)); sb.Completed += new EventHandler((object obj, EventArgs ev) => { UIUtils.SetVisibility(keybdLayer, false); isAnimating = false; }); sb.Begin(); } } if (pTouchInfo.Action == TouchAction.Down) { //화면을 터치하면 앱바 숨김 if (ApplicationBar.IsVisible) { ApplicationBar.IsVisible = false; } } else if (pTouchInfo.Action == TouchAction.Move) { //움직임 있으면 기본 버튼 숨김 숨김 if (screenType == ScreenTypes.PowerPointSlideShow2007 || screenType == ScreenTypes.PowerPointSlideShow2010 || screenType == ScreenTypes.PowerPointSlideShow2013) { UIUtils.SetVisibility(layerLeftSlideshow, false); UIUtils.SetVisibility(layerRightSlideshow, false); } else { UIUtils.SetVisibility(btnWindows, false); UIUtils.SetVisibility(btnKeyboard, false); UIUtils.SetVisibility(btnMenu, false); } } else if (pTouchInfo.Action == TouchAction.Up) { if (!ApplicationBar.IsVisible) { //앱바가 숨김상태이고 연결된 상태에서 터치가 않되고 있다면 기본 버튼 표시 if (ConnectionManager.Instance.IsConnected) { if (screenType == ScreenTypes.PowerPointSlideShow2007 || screenType == ScreenTypes.PowerPointSlideShow2010 || screenType == ScreenTypes.PowerPointSlideShow2013) { UIUtils.SetVisibility(layerLeftSlideshow, true); UIUtils.SetVisibility(layerRightSlideshow, true); } else { //UIUtils.SetVisibility(btnScreen, true); UIUtils.SetVisibility(btnWindows, true); UIUtils.SetVisibility(btnKeyboard, true); } } else { //연결이 끊긴 상태이면 윈도우, 키보드 버튼 숨김 //UIUtils.SetVisibility(btnScreen, false); UIUtils.SetVisibility(btnWindows, false); UIUtils.SetVisibility(btnKeyboard, false); } //스크린 타입이 없으면 항시 보임 if (screenType != ScreenTypes.PowerPointSlideShow2007 && screenType != ScreenTypes.PowerPointSlideShow2010 && screenType != ScreenTypes.PowerPointSlideShow2013) { UIUtils.SetVisibility(btnMenu, true); } } } if (ConnectionManager.Instance.IsConnected) { //버튼을 제외한 영역 부터 터치 좌표 구함. TouchPointCollection tpCols = e.GetTouchPoints(this.LayoutRoot); for (int i = 0; i < 5; i++) { if (tpCols.Count > i) { //ID는 1부터로 서버에서 정의함 touchInfos[i].Id = tpCols[i].TouchDevice.Id + 1; touchInfos[i].X = (int)tpCols[i].Position.X; touchInfos[i].Y = (int)tpCols[i].Position.Y; switch (tpCols[i].Action) { case TouchAction.Down: touchInfos[i].Action = TouchActionTypes.Begin; if (PointingControlManager.Instance.DeviceType == DeviceTypes.Mouse) { //메인 핑거 저장 if (primaryPointer == null && tpCols.Count == 1) { primaryPointer = touchInfos[i].Clone(); } //클릭 버튼 ID 저장 if (primaryPointer != null && tpCols.Count == 2) { if (primaryPointer.Id != touchInfos[i].Id) { secondaryPointer = touchInfos[i].Clone(); } } } break; case TouchAction.Move: touchInfos[i].Action = TouchActionTypes.Move; if (PointingControlManager.Instance.DeviceType == DeviceTypes.Mouse) { if (primaryPointer != null && primaryPointer.Id == touchInfos[i].Id) { //오차 범위 수평, 수직3 이외로 움직일때만 이동 문구 표시 if ((Math.Abs(primaryPointer.X - touchInfos[i].X) > 3 || Math.Abs(primaryPointer.Y - touchInfos[i].Y) > 3)) { UIUtils.SetVisibility(txtInfomation, true, I18n.GetString("MainPageMouseMovePointer")); } //메인 핑거 위치 이동 primaryPointer = touchInfos[i].Clone(); } else if (secondaryPointer != null && secondaryPointer.Id == touchInfos[i].Id) { //클릭 버튼 위치 이동 secondaryPointer = touchInfos[i].Clone(); } } break; case TouchAction.Up: touchInfos[i].Action = TouchActionTypes.End; if (PointingControlManager.Instance.DeviceType == DeviceTypes.Mouse) { if (secondaryPointer != null && secondaryPointer.Id == touchInfos[i].Id) { //클릭 버튼 초기화 UIUtils.SetVisibility(txtInfomation, false); secondaryPointer = null; } else if (primaryPointer != null && primaryPointer.Id == touchInfos[i].Id) { //메인핑거 초기화 및 클릭버튼 초기화 UIUtils.SetVisibility(txtInfomation, false); primaryPointer = null; secondaryPointer = null; } } break; } } else { touchInfos[i].Id = 0; touchInfos[i].X = 0; touchInfos[i].Y = 0; touchInfos[i].Action = TouchActionTypes.None; } } if (PointingControlManager.Instance.DeviceType != DeviceTypes.Mouse) { //마우스 이외의 모드이면 숨김 UIUtils.SetVisibility(txtInfomation, false); } //마우스 모드 버튼 클릭 화면 표시 if (secondaryPointer != null && (secondaryPointer.Action == TouchActionTypes.Begin || secondaryPointer.Action == TouchActionTypes.End)) { if (secondaryPointer.X < primaryPointer.X && secondaryPointer.Y != primaryPointer.Y) { if (secondaryPointer.Y < primaryPointer.Y && SettingManager.Instance.SettingInfo.UseExtendButton) { //브라우저 뒤로 UIUtils.SetVisibility(txtInfomation, true, I18n.GetString("MainPageMouseBackClick")); } else { //마우스 우측 버튼 UIUtils.SetVisibility(txtInfomation, true, I18n.GetString("MainPageMouseLeftClick")); } } else if (secondaryPointer.X > primaryPointer.X && secondaryPointer.Y != primaryPointer.Y) { if (secondaryPointer.Y < primaryPointer.Y && SettingManager.Instance.SettingInfo.UseExtendButton) { //브라우저 앞으로 UIUtils.SetVisibility(txtInfomation, true, I18n.GetString("MainPageMouseForwardClick")); } else { //마우스 오른족 버튼 UIUtils.SetVisibility(txtInfomation, true, I18n.GetString("MainPageMouseRightClick")); } } } //마우스 / 터치 스크린 좌표 이동 PointingControlManager.Instance.MoveTouch(touchInfos); } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (Visibility == System.Windows.Visibility.Collapsed) { return; } TouchPointCollection points = e.GetTouchPoints(this); System.Windows.Point center = new System.Windows.Point(joystick.ActualWidth / 2, joystick.ActualHeight / 2); for (int i = 0; i < points.Count; i++) { TouchPoint point = points[i]; // If Pointer enter on the main stick if (IsEnabled && point.Action == TouchAction.Down && XamlHelper.IsControlChildOf(point.TouchDevice.DirectlyOver, mainStickContainer) && idPointer == -1) { #region Pointer enter on MainStick // Lock stick type calibrationStickMoving = false; mainStickMoving = true; // Store TouchDeviceId idPointer = point.TouchDevice.Id; // Updating sticks data Refresh(point.Position, center); // Update mainStick position MoveJoystick(newX, newY); // Prepare event args JoystickMoveEventArgs args = new JoystickMoveEventArgs { Angle = (int)angle, Speed = (float)normalizedDistance }; // Fire event if (Moving != null) { Moving(this, args); } #endregion } // Else if pointer enter on calibrationstick else if (IsEnabled && point.Action == TouchAction.Down && (XamlHelper.IsControlChildOf(point.TouchDevice.DirectlyOver, CalibrationPath) || XamlHelper.IsControlChildOf(point.TouchDevice.DirectlyOver, CalibrationTxt)) && idPointer == -1) { // Lock stick type calibrationStickMoving = true; mainStickMoving = false; // Store TouchDeviceId idPointer = point.TouchDevice.Id; // Updating sticks data Refresh(point.Position, center); } // Else if the pointer moving else if (point.TouchDevice.Id == idPointer && point.Action == TouchAction.Move) { // Updating sticks data Refresh(point.Position, center); // If calibrating if (calibrationStickMoving) { // Update angle rotationTransform.Rotation = basicAngle; // Fire event if (Calibrating != null) { JoystickCalibrationEventArgs args = new JoystickCalibrationEventArgs { Angle = (int)basicAngle }; Calibrating(this, args); } } else if (mainStickMoving) { // Update main stick position MoveJoystick(newX, newY); // Fire event if (Moving != null) { JoystickMoveEventArgs args = new JoystickMoveEventArgs { Angle = (int)angle, Speed = (float)normalizedDistance }; Moving(this, args); } } } // On pointer released else if (point.TouchDevice.Id == idPointer && point.Action == TouchAction.Up) { // release the pointer Id idPointer = -1; if (mainStickMoving) { // Fire event if (Released != null) { JoystickMoveEventArgs args = new JoystickMoveEventArgs { Angle = (int)angle, Speed = (float)normalizedDistance }; Released(this, args); } } if (calibrationStickMoving) { // Fire event if (CalibrationReleased != null) { JoystickCalibrationEventArgs args = new JoystickCalibrationEventArgs { Angle = (int)basicAngle }; CalibrationReleased(this, args); } } // Reinit data newX = 0; newY = 0; angle = 0; normalizedDistance = 0; // Update main stick position MoveJoystick(newX, newY); // Reinit calibration rotation rotationTransform.Rotation = 135; // Reinit flags calibrationStickMoving = false; mainStickMoving = false; } } }