private void imgResult_Tap(object sender, GestureEventArgs e) { //Si premier clic, on enrgistre le X et le Y if (clic1) { tmp.X = Convert.ToInt32(e.GetPosition(imgResult).X); tmp.Y = Convert.ToInt32(e.GetPosition(imgResult).Y); //On affiche le premier point e1.Margin = new Thickness(tmp.X, tmp.Y, 0, 0); e1.Visibility = Visibility.Visible; clic1 = false; clic2 = true; return; } //Si second clic, on enregistre longeur et largeur if (clic2) { //Longueur int x = Convert.ToInt32(e.GetPosition(imgResult).X); if (tmp.X > x) { MessageBox.Show("This point should be the corner on the down right", "Error", MessageBoxButton.OK); } else { tmp.Longueur = x - tmp.X; int y = Convert.ToInt32(e.GetPosition(imgResult).Y); if (tmp.Y > y) { MessageBox.Show("This point should be the corner on the down right", "Error", MessageBoxButton.OK); } else { tmp.Hauteur = y - tmp.Y; clic2 = false; //On enlève l'ellipse e1.Visibility = Visibility.Collapsed; //On affiche le rectable r1.Margin = new Thickness(e1.Margin.Left + 10, e1.Margin.Top +6,0,0); r1.Width = tmp.Longueur; r1.Height = tmp.Hauteur; r1.Visibility = Visibility.Visible; //On choisit l'objet objet = true; ContentPanelItem.Visibility = Visibility.Visible; } } } }
private void Border_Tap(object sender, GestureEventArgs e) { //determine the click location var pos = e.GetPosition(_border); // forward to the browser _browser.InvokeScript("eval", string.Format("document.elementFromPoint({0},{1}).click()", pos.X, pos.Y)); }
private void onDragStarted(object sender, Microsoft.Phone.Controls.GestureEventArgs e) { if (disableTopLevelGesture || isReordering || isDraggingListBox) { return; } e.Handled = true; isDraggingListBox = true; lastDraggedYDist = 0.0; dragStartY = e.GetPosition((UIElement)listbox).Y; }
private void GestureListener_Hold(object sender, GestureEventArgs e) { if (ok == false) { ok = true; var pushPin = new Pushpin(); var position = e.GetPosition(map1); var location = map1.ViewportPointToLocation(position); thisApp.Lat = (decimal)location.Latitude; thisApp.Long = (decimal)location.Longitude; PushpinLayer.AddChild(pushPin, location); } }
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; }
private void GestureListener_Hold(object sender, Microsoft.Phone.Controls.GestureEventArgs e) { var pushpinLocation = googlemap.ViewportPointToLocation(e.GetPosition(googlemap)); Pushpin pushpin = new Pushpin { Location = pushpinLocation, Template = Application.Current.Resources["PushpinControlTemplate"] as ControlTemplate, Content = "1" }; if (googlemap.Children.Any(p => p is Pushpin)) { googlemap.Children.Remove(googlemap.Children.Single(p => p is Pushpin)); } googlemap.Children.Add(pushpin); EnableProceedButton(); }
private void onDragStarted(object sender, Microsoft.Phone.Controls.GestureEventArgs e) { if (DisableGesture) { return; } if (_reorderStarted) { e.Handled = true; } else { if (_draggingToDelete) { return; } _dragStartX = e.GetPosition(this).X; } }
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]; } } } }
private void GestureListener_DoubleTap(object sender, Microsoft.Phone.Controls.GestureEventArgs e) { if (Math.Abs(_totalImageScale - 1) < .0001) { const double DOUBLE_TAP_ZOOM_IN = 3; double imageScale = Math.Min(DOUBLE_TAP_ZOOM_IN, _maxImageZoom); Point imagePositionTapped = e.GetPosition(MapImage); // we want this point to be centered. double x = imagePositionTapped.X * imageScale - (MapImage.ActualWidth / 2); double y = imagePositionTapped.Y * imageScale - (MapImage.ActualHeight / 2); Point imageDelta = new Point(-1 * x, -1 * y); // FFV - animation? UpdateImageScale(imageScale); UpdateImagePosition(imageDelta); } else { ResetImagePosition(); } }
private void OnDoubleTap(object sender, GestureEventArgs e) { Point center = e.GetPosition(Presenter); _relativeMidpoint = new Point(center.X / Presenter.ActualWidth, center.Y / Presenter.ActualHeight); var xform = Presenter.TransformToVisual(Viewport); _screenMidpoint = xform.Transform(center); if (_scale > _baseScale) { _scale = 0; CoerceScale(true); _scale = _coercedScale; ResizeImage(true); } else { _scale = _baseScale * 3; CoerceScale(false); ResizeImage(false); } }
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)); }
/// <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(); } }
/// <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)); } }
void listener_Hold(object sender, GestureEventArgs e) { ((MenuItem)menu.Items[0]).Header = "Identifying Location..."; menu.IsOpen = true; System.Device.Location.GeoCoordinate location = this.BingMap.ViewportPointToLocation(e.GetPosition(this.BingMap)); MobileSrc.Services.GeocodeServices.GeocodeServiceClient rclient = new MobileSrc.Services.GeocodeServices.GeocodeServiceClient("BasicHttpBinding_IGeocodeService"); MobileSrc.Services.GeocodeServices.ReverseGeocodeRequest req = new MobileSrc.Services.GeocodeServices.ReverseGeocodeRequest(); req.Credentials = new MobileSrc.Services.GeocodeServices.Credentials(); req.Credentials.ApplicationId = BingMapsApiKey; req.Location = new MobileSrc.Services.GeocodeServices.Location(); req.Location.Latitude = location.Latitude; req.Location.Longitude = location.Longitude; req.ExecutionOptions = new MobileSrc.Services.GeocodeServices.ExecutionOptions(); rclient.ReverseGeocodeCompleted += new EventHandler<MobileSrc.Services.GeocodeServices.ReverseGeocodeCompletedEventArgs>(client_ReverseGeocodeCompleted); rclient.ReverseGeocodeAsync(req); }
/// <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(); }
private void LayoutRoot_Tap(object sender, GestureEventArgs e) { this.LayoutRoot.Tap -= LayoutRoot_Tap; this.PlayAudioFile("ThrowAudio.wav"); Image tomatoImage = new Image(); tomatoImage.Source = new BitmapImage(new Uri("tomato.png", UriKind.RelativeOrAbsolute)); tomatoImage.Height = 74; tomatoImage.Width = 63; TomatoRedirection(tomatoImage); _tomatoImages.Add(tomatoImage); LayoutRoot.Children.Add(tomatoImage); System.Windows.Point tappedHere = e.GetPosition(this.LayoutRoot); _tappedPoints.Add(tappedHere); _tapCount++; // Create a duration of 0.5 seconds. Duration duration = new Duration(TimeSpan.FromMilliseconds(400)); // Create two DoubleAnimations and set their properties. DoubleAnimation myDoubleAnimation1 = new DoubleAnimation(); DoubleAnimation myDoubleAnimation2 = new DoubleAnimation(); myDoubleAnimation1.Duration = duration; myDoubleAnimation2.Duration = duration; Storyboard sb = new Storyboard(); sb.Duration = duration; sb.Children.Add(myDoubleAnimation1); sb.Children.Add(myDoubleAnimation2); Storyboard.SetTarget(myDoubleAnimation1, tomatoImage); Storyboard.SetTarget(myDoubleAnimation2, tomatoImage); // Set the attached properties of Canvas.Left and Canvas.Top // to be the target properties of the two respective DoubleAnimations. Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)")); Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)")); myDoubleAnimation1.To = tappedHere.X;//widhth 63 myDoubleAnimation2.To = tappedHere.Y; //Height 74 ScaleTransform scale = new ScaleTransform(); tomatoImage.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5); tomatoImage.RenderTransform = scale; DoubleAnimation growAnimationX = new DoubleAnimation(); growAnimationX.Duration = TimeSpan.FromMilliseconds(300); growAnimationX.From = 5; growAnimationX.To = 1; DoubleAnimation growAnimationY = new DoubleAnimation(); growAnimationY.Duration = TimeSpan.FromMilliseconds(300); growAnimationY.From = 5; growAnimationY.To = 1; Storyboard.SetTargetProperty(growAnimationX, new PropertyPath("(Image.RenderTransform).(ScaleTransform.ScaleX)")); Storyboard.SetTarget(growAnimationX, tomatoImage); Storyboard.SetTargetProperty(growAnimationY, new PropertyPath("(Image.RenderTransform).(ScaleTransform.ScaleY)")); Storyboard.SetTarget(growAnimationY, tomatoImage); sb.Children.Add(growAnimationX); sb.Children.Add(growAnimationY); // Begin the animation. sb.Begin(); sb.Completed += new EventHandler(sb_Completed); }
private void canvas1_Tap(object sender, GestureEventArgs e) { if (toolState == 1) { long before = DateTime.Now.Ticks; undoBm = new WriteableBitmap(canvas1, null); //UNDOop updateUndoList(); cur_p.x = (short)e.GetPosition(canvas1).X; cur_p.y = (short)e.GetPosition(canvas1).Y; bm = new WriteableBitmap(canvas1, null); flood3(cur_p.y*bm.PixelWidth + cur_p.x, Globals.getColorAsInt(), bm.Pixels[cur_p.x + cur_p.y*bm.PixelWidth]); bm.Invalidate(); updateCanvasFromWBM(bm); //Used to measure performance long after = DateTime.Now.Ticks; TimeSpan elapsedTime = new TimeSpan(after - before); makeToast("Bucket Applied -", string.Format(" {0}ms", elapsedTime.TotalMilliseconds), 500); } if (toolState == 3) { if (!activelyDrawing) { prev_p.x = (short)e.GetPosition(canvas1).X; prev_p.y = (short)e.GetPosition(canvas1).Y; activelyDrawing = true; } else { short tx = prev_p.x; short ty = prev_p.y; cur_p.x = (short)e.GetPosition(canvas1).X; cur_p.y = (short)e.GetPosition(canvas1).Y; Size s = new Size(); s.Height = (int)Math.Abs(cur_p.y -ty); s.Width = (int)Math.Abs(cur_p.x - tx); System.Diagnostics.Debug.WriteLine(s.Height + " " + s.Width); Point o = new Point(Math.Min(cur_p.x, tx), Math.Min(cur_p.y, ty)); Ellipse tempRect = new Ellipse() { Width = s.Width, Height = s.Height }; tempRect.Margin = new Thickness(o.X, o.Y, 0, 0); tempRect.Stroke = new SolidColorBrush(Globals.scb.Color); tempRect.StrokeThickness = Globals.brushSize; tempRect.StrokeStartLineCap = Globals.plc; updateUndoList(); this.canvas1.Children.Add(tempRect); activelyDrawing = false; } } }
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); }
private void gesture_Tap(object sender, GestureEventArgs e) { var point = e.GetPosition(ContentPanel); message.Text = string.Format("tap at ({0},{1})", point.X, point.Y); flickMessage.Text = null; }
/// <summary> /// Changes the current camera effect. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void OnMyCameraMediaElementTapped(object sender, GestureEventArgs e) { var uiTapPoint = e.GetPosition(_mediaElement); if (_focusSemaphore.WaitOne(0)) { // Get tap coordinates as a foundation point var tapPoint = new Windows.Foundation.Point(uiTapPoint.X, uiTapPoint.Y); // adjust to center focus on the tap point var displayOrigin = new Windows.Foundation.Point( tapPoint.X - _focusRegionSize.Width / 2, tapPoint.Y - _focusRegionSize.Height / 2); // adjust for resolution difference between preview image and the canvas var viewFinderOrigin = new Windows.Foundation.Point(displayOrigin.X , displayOrigin.Y); var focusrect = new Windows.Foundation.Rect(viewFinderOrigin, _focusRegionSize); // clip to preview resolution var viewPortRect = new Windows.Foundation.Rect(0, 0,_camera.PreviewResolution.Width,_camera.PreviewResolution.Height); focusrect.Intersect(viewPortRect); _camera.FocusRegion = focusrect; // show a focus indicator FocusIndicator.Margin = new Thickness(uiTapPoint.X - (_focusRegionSize.Width/2), uiTapPoint.Y - (_focusRegionSize.Height/2), 0, 0); FocusIndicator.SetValue(Shape.StrokeProperty, _notFocusedBrush); FocusIndicator.SetValue(Canvas.VisibilityProperty, Visibility.Visible); CameraFocusStatus status = await _camera.FocusAsync(); if (status == CameraFocusStatus.Locked) { FocusIndicator.SetValue(Shape.StrokeProperty, _focusedBrush); _manuallyFocused = true; _camera.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.Exposure & AutoFocusParameters.Focus & AutoFocusParameters.WhiteBalance); } else { _manuallyFocused = false; _camera.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.None); } _focusSemaphore.Release(); } }
private void gestureListener_DoubleTap(object sender, GestureEventArgs e) { if (imageMan == null) return; Point p = e.GetPosition(image); if (zoomed) { zoomed = false; ApplyZoomTransform(sender as Image, 1, p); } else { zoomed = true; ApplyZoomTransform(sender as Image, zoomFactor, p); } }
void Map_Hold(object sender, GestureEventArgs e) { ClearQuery(); Point2D point = myMap.ScreenToMap(e.GetPosition(myMap)); double radius = 100000;//Map.Resolution * 10; Utility.Point2D p = new Utility.Point2D(point.X, point.Y); Utility.Geometry geometry = new Utility.Geometry(); geometry.Type = Utility.GeometryType.POINT; geometry.Parts = new int[] { 1 }; geometry.Points = new Utility.Point2D[1] { p }; Utility.QueryParameterSet query = new Utility.QueryParameterSet(); query.ReturnContent = true; query.ExpectCount = 1; query.QueryOption = Utility.QueryOption.ATTRIBUTEANDGEOMETRY; query.QueryParams = new Utility.QueryParameter[] { new Utility.QueryParameter("China_PreCenCity_P_Label@China400") }; _queryMap.FindNearest(mapName, geometry, radius, query, new EventHandler<Utility.QueryEventArgs>(Query_Completed), new EventHandler<Utility.FailedEventArgs>(Query_Failed)); }
// 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. System.Windows.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()."; }); } } }
void Map_DoubleTap(object sender, GestureEventArgs e) { Point point = e.GetPosition(myMap); Point2D p = myMap.ScreenToMap(point); double resolution = myMap.Resolution / 2; Point2D leftBottom = new Point2D(p.X - point.X * resolution, p.Y - (myMap.RenderSize.Height - point.Y) * resolution); Rectangle2D rec = new Rectangle2D(leftBottom, myMap.RenderSize.Width * resolution, myMap.RenderSize.Height * resolution); myMap.ZoomTo(rec); }
/// <summary> /// 标记后显示该位置的相关信息(地理位置名称等信息) ///地图maker标记函数(长按) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void amap_hold(object sender, GestureEventArgs e) { //获取用户标识点所在位置经纬度 TabLatLng = _amap.GetProjection().FromScreenLocation((e.GetPosition(_amap))); //删除用户先前标识的_tabMaker if (_tabMarker != null) _tabMarker.Destroy(); //创建新的_tabMaker _tabMarker = _amap.AddMarker(new AMapMarkerOptions() { Position = TabLatLng,//maker添加位置 IconUri = new Uri("Images/RED.png", UriKind.RelativeOrAbsolute)//maker图标 }); NavigateEndLngLng = TabLatLng; //纠正定位偏差,将搜索半径设置为50米 amapHoldResult = await AMapReGeoCodeSearch.GeoCodeToAddress(TabLatLng.longitude, TabLatLng.latitude,50, "", Extensions.All); //amapHoldResult = await AMapReGeoCodeSearch.GeoCodeToAddress(TabLatLng.longitude, TabLatLng.latitude); Dispatcher.BeginInvoke(() => { if (amapHoldResult.Erro == null && amapHoldResult.ReGeoCode != null) { AMapReGeoCode regeocode = amapHoldResult.ReGeoCode; ShowDownStateSettings(); MakerTextBlock.Text = regeocode.Formatted_address; } } ); }
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); } } }
//处理 tap 事件 private void DrawingSurfaceBackground_Tap(object sender, GestureEventArgs e) { //点击的坐标 var currentPoint = e.GetPosition(null); double tmp = 0; // 根据手机的orientation转换得到在渲染界面中的坐标 // Rotate the point to get it relative to the // native rendering surface instead of the XAML rendering surface switch (Orientation) { case PageOrientation.LandscapeLeft: tmp = currentPoint.X; currentPoint.X = currentPoint.Y; currentPoint.Y = Application.Current.Host.Content.ActualWidth - tmp; break; case PageOrientation.LandscapeRight: tmp = currentPoint.X; currentPoint.X = Application.Current.Host.Content.ActualHeight - currentPoint.Y; currentPoint.Y = tmp; break; } // Convert dips to native pixels currentPoint.X = DipsToPixels(currentPoint.X); currentPoint.Y = DipsToPixels(currentPoint.Y); var objName = m_d3dBackground.OnHitObject((int)currentPoint.X, (int)currentPoint.Y); if (objName != null) { m_d3dBackground.ToggleHitEffect(objName); if (objName == "Cylinder_Node") { HitCountCylinder.Text = (++m_hitCountCylinder).ToString(); } else if (objName == "Cube_Node") { HitCountCube.Text = (++m_hitCountCube).ToString(); } else if (objName == "Sphere_Node") { HitCountSphere.Text = (++m_hitCountSphere).ToString(); } else if (objName == "Cone_Node") { HitCountCone.Text = (++m_hitCountCone).ToString(); } else if (objName == "Teapot_Node") { HitCountTeapot.Text = (++m_hitCountTeapot).ToString(); } } }
/// <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); }