Cell FindCell(GestureEventArgs e, out FrameworkElement element) { Cell cell = null; element = e.OriginalSource as FrameworkElement; if (element != null) { cell = element.DataContext as Cell; } if (cell == null) { System.Windows.Point pos = e.GetPosition(_listBox); IEnumerable <UIElement> elements = VisualTreeHelper.FindElementsInHostCoordinates(pos, _listBox); foreach (FrameworkElement frameworkElement in elements.OfType <FrameworkElement>()) { if ((cell = frameworkElement.DataContext as Cell) != null) { element = frameworkElement; break; } } } return(cell); }
private void MapHold(object sender, System.Windows.Input.GestureEventArgs e) { var position = e.GetPosition(AssociatedObject); var coordinate = AssociatedObject.ConvertViewportPointToGeoCoordinate(position); Position = new Coordinate(coordinate.Latitude, coordinate.Longitude); }
void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(map);//获得在map容器的像素坐标 if (start == null) { start = map.FromScreenPixelToLngLat(p);//确定起点 startText.Text = start.ToString(); map.Children.Add(new MMarker() { LngLat = start, IsEditable = true, IconURL = "/bus_start_pic.jpg", Anchor = new Point(0.5, 1) }); } else if (end == null) { end = map.FromScreenPixelToLngLat(p);//确定终点 endText.Text = start.ToString(); map.Children.Add(new MMarker() { LngLat = end, IconURL = "/bus_end_pic.jpg", Anchor = new Point(0.5, 1) }); } }
protected override void OnDoubleTap(System.Windows.Input.GestureEventArgs e) #endif { if (isAnimating) { return; } e.Handled = true; if (currentScale == 1 && currentPosition.X == 0 && currentPosition.Y == 0) { var point = e.GetPosition(this); currentScale = MaxZoomFactor; currentPosition = CalculatePositionByPoint(point, currentScale); ApplyScaleAndPosition(true); } else { ResetZoomAndPosition(true); } #if WINRT base.OnDoubleTapped(e); #else base.OnDoubleTap(e); #endif }
private void OnDoubleTap(object sender, GestureEventArgs e) { e.Handled = true; _originalScale = _scale; Point center = e.GetPosition(ImageElement); _relativeMidpoint = new Point(center.X / ImageElement.ActualWidth, center.Y / ImageElement.ActualHeight); var xform = ImageElement.TransformToVisual(ImageViewportElement); _screenMidpoint = xform.Transform(center); if (doubleTap) { _scale = 0; doubleTap = false; } else { doubleTap = true; _scale = _originalScale * 3; } CoerceScale(false); ResizeImage(false); }
private static void OnHold(object sender, System.Windows.Input.GestureEventArgs e) { _state = GestureState.Hold; var touchPoint = e.GetPosition(Application.Current.RootVisual); touchPoint = GetInverseTransform(true).Transform(touchPoint); RaiseGestureEvent((handler) => handler.Hold, () => new Microsoft.Phone.Controls.GestureEventArgs(_gestureOrigin, touchPoint), false); }
private void Map_OnTapped(object sender, System.Windows.Input.GestureEventArgs e) { if (!this.ViewModel.IsFormEnabled) { return; } this.SetPushpin(this.Map.ConvertViewportPointToGeoCoordinate(e.GetPosition((UIElement)this.Map)), false); PageBase.SetInProgress(false); }
void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(map); //获得在map容器的像素坐标 MLngLat xy = map.FromScreenPixelToLngLat(p); //确定经纬度 x = xy.LngX; y = xy.LatY; ReGeoCodeToAddressWithOption(); map.Tap -= new EventHandler <System.Windows.Input.GestureEventArgs>(map_Tap); }
private void image_Tap(object sender, System.Windows.Input.GestureEventArgs e) { //Ottengo il punto in cui viene effettuato il Tap, quindi lo metto in nuovo oggetto di tipo Point Point punto = e.GetPosition(this); //Calcolo le distanze geometriche tra il punto in cui viene fatto il tap // e i vari punti in cui ci sono le differenze // Distanza per l'asse delle X double X1 = Math.Abs(punto.X - punto1.X); double X2 = Math.Abs(punto.X - punto2.X); double X3 = Math.Abs(punto.X - punto3.X); double X4 = Math.Abs(punto.X - punto4.X); //Distanza per l'asse delle Y double Y1 = Math.Abs(punto.Y - punto1.Y); double Y2 = Math.Abs(punto.Y - punto2.Y); double Y3 = Math.Abs(punto.Y - punto3.Y); double Y4 = Math.Abs(punto.Y - punto4.Y); //Se la distanza tra il punto in cui si tocca e la differenza è <10, mostra l'immagine del cerchio // che indica che la differenza è stata trovata, e incremento il contatore delle differenze trovate if (X1 < 30 && Y1 < 30) { circle1.Visibility = Visibility.Visible; i++; } if (X2 < 30 && Y2 < 30) { circle2.Visibility = Visibility.Visible; i++; } if (X3 < 30 && Y3 < 30) { circle3.Visibility = Visibility.Visible; i++; } if (X4 < 30 && Y4 < 30) { circle4.Visibility = Visibility.Visible; i++; } //Se sono state trovate tutte le differenze vado avanti if (i == 4) { original.Source = null; image.Source = null; circle1.Source = null; circle2.Source = null; circle3.Source = null; circle4.Source = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); NavigationService.Navigate(new Uri("/lvlSet2/s2lvl2.xaml", UriKind.Relative)); } }
private void handleHold(object sender, System.Windows.Input.GestureEventArgs e) { if (!entryIsOpen) { if (e.OriginalSource.GetType() == typeof(Canvas)) { Canvas canvas = (Canvas)e.OriginalSource; Debug.WriteLine("Hold auf " + canvas.Name); savePosition(e.GetPosition(canvas).X / canvas.Width, e.GetPosition(canvas).Y / canvas.Height, canvas); } else { Debug.WriteLine("Hold nicht auf Image"); } showDamageEntryBar(sender, e); } else { handleTap(sender, e); handleHold(sender, e); } }
void map1_Tap(object sender, System.Windows.Input.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 SetMarkerLocation(map1.ConvertViewportPointToGeoCoordinate(e.GetPosition(map1))); } } }
//マップをホールド。ピンの追加 private void MyMap_Hold(object sender, System.Windows.Input.GestureEventArgs e) { if (pin_hold_flag == false) { var holdLocation = MyMap.ViewportPointToLocation(e.GetPosition(MyMap)); AddNewPin(holdLocation); var vc = VibrateController.Default; vc.Start(TimeSpan.FromMilliseconds(50)); //DB.SaveInfoToIsoStrage(PushPinView); } pin_hold_flag = false; }
private void image_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point position = e.GetPosition(sender as UIElement); Point p = new Point(((Point)@position).X / this.Width, ((Point)@position).Y / this.FixedHeight); SpriteElementData elementByRelativePoint = this.CurrentDesc.GetElementByRelativePoint(p); if (elementByRelativePoint == null) { return; } EventAggregator.Current.Publish(new SpriteElementTapEvent() { Data = elementByRelativePoint }); }
void stopMap_Hold(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(stopMap); GeoCoordinate geo = new GeoCoordinate(); geo = stopMap.ViewportPointToLocation(p); PinViewModel pin = new PinViewModel("") { IsCustom = true, Location = geo, Source = new BitmapImage(new Uri("/Images/appbar.compas.rest.png", UriKind.Relative)) }; App.ViewModel.SearchPins.Add(pin); }
private void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(this.map); GeoCoordinate geo = new GeoCoordinate(); geo = map.ViewportPointToLocation(p); //map.ZoomLevel = 17; map.Center = geo; locationPushpin.Location = geo; if (this.map.Children.Contains(locationPushpin)) { this.map.Children.Remove(locationPushpin); } //---add the pushpin to the map--- map.Children.Add(locationPushpin); }
private void Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (sendType.Visibility == Visibility.Collapsed) { client.Send(click); Point p = e.GetPosition(image); Point revamped = p; revamped.X = revamped.X * 1920 / image.Width; revamped.Y = revamped.Y * 1080 / image.Height; client.Send((revamped.X.ToString() + "," + revamped.Y.ToString() + new string('x', 260)).Substring(0, 260)); } else { sendType.Visibility = Visibility.Collapsed; SendButton.Visibility = Visibility.Collapsed; sendType.Text = ""; } }
// On map tap set starting point - Philippos, Philokypros void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { System.Windows.Point p = e.GetPosition(map); GeoCoordinate s = map.ConvertViewportPointToGeoCoordinate(p); curLat = s.Latitude; curLon = s.Longitude; // Redraw map and image - Philippos map.Layers.Clear(); MapLayer myLayer = new MapLayer(); MapOverlay myOverlay = new MapOverlay() { GeoCoordinate = new GeoCoordinate(35.144925, 33.410800) }; ExpanderView expander = new ExpanderView(); expander.Header = new Image() { Source = new BitmapImage(new Uri("/images/2.png", UriKind.Relative)), Width = prevWidth }; myOverlay.Content = expander; myLayer.Add(myOverlay); // Draw start point - Philippos Polygon polygon = new Polygon(); polygon.Points.Add(new System.Windows.Point(0, 0)); polygon.Points.Add(new System.Windows.Point(0, 25)); polygon.Points.Add(new System.Windows.Point(25, 0)); polygon.Fill = new SolidColorBrush(Colors.Blue); polygon.Tag = new GeoCoordinate(curLat, curLon); MapOverlay overlay = new MapOverlay(); overlay.Content = polygon; overlay.GeoCoordinate = s; overlay.PositionOrigin = new System.Windows.Point(0.0, 1.0); myLayer.Add(overlay); map.Layers.Add(myLayer); }
private void pushpinLayer_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (!this._shouldPick) { return; } Point position = e.GetPosition((UIElement)this.map); GeoCoordinate geoCoordinate = new GeoCoordinate(); GeoCoordinate location = this.map.ViewportPointToLocation(position); ((PresentationFrameworkCollection <UIElement>) this.pushpinLayer.Children).Clear(); Image image = new Image(); image.Source = ((ImageSource) new BitmapImage(new Uri("/VKMessenger;component/Resources/Map_Pin.png", UriKind.Relative))); image.Stretch = ((Stretch)0); PositionOrigin bottomCenter = PositionOrigin.BottomCenter; this.pushpinLayer.AddChild((UIElement)image, location, bottomCenter); this._lastPosition = location; }
//マップをタップ private void MyMap_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (pin_tap_flag == false) { PushPinView.ClearSelected(); TP.Clear(); refreshTwoPointLine(); //候補地ピンの座標を設定 candidatePin.Location = MyMap.ViewportPointToLocation(e.GetPosition(MyMap)); //MyMap.SetView(candidatePin.Location, MyMap.ZoomLevel); if (MyMap.Children.Contains(candidatePin) == false) { MyMap.Children.Add(candidatePin); } } pin_tap_flag = false; }
private void image_Tap_1(object sender, System.Windows.Input.GestureEventArgs e) { Point position = e.GetPosition((UIElement)this.image); if (((FrameworkElement)this.image).ActualHeight == 0.0 || ((FrameworkElement)this.image).ActualWidth == 0.0) { return; } // ISSUE: explicit reference operation // ISSUE: explicit reference operation int relativePosition = this.GetTagIndForRelativePosition((int)(((Point)@position).X * 100.0 / ((FrameworkElement)this.image).ActualWidth), (int)(((Point)@position).Y * 100.0 / ((FrameworkElement)this.image).ActualHeight)); if (relativePosition >= 0) { this.SelectTaggedUser(relativePosition); } else { this.ResetTaggedUsersSelection(); } }
void select(object sender, System.Windows.Input.GestureEventArgs e) { TextPointer holdPointer = _contentCache.GetPositionFromPoint(e.GetPosition(_contentCache)); int offset = 3; TextPointer startPointer = holdPointer.GetPositionAtOffset(offset, LogicalDirection.Backward); while (startPointer == null && offset != -1) { startPointer = holdPointer.GetPositionAtOffset(--offset, LogicalDirection.Backward); } offset = 3; TextPointer endPointer = holdPointer.GetPositionAtOffset(offset, LogicalDirection.Forward); while (endPointer == null && offset != -1) { endPointer = holdPointer.GetPositionAtOffset(--offset, LogicalDirection.Forward); } _contentCache.Selection.Select(startPointer, endPointer); }
// Provide touch focus in the viewfinder. void focus_Tapped(object sender, System.Windows.Input.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); } catch (Exception ex) { LittleWatson.ReportException(ex); // Cannot focus when a capture is in progress. this.Dispatcher.BeginInvoke(delegate() { // Hide focus brackets. focusBrackets.Visibility = Visibility.Collapsed; }); } } } }
private async void MapTap(object sender, System.Windows.Input.GestureEventArgs e) { if (Enabled == true) { GeoCoordinate myGeoCoordinate = this.MyMap.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.MyMap)); if (!myGeoCoordinate.IsUnknown) { MyCoordinates.Add(myGeoCoordinate); PointList.Items.Add(MyCoordinates.Count + ". " + await GetAddress(myGeoCoordinate.Latitude, myGeoCoordinate.Longitude)); AddPushpin(myGeoCoordinate, MyCoordinates.Count); } else { MessageBox.Show("Unkown position"); } } }
private void Mymap_Hold(object sender, GestureEventArgs e) { if (Mymap.Layers.Contains(floorPoisDetail)) Mymap.Layers.Remove(floorPoisDetail); if (!_tileLoaded) RemoveIndoorStaff(); var p = e.GetPosition(this.Mymap); _tapLocation = new GeoCoordinate(); _tapLocation = Mymap.ConvertViewportPointToGeoCoordinate(p); _isSearch = false; AddPoi(_tapLocation); }
private void TextBoxPost_OnTap(object sender, System.Windows.Input.GestureEventArgs e) { this._textBoxTapPoint = e.GetPosition((UIElement)this.stackPanel); }
void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { layer.Children.Clear(); layer.AddChild(Pin_My, map.ViewportPointToLocation(e.GetPosition(map))); Pin_My.Tag = map.ViewportPointToLocation(e.GetPosition(map)); }
private void Map_OnTap(object sender, System.Windows.Input.GestureEventArgs e) { if (!this._shouldPick) { return; } GeoCoordinate geoCoordinate = this.map.ConvertViewportPointToGeoCoordinate(e.GetPosition((UIElement)this.map)); this._mapOverlayPushpin.Content = this._pinImage; this._mapOverlayPushpin.GeoCoordinate = geoCoordinate; this._lastPosition = geoCoordinate; this.StopGeoWatcher(); }
private void MapHold(object sender, GestureEventArgs e) { var p = e.GetPosition(Map); _mainViewModel.EditingUserPin = null; if (_touchedPin == null || ((UserPin) _touchedPin.DataContext).IsTemporary) { CatalogPushpin.Location = Map.ViewportPointToLocation(p); GoToState(StatePinDrop, true); } else { var pinP = _touchedPin.TransformToVisual(Map).Transform(new Point()); PushpinHoldStoryboard.Stop(); Storyboard.SetTarget(PushpinHoldAnimationY, _touchedPin); Storyboard.SetTarget(PushpinHoldAnimationX, _touchedPin); PushpinHoldAnimationX.To = p.X - pinP.X; PushpinHoldAnimationY.To = p.Y - pinP.Y - _touchedPin.RenderSize.Height + Globals.PinDragFloatOffsetY; PushpinHoldStoryboard.Begin(); _mainViewModel.HeldUserPin = (UserPin) _touchedPin.DataContext; } }
/// <summary> /// Called before the <see cref="E:System.Windows.UIElement.Hold" /> event occurs. /// </summary> protected override void OnHold(GestureEventArgs e) { var coordinate = Map.ViewportPointToLocation(e.GetPosition(Map)); _context.CommandAddPlace.ExecuteIfNotNull(coordinate.ToLocalLocation()); base.OnHold(e); }
private void mapPostItinerary_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (endPointOverlay != null) { myLocationLayer.Remove(endPointOverlay); } GeoCoordinate asd = this.mapPostItinerary.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.mapPostItinerary)); //MessageBox.Show("lat: " + asd.Latitude + "; long: " + asd.Longitude); //dat pushpin endPointOverlay = MarkerDraw.DrawMapMarker(asd); // Create a MapLayer to contain the MapOverlay. myLocationLayer.Add(endPointOverlay); // Add the MapLayer to the Map. mapPostItinerary.Layers.Remove(myLocationLayer); mapPostItinerary.Layers.Add(myLocationLayer); //mapPostItinerary.Layers.Remove() //hien thi thong tin diem den tren textbox geoQ.GeoCoordinate = asd; geoQ.QueryAsync(); }
private void Foo_DoubleTap_1(object sender, FakeDoubleTapEventArgs e) { FrameworkElement source = (FrameworkElement)sender; var point = e.GetPosition(source); view.AddScale(1.4, point.X - source.ActualWidth / 2, point.Y - source.ActualHeight / 2); e.Handled = true; }