private void Rectangle_Tap_1(object sender, GestureEventArgs e)
    {
        System.Windows.Point point = e.GetPosition(Player);
        double Y = point.Y;
        double X = point.X;

        altitude += 100;
        if (X < 80)
        {
            counter           = 400;
            playerMoveTimeout = 40;
            playerState       = _RIGHT;
        }
        else if (X > 120)
        {
            counter           = 400;
            playerMoveTimeout = 40;
            playerState       = _LEFT;
        }
        else
        {
            counter           = 400;
            playerMoveTimeout = 40;
            playerState       = _CENTER;
        }
    }
Exemplo n.º 2
0
        public void AddEventItem(object sender, GestureEventArgs e)
        {
            Grid grid = sender as Grid;
            Point point = e.GetPosition(grid);

            string eventTitle = " + New title event";
            double width = (grid.Parent as ScrollViewer).Width - 50;

            DateTime dateTime = _lastItem.ItemDate;
            int hour = (int)Math.Ceiling((point.Y) / Constants.GRID_HOURS_CELL_HEIGHT);
            EventItem eventItem = new EventItem()
               {
                   EventColor = CustomColor.CornflowerBlue,
                   EventStart = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, hour, 0, 0),
                   EventEnd = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, hour + 1, 0, 0),
                   EventTitle = eventTitle,
                   EventLocation = string.Empty
               };

            DailyDetailItem eventDetails = new DailyDetailItem(eventItem);
            eventDetails.Click += EditEvent;

            _lastItem.EventsForDay.Add(eventItem);

            eventDetails.SetValue(Grid.RowProperty, hour);
            eventDetails.SetValue(Grid.RowSpanProperty, 1);
            eventDetails.SetValue(Grid.ColumnProperty, 1);
            grid.Children.Add(eventDetails);
        }
Exemplo n.º 3
0
        void focus_Tapped(object sender, GestureEventArgs e)
        {
            if (_phoneCamera != null)
            {
                if (_phoneCamera.IsFocusAtPointSupported == true)
                {
                    Point tapLocation = e.GetPosition(viewfinderCanvas);

                    focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                    focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                    double focusXPercentage = tapLocation.X / viewfinderCanvas.ActualWidth;
                    double focusYPercentage = tapLocation.Y / viewfinderCanvas.ActualHeight;

                    focusBrackets.Visibility = Visibility.Visible;
                    try
                    {
                        _phoneCamera.FocusAtPoint(focusXPercentage, focusYPercentage);
                    }
                    catch (Exception xe)
                    {
                        MessageBox.Show("Can't recognize BarCode");
                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                    }
                }
            }
        }
        /// <summary>
        /// <see cref="UIElement.Tap"/> event handler.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">The <see cref="GestureEventArgs"/> instance containing the event data.</param>
        private void OnPreviewTap(object sender, GestureEventArgs e)
        {
            Point pointOnPreview = e.GetPosition(this.LivePreview);

            // Don't notify about touches made close to the edges.
            if (pointOnPreview.X < this.TapBoundary || pointOnPreview.X > this.LivePreview.Width - this.TapBoundary ||
                pointOnPreview.Y < this.TapBoundary || pointOnPreview.Y > this.PreviewHeight - this.TapBoundary)
            {
                return;
            }

            Point positionPercentage = new Point(pointOnPreview.X / this.LivePreview.ActualWidth, pointOnPreview.Y / this.LivePreview.ActualHeight);

            // We flip preview's X-axis for the front-facing camera.
            if (this.cameraType == CameraType.FrontFacing)
            {
                positionPercentage.X = 1.0 - positionPercentage.X;
            }

            EventHandler <PreviewTapLocationEventArgs> handler = this.PreviewTap;

            if (handler != null)
            {
                handler.Invoke(this, new PreviewTapLocationEventArgs(positionPercentage));
            }
        }
Exemplo n.º 5
0
        private void MainImage_OnTap(object sender, GestureEventArgs e)
        {
            Point p = new Point();

            p = e.GetPosition(MainImage);
            GetColor(p);
        }
Exemplo n.º 6
0
        private void gesture_DoubleTap(object sender, GestureEventArgs e)
        {
            var point = e.GetPosition(ContentPanel);

            message.Text     += string.Format("\r\ndouble tap at ({0},{1})", point.X, point.Y);
            flickMessage.Text = null;
        }
    private void map1_Tap(object sender, GestureEventArgs e)
    {
        var position      = e.GetPosition(myMap);
        var geoCoordinate = new GeoCoordinate();

        geoCoordinate = myMap.ViewportPointToLocation(position);
        OpenDirectionTo(geoCoordinate);
    }
Exemplo n.º 8
0
 public override void Tap(GestureEventArgs e)
 {
     base.Tap(e);
     Pushpin pushpin = new Pushpin();
     Point2D point = _map.ScreenToMap(e.GetPosition(_map));
     pushpin.Location = point;
     _eLayer.AddChild(pushpin);
     _pushpins.Add(pushpin);
 }
Exemplo n.º 9
0
 public override void Tap(GestureEventArgs e)
 {
     Point2D point = _map.ScreenToMap(e.GetPosition(_map));
     DrawEventArgs args = new DrawEventArgs
     {
         Geometry =new GeoPoint(point.X,point.Y)
     };
     OnDrawComplete(args);
     base.Tap(e);
 }
Exemplo n.º 10
0
        private void MapControl_Tap(object sender, GestureEventArgs e)
        {
            GeoCoordinate coordinate = MapControl.ViewportPointToLocation(e.GetPosition(MapControl));

            if (EventCoordinate == coordinate)
            {
                return;
            }
            LocationsController.Instance.UnSelect();
        }
Exemplo n.º 11
0
        // Provide touch focus in the viewfinder.
        async void focus_Tapped(object sender, GestureEventArgs e)
        {
            if (cam == null)
            {
                return;
            }


            Point uiTapPoint = e.GetPosition(viewfinderCanvas);

            if (PhotoCaptureDevice.IsFocusRegionSupported(cam.SensorLocation))
            {
                Size _focusRegionSize = new Size(100, 100);

                // Get tap coordinates as a foundation point
                Windows.Foundation.Point tapPoint = new Windows.Foundation.Point(uiTapPoint.X, uiTapPoint.Y);

                double xRatio = viewfinderCanvas.ActualHeight / cam.PreviewResolution.Width;
                double yRatio = viewfinderCanvas.ActualWidth / cam.PreviewResolution.Height;

                // adjust to center focus on the tap point
                Windows.Foundation.Point displayOrigin = new Windows.Foundation.Point(
                    tapPoint.Y - _focusRegionSize.Width / 2, (viewfinderCanvas.ActualWidth - tapPoint.X) - _focusRegionSize.Height / 2);

                // adjust for resolution difference between preview image and the canvas
                Windows.Foundation.Point viewFinderOrigin = new Windows.Foundation.Point(displayOrigin.X / xRatio, displayOrigin.Y / yRatio);

                Rect focusrect = new Rect(viewFinderOrigin, _focusRegionSize);

                // clip to preview resolution
                Rect viewPortRect = new Rect(0, 0, cam.PreviewResolution.Width, cam.PreviewResolution.Height);
                focusrect.Intersect(viewPortRect);

                cam.FocusRegion = focusrect;

                // show a focus indicator
                //focusBrackets.SetValue(Shape.StrokeProperty, new SolidColorBrush(Colors.Blue));
                focusBrackets.Visibility = Visibility.Visible;
                focusBrackets.SetValue(Canvas.LeftProperty, uiTapPoint.X - _focusRegionSize.Width / 2);
                focusBrackets.SetValue(Canvas.TopProperty, uiTapPoint.Y - _focusRegionSize.Height / 2);

                CameraFocusStatus status = await cam.FocusAsync();

                if (status == CameraFocusStatus.Locked)
                {
                    //focusBrackets.SetValue(Shape.StrokeProperty, new SolidColorBrush(Colors.Green));
                    cam.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.Focus);
                }
                else
                {
                    cam.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.None);
                }
            }
        }
        private void OverlayViewRenderer_Tap(object sender, GestureEventArgs e)
        {
            var tappableView = Element as TappableView;

            if (tappableView != null)
            {
                var nativePoint = e.GetPosition(this);
                var xfPoint = new Xamarin.Forms.Point(nativePoint.X, nativePoint.Y);
                tappableView.OnTap(xfPoint);
            }
        }
Exemplo n.º 13
0
 public override void OnTap(GestureEventArgs e)
 {
     Point2D point = Map.ScreenToMap(e.GetPosition(Map));
     DrawEventArgs args = new DrawEventArgs
     {
         DrawName = Name,
         Element = new Pushpin { Location = point },
         Geometry = new GeoPoint(point.X, point.Y)
     };
     OnDrawComplete(args);
     base.OnTap(e);
 }
Exemplo n.º 14
0
        void PowerListBoxItem_Tap(object sender, GestureEventArgs e)
        {
            if (_selecterRt == null || !IsSelected)
            {
                return;
            }
            var pt = e.GetPosition(_selecterRt);

            if (pt.X > _selecterRt.ActualWidth || pt.Y > _selecterRt.ActualHeight)
            {
                ListBox.InvokeItemSelectedEvent(this);
            }
        }
Exemplo n.º 15
0
 protected override void OnDoubleTap(GestureEventArgs e)
 {
     if (IsDoubleTap == true)
     {
         base.OnDoubleTap(e);
         //if (this.Action != null)
         //{
         //    this.Action.OnDoubleTap(e);
         //}
         Point2D center = ScreenToMap(e.GetPosition(this));
         ZoomToResolution(GetNextResolution(true), center);
     }
 }
Exemplo n.º 16
0
        // Provide touch focus in the viewfinder.
        void focus_Tapped(object sender, GestureEventArgs e)
        {
            if (cam != null)
            {
                if (cam.IsFocusAtPointSupported == true)
                {
                    try
                    {
                        // Determine location of tap.
                        Point tapLocation = e.GetPosition(viewfinderCanvas);

                        // Position focus brackets with estimated offsets.
                        focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                        focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                        // Determine focus point.
                        double focusXPercentage = tapLocation.X / viewfinderCanvas.Width;
                        double focusYPercentage = tapLocation.Y / viewfinderCanvas.Height;

                        // Show focus brackets and focus at point
                        focusBrackets.Visibility = Visibility.Visible;
                        cam.FocusAtPoint(focusXPercentage, focusYPercentage);

                        // Write a message to the UI.
                        this.Dispatcher.BeginInvoke(delegate()
                        {
                            txtDebug.Text = String.Format("Camera focusing at point: {0:N2} , {1:N2}", focusXPercentage, focusYPercentage);
                        });
                    }
                    catch (Exception focusError)
                    {
                        // Cannot focus when a capture is in progress.
                        this.Dispatcher.BeginInvoke(delegate()
                        {
                            // Write a message to the UI.
                            txtDebug.Text = focusError.Message;
                            // Hide focus brackets.
                            focusBrackets.Visibility = Visibility.Collapsed;
                        });
                    }
                }
                else
                {
                    // Write a message to the UI.
                    this.Dispatcher.BeginInvoke(delegate()
                    {
                        txtDebug.Text = "Camera does not support FocusAtPoint().";
                    });
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Set autofocus area to tap location and refocus.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void videoCanvas_Tap(object sender, GestureEventArgs e)
        {
            System.Windows.Point uiTapPoint = e.GetPosition(VideoCanvas);

            if (PhotoCaptureDevice.IsFocusRegionSupported(_dataContext.Device.SensorLocation) && _focusSemaphore.WaitOne(0))
            {
                // Get tap coordinates as a foundation point
                Windows.Foundation.Point tapPoint = new Windows.Foundation.Point(uiTapPoint.X, uiTapPoint.Y);

                double xRatio = VideoCanvas.ActualHeight / _dataContext.Device.PreviewResolution.Width;
                double yRatio = VideoCanvas.ActualWidth / _dataContext.Device.PreviewResolution.Height;

                // adjust to center focus on the tap point
                Windows.Foundation.Point displayOrigin = new Windows.Foundation.Point(
                    tapPoint.Y - _focusRegionSize.Width / 2,
                    (VideoCanvas.ActualWidth - tapPoint.X) - _focusRegionSize.Height / 2);

                // adjust for resolution difference between preview image and the canvas
                Windows.Foundation.Point viewFinderOrigin = new Windows.Foundation.Point(displayOrigin.X / xRatio, displayOrigin.Y / yRatio);
                Windows.Foundation.Rect  focusrect        = new Windows.Foundation.Rect(viewFinderOrigin, _focusRegionSize);

                // clip to preview resolution
                Windows.Foundation.Rect viewPortRect = new Windows.Foundation.Rect(0, 0, _dataContext.Device.PreviewResolution.Width, _dataContext.Device.PreviewResolution.Height);
                focusrect.Intersect(viewPortRect);

                _dataContext.Device.FocusRegion = focusrect;

                // show a focus indicator
                FocusIndicator.SetValue(Shape.StrokeProperty, _notFocusedBrush);
                FocusIndicator.SetValue(Canvas.LeftProperty, uiTapPoint.X - _focusRegionSize.Width / 2);
                FocusIndicator.SetValue(Canvas.TopProperty, uiTapPoint.Y - _focusRegionSize.Height / 2);
                FocusIndicator.SetValue(Canvas.VisibilityProperty, Visibility.Visible);

                CameraFocusStatus status = await _dataContext.Device.FocusAsync();

                if (status == CameraFocusStatus.Locked)
                {
                    FocusIndicator.SetValue(Shape.StrokeProperty, _focusedBrush);
                    _manuallyFocused = true;
                    _dataContext.Device.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters,
                                                    AutoFocusParameters.Exposure & AutoFocusParameters.Focus & AutoFocusParameters.WhiteBalance);
                }
                else
                {
                    _manuallyFocused = false;
                    _dataContext.Device.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.None);
                }

                _focusSemaphore.Release();
            }
        }
Exemplo n.º 18
0
        private void image_Tap(object sender, GestureEventArgs e)
        {
            Point             position = e.GetPosition(sender as UIElement);
            SpriteElementData elementByRelativePoint = this.CurrentDesc.GetElementByRelativePoint(new Point(position.X / this.Width, position.Y / this.FixedHeight));

            if (elementByRelativePoint == null)
            {
                return;
            }
            EventAggregator.Current.Publish((object)new SpriteElementTapEvent()
            {
                Data = elementByRelativePoint
            });
        }
Exemplo n.º 19
0
 private void stckStart_Tap(object sender, GestureEventArgs e)
 {
     startGame(getTimeout());
     //TODO Remove duplicate code to get initial tap location
     #region duplicatecode
     Random r     = new Random();
     byte   alpha = (byte)r.Next(130, 256);
     byte   red   = (byte)r.Next(0, 256);
     byte   green = (byte)r.Next(0, 256);
     byte   blue  = (byte)r.Next(0, 256);
     Point  p     = e.GetPosition(tapCanvas);
     addTapSpot(p, Color.FromArgb(alpha, red, green, blue));
     #endregion
 }
Exemplo n.º 20
0
        private void GestureListener_Hold(object sender, GestureEventArgs e)
        {
            if (ViewModel.MessageGeo != null)
            {
                return;
            }

            var point    = new Point(e.GetPosition(Map).X, e.GetPosition(Map).Y);
            var location = Map.ViewportPointToLocation(point);

            _contactLocationChoosen    = true;
            ContactLocation.Visibility = Visibility.Visible;
            ContactLocation.Location   = location;

            var distance = CurrentLocation.Location.GetDistanceTo(ContactLocation.Location);

            if (distance < Constants.GlueGeoPointsDistance)
            {
                ContactLocation.Location = CurrentLocation.Location;
            }

            UpdateAttaching(true);
            SetContactLocationString();
        }
Exemplo n.º 21
0
        private void OnTap(object sender, GestureEventArgs e)
        {
            Point p = e.GetPosition(flipControl);

            if (flipControl.IsFlipped)
            {
                flipControl.FlipDirection = (p.X > flipControl.ActualWidth / 2.0) ? FlipDirection.Backwards : FlipDirection.Forwards;
            }
            else
            {
                flipControl.FlipDirection = (p.X < flipControl.ActualWidth / 2.0) ? FlipDirection.Backwards : FlipDirection.Forwards;
            }

            flipControl.IsFlipped = !flipControl.IsFlipped;
        }
Exemplo n.º 22
0
        void myMap_Tap(object sender, GestureEventArgs e)
        {
            myMap.Layers.RemoveAt(0);

            point = e.GetPosition(myMap);
            point.X -= 25;
            point.Y -= 45;

            pushpin = new Pushpin();
            pushpin.Background = this.Resources["PhoneAccentBrush"] as SolidColorBrush;

            overlay = new MapOverlay();
            overlay.Content = pushpin;
            coordinate = myMap.ConvertViewportPointToGeoCoordinate(point);
            overlay.GeoCoordinate = coordinate;
            layer = new MapLayer();
            layer.Add(overlay);
            myMap.Layers.Add(layer);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Occurs when the user taps on the map.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BingMap_Tap(object sender, GestureEventArgs e)
        {
            if (_pin == null)
            {
                // Drop a pushpin representing the pin.
                _pin          = new Pushpin();
                _pin.Template = Resources["PinPushpinTemplate"] as ControlTemplate;
                BingMap.Children.Add(_pin);
            }

            // Determine the coordinates of the point that was tapped.
            var point          = e.GetPosition(BingMap);
            var newPinLocation = BingMap.ViewportPointToLocation(point);

            // Update pin's location and the distance to me.
            _pin.Location = newPinLocation;
            ViewModel.Pin = newPinLocation;
            ViewModel.UpdateDistance();
        }
Exemplo n.º 24
0
        void myMap_Tap(object sender, GestureEventArgs e)
        {
            myMap.Layers.RemoveAt(0);

            point    = e.GetPosition(myMap);
            point.X -= 25;
            point.Y -= 45;

            pushpin            = new Pushpin();
            pushpin.Background = this.Resources["PhoneAccentBrush"] as SolidColorBrush;

            overlay               = new MapOverlay();
            overlay.Content       = pushpin;
            coordinate            = myMap.ConvertViewportPointToGeoCoordinate(point);
            overlay.GeoCoordinate = coordinate;
            layer = new MapLayer();
            layer.Add(overlay);
            myMap.Layers.Add(layer);
        }
Exemplo n.º 25
0
        bool FindIndices(GestureEventArgs e, out int sectionIndex, out int cellIndex)
        {
            sectionIndex = 0;
            cellIndex    = 0;

            TableSection section = null;
            Cell         cell    = null;

            System.Windows.Point pos = e.GetPosition(System.Windows.Application.Current.RootVisual);
            if (Device.Info.CurrentOrientation.IsLandscape())
            {
                double x = pos.Y;
                double y = System.Windows.Application.Current.RootVisual.RenderSize.Width - pos.X + (SystemTray.IsVisible ? 72 : 0);
                pos = new System.Windows.Point(x, y);
            }
            IEnumerable <UIElement> elements = VisualTreeHelper.FindElementsInHostCoordinates(pos, System.Windows.Application.Current.RootVisual);

            foreach (FrameworkElement element in elements.OfType <FrameworkElement>())
            {
                if (cell == null)
                {
                    cell = element.DataContext as Cell;
                }
                else if (section == null)
                {
                    section = element.DataContext as TableSection;
                }
                else
                {
                    break;
                }
            }

            if (cell == null || section == null)
            {
                return(false);
            }

            sectionIndex = Element.Root.IndexOf(section);
            cellIndex    = section.IndexOf(cell);
            return(true);
        }
Exemplo n.º 26
0
        //***********************************************************************************************************************

        //***********************************************************************************************************************
        /// <summary>
        /// Se produit pendant la manipulation.
        /// </summary>
        /// <param name="Sender">Objet source de l'appel.</param>
        /// <param name="Args"><b>EventArgs</b> qui contient les données d'événement.</param>
        //-----------------------------------------------------------------------------------------------------------------------
        private void OnDoubleTap(object Sender, GestureEventArgs Args)
        {
            //-------------------------------------------------------------------------------------------------------------------
            var Transform = (CompositeTransform)this.Root.RenderTransform;

            if (Transform != null)
            {
                //---------------------------------------------------------------------------------------------------------------
                Transform.ScaleY = Transform.ScaleX += 1;

                var Origin = Args.GetPosition(this);

                Transform.TranslateX -= (Origin.X);
                Transform.TranslateY -= (Origin.Y);

                this.LastUniformScale = Transform.ScaleX;
                //---------------------------------------------------------------------------------------------------------------
            }
            //-------------------------------------------------------------------------------------------------------------------
        }
Exemplo n.º 27
0
        private static void TextBlockOnTap(object sender, GestureEventArgs e)
        {
            var richTb = sender as RichTextBox;

            if (richTb == null)
            {
                return;
            }

            var textPointer = richTb.GetPositionFromPoint(e.GetPosition(richTb));

            var element = textPointer.Parent as TextElement;

            while (element != null && !(element is Run))
            {
                if (element.ContentStart != null &&
                    element != element.ElementStart.Parent)
                {
                    element = element.ElementStart.Parent as TextElement;
                }
                else
                {
                    element = null;
                }
            }

            if (element == null)
            {
                return;
            }

            var underline = element as Run;

            if (underline == null)
            {
                return;
            }

            HyperlinkClick(underline);
        }
Exemplo n.º 28
0
        private void ViewOnTap(object sender, GestureEventArgs args)
        {
            var point  = args.GetPosition(View);
            var column = (int)Math.Ceiling(point.X / 79);
            var row    = (int)Math.Ceiling(point.Y / 70);

            if (column <= 0 || row <= 0)
            {
                return;
            }

            //Debug.WriteLine("{0}-{1}", column, row);

            var itemIndex = (row - 1) * EmojiData.ItemsInRow + (column - 1);

            var emoji = EmojiDataItem.GetByIndex(CategoryIndex, SpriteOffset, itemIndex);

            if (emoji != null)
            {
                EmojiSelected(null, emoji);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Occurs when the map is tapped
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="curEdge"></param>
        private void graphMap_Tap(object sender, GestureEventArgs e)
        {
            //if a pin was tapped then handled will be true
            if (e.Handled)
            {
                return;
            }

            if (LocationService.CurrentBuilding == null)
            {
                MessageBox.Show(noBuildingErrorMsg);
                return;
            }

            //Add sniper icon and update selected location
            currentClickedPoint = e.GetPosition(graphMap);
            GeoCoordinate geo = graphMap.ViewportPointToLocation(currentClickedPoint);

            AddSelectedLocation(geo);

            mWebMapCommon.setSelectedLocation(false, mWebMapCommon.getCurrentFloor(), geo.Latitude, geo.Longitude);
        }
        /// <summary>
        /// Function called when the user has double tapped the zoomimage.
        /// </summary>
        /// <param name="sender">sender of the event - this will be the tilt
        /// container (eg, entire page).</param>
        /// <param name="e">Event arguments.</param>
        private void PTZImage_DoubleTap(object sender, GestureEventArgs e)
        {
            if (IsDoubleTapEnabled && null != Image && null != _viewport)
            {
                if (_scale <= _minScale)
                {
                    Point center = e.GetPosition(Image);
                    _relativeMidpoint = new Point(center.X / Image.ActualWidth, center.Y / Image.ActualHeight);

                    var xform = Image.TransformToVisual(_viewport);
                    _screenMidpoint = xform.Transform(center);

                    _scale = _minScale + (0.000806452 * _imagePanel.Width - 0.037097);
                    CoerceScale(false);
                    ResizeImage(false);
                }
                else
                {
                    ResetScale();
                }
            }
        }
Exemplo n.º 31
0
        void focus_Tapped(object sender, GestureEventArgs e)
        {
            if (_phoneCamera != null)
            {
                if (_phoneCamera.IsFocusAtPointSupported == true)
                {
                    // Determine the location of the tap.
                    Point tapLocation = e.GetPosition(viewfinderCanvas);

                    // Position the focus brackets with the estimated offsets.
                    focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                    focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                    // Determine the focus point.
                    double focusXPercentage = tapLocation.X / viewfinderCanvas.ActualWidth;
                    double focusYPercentage = tapLocation.Y / viewfinderCanvas.ActualHeight;

                    // Show the focus brackets and focus at point.
                    focusBrackets.Visibility = Visibility.Visible;
                    _phoneCamera.FocusAtPoint(focusXPercentage, focusYPercentage);
                }
            }
        }
Exemplo n.º 32
0
        void map1_Tap(object sender, GestureEventArgs e)
        {
            if (oneMarker != null)
            {
                Point markPoint = map1.ConvertGeoCoordinateToViewportPoint(oneMarker.GeoCoordinate);

                if ((markPoint.X < 0 || markPoint.Y < 0) ||
                    (map1.ActualWidth < markPoint.X) || (map1.ActualHeight < markPoint.Y))
                {
                    // tap event when we do not have the marker visible, so lets move it here
                    oneMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1));
                    DoCreateTheAreaCircle();
                    if (twoMarker != null && PolyCircle != null && PolyCircle.Path != null)
                    {
                        twoMarker.GeoCoordinate = PolyCircle.Path[0];
                    }
                }
            }
        }
Exemplo n.º 33
0
        private void MapTap(object sender, GestureEventArgs e)
        {
            Point position = e.GetPosition(map);
            GeoCoordinate coordinates = map.ViewportPointToCoordinates(new Media.Point(position.X, position.Y));
            ProgressIndicator.Text = coordinates.ToHumanReadableString();

            // example of how to determine viewport point by coordinates
            Media.Point point = map.CoordinatesToViewportPoint(coordinates);
            // point is relative to map.Viewport
            int x = Convert.ToInt32(point.X - map.Viewport.X),
                y = Convert.ToInt32(point.Y - map.Viewport.Y);
            //Debug.Assert(x == Convert.ToInt32(position.X) && y == Convert.ToInt32(position.Y));
        }
Exemplo n.º 34
0
        private void GeoMap_Tap(object sender, GestureEventArgs e)
        {
            var tapPosition = e.GetPosition((UIElement)e.OriginalSource);
            var geoCoordinate = GeoMap.ViewportPointToLocation(tapPosition);

            GoogleMapsSimpleService gmService = new GoogleMapsSimpleService();
            var geoLocation = new GeoLocation(geoCoordinate.Latitude, geoCoordinate.Longitude);

            //set pushpin
            Pushpin pin = locationPushPin;
            pin.Location = geoCoordinate;
            pin.Content = Address;
            NavigateToMap(geoCoordinate);

            //set current latitude and longitude
            this.Latitude = geoCoordinate.Latitude;
            this.Longitude = geoCoordinate.Longitude;

            //find address
            gmService.GetAddressByGeoLocation(geoLocation,
                (address)=>
                {
                    Dispatcher.BeginInvoke(()=>
                    {
                        string resultAddress = address.Substring(0,Math.Min(address.Length,254));
                        Address = resultAddress;
                        locationPushPin.Content = resultAddress;
                    });
                });
        }
 //adding custom pin to screen
 void map_Hold(object sender, GestureEventArgs e)
 {
     try
     {
         _pinImage.MaxHeight = 50;
         _pinImage.MaxWidth = 50;
         _pinImage.Opacity = 0.8;
         ImageLayer.Children.Remove(_pinImage);
         _customLocation = _map.ViewportPointToLocation(e.GetPosition(_map));
         ImageLayer.AddChild(_pinImage, _customLocation, PositionOrigin.BottomCenter);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message + "\n" + ex.Data + "\n" + ex.StackTrace);
     }
 }
Exemplo n.º 36
0
 public override void DoubleTap(GestureEventArgs e)
 {
     base.DoubleTap(e);
     Point2D point = _map.ScreenToMap(e.GetPosition(_map));
     EndDistance(point, true);
 }
        //removing popup
        void map_Tap(object sender, GestureEventArgs e)
        {
            //Discards any tap made on the customLocation's pin.
            //(Tap Event sequence -> (1)pinImage -> (2)map)
            if (!((_click_X == e.GetPosition(_map).X) && (_click_Y == e.GetPosition(_map).Y)))
            {
                ImageLayer.Children.Remove(_popupWindow);
            }

        }
 private void MapTap(object sender, GestureEventArgs e)
 {
     Point tapPoint = e.GetPosition(map);
     GeoCoordinate coordinate = map.ViewportPointToCoordinates(new Media.Point(tapPoint.X, tapPoint.Y));
     _geocodeManager.Query(new GeocodeRequestParameters(coordinate, null));
 }
        private void LayoutRoot_Tap(object sender, GestureEventArgs e)
        {
            Point p = e.GetPosition(null);

            MessageBox.Show(string.Format("X = {0}, Y = {1}", p.X, p.Y));
        }
Exemplo n.º 40
0
 private void SliderGrid_Tap(object sender, GestureEventArgs e)
 {
     UpdateSliderForX(e.GetPosition((UIElement)sender).X);
 }
Exemplo n.º 41
0
 public override void Hold(GestureEventArgs e)
 {
     base.Hold(e);
     Point2D point = _map.ScreenToMap(e.GetPosition(_map));
     EndDistance(point);
 }
Exemplo n.º 42
0
 public override void OnHold(GestureEventArgs e)
 {
     Point2D item = Map.ScreenToMap(e.GetPosition(Map));
     points.Add(item);
     endDraw(true);
     e.Handled = true;
     base.OnHold(e);
 }
Exemplo n.º 43
0
        private async void VideoCanvasOnTap(object sender, GestureEventArgs e)
        {
            try
            {
                System.Windows.Point uiTapPoint = e.GetPosition(VideoCanvas);

                if (PhotoCaptureDevice.IsFocusRegionSupported(PhotoCaptureDevice.SensorLocation) && _focusSemaphore.WaitOne(0))
                {
                    // Get tap coordinates as a foundation point
                    var tapPoint = new Windows.Foundation.Point(uiTapPoint.X, uiTapPoint.Y);

                    double xRatio = VideoCanvas.ActualHeight / PhotoCaptureDevice.PreviewResolution.Width;
                    double yRatio = VideoCanvas.ActualWidth / PhotoCaptureDevice.PreviewResolution.Height;

                    // adjust to center focus on the tap point
                    var displayOrigin = new Windows.Foundation.Point(
                        tapPoint.Y - _focusRegionSize.Width / 2,
                        (VideoCanvas.ActualWidth - tapPoint.X) - _focusRegionSize.Height / 2);

                    // adjust for resolution difference between preview image and the canvas
                    var viewFinderOrigin = new Windows.Foundation.Point(displayOrigin.X / xRatio, displayOrigin.Y / yRatio);
                    var focusrect        = new Windows.Foundation.Rect(viewFinderOrigin, _focusRegionSize);

                    // clip to preview resolution
                    var viewPortRect = new Windows.Foundation.Rect(0, 0, PhotoCaptureDevice.PreviewResolution.Width,
                                                                   PhotoCaptureDevice.PreviewResolution.Height);
                    focusrect.Intersect(viewPortRect);

                    PhotoCaptureDevice.FocusRegion = focusrect;

                    // show a focus indicator
                    FocusIndicator.SetValue(Shape.StrokeProperty, _notFocusedBrush);
                    FocusIndicator.SetValue(Canvas.LeftProperty, uiTapPoint.X - _focusRegionSize.Width / 2);
                    FocusIndicator.SetValue(Canvas.TopProperty, uiTapPoint.Y - _focusRegionSize.Height / 2);
                    FocusIndicator.SetValue(VisibilityProperty, Visibility.Visible);

                    CameraFocusStatus status = await PhotoCaptureDevice.FocusAsync();

                    if (status == CameraFocusStatus.Locked)
                    {
                        FocusIndicator.SetValue(Shape.StrokeProperty, _focusedBrush);
                        _manuallyFocused = true;
                        PhotoCaptureDevice.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters,
                                                       AutoFocusParameters.Exposure & AutoFocusParameters.Focus & AutoFocusParameters.WhiteBalance);
                    }
                    else
                    {
                        _manuallyFocused = false;
                        PhotoCaptureDevice.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.None);
                    }

                    _focusSemaphore.Release();
                }

                await Capture();
            }
            catch (Exception exception)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    new CustomMessageDialog(
                        AppMessages.CaptureVideoFailed_Title,
                        String.Format(AppMessages.CaptureVideoFailed, exception.Message),
                        App.AppInformation,
                        MessageDialogButtons.Ok).ShowDialog();
                });
            }
        }
        //adding popup to screen
        //(Tap Event sequence-> (1)pinImage -> (2)map)
        void pinImage_Tap(object sender, GestureEventArgs e)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine("clicked");
                _click_X = e.GetPosition(_map).X;
                _click_Y = e.GetPosition(_map).Y;

                ImageLayer.Children.Remove(_popupWindow);
                ImageLayer.AddChild(_popupWindow, _customLocation, PositionOrigin.BottomRight);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message + "\n" + ex.Data + "\n" + ex.StackTrace);
            }

        }
Exemplo n.º 45
0
        private void gesture_Hold(object sender, GestureEventArgs e)
        {
            var point = e.GetPosition(ContentPanel);

            message.Text = string.Format("hold at ({0},{1})", point.X, point.Y);
        }
Exemplo n.º 46
0
 private void SliderGrid_Tap(object sender, GestureEventArgs e)
 {
     UpdateSliderForX(e.GetPosition((UIElement)sender).X);
 }
Exemplo n.º 47
0
        public override void Tap(GestureEventArgs e)
        {
            base.Tap(e);
            Point2D point = _map.ScreenToMap(e.GetPosition(_map));
            if (!_isInited)
            {
                Init(point);
            }
            else
            {
                TextBlock text = new TextBlock();

                text.FontWeight = FontWeights.ExtraBlack;
                text.Foreground = new SolidColorBrush(Colors.Black);
                _eLayer.AddChild(text, point);
                Point2D lastPoint = _points[_points.Count - 1];
                double nowDistance = Math.Sqrt((point.X - lastPoint.X) * (point.X - lastPoint.X) + (point.Y - lastPoint.Y) * (point.Y - lastPoint.Y));
                double lastDistance = _distances[_distances.Count - 1];
                double distance = nowDistance + lastDistance;
                text.Text = string.Format("{0}公里", distance.ToString("0.0"));
                _distances.Add(distance);
                _distanceList.Add(text);
                _points.Add(point);
            }
        }
Exemplo n.º 48
0
 void PowerListBoxItem_Tap(object sender, GestureEventArgs e)
 {
     if (_selecterRt == null || !IsSelected)
         return;
     var pt = e.GetPosition(_selecterRt);
     if (pt.X > _selecterRt.ActualWidth || pt.Y > _selecterRt.ActualHeight)
     {
         ListBox.InvokeItemSelectedEvent(this);
     }
 }
Exemplo n.º 49
0
 void HandleMapTap(object sender, GestureEventArgs e)
 {
     var p = e.GetPosition(map);
     MapTappedOn(p);
 }
Exemplo n.º 50
0
 public override void OnHold(GestureEventArgs e)
 {
     Point2D item = Map.ScreenToMap(e.GetPosition(Map));
     points.Insert(points.Count - 2, item);
     if (points != null && points.Count - 2 <= 2)
         return;
     endDraw(true);
     e.Handled = true;
     base.OnHold(e);
 }
Exemplo n.º 51
0
        /// <summary>
        /// Called before the System.Windows.UIElement.Tap event occurs.
        /// </summary>
        /// <param name="e">Event data for the event.</param>
        protected override void OnTap(GestureEventArgs e)
        {
            if (State != EPubReader.State.Normal)
            {
                return;
            }

            Point p = e.GetPosition(this);

            // check anchor rects
            if (_currentIecIndex > DefaultCurrentLocation && Book.ItemElementsContainers[_currentIecIndex].Pages.Count > 0)
            {
                AnchorRect anchorRect = Book.ItemElementsContainers[_currentIecIndex].Pages[_currentPageIndex].AnchorRects.Where(ar => ar.Rect.Contains(p)).FirstOrDefault();
                if (anchorRect != null)
                {
                    if (anchorRect.Href.StartsWith("http://", StringComparison.OrdinalIgnoreCase) || anchorRect.Href.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
                    {
                        try
                        {
                            new WebBrowserTask()
                            {
                                Uri = new Uri(anchorRect.Href)
                            }.Show();
                        }
                        catch { }
                    }
                    else if (anchorRect.Href.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
                    {
                        try
                        {
                            new EmailComposeTask()
                            {
                                To = anchorRect.Href.Substring(7) // substring "mailto:"
                            }.Show();
                        }
                        catch { }
                    }
                    else
                    {
                        Navigate(anchorRect.Href);
                    }

                    e.Handled = true;
                }
            }

            if (!e.Handled && p.X <= ActualWidth / 3 && CurrentLocation > 0)
            {
                // previous page
                PreviousPage();

                e.Handled = true;
            }
            else if (!e.Handled && p.X >= ActualWidth * 2 / 3 && CurrentLocation < FurthestLocation - 1)
            {
                // next page
                NextPage();

                e.Handled = true;
            }
            else
            {
                base.OnTap(e);
            }
        }
Exemplo n.º 52
0
 private void root_Tap(object sender, GestureEventArgs e)
 {
     playingState.Margin = new Thickness(e.GetPosition(root).X, 0, 0, 0);
     place.Width = e.GetPosition(root).X + 15;
 }