/// <summary> /// Bir touch algılanırsa /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { //Point _FirstTouch = new Point(0, 0); //Point _SecondTouch = new Point(0, 0); if ((e.GetPrimaryTouchPoint(this) != null)) { IlkDokunus = e.GetPrimaryTouchPoint(this); if (IlkDokunus.Action == TouchAction.Down) { //_FirstTouch = new Point(0, 0); //_SecondTouch = new Point(0, 0); } else if (IlkDokunus.Action == TouchAction.Move) { if (e.GetTouchPoints(this).Count > 1) { IkinciDokunus = e.GetTouchPoints(this)[1]; } } if (IkinciDokunus != null) { var matrix = ((MatrixTransform)this.RenderTransform).Matrix; TouchCenter = matrix.Transform( AnaliticGeometryHelper.CenterPoint( IlkDokunus.Position, IkinciDokunus.Position ) ); } } }
// الداله دى لو الجهاز بتاعك بيدعم التاتش اسكرين /* * Action=====>Gets the last action that occurred at this location. * Bounds=====>Gets the bounds of the area that the finger has in contact with the screen. * Position====>Gets the location of the touch point. * Size========>Gets the size of the Bounds property. * TouchDevice=>Gets the touch device that generated this TouchPoint. */ private void Touch_FrameReportedRed(object sender, TouchFrameEventArgs e) { if (this.canvas1 != null) { foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.canvas1)) { if (_touchPoint.Action == TouchAction.Down) { _touchPoint.TouchDevice.Capture(this.canvas1); } else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(this.canvas1) != null) { if (_touchPoint.TouchDevice.Id == e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id) { Canvas.SetLeft(rectangleRed, _touchPoint.Position.X); } else if (_touchPoint.TouchDevice.Id != e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id) { Canvas.SetLeft(rectangleBlue, _touchPoint.Position.X); } } else if (_touchPoint.Action == TouchAction.Up) { this.canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice); } } } }
private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (_manipulationStartedArgs == null) { Touch.FrameReported -= Touch_FrameReported; return; } var point = e.GetPrimaryTouchPoint(null); if (point.Action == TouchAction.Up) { Touch.FrameReported -= Touch_FrameReported; return; } var manipulationPoint = e.GetPrimaryTouchPoint(_manipulationStartedArgs.ManipulationContainer); var length = Math.Pow(manipulationPoint.Position.X - _manipulationStartedArgs.ManipulationOrigin.X, 2.0) + Math.Pow(manipulationPoint.Position.Y - _manipulationStartedArgs.ManipulationOrigin.Y, 2.0); if (length > 30.0 * 30.0) { Touch.FrameReported -= Touch_FrameReported; return; } if (_startTime.HasValue && _startTime.Value.AddSeconds(0.5) <= DateTime.Now) { Touch.FrameReported -= Touch_FrameReported; VirtPanel.DisableVerticalScrolling(); _loadedStoryboard = EmojiControl.GetScaleStoryboard(_fromItem, 0.85, 1.0); Preview.Visibility = Visibility.Visible; var stickerImage = _fromItem as Image; if (stickerImage != null) { PreviewImage.Source = stickerImage.Source; var stickerItem = stickerImage.DataContext as TLStickerItem; if (stickerItem != null) { Image.DataContext = stickerItem; } } var grid = Preview; grid.Children.Remove(PreviewGrid); Execute.BeginOnUIThread(() => { PreviewGrid.RenderTransform = new CompositeTransform(); PreviewGrid.Opacity = 0.0; grid.Children.Add(PreviewGrid); }); } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (this.canvas1 != null) { // <snippet120> foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.canvas1)) { if (_touchPoint.Action == TouchAction.Down) { // Clear the canvas and capture the touch to it. this.canvas1.Children.Clear(); _touchPoint.TouchDevice.Capture(this.canvas1); } else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(this.canvas1) != null) { // This is the first (primary) touch point. Just record its position. if (_touchPoint.TouchDevice.Id == e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id) { pt1.X = _touchPoint.Position.X; pt1.Y = _touchPoint.Position.Y; } // This is not the first touch point. Draw a line from the first point to this one. else if (_touchPoint.TouchDevice.Id != e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id) { pt2.X = _touchPoint.Position.X; pt2.Y = _touchPoint.Position.Y; Line _line = new Line(); _line.Stroke = new RadialGradientBrush(Colors.White, Colors.Black); _line.X1 = pt1.X; _line.X2 = pt2.X; _line.Y1 = pt1.Y; _line.Y2 = pt2.Y; _line.StrokeThickness = 2; this.canvas1.Children.Add(_line); } } else if (_touchPoint.Action == TouchAction.Up) { // If this touch is captured to the canvas, release it. if (_touchPoint.TouchDevice.Captured == this.canvas1) { this.canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice); } } } // </snippet120> } }
private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPoint mainTouch = e.GetPrimaryTouchPoint(this); if (mainTouch.Action == TouchAction.Down) { first = mainTouch; } else if (mainTouch.Action == TouchAction.Up) { if (mainTouch.Position.X - first.Position.X > 25) { string clicktype = ""; string imgqual = ""; for (int i = 0; i < this.RadioGrid.Children.Count; i++) { RadioButton rb = (RadioButton)this.RadioGrid.Children[i]; if (rb.IsChecked == true && rb.GroupName == "ImgQual") { imgqual = (i + 1).ToString(); } else if (rb.IsChecked == true && rb.GroupName == "ClickType") { clicktype = (i - 3).ToString(); } } NavigationService.Navigate(new Uri("/MainPage.xaml?imgqual=" + imgqual + "&" + "clicktype=" + clicktype, UriKind.Relative)); Touch.FrameReported -= Touch_FrameReported; } //myPivot.SelectedIndex--; } }
void OnTouchFrameReported(object sender, TouchFrameEventArgs args) { TouchPoint touchPoint = args.GetPrimaryTouchPoint(this); if (touchPoint != null && touchPoint.Action == TouchAction.Down) { args.SuspendMousePromotionUntilTouchUp(); } if (touchPoint != null && touchPoint.TouchDevice.DirectlyOver is Rectangle) { Rectangle rectangle = (touchPoint.TouchDevice.DirectlyOver as Rectangle); // This DataContext is an object of type Student object dataContext = rectangle.DataContext; studentDisplay.DataContext = dataContext; if (touchPoint.Action == TouchAction.Down) { studentDisplay.Visibility = Visibility.Visible; } else if (touchPoint.Action == TouchAction.Up) { studentDisplay.Visibility = Visibility.Collapsed; } } }
// support pinch zooming private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { var touchpoints = e.GetTouchPoints(myDiagram.Panel); if (touchpoints.Count > 1) { var tp0 = touchpoints[0].Position; var tp1 = touchpoints[1].Position; var newDist = Math.Sqrt((tp0.X - tp1.X) * (tp0.X - tp1.X) + (tp0.Y - tp1.Y) * (tp0.Y - tp1.Y)); if (Double.IsNaN(startDist)) { startDist = newDist; startScale = myDiagram.Panel.Scale; var primary = e.GetPrimaryTouchPoint(myDiagram.Panel); if (primary != null) { myDiagram.Panel.ZoomPoint = primary.Position; } } else { myDiagram.Panel.Scale = startScale * newDist / startDist; } } else { startDist = Double.NaN; } }
private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPoint mainTouch = e.GetPrimaryTouchPoint(image); if (mainTouch.Action == TouchAction.Down) { first = mainTouch; } else if (mainTouch.Action == TouchAction.Up) { if (mainTouch.Position.X - first.Position.X < -350) { Touch.FrameReported -= Touch_FrameReported; NavigationService.Navigate(new Uri("/Options.xaml?", UriKind.Relative)); client.Send("7"); } else if (mainTouch.Position.Y - first.Position.Y < -150) { sendType.Visibility = Visibility.Visible; SendButton.Visibility = Visibility.Visible; sendType.Focus(); } //myPivot.SelectedIndex--; } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (draggingNow == true) { TouchPoint tp = e.GetPrimaryTouchPoint(map1); if (tp.Action == TouchAction.Move) { if (draggingArea == true) { if (twoMarker != null) { twoMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(tp.Position); areaRadius = (int)twoMarker.GeoCoordinate.GetDistanceTo(oneMarker.GeoCoordinate); DoCreateTheAreaCircle(); } } else if (oneMarker != null) { oneMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(tp.Position); DoCreateTheAreaCircle(); if (twoMarker != null && PolyCircle != null && PolyCircle.Path != null) { twoMarker.GeoCoordinate = PolyCircle.Path[0]; } } } else if (tp.Action == TouchAction.Up) { draggingArea = draggingNow = false; map1.IsEnabled = true; } } }
void OnFrameReported(object sender, TouchFrameEventArgs e) { TouchPoint touchPoint; try { touchPoint = e.GetPrimaryTouchPoint(this); } catch (Exception) { return; } if (touchPoint == null || touchPoint.Action != TouchAction.Move) { return; } System.Windows.Point position = touchPoint.Position; if (IsInPullToRefresh) { double delta = position.Y - _lastPosition.Y; PullToRefreshStatus += delta / 150.0; } _lastPosition = position; }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (e.GetPrimaryTouchPoint(this.FirstPivot_PV).Action == TouchAction.Up) { //this.pivot.IsHitTestVisible = true; //this.pivot.IsLocked = false; } }
void TouchFrameReported(object sender, TouchFrameEventArgs e) { if (!AssociatedObject.DesiredSize.Equals(new Size(0, 0))) //Code Fix by Devix: enables Multi-Page support { _processor.Process(e.GetTouchPoints(AssociatedObject)); #if DEBUG HandleDebugInfoAndFingers( e.GetTouchPoints(RootVisual), e.GetPrimaryTouchPoint(RootVisual)); #endif } }
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; } } } }
private void OnFrameReportedEventHandler(object sender, TouchFrameEventArgs e) { if (_isManipulating == false) { return; } try { _lastTouchPointPosition = e.GetPrimaryTouchPoint(_target.RootControl).Position; } catch (Exception) { Debug.WriteLine("Touch reported error on GestureObserver:OnFrameReportedEventHandler"); } }
private void onTouchFrameReported(object sender, TouchFrameEventArgs e) { TouchPoint primaryTouchPoint = e.GetPrimaryTouchPoint(null); if (primaryTouchPoint != null && primaryTouchPoint.Action == TouchAction.Down) { if (primaryTouchPoint.TouchDevice.DirectlyOver == txtblk) { txtblk.Foreground = new SolidColorBrush(Color.FromArgb(255, (byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256))); } else if (primaryTouchPoint.TouchDevice.DirectlyOver != KaiSon) { txtblk.Foreground = originalBrush; } } }
/// <summary> /// Touch handling /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { var parent = VisualTreeHelper.GetParent(this); while (parent != null) { if (parent is PhoneApplicationPage) { var page = parent as PhoneApplicationPage; // Get this' position on screen var transform = this.TransformToVisual(page); var absolutePosition = transform.Transform(new System.Windows.Point(0, 0)); var ourRect = new Xamarin.Forms.Rectangle(absolutePosition.X, absolutePosition.Y, this.Width, this.Height); // Get main touch point var mainTouchPoint = e.GetPrimaryTouchPoint(page); // Make sure our control is actually in the touch zone if (!ourRect.Contains(mainTouchPoint.Position.X, mainTouchPoint.Position.Y)) { return; } var touches = e.GetTouchPoints(this).Select(t => new NGraphics.Point(t.Position.X, t.Position.Y)); if (mainTouchPoint.Action == TouchAction.Move) { Element.TouchesMoved(touches); } else if (mainTouchPoint.Action == TouchAction.Down) { Element.TouchesBegan(touches); } else if (mainTouchPoint.Action == TouchAction.Up) { Element.TouchesEnded(touches); } break; } parent = VisualTreeHelper.GetParent(parent); } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (draggingNow == true) { TouchPoint tp = e.GetPrimaryTouchPoint(map1); if (tp.Action == TouchAction.Move && (selectedMarker != null)) { selectedMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(tp.Position); Start_ReverceGeoCoding(selectedMarker); } else if (tp.Action == TouchAction.Up) { selectedMarker = null; draggingNow = false; map1.IsEnabled = true; } } }
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; } } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (draggingNow == true) { TouchPoint tp = e.GetPrimaryTouchPoint(map2); if (tp.Action == TouchAction.Move) { if (oneMarker != null) { oneMarker.GeoCoordinate = map2.ConvertViewportPointToGeoCoordinate(tp.Position); } } else if (tp.Action == TouchAction.Up) { draggingNow = false; map2.IsEnabled = true; } } }
private void Touch_FrameReported(object sender, TouchFrameEventArgs e) { try { TouchPoint tPoint = e.GetPrimaryTouchPoint(this.map1); if (tPoint.Action == TouchAction.Down) { var marker = this.MakeDotMarker( this.map1.ConvertViewportPointToGeoCoordinate(tPoint.Position), false); // this.selectedMarker.GeoCoordinate = this.map1.ConvertViewportPointToGeoCoordinate(tPoint.Position); this.Start_ReverceGeoCoding(marker); this.StartGeoQ(); } } catch (ArgumentException) { } }
static void OnTouchFrameReported(object sender, TouchFrameEventArgs args) { TouchPoint touchPoint = args.GetPrimaryTouchPoint(null); if (touchPoint != null && touchPoint.Action == TouchAction.Down) { contactPoint = touchPoint.Position; contactTime = args.Timestamp; } else if (touchPoint != null && touchPoint.Action == TouchAction.Up) { // Check if finger is directly over StudentCard or child DependencyObject element = touchPoint.TouchDevice.DirectlyOver; while (element != null && !(element is StudentCard)) { element = VisualTreeHelper.GetParent(element); } if (element == null) { return; } // Get lift point and calculate difference Point liftPoint = touchPoint.Position; double distance = Math.Sqrt(Math.Pow(contactPoint.X - liftPoint.X, 2) + Math.Pow(contactPoint.Y - liftPoint.Y, 2)); // Qualify as a Tap if distance < 12 pixels within 1/4 second if (distance < 12 && args.Timestamp - contactTime < 250) { // Enumerate StudentCard objects and set IsOpen property foreach (StudentCard studentCard in studentCards) { studentCard.IsOpen = (element == studentCard && !studentCard.IsOpen); } } } }
/// <summary> /// When the target ScrollViewer is dragged, animates the PullDistance/PullFraction properties /// and updates the PullingDown/ReadyToRelease visual states as necessary. /// </summary> private void TouchFrameReported(object sender, TouchFrameEventArgs e) { TouchPoint primaryTouchPoint = e.GetPrimaryTouchPoint(this); switch (primaryTouchPoint.Action) { case TouchAction.Up: this.StopMeasuring(); break; case TouchAction.Down: this.initialPoint = primaryTouchPoint.Position; if (this.isCompressed) { this.StartMeasuring(); } break; case TouchAction.Move: if (this.isMeasuring) { if (Math.Abs(this.currentPosition.Y - primaryTouchPoint.Position.Y) > 0.0001) { this.currentPosition = primaryTouchPoint.Position; this.UpdateControl(); } } else { this.initialPoint = primaryTouchPoint.Position; } break; } }
/// <summary> /// Touch handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected static void Touch_FrameReported(object sender, TouchFrameEventArgs e) { // Get the primary touch point. We do not track multitouch at the moment. var primaryTouchPoint = e.GetPrimaryTouchPoint(System.Windows.Application.Current.RootVisual); var uiElements = VisualTreeHelper.FindElementsInHostCoordinates( primaryTouchPoint.Position, System.Windows.Application.Current.RootVisual); // System.Console.WriteLine("Starting Touch_FrameReported"); foreach (var uiElement in uiElements) { if (uiElement is System.Windows.Controls.Button || uiElement is System.Windows.Controls.TextBox || uiElement is System.Windows.Controls.ListBox || uiElement is System.Windows.Controls.CheckBox) { //System.Console.WriteLine("Element " + uiElement.GetType() + " focusable, breaking."); break; } // Are we interested? var renderer = uiElement as NControlViewRendererBase; if (renderer == null) { continue; } // Get NControlView element var element = renderer.Element; // System.Console.WriteLine("Handling " + primaryTouchPoint.Action + " for " + element.GetType().Name + " (renderer: " + renderer.GetType().Name + ")"); // Get this' position on screen var transform = System.Windows.Application.Current.RootVisual.TransformToVisual(renderer.Control); // Transform touches var touchPoints = e.GetTouchPoints(System.Windows.Application.Current.RootVisual); var touches = touchPoints .Select(t => transform.Transform(new System.Windows.Point(t.Position.X, t.Position.Y))) .Select(t => new NGraphics.Point(t.X, t.Y)).ToList(); var result = false; if (primaryTouchPoint.Action == TouchAction.Move) { result = element.TouchesMoved(touches); } else if (primaryTouchPoint.Action == TouchAction.Down) { result = element.TouchesBegan(touches); } else if (primaryTouchPoint.Action == TouchAction.Up) { result = element.TouchesEnded(touches); } if (result) { break; } } }
void Touch_FrameReported(object sender, TouchFrameEventArgs e) { if (!(ListBoxComponent.ActualHeight > 0)) { return; } foreach (TouchPoint _touchPoint in e.GetTouchPoints(ListBoxComponent)) { if (_touchPoint.Action == TouchAction.Down) { if (scrollViewer == null) { if (ListBoxComponent != null) { scrollViewer = FindScrollViewer(this); } if (scrollViewer == null) { return; } } } else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(ListBoxComponent) != null) { if (!moveStarted && scrollViewer != null) { var offset = scrollViewer.VerticalOffset; if (offset < 0.0001) { if (goBackAnimation != null) { goBackAnimation.SkipToFill(); } moveStarted = true; startY = _touchPoint.Position.Y; } } if (moveStarted) { double visibleHeight = (_touchPoint.Position.Y - startY) * touchSensebility; if (HeaderComponnet != null) { double newHeight = HeaderComponnet.Height + visibleHeight; if (newHeight < 0) { newHeight = 0; } bool inFullHeight = false; if (newHeight >= HeaderComponnet.ActualHeight) { newHeight = HeaderComponnet.ActualHeight; inFullHeight = true; if (!isActivated) { isActivated = true; } } if (!inFullHeight && isActivated) { isActivated = false; } HeaderComponnet.Height = newHeight; } startY = _touchPoint.Position.Y; } } else if (_touchPoint.Action == TouchAction.Up) { moveStarted = false; startY = 0.0f; if (isActivated) { if (OnActivatedDrop != null) { OnActivatedDrop(this, null); } isActivated = false; } if (HeaderComponnet.Height > 0) { goBackAnimation = CreateGoBackAnimation(); goBackAnimation.Begin(); } } } }
//터치 이벤트를 모두 처리한다. 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); } }
/// <summary> /// Touch handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected static void Touch_FrameReported(object sender, TouchFrameEventArgs e) { // Get the primary touch point. We do not track multitouch at the moment. var primaryTouchPoint = e.GetPrimaryTouchPoint(System.Windows.Application.Current.RootVisual); var paf = System.Windows.Application.Current.RootVisual as PhoneApplicationFrame; var allUiElements = VisualTreeHelper.FindElementsInHostCoordinates(new Rect(0, 0, paf.ActualWidth, paf.ActualHeight), paf); UIElement parent = paf; // Look for other popups using the popupprovider interface var popupInfoProvider = DependencyService.Get <IPopupInformationProvider>(); if (popupInfoProvider != null) { var popupParent = popupInfoProvider.GetPopupParent(); if (popupParent != null) { parent = popupParent; } } if (parent == paf) { var popups = VisualTreeHelper.GetOpenPopups(); // if popups, then we should use the message box as the parent when finding elements to click if (popups.Count() > 0) { var topMostPopup = popups.FirstOrDefault(p => p.IsOpen && p.ActualHeight != 0 && p.ActualWidth != 0); if (topMostPopup != null) { foreach (var element in allUiElements) { if (element == topMostPopup.Child) { parent = element; break; } } } } } var uiElements = VisualTreeHelper.FindElementsInHostCoordinates( primaryTouchPoint.Position, parent); foreach (var uiElement in uiElements) { if (uiElement is System.Windows.Controls.Button || uiElement is System.Windows.Controls.TextBox || uiElement is System.Windows.Controls.ListBox || uiElement is System.Windows.Controls.CheckBox) { //System.Console.WriteLine("Element " + uiElement.GetType() + " focusable, breaking."); break; } // Are we interested? var renderer = uiElement as NControlViewRendererBase; if (renderer == null) { continue; } // Get NControlView element var element = renderer.Element; // System.Console.WriteLine("Handling " + primaryTouchPoint.Action + " for " + element.GetType().Name + " (renderer: " + renderer.GetType().Name + ")"); // Get this' position on screen var transform = System.Windows.Application.Current.RootVisual.TransformToVisual(renderer.Control); // Transform touches var touchPoints = e.GetTouchPoints(System.Windows.Application.Current.RootVisual); var touches = touchPoints .Select(t => transform.Transform(new System.Windows.Point(t.Position.X, t.Position.Y))) .Select(t => new NGraphics.Point(t.X, t.Y)).ToList(); var result = false; if (primaryTouchPoint.Action == TouchAction.Move) { result = element.TouchesMoved(touches); } else if (primaryTouchPoint.Action == TouchAction.Down) { result = element.TouchesBegan(touches); } else if (primaryTouchPoint.Action == TouchAction.Up) { result = element.TouchesEnded(touches); } if (result) { break; } } }