// Tap on the canvas private void canvas_Tap(object sender, System.Windows.Input.GestureEventArgs e) { // stop velocity mapState.vx = mapState.vy = 0; // Get position relative to the mapCanvas int x = (int)e.GetPosition(mapCanvas).X; int y = (int)e.GetPosition(mapCanvas).Y; int hits = 0; // Check if the tap was on a zone foreach (var zonePair in zoneDict) { var zone = zonePair.Value; // scale Position takes into account if we are zoomed now or not if (x >= zone.offsetX * (mapState.zoomed ? 1.0 : mapState.scaleDown) && x <= (zone.offsetX + zone.originalWidth) * (mapState.zoomed ? 1.0 : mapState.scaleDown) && y >= zone.offsetY * (mapState.zoomed ? 1.0 : mapState.scaleDown) && y <= (zone.offsetY + zone.originalHeight) * (mapState.zoomed ? 1.0 : mapState.scaleDown)) { var bitmap = (WriteableBitmap)zone.zoneImage.Source; double dx = x - zone.offsetX * (mapState.zoomed ? 1.0 : mapState.scaleDown); double dy = y - zone.offsetY * (mapState.zoomed ? 1.0 : mapState.scaleDown); if (!mapState.zoomed) { dx *= mapState.scaleUp; dy *= mapState.scaleUp; } if (((bitmap.Pixels[(int)dx + (int)dy * bitmap.PixelWidth] >> 24) & 255) > 0) { if (mouseState.selectedZone == null || mouseState.selectedZone.ID != zone.ID) { if (mouseState.selectedZone != null) { setZoneColor(mouseState.selectedZone.zoneImage, 255, 255, 255); } mouseState.selectedZone = zone; setZoneColor(zone.zoneImage, 255, 216, 0); DebugTextbox.Text = "Hit: " + zone.name; ++hits; } } } } if (hits > 1) { DebugTextbox.Text = "ERROR: multiple hits"; } }
private void mapCircuit_Hold(object sender, System.Windows.Input.GestureEventArgs e) { if (!App.ViewModel.Track.IsLocal) { return; } var mapPosition = e.GetPosition(mapCircuit); var mapLayer = new MapLayer(); var geoCoordinate = mapCircuit.ConvertViewportPointToGeoCoordinate(mapPosition); lastSectorNumber++; double heading = (double)App.ViewModel.DegreesData.SelectedItem; var geographyPoint = GeographyPoint.Create(geoCoordinate.Latitude, geoCoordinate.Longitude, null, heading); var lineCoordinates = geographyPoint.ConvertToLine(0.02); var newSector = new TrackSectorViewModel { StartLatitude = lineCoordinates[0].Latitude, StartLongitude = lineCoordinates[0].Longitude, EndLatitude = lineCoordinates[0].Latitude, EndLongitude = lineCoordinates[0].Longitude, Heading = heading, IsFinishLine = false, SectorNumber = lastSectorNumber }; App.ViewModel.Track.Sectors.Add(newSector); App.ViewModel.Track.SelectedSector = newSector; NavigationService.Navigate(new Uri("/EditSectorPage.xaml", System.UriKind.Relative)); }
private void Map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (!ConfirmNewWayPoint && NewWaypointSet) { CreateRouteOnMap(); CreateWayPointsOnMap(); SpecialMapIcons(); } ApplicationBarOrganizer(1); GeoCoordinate tapLocation = Map.ConvertViewportPointToGeoCoordinate(e.GetPosition(Map)); CreateWayPoint(tapLocation, ListBox_WayPoints.Items.Count); NewWaypointSet = true; try { TempGeoPosition[0] = tapLocation.Latitude; TempGeoPosition[1] = tapLocation.Longitude; TempGeoPosition[2] = AdditionalInfos; TextBox_StatusMessage.Text = "New Position Set"; } catch { TextBox_StatusMessage.Text = "Invalid Position"; } }
private async void ViewfinderCanvas_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var point = e.GetPosition(ViewfinderCanvas); var bitmap = new WriteableBitmap((int)ViewfinderCanvas.ActualWidth, (int)ViewfinderCanvas.ActualHeight); using (var source = new CameraPreviewImageSource(App.Camera)) using (var effect = new FilterEffect(source)) using (var renderer = new WriteableBitmapRenderer(effect, bitmap, OutputOption.Stretch)) { effect.Filters = new List <IFilter>() { new RotationFilter(_rotationFilter.RotationAngle) }; await renderer.RenderAsync(); var picked = bitmap.Pixels[((int)point.Y) * bitmap.PixelWidth + ((int)point.X)]; _color = new Color { A = 0xFF, R = (byte)((picked & 0x00FF0000) >> 16), G = (byte)((picked & 0x0000FF00) >> 8), B = (byte)(picked & 0x000000FF) }; } ColorBorder.Background = new SolidColorBrush(_color); }
private async void mapControl_Hold(object sender, System.Windows.Input.GestureEventArgs e) { status.Text = "querying for address..."; var point = e.GetPosition(mapControl); var coordinate = mapControl.ConvertViewportPointToGeoCoordinate(point); var pushpin = new Pushpin { GeoCoordinate = coordinate, Content = ++pinNumber, }; MapExtensions.GetChildren(mapControl).Add(pushpin); position.Text = string.Format("Latitude: {0}\nLongitude: {1}\n", FormatCoordinate(coordinate.Latitude, 'N', 'S'), FormatCoordinate(coordinate.Longitude, 'E', 'W')); ReverseGeocodeQuery query = new ReverseGeocodeQuery { GeoCoordinate = coordinate }; IList <MapLocation> results = await query.GetMapLocationsAsync(); position.Text += string.Format("{0} locations found.\n", results.Count); MapLocation location = results.FirstOrDefault(); if (location != null) { position.Text += FormatAddress(location.Information.Address); } status.Text += "complete"; }
void focus_Tapped(object sender, System.Windows.Input.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. try { focusBrackets.Visibility = Visibility.Visible; _phoneCamera.FocusAtPoint(focusXPercentage, focusYPercentage); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
/// <summary> /// Event handler called when the user tap and hold in the map /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="e">Event arguments</param> private async void OnMapHold(object sender, System.Windows.Input.GestureEventArgs e) { ReverseGeocodeQuery query; List <MapLocation> mapLocations; string pushpinContent; MapLocation mapLocation; query = new ReverseGeocodeQuery(); query.GeoCoordinate = this.Map.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.Map)); mapLocations = (List <MapLocation>) await query.GetMapLocationsAsync(); mapLocation = mapLocations.FirstOrDefault(); if (mapLocation != null) { this.RouteDirectionsPushPin.GeoCoordinate = mapLocation.GeoCoordinate; pushpinContent = mapLocation.Information.Name; pushpinContent = string.IsNullOrEmpty(pushpinContent) ? mapLocation.Information.Description : null; pushpinContent = string.IsNullOrEmpty(pushpinContent) ? string.Format("{0} {1}", mapLocation.Information.Address.Street, mapLocation.Information.Address.City) : null; this.RouteDirectionsPushPin.Content = pushpinContent.Trim(); this.RouteDirectionsPushPin.Visibility = Visibility.Visible; } }
private async void MessageHeader_Tap(object sender, System.Windows.Input.GestureEventArgs e) { StackPanel panel = (StackPanel)sender; Point point = e.GetPosition(panel); // For clicks on the right side, apply them to the star. if (point.X > (panel.ActualWidth * 0.8)) { // Add/remove star MailMessage message = (MailMessage)panel.DataContext; Account account = App.AccountManager.GetCurrentAccount(); await account.SetStarAsync(message, starred : !message.Flagged); // Refresh the UI panel.DataContext = null; panel.DataContext = message; } else { WebBrowser bodyField = (WebBrowser)panel.Children[1]; ListBox attachmentsFieled = (ListBox)panel.Children[2]; if (bodyField.Visibility == System.Windows.Visibility.Collapsed) { bodyField.Visibility = System.Windows.Visibility.Visible; attachmentsFieled.Visibility = System.Windows.Visibility.Visible; } else { bodyField.Visibility = System.Windows.Visibility.Collapsed; attachmentsFieled.Visibility = System.Windows.Visibility.Collapsed; } } }
void Page_Taped(object sender, System.Windows.Input.GestureEventArgs e) { if (Menu.Visibility == System.Windows.Visibility.Visible) { Menu.Visibility = System.Windows.Visibility.Collapsed; return; } var pos = e.GetPosition(this); var col = (int)(pos.X * 3 / this.ActualWidth); var row = (int)(pos.Y * 3 / this.ActualHeight); if (col == 2 || row == 2) { //ListBox.Panel.LineUp(); //ListBox.Panel.PageDown(); //ListBox.Panel.SetVerticalOffset(ListBox.Panel.VerticalOffset + 1.62); } else if (col == 0 || row == 0) { //ListBox.Panel.LineDown(); //ListBox.Panel.PageUp(); //ListBox.Panel.SetVerticalOffset(ListBox.Panel.VerticalOffset - 1.62); } else { Menu.Visibility = System.Windows.Visibility.Visible; } }
private void Map_OnTap(object sender, GestureEventArgs e) { Point clickLocation = e.GetPosition(Map); GeoCoordinate coordinate = Map.ConvertViewportPointToGeoCoordinate(clickLocation); SetPushpin(coordinate); ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true; }
void amap_Tap(object sender, System.Windows.Input.GestureEventArgs e) { this.Dispatcher.BeginInvoke(() => { //点击地图获取点击点的经纬度, 屏幕坐标转换为地图坐标 LatLng lats = amap.GetProjection().FromScreenLocation(e.GetPosition(amap)); cameraloutput1.Text = "target:lat/lng:(" + lats.latitude + "," + lats.longitude + ")"; }); }
private void Map_OnTap(object sender, GestureEventArgs e) { e.Handled = true; Point clickLocation = e.GetPosition(Map); GeoCoordinate coordinate = Map.ConvertViewportPointToGeoCoordinate(clickLocation); // AddPushpin(coordinate); }
private void Map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Map map = (sender as Map); Point p = e.GetPosition(map); GeoCoordinate location = (map).ConvertViewportPointToGeoCoordinate(p); VibrateController.Default.Start(TimeSpan.FromMilliseconds(500)); MapPointMessage.Send(Coordinate.FromGeoCoordinate(location)); }
private async void Canvas_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (!_focusing && !_capturing) { _focusing = true; var point = e.GetPosition(Canvas); var scaleX = _device.PreviewResolution.Width / Canvas.ActualWidth; var scaleY = _device.PreviewResolution.Height / Canvas.ActualHeight; // Show focusing bracket and set focus region if supported by the HW if (PhotoCaptureDevice.IsFocusRegionSupported(SENSOR_LOCATION)) { FocusBracket.RenderTransform = new TranslateTransform() { X = point.X, Y = point.Y }; FocusBracket.Visibility = Visibility.Visible; _device.FocusRegion = new Windows.Foundation.Rect(point.X * scaleX, point.Y * scaleY, 1, 1); } // Focus and capture if focus is supported by the HW, otherwise just capture if (PhotoCaptureDevice.IsFocusSupported(SENSOR_LOCATION)) { CameraFocusStatus status; try { status = await _device.FocusAsync(); } catch (Exception) { status = CameraFocusStatus.NotLocked; } _focusing = false; FocusBracket.Visibility = Visibility.Collapsed; if (status == CameraFocusStatus.Locked) { await CaptureAsync(); } } else { await CaptureAsync(); } } }
private void map_Hold(object sender, System.Windows.Input.GestureEventArgs e) { g = map.ConvertViewportPointToGeoCoordinate(e.GetPosition(map)); ReverseGeocodeQuery MyGeocodeQuery = new ReverseGeocodeQuery(); MyGeocodeQuery.GeoCoordinate = g; MyGeocodeQuery.QueryCompleted += MyGeocodeQuery_QueryCompleted; MyGeocodeQuery.QueryAsync(); }
void amap_Tap(object sender, System.Windows.Input.GestureEventArgs e) { //添加Marker AMapMarker marker1; marker1 = amap.AddMarker(new AMapMarkerOptions() { Position = amap.GetProjection().FromScreenLocation(e.GetPosition(amap)), IconUri = new Uri("Images/ROSE.png", UriKind.Relative), //Anchor = new Point(1, 1),//图标中心点 }); amap.AddAMapLayer(mapLayer); mapLayer.AddMarker(new AMapMarkerOptions() { Position = amap.GetProjection().FromScreenLocation(e.GetPosition(amap)), IconUri = new Uri("Images/AZURE.png", UriKind.Relative), Anchor = new Point(0.5, 0.5), }); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditMap_Tap(object sender, System.Windows.Input.GestureEventArgs e) { Point p = e.GetPosition(this.EditMap); GeoCoordinate geo = new GeoCoordinate(); geo = EditMap.ViewportPointToLocation(p); Pushpin.Location = geo; LatTxt.Text = Pushpin.Location.Latitude.ToString(); LonTxt.Text = Pushpin.Location.Longitude.ToString(); EditMap.Center = Pushpin.Location; EditMap.ZoomLevel = 15; }
private void Map_Hold(object sender, System.Windows.Input.GestureEventArgs e) { GeoCoordinate geo = this.Map.ConvertViewportPointToGeoCoordinate(e.GetPosition(this.Map)); if (this.FakeGPSBtn.IsChecked.Value) { this.LatitudeTbx.Text = geo.Latitude.ToString(); IsolatedStorageSettings.ApplicationSettings["DEBUG:FakeLat"] = geo.Latitude; this.LongitudeTbx.Text = geo.Longitude.ToString(); IsolatedStorageSettings.ApplicationSettings["DEBUG:FakeLng"] = geo.Longitude; } }
private void OnViewfinderTap(object sender, System.Windows.Input.GestureEventArgs e) { if (this.viewModel.State == ViewModelState.Loaded) { Point pointOnLivePreview = e.GetPosition(this.livePreviewTapTarget); Tracing.Trace("TAPPED AT: " + pointOnLivePreview); Point deltaFromCenter = new Point( pointOnLivePreview.X - this.livePreviewTapTarget.ActualWidth / 2, pointOnLivePreview.Y - this.livePreviewTapTarget.ActualHeight / 2); // Clamp delta to the actual size of the preview // Size previewSize = CalculateLivePreviewSize(); deltaFromCenter.X = Math.Max(-1 * previewSize.Width / 2, deltaFromCenter.X); deltaFromCenter.X = Math.Min(previewSize.Width / 2, deltaFromCenter.X); deltaFromCenter.Y = Math.Max(-1 * previewSize.Height / 2, deltaFromCenter.Y); deltaFromCenter.Y = Math.Min(previewSize.Height / 2, deltaFromCenter.Y); // Move the focus brackets into position // CompositeTransform pointFocusBracketsTransform = (CompositeTransform)this.pointFocusBrackets.RenderTransform; pointFocusBracketsTransform.TranslateX = deltaFromCenter.X; pointFocusBracketsTransform.TranslateY = deltaFromCenter.Y; Point focusPointInScreenCoordinates = new Point( (previewSize.Width / 2) + deltaFromCenter.X, (previewSize.Height / 2) + deltaFromCenter.Y); // Convert focus point to coordinates in the preview resolution, which may be much larger and rotated // Size previewResolution = this.viewModel.PreviewResolution; double scaleFactor; Point focusPoint; if (IsPortrait(this.Orientation)) { scaleFactor = previewResolution.Height / previewSize.Width; focusPoint = new Point( focusPointInScreenCoordinates.Y * scaleFactor, previewResolution.Height - (focusPointInScreenCoordinates.X * scaleFactor)); } else { scaleFactor = previewResolution.Width / previewSize.Width; focusPoint = new Point( focusPointInScreenCoordinates.X * scaleFactor, focusPointInScreenCoordinates.Y * scaleFactor); } Tracing.Trace("FOCUSING AT: " + focusPoint); this.viewModel.BeginPointFocusAndCapture(focusPoint); } }
private void Map_Tap(object sender, System.Windows.Input.GestureEventArgs e) { GeoCoordinate location; bool canConvert = (sender as Map).TryViewportPointToLocation(e.GetPosition(sender as Map), out location); VibrateController.Default.Start(TimeSpan.FromMilliseconds(500)); if (canConvert) { MapPointMessage.Send(Coordinate.FromGeoCoordinate(location)); } }
void Control_Hold(object sender, System.Windows.Input.GestureEventArgs e) { FrameworkElement control = sender as FrameworkElement; GestureRenderer renderer = control.Parent as GestureRenderer; Element element = renderer.Element; Console.WriteLine("Control_Hold [" + control.Name + "] " + e.GetPosition(control).ToString()); if (GestureMonitor != null) { GestureMonitor.RaiseEvent(element, new GestureMonitorEventArgs(element, GestureType.Hold)); } }
// 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 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.Width; double focusYPercentage = tapLocation.Y / viewfinderCanvas.Height; // Show the 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()."; }); } } }
private async void ViewFinderTap(object sender, GestureEventArgs e) { if (this.isPreviewRunning && !this.commandeRunning) { try { this.commandeRunning = true; //compute vector between preview picture center and Inverted transformation center var tmp = this.viewfinderBrush.Transform.Inverse.TransformBounds(new Rect(new Point(), this.viewfinderCanvas.RenderSize)); var dx = this.captureDevice.PreviewResolution.Width / 2 - (tmp.X + tmp.Width / 2); var dy = this.captureDevice.PreviewResolution.Height / 2 - (tmp.Y + tmp.Height / 2); //invert tap position var p = e.GetPosition(this); var pInPreview = this.viewfinderBrush.Transform.Inverse.Transform(p); //transform inverted position to picture reference double X = pInPreview.X + dx; double Y = pInPreview.Y + dy; if (X < 0) { X = 0; } if (X >= this.captureDevice.PreviewResolution.Width) { X = this.captureDevice.PreviewResolution.Width - 1; } if (Y >= this.captureDevice.PreviewResolution.Height) { Y = this.captureDevice.PreviewResolution.Height - 1; } if (Y < 0) { Y = 0; } this.captureDevice.FocusRegion = new Windows.Foundation.Rect(new Windows.Foundation.Point(X, Y), new Size()); await this.captureDevice.FocusAsync(); } catch (Exception ex) { } finally { this.commandeRunning = false; } } }
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(); }
private void Entries_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (Entries.SelectedItem != null) { var item = Entries.GetContainerForItem(Entries.SelectedItem); if (item != null) { var position = e.GetPosition(item); if (!(position.X >= 0 && position.X <= item.ActualWidth && position.Y >= 0 && position.Y <= item.ActualHeight)) { Entries.SelectedItem = null; } } } }
void Page_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var element = (UIElement)sender; Point p = e.GetPosition(element); Rect rect = new Rect(p.X - 50, p.Y, 100, 100); var elementsAtTap = VisualTreeHelper.FindElementsInHostCoordinates(rect, element); List <UIElement> controls = new List <UIElement>(); if (elementTypes.Count > 1) { var controlsWithPriorities = elementsAtTap .Where(c => elementTypes.Contains(c.GetType())) .Select(c => new { Priority = elementTypes.IndexOf(c.GetType()), Control = c }) .ToList(); if (controlsWithPriorities.Count > 0) { int maxPriority = controlsWithPriorities.Min(x => x.Priority); controls = controlsWithPriorities.Where(x => x.Priority == maxPriority).Select(x => x.Control).ToList(); } } else if (elementTypes.Count == 1) { controls = elementsAtTap.Where(c => c.GetType() == elementTypes.Single()).ToList(); } if (controls.Count > 0) { if (MapElementTap != null) { if (controls.Count == 1) { MapElementTap(Page.Map, controls.Single()); } else { MapElementTap(Page.Map, TransitBase.Extensions.MinBy(controls, c => distanceTo(c, p, element))); } } } else { if (EmptyMapTap != null) { EmptyMapTap(Page.Map, new EventArgs()); } } }
/// <summary>Raises a <see cref="ReceivedTap"/> event for the given gesture data.</summary> /// <param name="e">The gesture event arguments providing tap information.</param> /// <param name="tapCount">Number of times the same coordinates was tapped on. Must be 1 or higher.</param> private void RaiseReceivedTapEventUsing(System.Windows.Input.GestureEventArgs e, int tapCount) { // Do not continue if the given event was already handled. if (e.Handled) { return; } // Do not continue if the "ReceivedTap" event has no subscribers. if (this.ReceivedTap == null) { return; } // Do not continue if a UI control has not been assigned. // This is needed to convert the touch coordinates to a position relative to the control. if (fUIEventSource == null) { return; } // Convert the tap coordinates to pixels. var relativePosition = e.GetPosition(fUIEventSource); double scaleFactor = (double)System.Windows.Application.Current.Host.Content.ScaleFactor / 100.0; relativePosition.X = Math.Round(relativePosition.X * scaleFactor, MidpointRounding.AwayFromZero); relativePosition.Y = Math.Round(relativePosition.Y * scaleFactor, MidpointRounding.AwayFromZero); // Create the tap event arguments. Corona.WinRT.Interop.Input.TouchPoint tapPoint; tapPoint.X = relativePosition.X; tapPoint.Y = relativePosition.Y; tapPoint.Timestamp = DateTimeOffset.Now; var tapEventArgs = new Corona.WinRT.Interop.Input.TapEventArgs(tapPoint, tapCount); // Raise the event. ReceivedTap(this, tapEventArgs); // Flag the event as handled if set. if (tapEventArgs.Handled) { e.Handled = true; } }
private void Grid_Tap(object sender, System.Windows.Input.GestureEventArgs e) { try { Point point = e.GetPosition(sender as Grid); if (point.X > 46 || point.Y > 63) { NavigationService.Navigate(new Uri(string.Format("/Player/Album.xaml?albumName={0}", (((sender as Grid).Children[3]) as TextBlock).Text), UriKind.Relative)); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { albumsList.SelectedItem = null; } }
/// <summary> /// Add new note to view and raise AddedNote event /// </summary> private void KeyCanvas_OnTap(object sender, System.Windows.Input.GestureEventArgs e) { e.Handled = true; var canvas = sender as Canvas; if (canvas == null) { return; } var key = canvas.DataContext as KeyContext; if (key == null) { return; } var tapPoint = e.GetPosition(canvas); var tactPostition = Math.Round((tapPoint.X - (tapPoint.X % _cellWidth)) / _cellWidth); _pianoRollContext.AddNote((byte)key.Value, (byte)tactPostition); }
private void mapCircuit_Tap(object sender, System.Windows.Input.GestureEventArgs e) { if (!App.ViewModel.Track.IsLocal) { return; } double smallestDistance = double.MaxValue; TrackSectorViewModel selectedSector = null; var mapPosition = e.GetPosition(mapCircuit); var geoCoordinate = mapCircuit.ConvertViewportPointToGeoCoordinate(mapPosition); var goegraphyPoint = GeographyPoint.Create(geoCoordinate.Latitude, geoCoordinate.Longitude, null, geoCoordinate.Course); foreach (var sector in App.ViewModel.Track.Sectors) { if (double.IsNaN(sector.StartLatitude) || double.IsNaN(sector.StartLongitude) || double.IsNaN(sector.EndLatitude) || double.IsNaN(sector.EndLongitude)) { continue; } var sectorLineStartPoint = GeographyPoint.Create(sector.StartLatitude, sector.StartLongitude); var sectorLineEndPoint = GeographyPoint.Create(sector.EndLatitude, sector.EndLongitude); var midpoint = GeoUtmConverter.Midpoint(sectorLineStartPoint, sectorLineEndPoint, sector.Heading); double distance = midpoint.Distance(goegraphyPoint); if (distance < 0.5 && distance < smallestDistance) { smallestDistance = distance; selectedSector = sector; } } if (selectedSector == null) { return; } App.ViewModel.Track.SelectedSector = selectedSector; NavigationService.Navigate(new Uri("/EditSectorPage.xaml", System.UriKind.Relative)); }
private void UpperOrLowerPictureTap(object sender, GestureEventArgs e) { var timerValue = int.Parse(TimeTextBlock.Text); if (timerValue >= App.ViewModel.TimeDetuctValue) { TimeTextBlock.Text = (timerValue - App.ViewModel.TimeDetuctValue).ToString(CultureInfo.InvariantCulture); DeductTimeTextBlock.Text = "-" + App.ViewModel.TimeDetuctValue; RadAnimationManager.Play(DeductTimeTextBlock, TimerDeductAnimation(), () => DeductTimeTextBlock.Text = string.Empty); } _wrongSoundEffect.Play(); var point = e.GetPosition(sender as UIElement); var r1 = new Rectangle { Fill = new SolidColorBrush(Colors.Red) { Opacity = 1 }, Width = 16, Height = 16 }; Canvas.SetLeft(r1, point.X - 8); Canvas.SetTop(r1, point.Y - 8); UpperPictureCanvas.Children.Add(r1); var r2 = new Rectangle { Fill = new SolidColorBrush(Colors.Red) { Opacity = 1 }, Width = 16, Height = 16 }; Canvas.SetLeft(r2, point.X - 8); Canvas.SetTop(r2, point.Y - 8); LowerPictureCanvas.Children.Add(r2); RadAnimationManager.Play(r1, _tapWrongAnimation, () => UpperPictureCanvas.Children.Remove(r1)); RadAnimationManager.Play(r2, _tapWrongAnimation, () => LowerPictureCanvas.Children.Remove(r2)); }