Rev 2432 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2432 | Rev 2434 | ||
---|---|---|---|
Line 739... | Line 739... | ||
739 | private void Window_Closed(object sender, EventArgs e) |
739 | private void Window_Closed(object sender, EventArgs e) |
740 | { |
740 | { |
741 | Application.Current.Shutdown(); |
741 | Application.Current.Shutdown(); |
742 | } |
742 | } |
Line 743... | Line -... | ||
743 | - | ||
744 | #region doubletap/click //http://stackoverflow.com/questions/9001023/capturing-double-tap-touch-on-multi-touch-screen |
- | |
745 | private Point? _lastTapLocation; |
- | |
746 | private readonly Stopwatch _doubleTapStopwatch = new Stopwatch(); |
- | |
747 | - | ||
748 | private bool IsDoubleTap(TouchEventArgs e) |
- | |
749 | { |
- | |
750 | Point currentTapPosition = e.GetTouchPoint(this).Position; |
- | |
751 | bool tapsAreCloseInDistance = false; |
- | |
752 | if (_lastTapLocation != null) |
- | |
753 | { |
- | |
754 | tapsAreCloseInDistance = GetDistanceBetweenPoints(currentTapPosition, (Point)_lastTapLocation) < 70; |
- | |
755 | } |
- | |
756 | _lastTapLocation = currentTapPosition; |
- | |
757 | - | ||
758 | TimeSpan elapsed = _doubleTapStopwatch.Elapsed; |
- | |
759 | _doubleTapStopwatch.Restart(); |
- | |
760 | bool tapsAreCloseInTime = (elapsed != TimeSpan.Zero && elapsed < TimeSpan.FromSeconds(0.4)); |
- | |
761 | - | ||
762 | if (tapsAreCloseInTime && tapsAreCloseInDistance) |
- | |
763 | { |
- | |
764 | _lastTapLocation = null; |
- | |
765 | } |
- | |
766 | return tapsAreCloseInDistance && tapsAreCloseInTime; |
- | |
767 | } |
- | |
768 | - | ||
769 | private void OnPreviewTouchDown(object sender, TouchEventArgs e) |
- | |
770 | { |
- | |
771 | if (IsDoubleTap(e)) |
- | |
772 | { |
- | |
773 | MainMap.CanDragMap = false; |
- | |
774 | MessageBox.Show("Blubb!"); |
- | |
775 | } |
- | |
776 | } |
- | |
777 | public static double GetDistanceBetweenPoints(Point p, Point q) |
- | |
778 | { |
- | |
779 | double a = p.X - q.X; |
- | |
780 | double b = p.Y - q.Y; |
- | |
781 | double distance = Math.Sqrt(a * a + b * b); |
- | |
782 | return distance; |
- | |
783 | } |
- | |
784 | private bool IsDoubleClick(MouseButtonEventArgs e) |
- | |
785 | { |
- | |
786 | Point currentTapPosition = e.GetPosition(this); |
- | |
787 | bool tapsAreCloseInDistance = false; |
- | |
788 | if (_lastTapLocation != null) |
- | |
789 | { |
- | |
790 | tapsAreCloseInDistance = GetDistanceBetweenPoints(currentTapPosition, (Point)_lastTapLocation) < 70; |
- | |
791 | } |
- | |
792 | _lastTapLocation = currentTapPosition; |
- | |
793 | - | ||
794 | TimeSpan elapsed = _doubleTapStopwatch.Elapsed; |
- | |
795 | _doubleTapStopwatch.Restart(); |
- | |
796 | bool tapsAreCloseInTime = (elapsed != TimeSpan.Zero && elapsed < TimeSpan.FromSeconds(0.4)); |
- | |
797 | - | ||
798 | if (tapsAreCloseInTime && tapsAreCloseInDistance) |
- | |
799 | { |
- | |
800 | _lastTapLocation = null; |
- | |
801 | } |
- | |
802 | return tapsAreCloseInDistance && tapsAreCloseInTime; |
- | |
803 | } |
743 | |
804 | Point pWPAdd; |
744 | Point pWPAdd; |
805 | private void GridGMapControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
745 | private void GridGMapControl_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
806 | { |
746 | { |
807 | if (IsDoubleClick(e)) |
747 | if(e.ClickCount == 2) |
808 | { |
748 | { |
809 | pWPAdd = new Point(e.GetPosition(this).X, e.GetPosition(this).Y); |
749 | pWPAdd = new Point(e.GetPosition(this).X, e.GetPosition(this).Y); |
810 | canvasAddPoint.Margin = new Thickness(e.GetPosition(this).X, e.GetPosition(this).Y, canvasAddPoint.Margin.Left, canvasAddPoint.Margin.Bottom); |
750 | canvasAddPoint.Margin = new Thickness(e.GetPosition(this).X, e.GetPosition(this).Y, canvasAddPoint.Margin.Left, canvasAddPoint.Margin.Bottom); |
811 | canvasAddPoint.Visibility = Visibility.Visible; |
751 | canvasAddPoint.Visibility = Visibility.Visible; |
Line 851... | Line 791... | ||
851 | PointLatLng p = MainMap.FromLocalToLatLng((int)pWPAdd.X, (int)pWPAdd.Y); |
791 | PointLatLng p = MainMap.FromLocalToLatLng((int)pWPAdd.X, (int)pWPAdd.Y); |
852 | _addWP(p,3); |
792 | _addWP(p,3); |
853 | } |
793 | } |
854 | } |
794 | } |
Line 855... | Line -... | ||
855 | - | ||
856 | #endregion doubletap/click |
795 | |
Line 857... | Line 796... | ||
857 | #endregion events |
796 | #endregion events |
Line 858... | Line 797... | ||
858 | 797 |