public void DrawingField_Tapped(object sender, TappedRoutedEventArgs e) { var drawingField = sender as Canvas; if (drawingField != null) { double pointedX = e.GetPosition(this).X; double pointedY = e.GetPosition(this).Y; UIElement createElement = CreateSelectedElement(); Canvas.SetTop(createElement, pointedY - 100); Canvas.SetLeft(createElement, pointedX - 100); drawingField.Children.Add(createElement); } }
private void _theCanvas_Tapped(object sender, TappedRoutedEventArgs e) { _pointerDeviceType.Text = e.PointerDeviceType.ToString(); var position = e.GetPosition(_root); _x.Text = position.X.ToString(); _y.Text = position.Y.ToString(); }
protected override void OnTapped(TappedRoutedEventArgs e) { Point pt = e.GetPosition(this); // Create dot Ellipse ellipse = new Ellipse { Width = 3, Height = 3, Fill = this.Foreground }; Canvas.SetLeft(ellipse, pt.X); Canvas.SetTop(ellipse, pt.Y); canvas.Children.Add(ellipse); // Create text TextBlock txtblk = new TextBlock { Text = String.Format("{0}", pt), FontSize = 24 }; Canvas.SetLeft(txtblk, pt.X); Canvas.SetTop(txtblk, pt.Y); canvas.Children.Add(txtblk); e.Handled = true; base.OnTapped(e); }
private void ExecuteTappedCommand(TappedRoutedEventArgs args) { Canvas canvas = args.OriginalSource as Canvas; if (canvas == null) { return; } int ellipsesCount = canvas.Children .Where(c => c.GetType() == typeof(Ellipse)) .Count(); if (ellipsesCount >= MaxTaps) { return; } Ellipse circle = this.CreateEllipse(15, 15, DefaultEllipseColor); Point position = args.GetPosition(canvas); // Set the position of the new circles in the canvas. Canvas.SetLeft(circle, position.X - circle.Width / 2); Canvas.SetTop(circle, position.Y - circle.Height / 2); canvas.Children.Add(circle); }
private void theCanvas_DoubleTapped(object sender, TappedRoutedEventArgs e) { e.Handled = true; var position = e.GetPosition(this.theCanvas); Canvas.SetTop(this.rect, position.Y); Canvas.SetLeft(this.rect, position.X); }
private void ImageTapped(object sender, TappedRoutedEventArgs e) { var position = e.GetPosition((sender as FrameworkElement)); var closestMatch = ViewModel.Entries.Select(a => new { Entry = a, Distance = Math.Sqrt( Math.Pow(Math.Abs(position.X - a.X), 2) + Math.Pow(Math.Abs(position.Y - a.Y), 2) ) }) .OrderBy(a => a.Distance) .FirstOrDefault(); if (closestMatch == null) return; // More than 45% outside the radius isn't accurate enough. if (closestMatch.Distance > closestMatch.Entry.Radius * 1.45) return; switch (closestMatch.Entry.Entity.MarkerType) { case "Dealer": var context = KernelResolver.Current.Get<IDealersViewModelContext>(); var dealer = context.Dealers.SingleOrDefault(a => a.Entity.Id == closestMatch.Entry.Entity.TargetId); if (dealer == null) return; ViewModelLocator.Current.NavigationViewModel.NavigateToDealerDetailPage.Execute(dealer); break; } }
private void img_map_Tapped(object sender, TappedRoutedEventArgs e) { Point tapped_point = e.GetPosition(img_map); if (tapped_point.X > 190 && tapped_point.Y < 372) { Thickness margin = img_character.Margin; margin.Left += 10; img_character.Margin = margin; } if (tapped_point.X < 190 && tapped_point.Y < 372) { Thickness margin = img_character.Margin; margin.Right += 10; img_character.Margin = margin; } if (tapped_point.X > 190 && tapped_point.Y > 372) { Thickness margin = img_character.Margin; margin.Bottom += 10; img_character.Margin = margin; } if (tapped_point.X < 190 && tapped_point.Y > 372) { Thickness margin = img_character.Margin; margin.Top += 10; img_character.Margin = margin; } }
private void butFav_Tapped(object sender, TappedRoutedEventArgs e) { var p = e.GetPosition(null); Bang(p); if (ChangeViewState != null) ChangeViewState("AddFavourite", null); }
private void map_Tapped(object sender, TappedRoutedEventArgs e) { var pos = e.GetPosition(SpeedTrapMap); Location location; //Take the tapped location and get a GPS coordinate pair from it using the Bing Maps API SpeedTrapMap.TryPixelToLocation(pos, out location); //Flyout control from Callisto. Very handy. Flyout f = new Flyout(); // Flyout is a ContentControl so set your content within it. f.Content = new NewSpeedTrap(location.Longitude, location.Latitude); f.Placement = PlacementMode.Top; f.PlacementTarget = layoutRoot; // this is an UI element (usually the sender) layoutRoot.Children.Add(f.HostPopup); f.Closed += (async (b, c) => { layoutRoot.Children.Remove(f.HostPopup); //Refresh the speed trap locations await fetchSpeedTraps(); }); f.IsOpen = true; }
public UwpTapEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.TappedRoutedEventArgs args, int numberOfTaps) { ViewPosition = element.GetXfViewFrame(); //Touches = new Xamarin.Forms.Point[] { args.GetPosition(null).ToXfPoint() }; Touches = new Xamarin.Forms.Point[] { args.GetPosition(element).ToXfPoint() }; NumberOfTaps = numberOfTaps; }
private void gvMain_Tapped(object sender, TappedRoutedEventArgs e) { if (RenderingService.MagicRenderer != null && RenderingService.MagicRenderer is ISpriteRenderer) { var p = e.GetPosition(null); ((ISpriteRenderer)RenderingService.MagicRenderer).AddSprite(p.X, p.Y, 0, 0.3d); } }
// TODO: Use a combination of PointerPressed/PointerReleased instead of tap events private async void OnTapped(object sender, TappedRoutedEventArgs e) { if (GameClient == null) return; var position = e.GetPosition(canvas); await PerformBasicTouchNavigation(canvas, position.ToVector2()); }
/// <summary> /// Called before the Tapped event occurs. /// </summary> /// <param name="e">Event data for the event.</param> protected override void OnTapped(Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { base.OnTapped(e); if (e != null) { this.OnPointerTapped(e.GetPosition(this)); } }
public UwpTapEventArgs(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Input.TappedRoutedEventArgs args, int numberOfTaps) { ElementPosition = element.GetXfViewFrame(); var point = args.GetPosition(element); ElementTouches = new Xamarin.Forms.Point[] { point.ToXfPoint() }; WindowTouches = new Xamarin.Forms.Point[] { element.PointInNativeAppWindowCoord(point).ToXfPoint() }; NumberOfTaps = numberOfTaps; }
void MyMap_Tapped(object sender, TappedRoutedEventArgs e) { var pos = e.GetPosition(MyMap); Bing.Maps.Location location = new Bing.Maps.Location(); miniTockeShapeLayer = new MapShapeLayer(); MyMap.TryPixelToLocation(pos, out location); GetAddressByLocation(location); locationCollection.Add(location); }
public void pageTapped_Tapped(object sender, TappedRoutedEventArgs e) { Windows.Foundation.Point position = e.GetPosition(w.getSpaceship().image); w.getSpaceship().velocity=new Vector((float)position.X, (float)position.Y); timer.Tick += new EventHandler<object>(step); timer.Interval = new TimeSpan(0, 0, 0, 0, 10); timer.Start(); }
private static void OnTap(object sender, TappedRoutedEventArgs e) { Grid c = sender as Grid; ICommand cmd = c.GetValue(SelectionTappedCommandBehavior.CommandProperty) as ICommand; object param = c.GetValue(SelectionTappedCommandBehavior.CommandParameterProperty) ?? e.GetPosition(c); if (cmd != null && cmd.CanExecute(param)) { cmd.Execute(param); } }
private void butClose_Tapped(object sender, TappedRoutedEventArgs e) { if (RenderingService.MagicRenderer != null && RenderingService.MagicRenderer is ISpriteRenderer) { var p = e.GetPosition(null); ((ISpriteRenderer)RenderingService.MagicRenderer).AddSprite(p.X + 15, p.Y + 15, 0, 0.3d); } if (ChangeViewState != null) ChangeViewState("Minimized",null); }
private void WaveCanvas_Tapped(object sender, TappedRoutedEventArgs e) { Point p = e.GetPosition(WaveCanvas); double seekTo = p.X / WaveCanvas.ActualWidth; if (Utterance != null) { MediaPlayer.Position = TimeSpan.FromSeconds(seekTo * MediaPlayer.NaturalDuration.TimeSpan.TotalSeconds); Utterance.DrawPositionBar(WaveCanvas, MediaPlayer); } }
private void UIElement_OnTapped(object sender, TappedRoutedEventArgs e) { var flag = e.GetPosition(Window.Current.Content).X > Window.Current.Bounds.Width / 2; if (flag) { ImageViewer.SelectedIndex += 1; } else if (ImageViewer.SelectedIndex > 0) { ImageViewer.SelectedIndex -= 1; } }
private void Map_Tapped_1(object sender, TappedRoutedEventArgs e) { // Convert screen point to map point var mapPoint = MyMap.ScreenToMap(e.GetPosition(MyMap)); // Create graphic Graphic g = new Graphic() { Geometry = mapPoint }; // Get layer and add point to it var graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.Graphics.Add(g); }
private void Map_Tapped_1(object sender, TappedRoutedEventArgs e) { // Convert screen point to mappoint var mp = MyMap.ScreenToMap(e.GetPosition(MyMap)); // Create graphic Graphic g = new Graphic() { Geometry = mp }; // Get layer and add point var layer = MyMap.Layers.OfType<GraphicsLayer>().First(); layer.Graphics.Add(g); }
public override void OnClick(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { if (sender is DrawingCanvas) { DrawingCanvas canvas = sender as DrawingCanvas; if (clicked) { clicked = false; Point pos = new Point() { X = rect.Margin.Left, Y = rect.Margin.Top }; DrawableClassObject clObject = ModelManager.GetInstance() .CreateNewClass(new Point(rect.Width, rect.Height), rect.Fill, VisualShape.Ellipse, pos, 1); EditPage.Instance.ClassGallery.FillClasses(); EditPage.Instance.DrawClassView(clObject); return; } rect = new Ellipse(); double x = e.GetPosition(canvas).X; double y = e.GetPosition(canvas).Y; rect.Fill = _randomColor.Shuffle(); thickness = new Thickness(x, y, 0, 0); rect.Margin = thickness; off_x = x; off_y = y; canvas.AddUIControl(rect); clicked = true; } else if (sender is GalleryIcon) { GalleryIcon icon = sender as GalleryIcon; EditPage.Instance.DrawClassView(icon.ClassObject); } }
internal virtual bool ShouldToggleExpandOnTap(Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { if (ElementTreeHelper.IsElementRendered(this.expanderHeaderLayoutRoot)) { Point position = e.GetPosition(this.expanderHeaderLayoutRoot); var rect = new Rect(new Point(), this.expanderHeaderLayoutRoot.RenderSize); return(rect.Contains(position)); } return(false); }
/// <summary> /// ${ui_action_DrawPoint_event_OnTapped_D} /// </summary> public override void OnTapped(TappedRoutedEventArgs e) { base.OnTapped(e); Point2D center = Map.ScreenToMap(e.GetPosition(Map)); DrawEventArgs args = new DrawEventArgs { DrawName = Name, Element = new Pushpin { Location = center }, Geometry = new GeoPoint(center.X, center.Y) }; OnDrawComplete(args); }
private void gvMain_SingleTapped(object sender, TappedRoutedEventArgs e) { var pt = e.GetPosition(null); var item = (PhotoComment)gvMain.SelectedItem; GeneralSystemWideMessage msg = new GeneralSystemWideMessage(item.AuthorUserId); MessageBox("Load this users Favourites?", "Yes", "YesLoadAuthor", "HomeView", "No", "NoLoadAuthor", "HomeView", imageIcon: item.AuthorBuddyIcon, msgToPassAlong: msg); if (RenderingService.MagicRenderer != null && RenderingService.MagicRenderer is ISpriteRenderer) { ((ISpriteRenderer)RenderingService.MagicRenderer).AddSprite(pt.X, pt.Y, 0, 0.3d); } }
private void UserControl_Tapped(object sender, TappedRoutedEventArgs e) { Point point = e.GetPosition(this); double normalized = point.X / (sender as UserControl).ActualWidth; double rawRate = normalized * 5; int rateValue = (int)rawRate + 1; double newOffsetValue = 0.2 * rateValue; Offset = newOffsetValue; Value = rateValue; #if DEBUG string dbgString = string.Format("NO:{0},Raw:{1},Rate:{2}", newOffsetValue, rawRate, rateValue); System.Diagnostics.Debug.WriteLine(dbgString); #endif }
private async void Map_Tapped_1(object sender, TappedRoutedEventArgs e) { var mp = MyMap.ScreenToMap(e.GetPosition(MyMap)); Graphic g = new Graphic() { Geometry = mp }; var layer = MyMap.Layers.OfType<GraphicsLayer>().First(); layer.Graphics.Add(g); ESRI.ArcGIS.Runtime.Tasks.Locator locatorTask = new ESRI.ArcGIS.Runtime.Tasks.Locator( new Uri("http://tasks.arcgisonline.com/ArcGIS/rest/services/Locators/TA_Streets_US_10/GeocodeServer", UriKind.Absolute)); LocationToAddressParameter parameter = new LocationToAddressParameter(); // Tolerance (distance) specified in meters parameter.Distance = 30; parameter.Location = mp; parameter.OutSpatialReference = MyMap.SpatialReference; try { LocationToAddressResult result = await locatorTask.LocationToAddressAsync(parameter, CancellationToken.None); Address address = result.Address; IDictionary<string, object> attributes = address.Attributes; Graphic graphic = new Graphic() { Geometry = mp}; string latlon = String.Format("{0}, {1}", address.Location.X, address.Location.Y); string address1 = attributes["Street"].ToString(); string address2 = String.Format("{0}, {1} {2}", attributes["City"], attributes["State"], attributes["ZIP"]); graphic.Attributes.Add("LatLon", latlon); graphic.Attributes.Add("Address1", address1); graphic.Attributes.Add("Address2", address2); _locationGraphicsLayer.Graphics.Add(graphic); } catch(Exception ex) { return; } }
private void drawingCanvas_Tapped(object sender, TappedRoutedEventArgs e) { Point mouseLocation = e.GetPosition(this.drawingCanvas); Square mySquare = new Square(100); if (mySquare is IDraw) { IDraw drawSquare = mySquare; drawSquare.SetLocation((int)mouseLocation.X, (int)mouseLocation.Y); drawSquare.Draw(drawingCanvas); } if (mySquare is IColor) { IColor colorSquare = mySquare; colorSquare.SetColor(Colors.BlueViolet); } }
private void mymap_Tapped(object sender, TappedRoutedEventArgs e) { var pos = e.GetPosition(mymap); //BasicGeoposition bg = new BasicGeoposition //{ // Latitude = Math.Round(pos.Position.Latitude, 4), // Longitude = Math.Round(pos.Position.Longitkkude, 4) //}; //Geolocator gl = new Geolocator(); //Geopoint gpp = //mymap.GetLocationFromOffset(pos, out gpp); }
private async void OnClicked(object sender, TappedRoutedEventArgs e) { var richTB = sender as RichTextBlock; var textPointer = richTB.GetPositionFromPoint(e.GetPosition(richTB)); var element = textPointer.Parent as TextElement; while (element != null && !(element is Underline)) { 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 Underline; if (underline.Name == "email") { await Launcher.LaunchUriAsync(new Uri("mailto:[email protected]")); } if (underline.Name == "github") { await Launcher.LaunchUriAsync(new Uri("https://github.com/nexDevelopment/nexMuni")); } if (underline.Name == "twitter") { await Launcher.LaunchUriAsync(new Uri("https://twitter.com/nexdevco")); } if (underline.Name == "website") { await Launcher.LaunchUriAsync(new Uri("http://nexdev.co")); } }
private void InputGrid_Tapped(object sender, TappedRoutedEventArgs e) { var p = e.GetPosition(RedCanvas); var ellipse = new Ellipse() { Width = 30, Height = 30, Fill = new SolidColorBrush(Colors.Black) }; var halfXSpacer = _xSpacer / 2; var halfYSpacer = _ySpacer / 2; var approachX = Math.Round(p.X / halfXSpacer) * halfXSpacer; var approachY = Math.Round(p.Y / halfYSpacer) * halfYSpacer; Canvas.SetLeft(ellipse, approachX - 15); Canvas.SetTop(ellipse, approachY - 15); _redPolygon.Points.Add(new Point(approachX, approachY)); PointsCanvas.Children.Add(ellipse); }
private void Map_Tapped(object sender, TappedRoutedEventArgs e) { if (myMap.Children.Contains(_locationIcon)) { myMap.Children.Remove(_locationIcon); } var pos = e.GetPosition(myMap); Bing.Maps.Location location; myMap.TryPixelToLocation(pos, out location); //fill up myTappedLocation var for making a new spot myTappedLocation = location; MapLayer.SetPosition(_locationIcon, location); myMap.Children.Add(_locationIcon); myMap.SetView(location); }
/// <summary> /// Click or Tap on an item /// On Items Panel, the tap action only scroll to selected tap object /// </summary> private void OnTapped(object sender, TappedRoutedEventArgs args) { if (this.Children == null || this.Children.Count == 0) return; // if not focused, dont do anything if (this.ParentDatePickerSelector != null) { if (!this.ParentDatePickerSelector.IsFocused) return; } var positionY = args.GetPosition(this).Y; var positionX = args.GetPosition(this).X; foreach (PickerSelectorItem child in this.Children) { if (this.Orientation == Orientation.Vertical) { var childPositionY = child.GetVerticalPosition(); var height = child.RectPosition.Height; if (!(positionY >= childPositionY) || !(positionY <= (childPositionY + height))) continue; } else { var childPositionX = child.GetHorizontalPosition(); var width = child.RectPosition.Width; if (!(positionX >= childPositionX) || !(positionX <= (childPositionX + width))) continue; } this.ScrollToSelectedIndex(child, animationDuration); break; } }
private void butPromote_Tapped(object sender, TappedRoutedEventArgs e) { var p = e.GetPosition(null); Bang(p); if (ChangeViewState != null) ChangeViewState("PromoteIt", null); }